Skip to content

Commit

Permalink
Merge pull request #241 from nim-ka/separate-ro
Browse files Browse the repository at this point in the history
Add separate section for read-only status
  • Loading branch information
Aurumaker72 authored Nov 27, 2024
2 parents 5004e00 + d1e533e commit 0dba5c7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
10 changes: 0 additions & 10 deletions view/gui/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>(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<bool>(data);
Expand Down Expand Up @@ -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);
Expand Down
23 changes: 13 additions & 10 deletions view/gui/features/Statusbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<int32_t> parts)
{
auto parts = emu_launched ? emu_parts : idle_parts;

RECT rect{};
GetClientRect(g_main_hwnd, &rect);

Expand All @@ -48,7 +46,7 @@ namespace Statusbar
{
scale = max(scale, 1.0f);
}

if (!g_config.statusbar_scale_up)
{
scale = min(scale, 1.0f);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -124,6 +119,12 @@ namespace Statusbar
}
}

void on_readonly_changed(std::any data)
{
auto value = std::any_cast<bool>(data);
post(value ? "Read-only" : "Read/write", Section::Readonly);
}

void on_rerecords_changed(std::any data)
{
auto value = std::any_cast<uint64_t>(data);
Expand All @@ -148,7 +149,7 @@ namespace Statusbar

void on_size_changed(std::any)
{
update_size();
update_size(emu_launched ? emu_parts : idle_parts);
}

void init()
Expand All @@ -158,6 +159,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,
Expand Down
1 change: 1 addition & 0 deletions view/gui/features/Statusbar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Statusbar
{
Notification,
VCR,
Readonly,
Input,
Rerecords,
FPS,
Expand Down

0 comments on commit 0dba5c7

Please sign in to comment.