Compare commits
2 commits
837a877dbe
...
f29382b9ac
Author | SHA1 | Date | |
---|---|---|---|
f29382b9ac | |||
956122549e |
10 changed files with 27 additions and 32 deletions
|
@ -2,7 +2,7 @@ use crate::prelude::*;
|
|||
use anyhow::{Context, Result, bail};
|
||||
|
||||
use assetpath::AssetPath;
|
||||
use ecs::World;
|
||||
use ecs::*;
|
||||
|
||||
use super::validator::buttoninfo::{NeighbourDirection, NeighbourInfo};
|
||||
use super::validator::gridinfo::GridInfo;
|
||||
|
@ -310,7 +310,7 @@ impl TopLevelGui for GuiBuilder {
|
|||
self.set_visibility(world, true)?;
|
||||
|
||||
if let Some(button) = &self.default_select {
|
||||
button.select(world.resources.get_mut::<GuiHandler>())?;
|
||||
button.select(world.resources.get_mut()?)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::{
|
|||
|
||||
use anyhow::{Result, anyhow};
|
||||
use assetpath::AssetPath;
|
||||
use ecs::World;
|
||||
use ecs::*;
|
||||
use utilities::prelude::*;
|
||||
use vulkan_rs::prelude::*;
|
||||
|
||||
|
@ -450,7 +450,7 @@ impl Visibility for Button {
|
|||
|
||||
fn set_visibility(&self, world: &mut World, visibility: bool) -> Result<()> {
|
||||
if visibility != self.visible.load(SeqCst) {
|
||||
let gui_handler = world.resources.get_mut::<GuiHandler>();
|
||||
let gui_handler: &mut GuiHandler = world.resources.get_mut()?;
|
||||
|
||||
self.visible.store(visibility, SeqCst);
|
||||
|
||||
|
@ -583,7 +583,7 @@ impl Button {
|
|||
|
||||
let selected_changed = move |world: &mut World, selected: bool| {
|
||||
if let Some(button) = button_weak.upgrade() {
|
||||
let gui_handler = world.resources.get_mut::<GuiHandler>();
|
||||
let gui_handler = world.resources.get_mut()?;
|
||||
|
||||
if selected {
|
||||
button.set_button_state(gui_handler, ButtonState::Selected)?;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
use anyhow::Result;
|
||||
use ecs::World;
|
||||
use ecs::*;
|
||||
|
||||
use crate::builder::validator::gridinfo::GridInfo;
|
||||
|
||||
|
@ -445,7 +445,7 @@ impl Grid {
|
|||
|
||||
if self.framable.is_framed() {
|
||||
self.child_position(
|
||||
world.resources.get_mut::<GuiHandler>(),
|
||||
world.resources.get_mut()?,
|
||||
child_gridable,
|
||||
pos_x,
|
||||
pos_y,
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::{
|
|||
};
|
||||
use anyhow::Result;
|
||||
use assetpath::AssetPath;
|
||||
use ecs::World;
|
||||
use ecs::*;
|
||||
use utilities::prelude::*;
|
||||
use vulkan_rs::prelude::*;
|
||||
|
||||
|
@ -283,7 +283,7 @@ impl Visibility for Icon {
|
|||
|
||||
fn set_visibility(&self, world: &mut World, visibility: bool) -> Result<()> {
|
||||
if visibility != self.visible.load(SeqCst) {
|
||||
let gui_handler = world.resources.get_mut::<GuiHandler>();
|
||||
let gui_handler: &mut GuiHandler = world.resources.get_mut()?;
|
||||
|
||||
self.visible.store(visibility, SeqCst);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ use super::{
|
|||
wrapper::{IconizableWrapper, TextableWrapper},
|
||||
};
|
||||
|
||||
use ecs::World;
|
||||
use ecs::*;
|
||||
use vulkan_rs::prelude::*;
|
||||
|
||||
use std::sync::{
|
||||
|
@ -232,7 +232,7 @@ impl Visibility for Label {
|
|||
|
||||
fn set_visibility(&self, world: &mut World, visibility: bool) -> Result<()> {
|
||||
if visibility != self.visible() {
|
||||
let gui_handler = world.resources.get_mut::<GuiHandler>();
|
||||
let gui_handler: &mut GuiHandler = world.resources.get_mut()?;
|
||||
|
||||
self.visible.store(visibility, SeqCst);
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ use std::sync::{
|
|||
};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use ecs::World;
|
||||
use ecs::*;
|
||||
use utilities::prelude::*;
|
||||
|
||||
use super::fill_type::InnerFillType;
|
||||
|
@ -103,7 +103,7 @@ impl MultiLineTextFieldBuilder {
|
|||
|
||||
move |world: &mut World, _text| {
|
||||
if let Some(tf) = weak_tf.upgrade() {
|
||||
tf.update_text(world.resources.get_mut::<GuiHandler>())?;
|
||||
tf.update_text(world.resources.get_mut()?)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -378,7 +378,7 @@ impl Visibility for MultiLineTextField {
|
|||
|
||||
fn set_visibility(&self, world: &mut World, visibility: bool) -> Result<()> {
|
||||
if visibility != self.visible() {
|
||||
let gui_handler = world.resources.get_mut::<GuiHandler>();
|
||||
let gui_handler = world.resources.get_mut()?;
|
||||
|
||||
if visibility {
|
||||
self.writeable.add(gui_handler)?;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{builder::validator::progressbar_info::ProgressBarInfo, prelude::*};
|
||||
|
||||
use anyhow::Result;
|
||||
use ecs::World;
|
||||
use ecs::*;
|
||||
use std::sync::{
|
||||
Arc, Mutex,
|
||||
atomic::{AtomicBool, Ordering::SeqCst},
|
||||
|
@ -281,7 +281,7 @@ impl Visibility for ProgressBar {
|
|||
|
||||
fn set_visibility(&self, world: &mut World, visibility: bool) -> Result<()> {
|
||||
if visibility != self.visible() {
|
||||
let gui_handler = world.resources.get_mut::<GuiHandler>();
|
||||
let gui_handler: &mut GuiHandler = world.resources.get_mut()?;
|
||||
|
||||
self.visible.store(visibility, SeqCst);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{builder::validator::textfieldinfo::TextFieldInfo, prelude::*};
|
||||
use anyhow::Result;
|
||||
use ecs::World;
|
||||
use ecs::*;
|
||||
use utilities::prelude::*;
|
||||
|
||||
use std::sync::{
|
||||
|
@ -313,7 +313,7 @@ impl Visibility for TextField {
|
|||
|
||||
fn set_visibility(&self, world: &mut World, visibility: bool) -> Result<()> {
|
||||
if visibility != self.visible() {
|
||||
let gui_handler = world.resources.get_mut::<GuiHandler>();
|
||||
let gui_handler: &mut GuiHandler = world.resources.get_mut()?;
|
||||
|
||||
self.visible.store(visibility, SeqCst);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::prelude::*;
|
||||
use anyhow::Result;
|
||||
use ecs::World;
|
||||
use ecs::*;
|
||||
|
||||
use std::any::Any;
|
||||
use std::collections::HashMap;
|
||||
|
@ -296,8 +296,7 @@ impl Keyboard {
|
|||
|
||||
Box::new(move |world: &mut World| {
|
||||
if let Some(text_field) = weak_textfield.upgrade() {
|
||||
let gui_handler = world.resources.get_mut::<GuiHandler>();
|
||||
text_field.add_letter(gui_handler, ' ')?;
|
||||
text_field.add_letter(world.resources.get_mut()?, ' ')?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -340,8 +339,8 @@ impl Keyboard {
|
|||
if let Some(textfield) = weak_textfield.upgrade() {
|
||||
if let Some(button) = weak_button.upgrade() {
|
||||
if let Some(text) = button.text()? {
|
||||
let gui_handler = world.resources.get_mut::<GuiHandler>();
|
||||
textfield.add_letter(gui_handler, text.as_bytes()[0] as char)?;
|
||||
textfield
|
||||
.add_letter(world.resources.get_mut()?, text.as_bytes()[0] as char)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -369,8 +368,7 @@ impl TopGui for Keyboard {
|
|||
fn previous_tab(&self, world: &mut World, second_level: bool) -> Result<()> {
|
||||
// abuse event
|
||||
if !second_level {
|
||||
let gui_handler = world.resources.get_mut::<GuiHandler>();
|
||||
self.text_field.remove_last(gui_handler)?;
|
||||
self.text_field.remove_last(world.resources.get_mut()?)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -442,8 +440,7 @@ impl TopLevelGui for Keyboard {
|
|||
|
||||
fn enable(&self, world: &mut World) -> Result<()> {
|
||||
self.set_visibility(world, true)?;
|
||||
self.text_field
|
||||
.focus_input(world.resources.get_mut::<GuiHandler>())?;
|
||||
self.text_field.focus_input(world.resources.get_mut()?)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
use crate::prelude::*;
|
||||
use anyhow::Result;
|
||||
use assetpath::AssetPath;
|
||||
use ecs::World;
|
||||
use utilities::prelude::remove_life_time_mut;
|
||||
use ecs::*;
|
||||
|
||||
use std::any::Any;
|
||||
use std::collections::HashMap;
|
||||
|
@ -182,7 +181,7 @@ impl States {
|
|||
///
|
||||
/// * `id` - Set state with the given identifier or None
|
||||
pub fn set_state<'b>(&self, world: &mut World, id: impl Into<Option<&'b str>>) -> Result<()> {
|
||||
let gui_handler = unsafe { remove_life_time_mut(world.resources.get_mut::<GuiHandler>()) };
|
||||
let gui_handler: &mut GuiHandler = world.resources.get_mut_unchecked();
|
||||
|
||||
Self::_set_state(
|
||||
id.into().map(|id| self.get_state(id)).transpose()?,
|
||||
|
@ -261,8 +260,7 @@ impl States {
|
|||
|
||||
Ok(Box::new(move |world: &mut World| {
|
||||
if let Some(current) = weak_current_state.upgrade() {
|
||||
let gui_handler =
|
||||
unsafe { remove_life_time_mut(world.resources.get_mut::<GuiHandler>()) };
|
||||
let gui_handler: &mut GuiHandler = world.resources.get_mut_unchecked();
|
||||
|
||||
Self::_set_state(
|
||||
weak_state.as_ref().map(|w| w.upgrade()).flatten(),
|
||||
|
|
Loading…
Reference in a new issue