Implement Settings in Window
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Inferno {
|
||||
|
||||
class Window {
|
||||
public:
|
||||
Window(const WindowProperties &properties = WindowProperties());
|
||||
Window();
|
||||
virtual ~Window();
|
||||
|
||||
void initialize();
|
||||
|
||||
Reference in New Issue
Block a user