Skip to content

Commit

Permalink
Fixed an issue you using all_children_iter
Browse files Browse the repository at this point in the history
  • Loading branch information
mrhatman committed Feb 2, 2020
1 parent 9590395 commit 01bdea8
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 35 deletions.
11 changes: 9 additions & 2 deletions examples/states_ui/credits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ use amethyst::{
winit::{MouseButton, VirtualKeyCode},
};

<<<<<<< Updated upstream
use crate::{menu::MainMenu, util::delete_hierarchy};
=======
use crate::menu::MainMenu;
>>>>>>> Stashed changes

// A simple 'Screen' State, only capable of loading/showing the prefab ui and registering simple
// UI interactions (pressing escape or clicking anywhere).
Expand Down Expand Up @@ -48,9 +52,12 @@ impl SimpleState for CreditsScreen {
}

fn on_stop(&mut self, data: StateData<GameData>) {
if let Some(handler) = self.ui_handle {
delete_hierarchy(handler, data.world).expect("Failed to remove CreditScreen");
if let Some(root_entity) = self.ui_handle {
data.world
.delete_entity(root_entity)
.expect("Failed to remove CreditScreen");
}

self.ui_handle = None;
}
}
11 changes: 9 additions & 2 deletions examples/states_ui/game.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<<<<<<< Updated upstream
use crate::{pause::PauseMenuState, util::delete_hierarchy};
=======
use crate::pause::PauseMenuState;
>>>>>>> Stashed changes
use amethyst::{
audio::output::init_output,
core::Time,
Expand Down Expand Up @@ -46,9 +50,12 @@ impl SimpleState for Game {
}

fn on_stop(&mut self, data: StateData<'_, GameData<'_, '_>>) {
if let Some(entity) = self.ui_root {
delete_hierarchy(entity, data.world).expect("Failed to remove Game Screen");
if let Some(root_entity) = self.ui_root {
data.world
.delete_entity(root_entity)
.expect("Failed to remove Game Screen");
}

self.ui_root = None;
self.fps_display = None;
self.random_text = None;
Expand Down
1 change: 0 additions & 1 deletion examples/states_ui/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ mod events;
mod game;
mod menu;
mod pause;
mod util;
mod welcome;

/// Quick overview what you can do when running this example:
Expand Down
7 changes: 5 additions & 2 deletions examples/states_ui/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,12 @@ impl SimpleState for MainMenu {

fn on_stop(&mut self, data: StateData<GameData>) {
// after destroying the current UI, invalidate references as well (makes things cleaner)
if let Some(entity) = self.ui_root {
delete_hierarchy(entity, data.world).expect("Failed to remove MainMenu");
if let Some(root_entity) = self.ui_root {
data.world
.delete_entity(root_entity)
.expect("Failed to remove MainMenu");
}

self.ui_root = None;
self.button_start = None;
self.button_load = None;
Expand Down
25 changes: 0 additions & 25 deletions examples/states_ui/util.rs

This file was deleted.

8 changes: 5 additions & 3 deletions examples/states_ui/welcome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use amethyst::{
winit::{MouseButton, VirtualKeyCode},
};

use crate::util::delete_hierarchy;

#[derive(Default, Debug)]
pub struct WelcomeScreen {
Expand Down Expand Up @@ -43,9 +42,12 @@ impl SimpleState for WelcomeScreen {
}

fn on_stop(&mut self, data: StateData<GameData>) {
if let Some(handler) = self.ui_handle {
delete_hierarchy(handler, data.world).expect("Failed to remove WelcomeScreen");
if let Some(root_entity) = self.ui_handle {
data.world
.delete_entity(root_entity)
.expect("Failed to remove WelcomeScreen");
}

self.ui_handle = None;
}
}

0 comments on commit 01bdea8

Please sign in to comment.