Compare commits
2 Commits
be875dbf3e
...
9b9fd65574
Author | SHA1 | Date |
---|---|---|
Milk.H | 9b9fd65574 | |
Milk.H | 2999765fde |
12
src/debug.rs
12
src/debug.rs
|
@ -106,6 +106,17 @@ impl Debug {
|
|||
}
|
||||
pub fn addWindow(&mut self, window: OpenWindows)
|
||||
{
|
||||
let mut found = false;
|
||||
for (hashId, windowType) in &self.windows
|
||||
{
|
||||
if *windowType == window
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
if (self.free_ids.is_empty())
|
||||
{
|
||||
self.windows.insert(self.next_id, window);
|
||||
|
@ -114,6 +125,7 @@ impl Debug {
|
|||
else {
|
||||
self.windows.insert(self.free_ids.pop().unwrap(), window);
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn removeWindow(&mut self, window: OpenWindows)
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@ use cgmath::prelude::*;
|
|||
use std::sync::Arc;
|
||||
const SCR_WIDTH: u32 = 1600;
|
||||
const SCR_HEIGHT: u32 = 900;
|
||||
const TITLE: &str = "GLFWtest";
|
||||
|
||||
enum gameState {
|
||||
Paused,
|
||||
|
|
64
src/scene.rs
64
src/scene.rs
|
@ -118,35 +118,8 @@ impl Scene{
|
|||
self.Car.Draw(&self.shaders[0]);
|
||||
|
||||
if self.tempData.DebugMode{
|
||||
let mut Callbacks = Vec::new();
|
||||
let windows = self.debug.windows.clone();
|
||||
for (id, window) in windows
|
||||
{
|
||||
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),
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for command in self.debug.drawImgui(&events_loop, &window, Callbacks)
|
||||
{
|
||||
use crate::debug::dEvent;
|
||||
match command
|
||||
{
|
||||
dEvent::exit => ret = SceneEnum::Exit,
|
||||
dEvent::loadModel(i) => self.Car = Model::new(MODELS[i as usize], Arc::clone(&self.gl)),
|
||||
dEvent::setTest(a, b) => {
|
||||
self.tempData.spinSpeed = a;
|
||||
self.tempData.selectedModel = b;
|
||||
},
|
||||
dEvent::addWindow(a) => self.debug.addWindow(a),
|
||||
dEvent::removeWindow(a) => self.debug.removeWindow(a),
|
||||
}
|
||||
}
|
||||
}
|
||||
self.handleDebug(events_loop, window, &mut ret)
|
||||
}
|
||||
|
||||
for event in events_loop.poll_iter() {
|
||||
if self.tempData.DebugMode {
|
||||
|
@ -173,5 +146,38 @@ impl Scene{
|
|||
ret
|
||||
}
|
||||
|
||||
fn handleDebug(&mut self, events_loop:&mut sdl2::EventPump, window: &sdl2::video::Window, ret: &mut SceneEnum)
|
||||
{
|
||||
let mut Callbacks = Vec::new();
|
||||
let windows = self.debug.windows.clone();
|
||||
for (id, window) in windows
|
||||
{
|
||||
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),
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for command in self.debug.drawImgui(&events_loop, &window, Callbacks)
|
||||
{
|
||||
use crate::debug::dEvent;
|
||||
match command
|
||||
{
|
||||
dEvent::exit => *ret = SceneEnum::Exit,
|
||||
dEvent::loadModel(i) => self.Car = Model::new(MODELS[i as usize], Arc::clone(&self.gl)),
|
||||
dEvent::setTest(a, b) => {
|
||||
self.tempData.spinSpeed = a;
|
||||
self.tempData.selectedModel = b;
|
||||
},
|
||||
dEvent::addWindow(a) => self.debug.addWindow(a),
|
||||
dEvent::removeWindow(a) => self.debug.removeWindow(a),
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue