From 81be82d0c6dab3f64a4ae32a91e5d0060f0d3009 Mon Sep 17 00:00:00 2001 From: Melik Houij Date: Thu, 23 Mar 2023 20:37:32 +0100 Subject: [PATCH] more work --- src/debug.rs | 59 ++++++++++++++++++++++++++++++++++++++++------------ src/scene.rs | 1 + 2 files changed, 47 insertions(+), 13 deletions(-) diff --git a/src/debug.rs b/src/debug.rs index 8705e48..ef1d5db 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -23,21 +23,23 @@ pub enum Callback { ModelInfo(info::ModelI), TestWind(info::testI), + MainMenu, } #[derive(Clone)] pub enum OpenWindows { - ModelInfo, - TestWind, + ModelInfo, + TestWind, + MainMenu, } pub struct Debug { imgui: imgui::Context, renderer: AutoRenderer, platform: SdlPlatform, - pub windows: HashMap, - next_id: i16, - free_ids:Vec + pub windows: HashMap, + next_id: u16, + free_ids:Vec } @@ -59,13 +61,13 @@ impl Debug { }; let mut windows = HashMap::new(); - windows.insert(0,OpenWindows::TestWind,); + windows.insert(0,OpenWindows::MainMenu,); Debug { imgui, renderer, platform, windows, - next_id: 2, + next_id: 1, free_ids: Vec::new(), } } @@ -85,12 +87,13 @@ impl Debug { { match call { Callback::ModelInfo(a) => - { - ret.append(&mut Debug::displayModel(ui, &a)) - }, + ret.append(&mut Debug::displayModel(ui, &a)), Callback::TestWind(mut a) => ret.append(&mut Debug::displayTest(ui, &mut a)), + Callback::MainMenu => + ret.append(&mut Debug::displayMain(ui)), } + } @@ -106,6 +109,7 @@ impl Debug { if (self.free_ids.is_empty()) { self.windows.insert(self.next_id, window); + self.next_id += 1; } else { self.windows.insert(self.free_ids.pop().unwrap(), window); @@ -118,6 +122,11 @@ impl Debug { for (hashId, windowType) in &self.windows { if let _window = windowType {id = *hashId; println!("found a match!")}; + match windowType + { + window => id = *hashId, + _ => () + } } self.windows.remove(&id); @@ -136,8 +145,8 @@ impl Debug { ui.text("Your Purpose in life is to suck my dick"); ui.slider("The Spin Speed", 0.1, 10.0, &mut spinSpeed); if ui - .button("Quit") { - ret.push(dEvent::exit); + .button("Close") { + ret.push(dEvent::removeWindow(OpenWindows::TestWind)); } if ui.list_box("Select Model to Load", &mut selectedModel, &MODELS, 5) { ret.push(dEvent::loadModel(selectedModel)); @@ -170,7 +179,31 @@ impl Debug { ret } -} + fn displayMain(ui: &mut imgui::Ui) -> Vec + { + let mut ret = Vec::new(); + ui.window("Welcome to the main Menu") + .size([500.0, 500.0], imgui::Condition::Always) + .build(|| { + ui.text("this is the main Debugger Menu, it's used to Debug the game"); + ui.text("although it isn't done yet"); + ui.separator(); + if ui.button("Open the Model Info") { + ret.push(dEvent::addWindow(OpenWindows::ModelInfo)) + } + if ui.button("Open the Test Modifier"){ + ret.push(dEvent::addWindow(OpenWindows::TestWind)) + } + if ui.button("Quit") { + ret.push(dEvent::exit) + } + + }); + ret + } + + + } diff --git a/src/scene.rs b/src/scene.rs index 4e9a55f..1313a5f 100644 --- a/src/scene.rs +++ b/src/scene.rs @@ -125,6 +125,7 @@ impl Scene{ match window { debug::OpenWindows::ModelInfo => Callbacks.push(debug::ModelInfo(&self.Car)), debug::OpenWindows::TestWind => Callbacks.push(debug::TestWind(self.tempData.spinSpeed, self.tempData.selectedModel)), + debug::OpenWindows::MainMenu => Callbacks.push(debug::Callback::MainMenu), } }