diff --git a/Cargo.toml b/Cargo.toml index ffe1c31..fda16e8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,6 +54,7 @@ sdl2 = { version = "0.37.0" } syn = { version = "2.0.67", features = ["extra-traits", "full"] } quote = "1.0.35" proc-macro2 = "1.0.86" +downcast-rs = "1.2.1" utilities = { git = "https://gavania.de/hodasemi/utilities.git" } vulkan-rs = { git = "https://gavania.de/hodasemi/vulkan_lib.git" } diff --git a/character_window/Cargo.toml b/character_window/Cargo.toml index 85b4138..5062943 100644 --- a/character_window/Cargo.toml +++ b/character_window/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" anyhow = { workspace = true } paste = { workspace = true } destructure_traitobject = { workspace = true } +downcast-rs = { workspace = true } engine = { path = "../engine" } rpg_components = { path = "../rpg_components" } \ No newline at end of file diff --git a/character_window/src/abilities/mod.rs b/character_window/src/abilities/mod.rs index 2f8007a..01cd7b6 100644 --- a/character_window/src/abilities/mod.rs +++ b/character_window/src/abilities/mod.rs @@ -56,7 +56,7 @@ impl AbilityPage { // abilities let ability_mode = PageContent::new( - Content::new(&engine, reference.clone(), { + Content::new::<_, Self>(&engine, reference.clone(), { let engine = engine.clone(); let hero = hero.clone(); @@ -100,7 +100,7 @@ impl AbilityPage { // addons let addons_mode = PageContent::::new( - Content::new(&engine, reference.clone(), { + Content::new::<_, Self>(&engine, reference.clone(), { let engine = engine.clone(); let hero = hero.clone(); diff --git a/character_window/src/content.rs b/character_window/src/content.rs index d292070..6b2c2a2 100644 --- a/character_window/src/content.rs +++ b/character_window/src/content.rs @@ -32,13 +32,14 @@ pub struct Content { } impl Content { - pub fn new( + pub fn new( engine: &Arc, reference: Weak, on_enable: F, ) -> Result where F: Fn() -> Result> + Send + Sync + 'static, + P: Page, { let base = GuiSnippet::from_str( engine.gui_handler(), @@ -48,9 +49,38 @@ impl Content { let left: Arc