From 0ed03f16af35a19bc2b19965d0bcdf0bae316b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20H=C3=BCbner?= Date: Wed, 5 Mar 2025 09:45:39 +0100 Subject: [PATCH] Fix majority of item tab --- character_window/Cargo.toml | 1 + character_window/src/abilities/mod.rs | 12 +- character_window/src/character/mod.rs | 155 +++--- character_window/src/content.rs | 93 ++-- character_window/src/inventory/content.rs | 346 ++++++------- .../src/inventory/item_right_side.rs | 460 ++++++++---------- .../src/inventory/jewel_right_side.rs | 126 +++-- .../src/inventory/map_right_side.rs | 6 +- character_window/src/inventory/mod.rs | 207 ++++---- character_window/src/lib.rs | 90 ++-- character_window/src/page_content.rs | 2 +- character_window/src/traits.rs | 4 +- rpg_components/src/items/ability_addon.rs | 13 +- rpg_components/src/items/ability_book.rs | 9 +- rpg_components/src/items/item.rs | 18 +- rpg_components/src/items/jewel.rs | 10 +- rpg_components/src/items/tooltip.rs | 4 +- 17 files changed, 760 insertions(+), 796 deletions(-) diff --git a/character_window/Cargo.toml b/character_window/Cargo.toml index ebef6bd..406f8e2 100644 --- a/character_window/Cargo.toml +++ b/character_window/Cargo.toml @@ -11,3 +11,4 @@ downcast-rs = { workspace = true } engine = { workspace = true } rpg_components = { path = "../rpg_components" } +assetpath.workspace = true diff --git a/character_window/src/abilities/mod.rs b/character_window/src/abilities/mod.rs index 9e7f8f8..ebcd10e 100644 --- a/character_window/src/abilities/mod.rs +++ b/character_window/src/abilities/mod.rs @@ -225,7 +225,7 @@ impl AbilityPage { } impl Page for AbilityPage { - fn enable(&mut self) -> Result> { + fn enable(&mut self, world: &mut World) -> Result> { println!("enable AbilityPage"); for mode in self.modes.iter_mut() { @@ -237,11 +237,11 @@ impl Page for AbilityPage { Ok(self.grid.clone()) } - fn disable(&mut self) -> Result<()> { + fn disable(&mut self, world: &mut World) -> Result<()> { Ok(()) } - fn select(&self) -> Result<()> { + fn select(&self, world: &mut World) -> Result<()> { let mode = &self.modes[self.current_mode]; mode.content().select()?; @@ -255,19 +255,19 @@ impl Page for AbilityPage { Ok(()) } - fn next_tab(&mut self) -> Result<()> { + fn next_tab(&mut self, world: &mut World) -> Result<()> { self.modes[self.current_mode] .content_mut() .next_tab(&self.engine, self.hero) } - fn previous_tab(&mut self) -> Result<()> { + fn previous_tab(&mut self, world: &mut World) -> Result<()> { self.modes[self.current_mode] .content_mut() .previous_tab(&self.engine, self.hero) } - fn event(&mut self, button: ControllerButton) -> Result { + fn event(&mut self, world: &mut World, button: ControllerButton) -> Result { Ok(match button { ControllerButton::LeftStick => { self.current_mode = (self.current_mode + 1) % self.modes.len(); diff --git a/character_window/src/character/mod.rs b/character_window/src/character/mod.rs index 1eacade..0c80bb9 100644 --- a/character_window/src/character/mod.rs +++ b/character_window/src/character/mod.rs @@ -43,7 +43,7 @@ impl CharacterPage { strength.set_callback({ let update_stats = Self::create_update_stats(hero, engine, reference); - move || { + move |_world| { update_stats(|attributes| { attributes.add_strength(Strength::from(1)); }) @@ -54,7 +54,7 @@ impl CharacterPage { agility.set_callback({ let update_stats = Self::create_update_stats(hero, engine, reference); - move || { + move |_world| { update_stats(|attributes| { attributes.add_agility(Agility::from(1)); }) @@ -65,7 +65,7 @@ impl CharacterPage { intelligence.set_callback({ let update_stats = Self::create_update_stats(hero, engine, reference); - move || { + move |_world| { update_stats(|attributes| { attributes.add_intelligence(Intelligence::from(1)); }) @@ -80,14 +80,14 @@ impl CharacterPage { }) } - fn refresh(&self) -> Result<()> { - self.update_stats()?; - self.update_attributes()?; + fn refresh(&self, world: &mut World) -> Result<()> { + self.update_stats(world)?; + self.update_attributes(world)?; Ok(()) } - fn update_stats(&self, world: &World) -> Result<()> { + fn update_stats(&self, world: &mut World) -> Result<()> { let air_def: Arc