diff options
author | Silas Bartha <[email protected]> | 2024-05-16 20:28:58 -0400 |
---|---|---|
committer | Silas Bartha <[email protected]> | 2024-05-16 20:28:58 -0400 |
commit | 56aafda8495243fa939bdce01f36d4adbf4ec556 (patch) | |
tree | df8b1bbe1dc0e8b3f2d179a36c015b16e1f3d483 /src/resources.rs | |
parent | 363157a7f831fc29c6ed1a26880ea756521317b9 (diff) |
Added configurable logfile path
Diffstat (limited to 'src/resources.rs')
-rw-r--r-- | src/resources.rs | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/src/resources.rs b/src/resources.rs index a8d5a7f..a373a80 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -1,11 +1,10 @@ use std::{ - io::{stdout, Stdout}, - sync::{Arc, Mutex}, + any::Any, io::{stdout, Stdout}, sync::{Arc, Mutex} }; use bevy::{ prelude::*, - utils::{HashMap, HashSet, Uuid}, + utils::HashSet, }; use crossterm::{ event::{ @@ -72,34 +71,34 @@ impl Default for Terminal { } } -#[derive(Resource, Default)] -pub struct TerminalUI { - widgets: HashMap<Uuid, Box<dyn TerminalWidget + Sync + Send>>, -} - -impl TerminalUI { - pub fn insert_widget(&mut self, widget: Box<dyn TerminalWidget + Sync + Send>) -> Uuid { - let id = Uuid::new_v4(); - self.widgets.insert(id, widget); - id - } - - pub fn get_widget(&mut self, id: Uuid) -> Option<&mut Box<dyn TerminalWidget + Sync + Send>> { - self.widgets.get_mut(&id) - } - - pub fn destroy_widget(&mut self, id: Uuid) { - self.widgets.remove(&id); - } - - pub fn widgets(&mut self) -> Vec<&mut Box<dyn TerminalWidget + Sync + Send>> { - let mut vec = self.widgets.values_mut().collect::<Vec<_>>(); - vec.sort_by(|a, b| a.depth().cmp(&b.depth()).reverse()); - vec - } -} - -pub trait TerminalWidget { +// #[derive(Resource, Default)] +// pub struct TerminalUI { +// widgets: HashMap<Uuid, Box<dyn TerminalWidget + Sync + Send>>, +// } +// +// impl TerminalUI { +// pub fn insert_widget(&mut self, widget: Box<dyn TerminalWidget + Sync + Send>) -> Uuid { +// let id = Uuid::new_v4(); +// self.widgets.insert(id, widget); +// id +// } +// +// pub fn get_widget(&mut self, id: Uuid) -> Option<&mut Box<dyn TerminalWidget + Sync + Send>> { +// self.widgets.get_mut(&id) +// } +// +// pub fn destroy_widget(&mut self, id: Uuid) { +// self.widgets.remove(&id); +// } +// +// pub fn widgets(&mut self) -> Vec<&mut Box<dyn TerminalWidget + Sync + Send>> { +// let mut vec = self.widgets.values_mut().collect::<Vec<_>>(); +// vec.sort_by(|a, b| a.depth().cmp(&b.depth()).reverse()); +// vec +// } +// } + +pub trait TerminalWidget: Any { fn init(&mut self) {} fn update(&mut self) {} fn render(&mut self, frame: &mut Frame, rect: Rect); |