Implement Settings in Window

This commit is contained in:
Rick van Vonderen
2019-12-18 02:42:37 +01:00
parent f5cdd27508
commit 9c2ceea7e2
4 changed files with 14 additions and 6 deletions
+3 -1
View File
@@ -29,7 +29,7 @@ namespace Inferno {
nlohmann::json m_json = this->load();
try {
m_properties.title = m_json["window"]["title"].get<std::string>().c_str();
m_properties.title = strdup(m_json["window"]["title"].get<std::string>().c_str());
m_properties.width = m_json["window"]["width"].get<int>();
m_properties.height = m_json["window"]["height"].get<int>();
}
@@ -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
+2 -2
View File
@@ -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 {
+8 -2
View File
@@ -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();
}
+1 -1
View File
@@ -17,7 +17,7 @@ namespace Inferno {
class Window {
public:
Window(const WindowProperties &properties = WindowProperties());
Window();
virtual ~Window();
void initialize();