window: show window dimensions on title bar when resizing window

This commit is contained in:
Hyper 2024-11-23 20:23:27 +00:00
parent ff79eae6c4
commit b8da31869e
2 changed files with 17 additions and 8 deletions

View file

@ -4,6 +4,7 @@
#include <SDL_syswm.h>
bool m_isFullscreenKeyReleased = true;
bool m_isResizing = false;
int Window_OnSDLEvent(void*, SDL_Event* event)
{
@ -93,8 +94,10 @@ int Window_OnSDLEvent(void*, SDL_Event* event)
break;
case SDL_WINDOWEVENT_RESIZED:
m_isResizing = true;
Window::s_width = event->window.data1;
Window::s_height = event->window.data2;
Window::SetTitle(std::format("{} - [{}x{}]", Window::GetTitle(), Window::s_width, Window::s_height).c_str());
break;
case SDL_WINDOWEVENT_MOVED:
@ -187,4 +190,10 @@ void Window::Update()
Config::WindowWidth = Window::s_width;
Config::WindowHeight = Window::s_height;
}
if (m_isResizing)
{
SetTitle();
m_isResizing = false;
}
}

View file

@ -58,16 +58,16 @@ public:
}
}
static const char* GetTitle()
{
return Config::Language == ELanguage::Japanese
? "SONIC WORLD ADVENTURE"
: "SONIC UNLEASHED";
}
static void SetTitle(const char* title = nullptr)
{
if (!title)
{
title = Config::Language == ELanguage::Japanese
? "SONIC WORLD ADVENTURE"
: "SONIC UNLEASHED";
}
SDL_SetWindowTitle(s_pWindow, title);
SDL_SetWindowTitle(s_pWindow, title ? title : GetTitle());
}
static bool IsFullscreen()