diff --git a/README.md b/README.md index 995dde1..75fb336 100644 --- a/README.md +++ b/README.md @@ -203,4 +203,14 @@ since the last update i did a few things. ```rust pub struct crate::std::io::Element -``` \ No newline at end of file +``` + +## UPDATE: 29/04/23 + +after taking a bit of a break to get my A level work done and play some games, i've finally found time to get back into +this project + +over the last couple of days I've made some signifcant changes to this project. +I have started the development of a TUI (terminal user interface) library allowing for widgets to be displayed +on screen using ascii. +its pretty barebones at the moment but I'm hoping to add more features as time goes on! diff --git a/src/user/lib/libgui/libgui_core.rs b/src/user/lib/libgui/libgui_core.rs index 896192c..4e94a95 100644 --- a/src/user/lib/libgui/libgui_core.rs +++ b/src/user/lib/libgui/libgui_core.rs @@ -39,19 +39,19 @@ pub trait Element { } } -pub struct Container { +pub struct Container<'a> { // a simple container objects for grouping // other containers together frame: Vec>, - elements: Vec>, + elements: Vec>, position: Pos, // x,y // outlined: bool, dimensions: Pos, // x,y } -impl Container { - fn new(position: Pos, dimensions: Pos, outlined: bool) -> Container { +impl Container<'a> { + fn new(position: Pos, dimensions: Pos, outlined: bool) -> Container<'a> { Self { frame: vec![vec![' '; dimensions.x as usize]; dimensions.y as usize], elements: Vec::new(), @@ -60,12 +60,9 @@ impl Container { dimensions, } } - fn place(&self, element: Vec>) { - return; // unimplemented - } } -impl Element for Container { +impl Element for Container<'_> { fn render(&self) -> (Vec>, Pos) { // returns all elements as a single frame @@ -255,18 +252,18 @@ pub fn test_elements() { containers.push(Container::new(Pos::new(0, 1), Pos::new(80, 24), true)); - containers[0] - .elements - .push(Box::new(libgui_elements::TextBox::new( - String::from("ANNOUNCEMENTS"), - String::from( - "CrystalRPG coming soon! XD + let tbox = libgui_elements::TextBox::new( + String::from("ANNOUNCEMENTS"), + String::from( + "CrystalRPG coming soon! XD this is gonna be the best game ever", - ), - Pos::new(25, 10), - Pos::new(0, 0), - true, - ))); + ), + Pos::new(25, 10), + Pos::new(0, 0), + true, + ); + + containers[0].elements.push(Box::new(&tbox)); let mut bar = IndicatorBar::new(Pos::new(7, 7), 12); bar.set_value(70); @@ -280,7 +277,7 @@ this is gonna be the best game ever", // function to generate a box in a random location on the screen. -fn generate_box() -> Container { +fn generate_box() -> Container<'static> { use crate::std::random::Random; let width = Random::int(5, 20); let height = Random::int(5, 10);