This is going to require a major rewrite of every component of this program. Going to revert back to the linear game loop for now

master
mitchellhansen 7 years ago
parent 5fcf1c0e44
commit 2d2a854f0f

@ -1,3 +1,3 @@
[LOGGING] [LOGGING]
log_level = 0 # INFO, WARN, ERROR log_level = 0 # INFO, WARN, ERROR
log_dest = 0 # STDOUT, FILE log_dest = 0 # STDOUT, FILE

@ -1,3 +1,3 @@
[GRAPHICS] [GRAPHICS]
x_resolution = 800 x_resolution = 800
y_resolution = 800 y_resolution = 800

@ -1,66 +1,66 @@
#pragma once #pragma once
#include <mutex> #include <mutex>
#include <Logger.h> #include <Logger.h>
#include <list> #include <list>
class Gui { class Gui {
public: public:
Gui() { Gui() {
container_lock.lock(); container_lock.lock();
renderable_container.push_back(this); renderable_container.push_back(this);
container_lock.unlock(); container_lock.unlock();
}; };
virtual ~Gui() { virtual ~Gui() {
container_lock.lock(); container_lock.lock();
renderable_container.remove(this); renderable_container.remove(this);
container_lock.unlock(); container_lock.unlock();
}; };
virtual void render_gui() = 0; virtual void render_gui() = 0;
virtual void update_gui() = 0; virtual void update_gui() = 0;
// Instead of rendering nil, we can pass our render call if we would like // Instead of rendering nil, we can pass our render call if we would like
bool renderable() { return rendering; }; bool renderable() { return rendering; };
private: private:
// Whatever class that wants to call this must be a friend!!! // Whatever class that wants to call this must be a friend!!!
friend class Application; friend class Application;
static void do_render() { static void do_render() {
for (auto i : renderable_container) { for (auto i : renderable_container) {
i->update_gui(); i->update_gui();
if (i->renderable()) if (i->renderable())
i->render_gui(); i->render_gui();
} }
}; };
static std::mutex container_lock; static std::mutex container_lock;
static std::list<Gui*> renderable_container; static std::list<Gui*> renderable_container;
protected: protected:
bool rendering = true; bool rendering = true;
// Derived class will handle imgui calls // Derived class will handle imgui calls
}; };

@ -55,13 +55,13 @@ public:
if (event.get()->type == vr::Event::Closed) { if (event.get()->type == vr::Event::Closed) {
window_ref->close(); window_ref->close();
} else if (event.get()->type == vr::Event::KeyPressed) { } else if (event.get()->type == vr::Event::KeyPressed) {
vr::KeyPressed *key_event = static_cast<vr::KeyPressed*>(event.get()); vr::KeyPressed *key_event = static_cast<vr::KeyPressed*>(event.get());
if (key_event->code == sf::Keyboard::Escape) { if (key_event->code == sf::Keyboard::Escape) {
window_ref->close(); window_ref->close();
} }
} }
}; };

@ -1,4 +1,4 @@
#include "Gui.h" #include "Gui.h"
std::mutex Gui::container_lock; std::mutex Gui::container_lock;
std::list<Gui*> Gui::renderable_container; std::list<Gui*> Gui::renderable_container;

@ -282,107 +282,107 @@ void Input::transpose_sf_events(std::list<sf::Event> sf_event_queue) {
} }
} }
const std::vector<std::string> Input::key_strings = { const std::vector<std::string> Input::key_strings = {
"A", "A",
"B", "B",
"C", "C",
"D", "D",
"E", "E",
"F", "F",
"G", "G",
"H", "H",
"I", "I",
"J", "J",
"K", "K",
"L", "L",
"M", "M",
"N", "N",
"O", "O",
"P", "P",
"Q", "Q",
"R", "R",
"S", "S",
"T", "T",
"U", "U",
"V", "V",
"W", "W",
"X", "X",
"Y", "Y",
"Z", "Z",
"Num0", "Num0",
"Num1", "Num1",
"Num2", "Num2",
"Num3", "Num3",
"Num4", "Num4",
"Num5", "Num5",
"Num6", "Num6",
"Num7", "Num7",
"Num8", "Num8",
"Num9", "Num9",
"Escape", "Escape",
"LControl", "LControl",
"LShift", "LShift",
"LAlt", "LAlt",
"LSystem", "LSystem",
"RControl", "RControl",
"RShift", "RShift",
"RAlt", "RAlt",
"RSystem", "RSystem",
"Menu", "Menu",
"LBracket", "LBracket",
"RBracket", "RBracket",
"SemiColon", "SemiColon",
"Comma", "Comma",
"Period", "Period",
"Quote", "Quote",
"Slash", "Slash",
"BackSlash", "BackSlash",
"Tilde", "Tilde",
"Equal", "Equal",
"Dash", "Dash",
"Space", "Space",
"Return", "Return",
"BackSpace", "BackSpace",
"Tab", "Tab",
"PageUp", "PageUp",
"PageDown", "PageDown",
"End", "End",
"Home", "Home",
"Insert", "Insert",
"Delete", "Delete",
"Add", "Add",
"Subtract", "Subtract",
"Multiply", "Multiply",
"Divide", "Divide",
"Left", "Left",
"Right", "Right",
"Up", "Up",
"Down", "Down",
"Numpad0", "Numpad0",
"Numpad1", "Numpad1",
"Numpad2", "Numpad2",
"Numpad3", "Numpad3",
"Numpad4", "Numpad4",
"Numpad5", "Numpad5",
"Numpad6", "Numpad6",
"Numpad7", "Numpad7",
"Numpad8", "Numpad8",
"Numpad9", "Numpad9",
"F1" , "F1" ,
"F2" , "F2" ,
"F3" , "F3" ,
"F4" , "F4" ,
"F5" , "F5" ,
"F6" , "F6" ,
"F7" , "F7" ,
"F8" , "F8" ,
"F9" , "F9" ,
"F10", "F10",
"F11", "F11",
"F12", "F12",
"F13", "F13",
"F14", "F14",
"F15", "F15",
"Pause" "Pause"
}; };

Loading…
Cancel
Save