From 56aafda8495243fa939bdce01f36d4adbf4ec556 Mon Sep 17 00:00:00 2001 From: Silas Bartha Date: Thu, 16 May 2024 20:28:58 -0400 Subject: Added configurable logfile path --- src/resources.rs | 61 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 31 deletions(-) (limited to 'src/resources.rs') 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>, -} - -impl TerminalUI { - pub fn insert_widget(&mut self, widget: Box) -> Uuid { - let id = Uuid::new_v4(); - self.widgets.insert(id, widget); - id - } - - pub fn get_widget(&mut self, id: Uuid) -> Option<&mut Box> { - 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> { - let mut vec = self.widgets.values_mut().collect::>(); - vec.sort_by(|a, b| a.depth().cmp(&b.depth()).reverse()); - vec - } -} - -pub trait TerminalWidget { +// #[derive(Resource, Default)] +// pub struct TerminalUI { +// widgets: HashMap>, +// } +// +// impl TerminalUI { +// pub fn insert_widget(&mut self, widget: Box) -> Uuid { +// let id = Uuid::new_v4(); +// self.widgets.insert(id, widget); +// id +// } +// +// pub fn get_widget(&mut self, id: Uuid) -> Option<&mut Box> { +// 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> { +// let mut vec = self.widgets.values_mut().collect::>(); +// 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); -- cgit v1.2.3