Browse Source

Implement Settings in Window

master
Rick van Vonderen 5 years ago
parent
commit
9c2ceea7e2
  1. 4
      inferno/src/inferno/settings.cpp
  2. 4
      inferno/src/inferno/settings.h
  3. 10
      inferno/src/inferno/window.cpp
  4. 2
      inferno/src/inferno/window.h

4
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<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

4
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 {

10
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();
}

2
inferno/src/inferno/window.h

@ -17,7 +17,7 @@ namespace Inferno {
class Window {
public:
Window(const WindowProperties &properties = WindowProperties());
Window();
virtual ~Window();
void initialize();

Loading…
Cancel
Save