more work
parent
542223ddd9
commit
81be82d0c6
59
src/debug.rs
59
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<i16, OpenWindows>,
|
||||
next_id: i16,
|
||||
free_ids:Vec<i16>
|
||||
pub windows: HashMap<u16, OpenWindows>,
|
||||
next_id: u16,
|
||||
free_ids:Vec<u16>
|
||||
}
|
||||
|
||||
|
||||
|
@ -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<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
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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),
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue