Merge pull request 'no more bugs to be found' (#4) from sceneObj into master
Reviewed-on: #4ObjectDef
commit
9b9fd65574
12
src/debug.rs
12
src/debug.rs
|
@ -106,6 +106,17 @@ impl Debug {
|
||||||
}
|
}
|
||||||
pub fn addWindow(&mut self, window: OpenWindows)
|
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())
|
if (self.free_ids.is_empty())
|
||||||
{
|
{
|
||||||
self.windows.insert(self.next_id, window);
|
self.windows.insert(self.next_id, window);
|
||||||
|
@ -114,6 +125,7 @@ impl Debug {
|
||||||
else {
|
else {
|
||||||
self.windows.insert(self.free_ids.pop().unwrap(), window);
|
self.windows.insert(self.free_ids.pop().unwrap(), window);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pub fn removeWindow(&mut self, window: OpenWindows)
|
pub fn removeWindow(&mut self, window: OpenWindows)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,7 +6,6 @@ use cgmath::prelude::*;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
const SCR_WIDTH: u32 = 1600;
|
const SCR_WIDTH: u32 = 1600;
|
||||||
const SCR_HEIGHT: u32 = 900;
|
const SCR_HEIGHT: u32 = 900;
|
||||||
const TITLE: &str = "GLFWtest";
|
|
||||||
|
|
||||||
enum gameState {
|
enum gameState {
|
||||||
Paused,
|
Paused,
|
||||||
|
|
64
src/scene.rs
64
src/scene.rs
|
@ -118,35 +118,8 @@ impl Scene{
|
||||||
self.Car.Draw(&self.shaders[0]);
|
self.Car.Draw(&self.shaders[0]);
|
||||||
|
|
||||||
if self.tempData.DebugMode{
|
if self.tempData.DebugMode{
|
||||||
let mut Callbacks = Vec::new();
|
self.handleDebug(events_loop, window, &mut ret)
|
||||||
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),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for event in events_loop.poll_iter() {
|
for event in events_loop.poll_iter() {
|
||||||
if self.tempData.DebugMode {
|
if self.tempData.DebugMode {
|
||||||
|
@ -173,5 +146,38 @@ impl Scene{
|
||||||
ret
|
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