From b8da31869ece4530f8d3cc610bdf957679e2c03f Mon Sep 17 00:00:00 2001 From: Hyper <34012267+hyperbx@users.noreply.github.com> Date: Sat, 23 Nov 2024 20:23:27 +0000 Subject: [PATCH] window: show window dimensions on title bar when resizing window --- UnleashedRecomp/ui/window.cpp | 9 +++++++++ UnleashedRecomp/ui/window.h | 16 ++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/UnleashedRecomp/ui/window.cpp b/UnleashedRecomp/ui/window.cpp index 420b81e8..2d600f66 100644 --- a/UnleashedRecomp/ui/window.cpp +++ b/UnleashedRecomp/ui/window.cpp @@ -4,6 +4,7 @@ #include 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; + } } diff --git a/UnleashedRecomp/ui/window.h b/UnleashedRecomp/ui/window.h index b560981e..3802f8c0 100644 --- a/UnleashedRecomp/ui/window.h +++ b/UnleashedRecomp/ui/window.h @@ -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()