Compare commits

..

1 commit

Author SHA1 Message Date
e24cffddc8 Update Rust crate ron to 0.10.0 2025-04-08 09:03:41 +00:00
18 changed files with 199 additions and 343 deletions

View file

@ -7,7 +7,7 @@ members = ["character_window", "map", "rpg_components"]
destructure_traitobject = "0.3.0" destructure_traitobject = "0.3.0"
itertools = "0.14.0" itertools = "0.14.0"
serde = { version = "1.0.203", features = ["derive"] } serde = { version = "1.0.203", features = ["derive"] }
ron = "0.9.0" ron = "0.10.0"
paste = "1.0.15" paste = "1.0.15"
rayon = "1.10.0" rayon = "1.10.0"
chrono = { version = "0.4.35", features = ["serde"] } chrono = { version = "0.4.35", features = ["serde"] }

View file

@ -28,22 +28,23 @@ impl<A: Ability + 'static> AbilityPageRightSide<A> {
"fourth_ability", "fourth_ability",
]; ];
pub fn new( pub fn new(world: &mut World, hero: Entity, reference: &Weak<CharacterWindow>) -> Result<Self> {
commands: &mut Commands,
gui_handler: &mut GuiHandler,
item_settings: &mut ItemSettings,
engine_settings: &mut EngineSettings,
context: &mut Context,
hero: Entity,
reference: &Weak<CharacterWindow>,
) -> Result<Self> {
let snippet = GuiSnippet::from_str( let snippet = GuiSnippet::from_str(
commands, world,
gui_handler,
include_str!("../../resources/abilities/right_side.xml"), include_str!("../../resources/abilities/right_side.xml"),
)?; )?;
let color_settings = item_settings.rarity_color_settings.clone(); let color_settings = world
.resources
.get::<ItemSettings>()
.rarity_color_settings
.clone();
let (gui_handler, engine_settings, context): (
&mut GuiHandler,
&mut EngineSettings,
&mut Context,
) = world.resources.get_mut()?;
Self::rarity_icon_background(gui_handler, &snippet, "common", color_settings.common)?; Self::rarity_icon_background(gui_handler, &snippet, "common", color_settings.common)?;
Self::rarity_icon_background(gui_handler, &snippet, "uncommon", color_settings.uncommon)?; Self::rarity_icon_background(gui_handler, &snippet, "uncommon", color_settings.uncommon)?;
@ -63,7 +64,7 @@ impl<A: Ability + 'static> AbilityPageRightSide<A> {
button.set_callback({ button.set_callback({
let reference = reference.clone(); let reference = reference.clone();
move |commands, gui_handler| { move |world: &mut World| {
if let Some(menu) = reference.upgrade() { if let Some(menu) = reference.upgrade() {
let mut tabs = menu.tabs_mut(); let mut tabs = menu.tabs_mut();
let abilities = tabs.abilities::<A>(); let abilities = tabs.abilities::<A>();

View file

@ -17,8 +17,7 @@ use super::AbilityPage;
impl<A: Ability + 'static> Content<A, AbilityAddon> { impl<A: Ability + 'static> Content<A, AbilityAddon> {
fn show_addon_tooltip( fn show_addon_tooltip(
commands: &mut Commands, world: &mut World,
gui_handler: &mut GuiHandler,
hero: Entity, hero: Entity,
addon_index: usize, addon_index: usize,
reference: &Weak<CharacterWindow>, reference: &Weak<CharacterWindow>,
@ -31,7 +30,7 @@ impl<A: Ability + 'static> Content<A, AbilityAddon> {
let target_y = y; let target_y = y;
let addon = inventory.addon_at(addon_index); let addon = inventory.addon_at(addon_index);
let gui = addon.create_tooltip(commands, gui_handler, (target_x, target_y))?; let gui = addon.create_tooltip(world, (target_x, target_y))?;
gui.enable(world)?; gui.enable(world)?;
gui.perform_single_check(world.resources.get_mut()?, x, y)?; gui.perform_single_check(world.resources.get_mut()?, x, y)?;

View file

@ -35,21 +35,20 @@ pub struct AbilityPage<A: Ability + 'static> {
impl<A: Ability + 'static> AbilityPage<A> { impl<A: Ability + 'static> AbilityPage<A> {
pub fn new( pub fn new(
commands: &mut Commands, world: &mut World,
gui_handler: &mut GuiHandler,
hero: Entity, hero: Entity,
reference: Weak<CharacterWindow>, reference: Weak<CharacterWindow>,
close: &Arc<Button>, close: &Arc<Button>,
) -> Result<Self> { ) -> Result<Self> {
let gui_handler = world.resources.get_mut_unchecked::<GuiHandler>();
let grid = Grid::new(gui_handler, 2, 1, false)?; let grid = Grid::new(gui_handler, 2, 1, false)?;
let left_base = GuiSnippet::from_str( let left_base = GuiSnippet::from_str(
commands, world,
gui_handler,
include_str!("../../resources/abilities/left_side.xml"), include_str!("../../resources/abilities/left_side.xml"),
)?; )?;
grid.attach(commands, gui_handler, left_base.clone(), 0, 0, 1, 1)?; grid.attach(world, left_base.clone(), 0, 0, 1, 1)?;
Self::setup_content_switch(&left_base, reference.clone())?; Self::setup_content_switch(&left_base, reference.clone())?;
@ -58,7 +57,7 @@ impl<A: Ability + 'static> AbilityPage<A> {
// abilities // abilities
let ability_mode = PageContent::new( let ability_mode = PageContent::new(
Content::new::<_, Self>(commands, gui_handler, reference.clone(), { Content::new::<_, Self>(world, reference.clone(), {
let hero = hero.clone(); let hero = hero.clone();
move |world| { move |world| {
@ -72,11 +71,16 @@ impl<A: Ability + 'static> AbilityPage<A> {
})?, })?,
{ {
let ui = GuiSnippet::from_str( let ui = GuiSnippet::from_str(
commands, world,
gui_handler,
include_str!("../../resources/abilities/ability_tooltip.xml"), include_str!("../../resources/abilities/ability_tooltip.xml"),
)?; )?;
let (gui_handler, engine_settings, context): (
&mut GuiHandler,
&mut EngineSettings,
&mut Context,
) = world.resources.get_mut()?;
let equip: Arc<Label> = ui.element("equip")?; let equip: Arc<Label> = ui.element("equip")?;
equip.set_info_icon( equip.set_info_icon(
gui_handler, gui_handler,
@ -175,7 +179,7 @@ impl<A: Ability + 'static> AbilityPage<A> {
}) })
} }
fn update_page(&mut self, commands: &mut Commands, gui_handler: &mut GuiHandler) -> Result<()> { fn update_page(&mut self, world: &mut World) -> Result<()> {
match self.current_mode { match self.current_mode {
0 => println!("update ability view"), 0 => println!("update ability view"),
1 => println!("update addon view"), 1 => println!("update addon view"),
@ -187,27 +191,13 @@ impl<A: Ability + 'static> AbilityPage<A> {
mode.content_mut().update(world, self.hero)?; mode.content_mut().update(world, self.hero)?;
self.tooltip self.tooltip
.attach(commands, gui_handler, mode.tooltip().clone(), 0, 0, 1, 1)?; .attach(world, mode.tooltip().clone(), 0, 0, 1, 1)?;
self.content.attach( self.content
commands, .attach(world, mode.content_mut().base().clone(), 0, 0, 1, 1)?;
gui_handler,
mode.content_mut().base().clone(),
0,
0,
1,
1,
)?;
self.right_side.refresh(commands, gui_handler, self.hero)?; self.right_side.refresh(world, self.hero)?;
self.grid.attach( self.grid
commands, .attach(world, self.right_side.base().clone(), 1, 0, 1, 1)?;
gui_handler,
self.right_side.base().clone(),
1,
0,
1,
1,
)?;
Ok(()) Ok(())
} }

View file

@ -23,28 +23,26 @@ pub struct CharacterPage {
impl CharacterPage { impl CharacterPage {
pub fn new( pub fn new(
commands: &mut Commands, world: &mut World,
gui_handler: &mut GuiHandler,
hero: Entity, hero: Entity,
hero_name: &str, hero_name: &str,
reference: &Weak<CharacterWindow>, reference: &Weak<CharacterWindow>,
) -> Result<Self> { ) -> Result<Self> {
let snippet = GuiSnippet::from_str( let snippet = GuiSnippet::from_str(
commands, world,
gui_handler,
include_str!("../../resources/character/statistics.xml"), include_str!("../../resources/character/statistics.xml"),
)?; )?;
let grid: Arc<Grid> = snippet.element("statistic_tab")?; let grid: Arc<Grid> = snippet.element("statistic_tab")?;
let name: Arc<Label> = snippet.element("character_name")?; let name: Arc<Label> = snippet.element("character_name")?;
name.set_text(gui_handler, hero_name)?; name.set_text(world.resources.get_mut()?, hero_name)?;
let strength: Arc<Button> = snippet.element("strength_field")?; let strength: Arc<Button> = snippet.element("strength_field")?;
strength.set_callback({ strength.set_callback({
let update_stats = Self::create_update_stats(hero, reference.clone()); let update_stats = Self::create_update_stats(hero, reference.clone());
move |commands, gui_handler| { move |world| {
update_stats(world, |attributes: &mut Attributes| { update_stats(world, |attributes: &mut Attributes| {
attributes.add_strength(Strength::from(1)); attributes.add_strength(Strength::from(1));
}) })

View file

@ -33,8 +33,7 @@ pub struct Content<A: Ability + 'static, T: Send + Sync> {
impl<A: Ability + 'static, T: Send + Sync> Content<A, T> { impl<A: Ability + 'static, T: Send + Sync> Content<A, T> {
pub fn new<F, P>( pub fn new<F, P>(
commands: &mut Commands, world: &mut World,
gui_handler: &mut GuiHandler,
reference: Weak<CharacterWindow>, reference: Weak<CharacterWindow>,
on_enable: F, on_enable: F,
) -> Result<Self> ) -> Result<Self>
@ -42,11 +41,7 @@ impl<A: Ability + 'static, T: Send + Sync> Content<A, T> {
F: Fn(&mut World) -> Result<Vec<T>> + Send + Sync + 'static, F: Fn(&mut World) -> Result<Vec<T>> + Send + Sync + 'static,
P: Page, P: Page,
{ {
let base = GuiSnippet::from_str( let base = GuiSnippet::from_str(world, include_str!("../resources/content.xml"))?;
commands,
gui_handler,
include_str!("../resources/content.xml"),
)?;
let (gui_handler, engine_settings, context): ( let (gui_handler, engine_settings, context): (
&mut GuiHandler, &mut GuiHandler,
@ -63,12 +58,12 @@ impl<A: Ability + 'static, T: Send + Sync> Content<A, T> {
left.set_callback({ left.set_callback({
let reference = reference.clone(); let reference = reference.clone();
move |commands, gui_handler| { move |world| {
if let Some(window) = reference.upgrade() { if let Some(window) = reference.upgrade() {
let mut tab = window.tab_mut(); let mut tab = window.tab_mut();
let page = tab.downcast_mut::<P>(); let page = tab.downcast_mut::<P>();
page.previous_tab(commands, gui_handler)?; page.previous_tab(world)?;
} }
Ok(()) Ok(())
@ -84,12 +79,12 @@ impl<A: Ability + 'static, T: Send + Sync> Content<A, T> {
right.set_callback({ right.set_callback({
let reference = reference.clone(); let reference = reference.clone();
move |commands, gui_handler| { move |world| {
if let Some(window) = reference.upgrade() { if let Some(window) = reference.upgrade() {
let mut tab = window.tab_mut(); let mut tab = window.tab_mut();
let page = tab.downcast_mut::<P>(); let page = tab.downcast_mut::<P>();
page.next_tab(commands, gui_handler)?; page.next_tab(world)?;
} }
Ok(()) Ok(())
@ -110,16 +105,12 @@ impl<A: Ability + 'static, T: Send + Sync> Content<A, T> {
}) })
} }
fn clear_grid( fn clear_grid(world: &mut World, grid: &Arc<Grid>) -> Result<()> {
commands: &mut Commands,
gui_handler: &mut GuiHandler,
grid: &Arc<Grid>,
) -> Result<()> {
let (rows, columns) = grid.dimensions(); let (rows, columns) = grid.dimensions();
for x in 0..columns { for x in 0..columns {
for y in 0..rows { for y in 0..rows {
grid.detach(commands, gui_handler, x, y)?; grid.detach(world, x, y)?;
} }
} }
@ -130,23 +121,18 @@ impl<A: Ability + 'static, T: Send + Sync> Content<A, T> {
label.set_text(gui_handler, format!("{} / {}", self.page + 1, self.pages)) label.set_text(gui_handler, format!("{} / {}", self.page + 1, self.pages))
} }
pub fn update_base<F>( pub fn update_base<F>(&mut self, world: &mut World, setup: F) -> Result<()>
&mut self,
commands: &mut Commands,
gui_handler: &mut GuiHandler,
setup: F,
) -> Result<()>
where where
Self: ContentWrapper, Self: ContentWrapper,
F: Fn(&mut Commands, &mut GuiHandler, &Arc<Button>, &T, usize) -> Result<()>, F: Fn(&mut World, &Arc<Button>, &T, usize) -> Result<()>,
{ {
self.refresh(world)?; self.refresh(world)?;
let grid: Arc<Grid> = self.base.element("content")?; let grid: Arc<Grid> = self.base.element("content")?;
let label: Arc<Label> = self.base.element("tab_info")?; let label: Arc<Label> = self.base.element("tab_info")?;
Self::clear_grid(commands, gui_handler, &grid)?; Self::clear_grid(world, &grid)?;
self.set_tab(gui_handler, &label)?; self.set_tab(world.resources.get_mut()?, &label)?;
let (rows, columns) = grid.dimensions(); let (rows, columns) = grid.dimensions();
@ -157,14 +143,13 @@ impl<A: Ability + 'static, T: Send + Sync> Content<A, T> {
match self.data.get(index) { match self.data.get(index) {
Some(t) => { Some(t) => {
let snippet = GuiSnippet::from_str( let snippet = GuiSnippet::from_str(
commands, world,
gui_handler,
include_str!("../resources/content_button.xml"), include_str!("../resources/content_button.xml"),
)?; )?;
let button: Arc<Button> = snippet.element("button")?; let button: Arc<Button> = snippet.element("button")?;
setup(commands, gui_handler, &button, t, index)?; setup(world, &button, t, index)?;
grid.attach(commands, gui_handler, button, x, y, 1, 1)?; grid.attach(world, button, x, y, 1, 1)?;
} }
None => break 'outer, None => break 'outer,
} }

View file

@ -27,16 +27,13 @@ pub struct ItemRightSide {
impl ItemRightSide { impl ItemRightSide {
pub fn new<A: Ability + 'static>( pub fn new<A: Ability + 'static>(
commands: &mut Commands, world: &mut World,
gui_handler: &mut GuiHandler,
item_settings: &ItemSettings,
context: &Context,
file: &str, file: &str,
reference: &Weak<CharacterWindow>, reference: &Weak<CharacterWindow>,
hero: Entity, hero: Entity,
) -> Result<Self> { ) -> Result<Self> {
let snippet = GuiSnippet::from_str(commands, gui_handler, file)?; let snippet = GuiSnippet::from_str(world, file)?;
let icons = InventoryEmptyIcons::new(context, item_settings)?; let icons = InventoryEmptyIcons::new(world)?;
let me = Self { let me = Self {
snippet, snippet,
@ -124,12 +121,7 @@ impl ItemRightSide {
} }
impl RightSide for ItemRightSide { impl RightSide for ItemRightSide {
fn refresh( fn refresh(&mut self, world: &mut World, hero: Entity) -> Result<()> {
&mut self,
commands: &mut Commands,
gui_handler: &mut GuiHandler,
hero: Entity,
) -> Result<()> {
let (hero_object, resources) = world.entity_resources(hero)?; let (hero_object, resources) = world.entity_resources(hero)?;
let items = hero_object.get_component::<ItemSlotContainer>()?; let items = hero_object.get_component::<ItemSlotContainer>()?;
@ -156,8 +148,13 @@ struct InventoryEmptyIcons {
} }
impl InventoryEmptyIcons { impl InventoryEmptyIcons {
fn new(context: &Context, item_settings: &ItemSettings) -> Result<Self> { fn new(world: &World) -> Result<Self> {
let place_holder_settings = &item_settings.icon_place_holder_paths; let place_holder_settings = &world
.resources
.get::<ItemSettings>()
.icon_place_holder_paths;
let context = world.resources.get::<Context>();
Ok(Self { Ok(Self {
helmet: Self::image(context, &place_holder_settings.helmet)?, helmet: Self::image(context, &place_holder_settings.helmet)?,

View file

@ -59,19 +59,19 @@ pub struct JewelRightSide {
impl JewelRightSide { impl JewelRightSide {
pub fn new<A: Ability + 'static>( pub fn new<A: Ability + 'static>(
commands: &mut Commands, world: &mut World,
gui_handler: &mut GuiHandler,
engine_settings: &EngineSettings,
context: &Context,
file: &str, file: &str,
hero: Entity, hero: Entity,
reference: &Weak<CharacterWindow>, reference: &Weak<CharacterWindow>,
) -> Result<Self> { ) -> Result<Self> {
let snippet = GuiSnippet::from_str(commands, gui_handler, file)?; let snippet = GuiSnippet::from_str(world, file)?;
let combine: Arc<Label> = snippet.element("combine")?; let combine: Arc<Label> = snippet.element("combine")?;
let icon = engine_settings.controller_icon(context, ControllerButton::RightStick)?; let icon = world.resources.get::<EngineSettings>().controller_icon(
combine.set_info_icon(gui_handler, &icon)?; world.resources.get::<Context>(),
ControllerButton::RightStick,
)?;
combine.set_info_icon(world.resources.get_mut()?, &icon)?;
world.resources.insert_if_not_exists::<ReferenceObject>(); world.resources.insert_if_not_exists::<ReferenceObject>();
world.resources.insert_if_not_exists::<LowerJewels>(); world.resources.insert_if_not_exists::<LowerJewels>();
@ -93,7 +93,7 @@ impl JewelRightSide {
let weak_top = Arc::downgrade(&top); let weak_top = Arc::downgrade(&top);
let reference = reference.clone(); let reference = reference.clone();
move |commands, gui_handler, selected| { move |world, selected| {
let menu = reference.upgrade().unwrap(); let menu = reference.upgrade().unwrap();
if selected { if selected {
@ -108,37 +108,27 @@ impl JewelRightSide {
if let Some(reference_info) = reference_info.some() { if let Some(reference_info) = reference_info.some() {
let tooltip = match reference_info { let tooltip = match reference_info {
ReferenceObject::Item { item, .. } => { ReferenceObject::Item { item, .. } => {
let attributes = let attributes = unsafe { remove_life_time(world.entity(hero)?) }
world.entity(hero)?.get_component::<Attributes>()?; .get_component::<Attributes>()?;
item.create_tooltip( item.create_tooltip(world, attributes, (x + w as i32, y))?
commands,
gui_handler,
attributes,
(x + w as i32, y),
)?
} }
ReferenceObject::Jewel { jewel, .. } => { ReferenceObject::Jewel { jewel, .. } => {
let item_settings = world.resources.get_unchecked::<ItemSettings>(); let item_settings = world.resources.get_unchecked::<ItemSettings>();
jewel.create_tooltip( jewel.create_tooltip(world, item_settings, (x + w as i32, y))?
commands,
gui_handler,
item_settings,
(x + w as i32, y),
)?
} }
ReferenceObject::Empty => unreachable!(), ReferenceObject::Empty => unreachable!(),
}; };
tooltip.enable(commands, gui_handler)?; tooltip.enable(world)?;
tooltip.perform_single_check(gui_handler, x, y)?; tooltip.perform_single_check(world.resources.get_mut()?, x, y)?;
menu.add_tooltip("upper", tooltip); menu.add_tooltip("upper", tooltip);
} }
} else { } else {
menu.remove_tooltip(commands, gui_handler, "upper")?; menu.remove_tooltip(world, "upper")?;
} }
Ok(()) Ok(())
@ -150,7 +140,7 @@ impl JewelRightSide {
let weak_top = Arc::downgrade(&lower); let weak_top = Arc::downgrade(&lower);
let reference = reference.clone(); let reference = reference.clone();
move |commands, gui_handler, selected| { move |world, selected| {
let menu = reference.upgrade().unwrap(); let menu = reference.upgrade().unwrap();
if selected { if selected {
@ -177,7 +167,7 @@ impl JewelRightSide {
menu.add_tooltip(format!("lower_{index}",), tooltip); menu.add_tooltip(format!("lower_{index}",), tooltip);
} }
} else { } else {
menu.remove_tooltip(commands, gui_handler, format!("lower_{index}"))?; menu.remove_tooltip(world, format!("lower_{index}"))?;
} }
Ok(()) Ok(())
@ -187,7 +177,7 @@ impl JewelRightSide {
lower.set_callback({ lower.set_callback({
let reference = reference.clone(); let reference = reference.clone();
move |commands, gui_handler| { move |world| {
let lower_info: &mut LowerJewels = world.resources.get_mut()?; let lower_info: &mut LowerJewels = world.resources.get_mut()?;
if lower_info.jewels[index].is_some() { if lower_info.jewels[index].is_some() {
@ -197,7 +187,7 @@ impl JewelRightSide {
let mut tabs = menu.tabs_mut(); let mut tabs = menu.tabs_mut();
let inventory = tabs.inventory::<A>(); let inventory = tabs.inventory::<A>();
inventory.update_page(commands, gui_handler, true)?; inventory.update_page(world, true)?;
} }
} }

View file

@ -9,20 +9,15 @@ pub struct MapRightSide {
} }
impl MapRightSide { impl MapRightSide {
pub fn new(commands: &mut Commands, gui_handler: &mut GuiHandler, file: &str) -> Result<Self> { pub fn new(world: &mut World, file: &str) -> Result<Self> {
let snippet = GuiSnippet::from_str(commands, gui_handler, file)?; let snippet = GuiSnippet::from_str(world, file)?;
Ok(Self { snippet }) Ok(Self { snippet })
} }
} }
impl RightSide for MapRightSide { impl RightSide for MapRightSide {
fn refresh( fn refresh(&mut self, _world: &mut World, _hero: Entity) -> Result<()> {
&mut self,
_commands: &mut Commands,
_gui_handler: &mut GuiHandler,
_hero: Entity,
) -> Result<()> {
Ok(()) Ok(())
} }

View file

@ -10,7 +10,6 @@ use anyhow::Result;
use ecs::*; use ecs::*;
use engine::prelude::*; use engine::prelude::*;
use rpg_components::components::inventory::Inventory; use rpg_components::components::inventory::Inventory;
use rpg_components::config::items::ItemSettings;
use rpg_components::items::ability_book::Ability; use rpg_components::items::ability_book::Ability;
use super::page_content::PageContent; use super::page_content::PageContent;
@ -39,24 +38,20 @@ pub struct InventoryPage<A: Ability + 'static> {
impl<A: Ability + 'static> InventoryPage<A> { impl<A: Ability + 'static> InventoryPage<A> {
pub fn new( pub fn new(
commands: &mut Commands, world: &mut World,
gui_handler: &mut GuiHandler,
engine_settings: &EngineSettings,
item_settings: &ItemSettings,
context: &Context,
hero: Entity, hero: Entity,
reference: Weak<CharacterWindow>, reference: Weak<CharacterWindow>,
close: &Arc<Button>, close: &Arc<Button>,
) -> Result<Self> { ) -> Result<Self> {
let gui_handler: &mut GuiHandler = world.resources.get_mut()?;
let grid = Grid::new(gui_handler, 2, 1, false)?; let grid = Grid::new(gui_handler, 2, 1, false)?;
let left_base = GuiSnippet::from_str( let left_base = GuiSnippet::from_str(
commands, world,
gui_handler,
include_str!("../../resources/inventory/left_side.xml"), include_str!("../../resources/inventory/left_side.xml"),
)?; )?;
grid.attach(commands, gui_handler, left_base.clone(), 0, 0, 1, 1)?; grid.attach(world, left_base.clone(), 0, 0, 1, 1)?;
Self::setup_content_switch(&left_base, reference.clone())?; Self::setup_content_switch(&left_base, reference.clone())?;
let tooltip = left_base.element("tooltip")?; let tooltip = left_base.element("tooltip")?;
@ -64,10 +59,10 @@ impl<A: Ability + 'static> InventoryPage<A> {
// items // items
let item_mode = PageContent::<A, _>::new( let item_mode = PageContent::<A, _>::new(
Content::new::<_, Self>(commands, gui_handler, reference.clone(), { Content::new::<_, Self>(world, reference.clone(), {
let hero = hero.clone(); let hero = hero.clone();
move |world| { move |world: &mut World| {
let hero_object = world.entity(hero)?; let hero_object = world.entity(hero)?;
let inventory = hero_object.get_component::<Inventory<A>>()?; let inventory = hero_object.get_component::<Inventory<A>>()?;
@ -78,11 +73,16 @@ impl<A: Ability + 'static> InventoryPage<A> {
})?, })?,
{ {
let ui = GuiSnippet::from_str( let ui = GuiSnippet::from_str(
commands, world,
gui_handler,
include_str!("../../resources/inventory/items/tooltip.xml"), include_str!("../../resources/inventory/items/tooltip.xml"),
)?; )?;
let (gui_handler, engine_settings, context): (
&mut GuiHandler,
&mut EngineSettings,
&mut Context,
) = world.resources.get_mut()?;
let equip: Arc<Label> = ui.element("equip")?; let equip: Arc<Label> = ui.element("equip")?;
equip.set_info_icon( equip.set_info_icon(
gui_handler, gui_handler,
@ -110,10 +110,7 @@ impl<A: Ability + 'static> InventoryPage<A> {
ui ui
}, },
ItemRightSide::new::<A>( ItemRightSide::new::<A>(
commands, world,
gui_handler,
item_settings,
context,
include_str!("../../resources/inventory/items/right_side.xml"), include_str!("../../resources/inventory/items/right_side.xml"),
&reference, &reference,
hero, hero,
@ -122,7 +119,7 @@ impl<A: Ability + 'static> InventoryPage<A> {
// jewels // jewels
let jewel_mode = PageContent::<A, _>::new( let jewel_mode = PageContent::<A, _>::new(
Content::new::<_, Self>(commands, gui_handler, reference.clone(), { Content::new::<_, Self>(world, reference.clone(), {
let hero = hero.clone(); let hero = hero.clone();
move |world| { move |world| {
@ -136,11 +133,16 @@ impl<A: Ability + 'static> InventoryPage<A> {
})?, })?,
{ {
let ui = GuiSnippet::from_str( let ui = GuiSnippet::from_str(
commands, world,
gui_handler,
include_str!("../../resources/inventory/jewels/tooltip.xml"), include_str!("../../resources/inventory/jewels/tooltip.xml"),
)?; )?;
let (gui_handler, engine_settings, context): (
&mut GuiHandler,
&mut EngineSettings,
&mut Context,
) = world.resources.get_mut()?;
let socket: Arc<Label> = ui.element("socket")?; let socket: Arc<Label> = ui.element("socket")?;
socket.set_info_icon( socket.set_info_icon(
gui_handler, gui_handler,
@ -162,10 +164,7 @@ impl<A: Ability + 'static> InventoryPage<A> {
ui ui
}, },
JewelRightSide::new::<A>( JewelRightSide::new::<A>(
commands, world,
gui_handler,
engine_settings,
context,
include_str!("../../resources/inventory/jewels/right_side.xml"), include_str!("../../resources/inventory/jewels/right_side.xml"),
hero, hero,
&reference, &reference,
@ -174,7 +173,7 @@ impl<A: Ability + 'static> InventoryPage<A> {
// maps // maps
let map_mode = PageContent::<A, _>::new( let map_mode = PageContent::<A, _>::new(
Content::new::<_, Self>(commands, gui_handler, reference.clone(), { Content::new::<_, Self>(world, reference.clone(), {
move |world| { move |world| {
let hero_object = world.entity(hero)?; let hero_object = world.entity(hero)?;
let inventory = hero_object.get_component::<Inventory<A>>()?; let inventory = hero_object.get_component::<Inventory<A>>()?;
@ -186,11 +185,16 @@ impl<A: Ability + 'static> InventoryPage<A> {
})?, })?,
{ {
let ui = GuiSnippet::from_str( let ui = GuiSnippet::from_str(
commands, world,
gui_handler,
include_str!("../../resources/inventory/maps/tooltip.xml"), include_str!("../../resources/inventory/maps/tooltip.xml"),
)?; )?;
let (gui_handler, engine_settings, context): (
&mut GuiHandler,
&mut EngineSettings,
&mut Context,
) = world.resources.get_mut()?;
let select: Arc<Label> = ui.element("select")?; let select: Arc<Label> = ui.element("select")?;
select.set_info_icon( select.set_info_icon(
gui_handler, gui_handler,
@ -212,8 +216,7 @@ impl<A: Ability + 'static> InventoryPage<A> {
ui ui
}, },
MapRightSide::new( MapRightSide::new(
commands, world,
gui_handler,
include_str!("../../resources/inventory/maps/right_side.xml"), include_str!("../../resources/inventory/maps/right_side.xml"),
)?, )?,
); );
@ -240,21 +243,12 @@ impl<A: Ability + 'static> InventoryPage<A> {
}) })
} }
fn switch_to_jewels( fn switch_to_jewels(&mut self, world: &mut World) -> Result<()> {
&mut self,
commands: &mut Commands,
gui_handler: &mut GuiHandler,
) -> Result<()> {
self.current_mode = 1; self.current_mode = 1;
self.update_page(commands, gui_handler, true) self.update_page(world, true)
} }
fn update_page( fn update_page(&mut self, world: &mut World, select: bool) -> Result<()> {
&mut self,
commands: &mut Commands,
gui_handler: &mut GuiHandler,
select: bool,
) -> Result<()> {
match self.current_mode { match self.current_mode {
0 => println!("update item view"), 0 => println!("update item view"),
1 => println!("update jewel view"), 1 => println!("update jewel view"),
@ -267,27 +261,11 @@ impl<A: Ability + 'static> InventoryPage<A> {
let mode = &mut self.modes[self.current_mode]; let mode = &mut self.modes[self.current_mode];
self.tooltip self.tooltip
.attach(commands, gui_handler, mode.tooltip().clone(), 0, 0, 1, 1)?; .attach(world, mode.tooltip().clone(), 0, 0, 1, 1)?;
self.content
self.content.attach( .attach(world, mode.content_mut().base().clone(), 0, 0, 1, 1)?;
commands, self.grid
gui_handler, .attach(world, mode.right_side_mut().base().clone(), 1, 0, 1, 1)?;
mode.content_mut().base().clone(),
0,
0,
1,
1,
)?;
self.grid.attach(
commands,
gui_handler,
mode.right_side_mut().base().clone(),
1,
0,
1,
1,
)?;
mode.content_mut().update(world, self.hero)?; mode.content_mut().update(world, self.hero)?;
mode.right_side_mut().refresh(world, self.hero)?; mode.right_side_mut().refresh(world, self.hero)?;

View file

@ -30,22 +30,12 @@ use std::{
use self::{abilities::AbilityPage, character::CharacterPage, inventory::InventoryPage}; use self::{abilities::AbilityPage, character::CharacterPage, inventory::InventoryPage};
trait Page: Any + Send + Sync + Downcast { trait Page: Any + Send + Sync + Downcast {
fn enable( fn enable(&mut self, world: &mut World) -> Result<Arc<Grid>>;
&mut self, fn disable(&mut self, world: &mut World) -> Result<()>;
commands: &mut Commands, fn select(&self, world: &mut World) -> Result<()>;
gui_handler: &mut GuiHandler, fn next_tab(&mut self, world: &mut World) -> Result<()>;
) -> Result<Arc<Grid>>; fn previous_tab(&mut self, world: &mut World) -> Result<()>;
fn disable(&mut self, commands: &mut Commands, gui_handler: &mut GuiHandler) -> Result<()>; fn event(&mut self, world: &mut World, button: ControllerButton) -> Result<bool>;
fn select(&self, commands: &mut Commands, gui_handler: &mut GuiHandler) -> Result<()>;
fn next_tab(&mut self, commands: &mut Commands, gui_handler: &mut GuiHandler) -> Result<()>;
fn previous_tab(&mut self, commands: &mut Commands, gui_handler: &mut GuiHandler)
-> Result<()>;
fn event(
&mut self,
commands: &mut Commands,
gui_handler: &mut GuiHandler,
button: ControllerButton,
) -> Result<bool>;
} }
impl_downcast!(Page); impl_downcast!(Page);
@ -140,17 +130,12 @@ pub struct CharacterWindow {
impl CharacterWindow { impl CharacterWindow {
pub fn new<A: Ability + 'static>( pub fn new<A: Ability + 'static>(
commands: &mut Commands, world: &mut World,
gui_handler: &mut GuiHandler,
engine_settings: &EngineSettings,
item_settings: &ItemSettings,
context: &Context,
hero: Entity, hero: Entity,
name: &str, name: &str,
close: Box<dyn FutureStateChange>, close: Box<dyn FutureStateChange>,
) -> Result<Arc<Self>> { ) -> Result<Arc<Self>> {
let menu_gui = let menu_gui = GuiBuilder::from_str(world, include_str!("../resources/menu.xml"))?;
GuiBuilder::from_str(commands, gui_handler, include_str!("../resources/menu.xml"))?;
let content_grid = menu_gui.element("tab_content")?; let content_grid = menu_gui.element("tab_content")?;
let open_character_page: Arc<Button> = menu_gui.element("open_statistics")?; let open_character_page: Arc<Button> = menu_gui.element("open_statistics")?;
@ -167,15 +152,9 @@ impl CharacterWindow {
tooltips: Mutex::default(), tooltips: Mutex::default(),
tabs: RwLock::new([ tabs: RwLock::new([
Box::new(CharacterPage::new(commands, gui_handler, hero, name, me).unwrap()), Box::new(CharacterPage::new(world, hero, name, me).unwrap()),
Box::new( Box::new(InventoryPage::<A>::new(world, hero, me.clone(), &close_button).unwrap()),
InventoryPage::<A>::new(commands, gui_handler, hero, me.clone(), &close_button) Box::new(AbilityPage::<A>::new(world, hero, me.clone(), &close_button).unwrap()),
.unwrap(),
),
Box::new(
AbilityPage::<A>::new(commands, gui_handler, hero, me.clone(), &close_button)
.unwrap(),
),
]), ]),
tab: AtomicUsize::new(0), tab: AtomicUsize::new(0),
}); });
@ -183,14 +162,13 @@ impl CharacterWindow {
let open_tab = { let open_tab = {
let weak_me = Arc::downgrade(&character_window); let weak_me = Arc::downgrade(&character_window);
move |commands: &mut Commands, gui_handler: &mut GuiHandler, index| { move |world: &mut World, index| {
if let Some(me) = weak_me.upgrade() { if let Some(me) = weak_me.upgrade() {
me.tab.store(index, SeqCst); me.tab.store(index, SeqCst);
let child = me.tab_mut().enable(commands, gui_handler)?; let child = me.tab_mut().enable(world)?;
me.tab_content_grid me.tab_content_grid.attach(world, child, 0, 0, 1, 1)?;
.attach(commands, gui_handler, child, 0, 0, 1, 1)?; me.tab().select(world)?;
me.tab().select(commands, gui_handler)?;
} }
Ok(()) Ok(())
@ -200,19 +178,19 @@ impl CharacterWindow {
open_character_page.set_callback({ open_character_page.set_callback({
let open_tab = open_tab.clone(); let open_tab = open_tab.clone();
move |commands, gui_handler| open_tab(commands, gui_handler, 0) move |world| open_tab(world, 0)
}); });
open_inventory_page.set_callback({ open_inventory_page.set_callback({
let open_tab = open_tab.clone(); let open_tab = open_tab.clone();
move |commands, gui_handler| open_tab(commands, gui_handler, 1) move |world| open_tab(world, 1)
}); });
open_ability_page.set_callback({ open_ability_page.set_callback({
let open_tab = open_tab.clone(); let open_tab = open_tab.clone();
move |commands, gui_handler| open_tab(commands, gui_handler, 2) move |world| open_tab(world, 2)
}); });
Self::setup_menu(&character_window)?; Self::setup_menu(&character_window)?;
@ -220,13 +198,8 @@ impl CharacterWindow {
Ok(character_window) Ok(character_window)
} }
pub fn event( pub fn event(&self, world: &mut World, button: ControllerButton) -> Result<bool> {
&self, self.tabs.write().unwrap()[self.tab.load(SeqCst)].event(world, button)
commands: &mut Commands,
gui_handler: &mut GuiHandler,
button: ControllerButton,
) -> Result<bool> {
self.tabs.write().unwrap()[self.tab.load(SeqCst)].event(commands, gui_handler, button)
} }
pub fn tabs<'a>(&'a self) -> Tabs<'a> { pub fn tabs<'a>(&'a self) -> Tabs<'a> {
@ -262,14 +235,9 @@ impl CharacterWindow {
.insert(name.to_string(), gui.into()); .insert(name.to_string(), gui.into());
} }
pub fn remove_tooltip( pub fn remove_tooltip(&self, world: &mut World, name: impl ToString) -> Result<()> {
&self,
commands: &mut Commands,
gui_handler: &mut GuiHandler,
name: impl ToString,
) -> Result<()> {
if let Some(tooltip) = self.tooltips.lock().unwrap().remove(&name.to_string()) { if let Some(tooltip) = self.tooltips.lock().unwrap().remove(&name.to_string()) {
tooltip.disable(commands, gui_handler)?; tooltip.disable(world)?;
} }
Ok(()) Ok(())
@ -312,13 +280,12 @@ impl TopLevelGui for CharacterWindow {
None None
} }
fn enable(&self, commands: &mut Commands, gui_handler: &mut GuiHandler) -> Result<()> { fn enable(&self, world: &mut World) -> Result<()> {
self.menu_gui.enable(commands, gui_handler)?; self.menu_gui.enable(world)?;
let child = self.tab_mut().enable(commands, gui_handler)?; let child = self.tab_mut().enable(world)?;
self.tab_content_grid self.tab_content_grid.attach(world, child, 0, 0, 1, 1)?;
.attach(commands, gui_handler, child, 0, 0, 1, 1)?; self.tab().select(world)?;
self.tab().select(commands, gui_handler)?;
let (gui_handler, engine_settings, context): ( let (gui_handler, engine_settings, context): (
&mut GuiHandler, &mut GuiHandler,
@ -347,8 +314,8 @@ impl TopLevelGui for CharacterWindow {
Ok(()) Ok(())
} }
fn disable(&self, commands: &mut Commands, gui_handler: &mut GuiHandler) -> Result<()> { fn disable(&self, world: &mut World) -> Result<()> {
self.menu_gui.disable(commands, gui_handler)?; self.menu_gui.disable(world)?;
Ok(()) Ok(())
} }
@ -369,48 +336,37 @@ impl GuiElementTraits for CharacterWindow {
} }
impl TopGui for CharacterWindow { impl TopGui for CharacterWindow {
fn decline(&self, commands: &mut Commands, gui_handler: &mut GuiHandler) -> Result<()> { fn decline(&self, world: &mut World) -> Result<()> {
(self.close)(commands, gui_handler) (self.close)(world)
} }
fn next_tab( fn next_tab(&self, world: &mut World, second_level: bool) -> Result<()> {
&self,
commands: &mut Commands,
gui_handler: &mut GuiHandler,
second_level: bool,
) -> Result<()> {
match second_level { match second_level {
false => { false => {
// disable old tab // disable old tab
self.tab_mut().disable(commands, gui_handler)?; self.tab_mut().disable(world)?;
// add to tab index // add to tab index
self.tab.store((self.tab.load(SeqCst) + 1) % 3, SeqCst); self.tab.store((self.tab.load(SeqCst) + 1) % 3, SeqCst);
// update tab content // update tab content
let child = self.tab_mut().enable(commands, gui_handler)?; let child = self.tab_mut().enable(world)?;
self.tab_content_grid self.tab_content_grid.attach(world, child, 0, 0, 1, 1)?;
.attach(commands, gui_handler, child, 0, 0, 1, 1)?; self.tab().select(world)?;
self.tab().select(commands, gui_handler)?;
} }
true => { true => {
self.tab_mut().next_tab(commands, gui_handler)?; self.tab_mut().next_tab(world)?;
} }
} }
Ok(()) Ok(())
} }
fn previous_tab( fn previous_tab(&self, world: &mut World, second_level: bool) -> Result<()> {
&self,
commands: &mut Commands,
gui_handler: &mut GuiHandler,
second_level: bool,
) -> Result<()> {
match second_level { match second_level {
false => { false => {
// disable old tab // disable old tab
self.tab_mut().disable(commands, gui_handler)?; self.tab_mut().disable(world)?;
// subtract from tab index // subtract from tab index
if self.tab.load(SeqCst) == 0 { if self.tab.load(SeqCst) == 0 {
@ -420,13 +376,12 @@ impl TopGui for CharacterWindow {
} }
// update tab content // update tab content
let child = self.tab_mut().enable(commands, gui_handler)?; let child = self.tab_mut().enable(world)?;
self.tab_content_grid self.tab_content_grid.attach(world, child, 0, 0, 1, 1)?;
.attach(commands, gui_handler, child, 0, 0, 1, 1)?; self.tab().select(world)?;
self.tab().select(commands, gui_handler)?;
} }
true => { true => {
self.tab_mut().previous_tab(commands, gui_handler)?; self.tab_mut().previous_tab(world)?;
} }
} }
@ -447,9 +402,7 @@ impl CharacterWindow {
// .add("open_statistics", open_statistics) // .add("open_statistics", open_statistics)
// .add("open_abilities", open_abilities) // .add("open_abilities", open_abilities)
// .add("open_inventory", open_inventory) // .add("open_inventory", open_inventory)
.add("close", move |commands, gui_handler| { .add("close", move |world| close(world))
close(commands, gui_handler)
})
.into(), .into(),
)?; )?;

View file

@ -8,12 +8,7 @@ use super::traits::*;
pub struct EmptyRightSide; pub struct EmptyRightSide;
impl RightSide for EmptyRightSide { impl RightSide for EmptyRightSide {
fn refresh( fn refresh(&mut self, _world: &mut World, _hero: Entity) -> Result<()> {
&mut self,
_commands: &mut Commands,
_gui_handler: &mut GuiHandler,
_hero: Entity,
) -> Result<()> {
unreachable!() unreachable!()
} }

View file

@ -14,19 +14,9 @@ pub trait PageContentWrapper: Send + Sync {
} }
pub trait RightSide: Send + Sync { pub trait RightSide: Send + Sync {
fn refresh( fn refresh(&mut self, world: &mut World, hero: Entity) -> Result<()>;
&mut self,
commands: &mut Commands,
gui_handler: &mut GuiHandler,
hero: Entity,
) -> Result<()>;
fn disable( fn disable(&mut self, _world: &mut World, _hero: Entity) -> Result<()> {
&mut self,
_commands: &mut Commands,
_gui_handler: &mut GuiHandler,
_hero: Entity,
) -> Result<()> {
Ok(()) Ok(())
} }

View file

@ -245,17 +245,10 @@ impl AbilityAddon {
Ok(item_system.addon(rarity, addon_type)) Ok(item_system.addon(rarity, addon_type))
} }
pub fn create_tooltip( pub fn create_tooltip(&self, world: &mut World, position: (i32, i32)) -> Result<Tooltip> {
&self, let gui = GuiBuilder::from_str(world, include_str!("../../resources/addon_snippet.xml"))?;
commands: &mut Commands,
gui_handler: &mut GuiHandler, let gui_handler: &mut GuiHandler = world.resources.get_mut()?;
position: (i32, i32),
) -> Result<Tooltip> {
let gui = GuiBuilder::from_str(
commands,
gui_handler,
include_str!("../../resources/addon_snippet.xml"),
)?;
let icon: Arc<Icon> = gui.element("addon_icon")?; let icon: Arc<Icon> = gui.element("addon_icon")?;
let rarity_label: Arc<Label> = gui.element("rarity_label")?; let rarity_label: Arc<Label> = gui.element("rarity_label")?;

View file

@ -298,16 +298,13 @@ impl<A: Ability> AbilityBook<A> {
pub fn create_tooltip( pub fn create_tooltip(
&self, &self,
commands: &mut Commands, world: &mut World,
gui_handler: &mut GuiHandler,
statistics: &Statistics, statistics: &Statistics,
position: (i32, i32), position: (i32, i32),
) -> Result<Tooltip> { ) -> Result<Tooltip> {
let gui = GuiBuilder::from_str( let gui = GuiBuilder::from_str(world, include_str!("../../resources/book_snippet.xml"))?;
commands,
gui_handler, let gui_handler: &mut GuiHandler = world.resources.get_mut()?;
include_str!("../../resources/book_snippet.xml"),
)?;
let ability_name: Arc<Label> = gui.element("ability_name")?; let ability_name: Arc<Label> = gui.element("ability_name")?;
let rarity_label: Arc<Label> = gui.element("rarity_label")?; let rarity_label: Arc<Label> = gui.element("rarity_label")?;

View file

@ -233,15 +233,16 @@ impl Item {
pub fn create_tooltip( pub fn create_tooltip(
&self, &self,
commands: &mut Commands, world: &mut World,
gui_handler: &mut GuiHandler,
attributes: &Attributes, attributes: &Attributes,
position: (i32, i32), position: (i32, i32),
) -> Result<Tooltip> { ) -> Result<Tooltip> {
let (stats, jewels) = ItemAffix::squash(self.affixes.iter()); let (stats, jewels) = ItemAffix::squash(self.affixes.iter());
let count = stats.len() + jewels.len(); let count = stats.len() + jewels.len();
let inspector_snippet = GuiBuilder::from_str(commands, gui_handler, &ITEM_SNIPPETS[count])?; let inspector_snippet = GuiBuilder::from_str(world, &ITEM_SNIPPETS[count])?;
let gui_handler = world.resources.get_mut_unchecked::<GuiHandler>();
let item_icon: Arc<Icon> = inspector_snippet.element("item_icon")?; let item_icon: Arc<Icon> = inspector_snippet.element("item_icon")?;
let slot_label: Arc<Label> = inspector_snippet.element("slot_label")?; let slot_label: Arc<Label> = inspector_snippet.element("slot_label")?;
@ -288,11 +289,8 @@ impl Item {
let mut index = Self::INSPECTOR_OFFSET; let mut index = Self::INSPECTOR_OFFSET;
for stat in stats { for stat in stats {
let stat_type_snippet = GuiSnippet::from_str( let stat_type_snippet =
commands, GuiSnippet::from_str(world, include_str!("../../resources/stat_type_snippet.xml"))?;
gui_handler,
include_str!("../../resources/stat_type_snippet.xml"),
)?;
let stat_type_label: Arc<Label> = stat_type_snippet.element("stat_type")?; let stat_type_label: Arc<Label> = stat_type_snippet.element("stat_type")?;
let stat_value_label: Arc<Label> = stat_type_snippet.element("stat_value")?; let stat_value_label: Arc<Label> = stat_type_snippet.element("stat_value")?;
@ -300,15 +298,14 @@ impl Item {
stat_type_label.set_text(gui_handler, &format!("{}", stat))?; stat_type_label.set_text(gui_handler, &format!("{}", stat))?;
stat_value_label.set_text(gui_handler, &stat.display_value())?; stat_value_label.set_text(gui_handler, &stat.display_value())?;
inspector_grid.attach(commands, gui_handler, stat_type_snippet, 0, index, 1, 1)?; inspector_grid.attach(world, stat_type_snippet, 0, index, 1, 1)?;
index += 1; index += 1;
} }
for jewel in jewels { for jewel in jewels {
let socket_snippet = GuiSnippet::from_str( let socket_snippet = GuiSnippet::from_str(
commands, world,
gui_handler,
include_str!("../../resources/item_socket_snippet.xml"), include_str!("../../resources/item_socket_snippet.xml"),
)?; )?;
@ -332,7 +329,7 @@ impl Item {
} }
} }
inspector_grid.attach(commands, gui_handler, socket_snippet, 0, index, 1, 1)?; inspector_grid.attach(world, socket_snippet, 0, index, 1, 1)?;
index += 1; index += 1;
} }

View file

@ -60,16 +60,14 @@ impl Jewel {
pub fn create_tooltip( pub fn create_tooltip(
&self, &self,
commands: &mut Commands, world: &mut World,
gui_handler: &mut GuiHandler,
item_settings: &ItemSettings, item_settings: &ItemSettings,
position: (i32, i32), position: (i32, i32),
) -> Result<Tooltip> { ) -> Result<Tooltip> {
let inspector_snippet: Arc<GuiBuilder> = GuiBuilder::from_str( let inspector_snippet: Arc<GuiBuilder> =
commands, GuiBuilder::from_str(world, include_str!("../../resources/jewel_tooltip.xml"))?;
gui_handler,
include_str!("../../resources/jewel_tooltip.xml"), let gui_handler: &mut GuiHandler = world.resources.get_mut()?;
)?;
let main_grid: Arc<Grid> = inspector_snippet.element("main_grid")?; let main_grid: Arc<Grid> = inspector_snippet.element("main_grid")?;
main_grid.change_position_unscaled(gui_handler, position.0, position.1)?; main_grid.change_position_unscaled(gui_handler, position.0, position.1)?;

View file

@ -18,8 +18,8 @@ impl Tooltip {
Self { grid, gui } Self { grid, gui }
} }
pub fn enable(&self, commands: &mut Commands, gui_handler: &mut GuiHandler) -> Result<()> { pub fn enable(&self, world: &mut World) -> Result<()> {
self.gui.enable(commands, gui_handler) self.gui.enable(world)
} }
pub fn check_fitting( pub fn check_fitting(