From cd4cb7f7375f272e2900e7943df19ea1960bef3e Mon Sep 17 00:00:00 2001 From: nim-ka Date: Tue, 26 Nov 2024 15:34:19 -0800 Subject: [PATCH 1/2] Add read-only section in status bar --- view/gui/Main.cpp | 10 ---------- view/gui/features/Statusbar.cpp | 12 ++++++++++-- view/gui/features/Statusbar.hpp | 1 + 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/view/gui/Main.cpp b/view/gui/Main.cpp index 33a93b24..805b2a0b 100644 --- a/view/gui/Main.cpp +++ b/view/gui/Main.cpp @@ -733,15 +733,6 @@ void on_movie_loop_changed(std::any data) SendMessage(g_main_hwnd, WM_INITMENU, 0, 0); } -void on_readonly_changed(std::any data) -{ - auto value = std::any_cast(data); - Statusbar::post(value - ? "Read-only" - : "Read/write"); - SendMessage(g_main_hwnd, WM_INITMENU, 0, 0); -} - void on_fullscreen_changed(std::any data) { auto value = std::any_cast(data); @@ -1987,7 +1978,6 @@ int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, Messenger::subscribe(Messenger::Message::EmuPausedChanged, on_emu_paused_changed); Messenger::subscribe(Messenger::Message::CapturingChanged, on_capturing_changed); Messenger::subscribe(Messenger::Message::MovieLoopChanged, on_movie_loop_changed); - Messenger::subscribe(Messenger::Message::ReadonlyChanged, on_readonly_changed); Messenger::subscribe(Messenger::Message::TaskChanged, on_task_changed); Messenger::subscribe(Messenger::Message::ScriptStarted, on_script_started); Messenger::subscribe(Messenger::Message::SpeedModifierChanged, on_speed_modifier_changed); diff --git a/view/gui/features/Statusbar.cpp b/view/gui/features/Statusbar.cpp index 3152ae5d..2341a4bd 100644 --- a/view/gui/features/Statusbar.cpp +++ b/view/gui/features/Statusbar.cpp @@ -17,7 +17,7 @@ namespace Statusbar { - const std::vector emu_parts = {200, 200, 77, 77, 77, 77, 77, -1}; + const std::vector emu_parts = {150, 150, 75, 75, 75, 75, 75, 75, -1}; const std::vector idle_parts = {400, -1}; HWND statusbar_hwnd; @@ -48,7 +48,7 @@ namespace Statusbar { scale = max(scale, 1.0f); } - + if (!g_config.statusbar_scale_up) { scale = min(scale, 1.0f); @@ -124,6 +124,12 @@ namespace Statusbar } } + void on_readonly_changed(std::any data) + { + auto value = std::any_cast(data); + post(value ? "Read-only" : "Read/write", Section::Readonly); + } + void on_rerecords_changed(std::any data) { auto value = std::any_cast(data); @@ -158,6 +164,8 @@ namespace Statusbar emu_launched_changed); Messenger::subscribe(Messenger::Message::StatusbarVisibilityChanged, statusbar_visibility_changed); + Messenger::subscribe(Messenger::Message::ReadonlyChanged, + on_readonly_changed); Messenger::subscribe(Messenger::Message::TaskChanged, on_task_changed); Messenger::subscribe(Messenger::Message::RerecordsChanged, diff --git a/view/gui/features/Statusbar.hpp b/view/gui/features/Statusbar.hpp index bcf40de1..3e9d8fb1 100644 --- a/view/gui/features/Statusbar.hpp +++ b/view/gui/features/Statusbar.hpp @@ -10,6 +10,7 @@ namespace Statusbar { Notification, VCR, + Readonly, Input, Rerecords, FPS, From d1e533e75784c99a25a042bcd71bedf0bbbb7c0b Mon Sep 17 00:00:00 2001 From: nim-ka Date: Tue, 26 Nov 2024 15:54:28 -0800 Subject: [PATCH 2/2] Fix bug with status bar not showing at low resolutions on emu launch --- view/gui/features/Statusbar.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/view/gui/features/Statusbar.cpp b/view/gui/features/Statusbar.cpp index 2341a4bd..c4ca4ad9 100644 --- a/view/gui/features/Statusbar.cpp +++ b/view/gui/features/Statusbar.cpp @@ -32,10 +32,8 @@ namespace Statusbar SendMessage(statusbar_hwnd, SB_SETTEXT, (int)section, (LPARAM)text.c_str()); } - void update_size() + void update_size(std::vector parts) { - auto parts = emu_launched ? emu_parts : idle_parts; - RECT rect{}; GetClientRect(g_main_hwnd, &rect); @@ -88,10 +86,7 @@ namespace Statusbar Messenger::broadcast(Messenger::Message::SlotChanged, (size_t)g_config.st_slot); } - if (!value && previous_value) - { - set_statusbar_parts(statusbar_hwnd, value ? emu_parts : idle_parts); - } + update_size(value ? emu_parts : idle_parts); previous_value = value; } @@ -154,7 +149,7 @@ namespace Statusbar void on_size_changed(std::any) { - update_size(); + update_size(emu_launched ? emu_parts : idle_parts); } void init()