Config: implemented toml reading

This commit is contained in:
Hyper
2024-10-17 21:20:35 +01:00
parent 554be01412
commit ee35458b5d
7 changed files with 121 additions and 21 deletions

View File

@@ -87,7 +87,12 @@ void Window::Init()
SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
SDL_AddEventWatch(Window_OnSDLEvent, s_window);
s_window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, Window::s_width, Window::s_height, SDL_WINDOW_RESIZABLE);
s_window = SDL_CreateWindow(title,
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
Config::WindowWidth,
Config::WindowHeight,
SDL_WINDOW_RESIZABLE);
if (auto icon = GetIconSurface())
{

View File

@@ -29,8 +29,8 @@ public:
static bool IsDisplayResolution(int w, int h, bool isExact = true)
{
auto width = w <= 0 ? Config::Width : w;
auto height = h <= 0 ? Config::Height : h;
auto width = w <= 0 ? Config::WindowWidth : w;
auto height = h <= 0 ? Config::WindowHeight : h;
SDL_Rect displayRect;
if (SDL_GetDisplayBounds(SDL_GetWindowDisplayIndex(s_window), &displayRect) == ERROR_SUCCESS)
@@ -73,7 +73,7 @@ public:
if (SDL_GetDisplayBounds(SDL_GetWindowDisplayIndex(s_window), &displayRect) == ERROR_SUCCESS)
{
// Maximise window if the config resolution is greater than the display.
if (IsDisplayResolution(Config::Width, Config::Height, false))
if (IsDisplayResolution(s_width, s_height, false))
SDL_MaximizeWindow(s_window);
}
@@ -83,8 +83,8 @@ public:
static void SetWindowDimensions(int w = -1, int h = -1)
{
auto width = w <= 0 ? Config::Width : w;
auto height = h <= 0 ? Config::Height : h;
auto width = w <= 0 ? Config::WindowWidth : w;
auto height = h <= 0 ? Config::WindowHeight : h;
auto isPendingMaximise = false;
if (IsDisplayResolution(width, height))