diff --git a/inferno/src/inferno/settings.cpp b/inferno/src/inferno/settings.cpp index 9832786..3d1d730 100644 --- a/inferno/src/inferno/settings.cpp +++ b/inferno/src/inferno/settings.cpp @@ -29,7 +29,7 @@ namespace Inferno { nlohmann::json m_json = this->load(); try { - m_properties.title = m_json["window"]["title"].get().c_str(); + m_properties.title = strdup(m_json["window"]["title"].get().c_str()); m_properties.width = m_json["window"]["width"].get(); m_properties.height = m_json["window"]["height"].get(); } @@ -40,6 +40,8 @@ namespace Inferno { void Settings::destroy() { + // Delete const char*s created by strdup() + delete m_properties.title; } nlohmann::json Settings::load() const diff --git a/inferno/src/inferno/settings.h b/inferno/src/inferno/settings.h index 3c65fe2..38f7c0d 100644 --- a/inferno/src/inferno/settings.h +++ b/inferno/src/inferno/settings.h @@ -7,8 +7,8 @@ namespace Inferno { struct SettingsProperties { const char* title = "Inferno default"; - int width = 1280; - int height = 720; + unsigned int width = 1280; + unsigned int height = 720; }; class Settings { diff --git a/inferno/src/inferno/window.cpp b/inferno/src/inferno/window.cpp index be2ec3c..bd5626e 100644 --- a/inferno/src/inferno/window.cpp +++ b/inferno/src/inferno/window.cpp @@ -4,15 +4,21 @@ #include "inferno/core.h" #include "inferno/event/applicationevent.h" #include "inferno/log.h" +#include "inferno/settings.h" #include "inferno/window.h" namespace Inferno { unsigned char Window::s_windowCount = 0; - Window::Window(const WindowProperties &properties) : - m_windowProperties(properties) + Window::Window() { + m_windowProperties = { + Settings::get().properties().title, + Settings::get().properties().width, + Settings::get().properties().height, + }; + this->initialize(); } diff --git a/inferno/src/inferno/window.h b/inferno/src/inferno/window.h index 3d36422..446934e 100644 --- a/inferno/src/inferno/window.h +++ b/inferno/src/inferno/window.h @@ -17,7 +17,7 @@ namespace Inferno { class Window { public: - Window(const WindowProperties &properties = WindowProperties()); + Window(); virtual ~Window(); void initialize();