mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:17:35 +00:00
BrickGame: Remember the "Show Shadow Piece" setting between executions
by using the ConfigServer.
This commit is contained in:
parent
439076df8a
commit
f532f9d279
3 changed files with 12 additions and 2 deletions
|
@ -477,6 +477,11 @@ void BrickGame::set_show_shadow_hint(bool should_show)
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BrickGame::show_shadow_hint()
|
||||||
|
{
|
||||||
|
return m_show_shadow_hint;
|
||||||
|
}
|
||||||
|
|
||||||
void BrickGame::timer_event(Core::TimerEvent&)
|
void BrickGame::timer_event(Core::TimerEvent&)
|
||||||
{
|
{
|
||||||
switch (m_brick_game->state()) {
|
switch (m_brick_game->state()) {
|
||||||
|
|
|
@ -27,6 +27,7 @@ public:
|
||||||
void reset();
|
void reset();
|
||||||
void toggle_pause();
|
void toggle_pause();
|
||||||
void set_show_shadow_hint(bool);
|
void set_show_shadow_hint(bool);
|
||||||
|
bool show_shadow_hint();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BrickGame(StringView app_name);
|
BrickGame(StringView app_name);
|
||||||
|
|
|
@ -59,10 +59,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
TRY(game_menu->try_add_action(GUI::Action::create("Toggle &Pause", { Mod_None, Key_P }, [&](auto&) {
|
TRY(game_menu->try_add_action(GUI::Action::create("Toggle &Pause", { Mod_None, Key_P }, [&](auto&) {
|
||||||
game->toggle_pause();
|
game->toggle_pause();
|
||||||
})));
|
})));
|
||||||
auto show_shadow_piece_action = TRY(GUI::Action::try_create_checkable("&Show Shadow Piece", GUI::Shortcut {}, [&](auto& action) {
|
|
||||||
|
auto show_shadow_piece_action = TRY(GUI::Action::try_create_checkable("Show Shadow Piece", GUI::Shortcut {}, [&](auto& action) {
|
||||||
game->set_show_shadow_hint(action.is_checked());
|
game->set_show_shadow_hint(action.is_checked());
|
||||||
|
Config::write_bool(app_name, app_name, "ShowShadowPiece"sv, action.is_checked());
|
||||||
}));
|
}));
|
||||||
show_shadow_piece_action->set_checked(true);
|
game->set_show_shadow_hint(Config::read_bool(app_name, app_name, "ShowShadowPiece"sv, true));
|
||||||
|
show_shadow_piece_action->set_checked(game->show_shadow_hint());
|
||||||
|
|
||||||
TRY(game_menu->try_add_action(show_shadow_piece_action));
|
TRY(game_menu->try_add_action(show_shadow_piece_action));
|
||||||
TRY(game_menu->try_add_separator());
|
TRY(game_menu->try_add_separator());
|
||||||
TRY(game_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
TRY(game_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue