more work

pull/3/head
Milk.H 2023-03-23 20:37:32 +01:00
parent 542223ddd9
commit 81be82d0c6
No known key found for this signature in database
GPG Key ID: 3D9DAE46AAC37BD8
2 changed files with 47 additions and 13 deletions

View File

@ -23,21 +23,23 @@ pub enum Callback
{ {
ModelInfo(info::ModelI), ModelInfo(info::ModelI),
TestWind(info::testI), TestWind(info::testI),
MainMenu,
} }
#[derive(Clone)] #[derive(Clone)]
pub enum OpenWindows { pub enum OpenWindows {
ModelInfo, ModelInfo,
TestWind, TestWind,
MainMenu,
} }
pub struct Debug { pub struct Debug {
imgui: imgui::Context, imgui: imgui::Context,
renderer: AutoRenderer, renderer: AutoRenderer,
platform: SdlPlatform, platform: SdlPlatform,
pub windows: HashMap<i16, OpenWindows>, pub windows: HashMap<u16, OpenWindows>,
next_id: i16, next_id: u16,
free_ids:Vec<i16> free_ids:Vec<u16>
} }
@ -59,13 +61,13 @@ impl Debug {
}; };
let mut windows = HashMap::new(); let mut windows = HashMap::new();
windows.insert(0,OpenWindows::TestWind,); windows.insert(0,OpenWindows::MainMenu,);
Debug { Debug {
imgui, imgui,
renderer, renderer,
platform, platform,
windows, windows,
next_id: 2, next_id: 1,
free_ids: Vec::new(), free_ids: Vec::new(),
} }
} }
@ -85,12 +87,13 @@ impl Debug {
{ {
match call { match call {
Callback::ModelInfo(a) => Callback::ModelInfo(a) =>
{ ret.append(&mut Debug::displayModel(ui, &a)),
ret.append(&mut Debug::displayModel(ui, &a))
},
Callback::TestWind(mut a) => Callback::TestWind(mut a) =>
ret.append(&mut Debug::displayTest(ui, &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()) if (self.free_ids.is_empty())
{ {
self.windows.insert(self.next_id, window); self.windows.insert(self.next_id, window);
self.next_id += 1;
} }
else { else {
self.windows.insert(self.free_ids.pop().unwrap(), window); self.windows.insert(self.free_ids.pop().unwrap(), window);
@ -118,6 +122,11 @@ impl Debug {
for (hashId, windowType) in &self.windows for (hashId, windowType) in &self.windows
{ {
if let _window = windowType {id = *hashId; println!("found a match!")}; if let _window = windowType {id = *hashId; println!("found a match!")};
match windowType
{
window => id = *hashId,
_ => ()
}
} }
self.windows.remove(&id); self.windows.remove(&id);
@ -136,8 +145,8 @@ impl Debug {
ui.text("Your Purpose in life is to suck my dick"); ui.text("Your Purpose in life is to suck my dick");
ui.slider("The Spin Speed", 0.1, 10.0, &mut spinSpeed); ui.slider("The Spin Speed", 0.1, 10.0, &mut spinSpeed);
if ui if ui
.button("Quit") { .button("Close") {
ret.push(dEvent::exit); ret.push(dEvent::removeWindow(OpenWindows::TestWind));
} }
if ui.list_box("Select Model to Load", &mut selectedModel, &MODELS, 5) { if ui.list_box("Select Model to Load", &mut selectedModel, &MODELS, 5) {
ret.push(dEvent::loadModel(selectedModel)); ret.push(dEvent::loadModel(selectedModel));
@ -170,7 +179,31 @@ impl Debug {
ret ret
} }
} fn displayMain(ui: &mut imgui::Ui) -> Vec<dEvent>
{
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
}
}

View File

@ -125,6 +125,7 @@ impl Scene{
match window { match window {
debug::OpenWindows::ModelInfo => Callbacks.push(debug::ModelInfo(&self.Car)), debug::OpenWindows::ModelInfo => Callbacks.push(debug::ModelInfo(&self.Car)),
debug::OpenWindows::TestWind => Callbacks.push(debug::TestWind(self.tempData.spinSpeed, self.tempData.selectedModel)), debug::OpenWindows::TestWind => Callbacks.push(debug::TestWind(self.tempData.spinSpeed, self.tempData.selectedModel)),
debug::OpenWindows::MainMenu => Callbacks.push(debug::Callback::MainMenu),
} }
} }