Merge pull request 'no more bugs to be found' (#4) from sceneObj into master

Reviewed-on: #4
ObjectDef
Milk.H 2023-03-27 08:44:16 +02:00
commit 9b9fd65574
3 changed files with 47 additions and 30 deletions

View File

@ -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)
{

View File

@ -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,

View File

@ -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),
}
}
}
}