mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
BrickGame: Add a menu option to disable the shadow drop hint
This commit is contained in:
parent
f3f14a7ef1
commit
439076df8a
3 changed files with 14 additions and 1 deletions
|
@ -471,6 +471,12 @@ void BrickGame::toggle_pause()
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BrickGame::set_show_shadow_hint(bool should_show)
|
||||||
|
{
|
||||||
|
m_show_shadow_hint = should_show;
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
void BrickGame::timer_event(Core::TimerEvent&)
|
void BrickGame::timer_event(Core::TimerEvent&)
|
||||||
{
|
{
|
||||||
switch (m_brick_game->state()) {
|
switch (m_brick_game->state()) {
|
||||||
|
@ -547,7 +553,7 @@ void BrickGame::paint_cell(GUI::Painter& painter, Gfx::IntRect rect, BrickGame::
|
||||||
break;
|
break;
|
||||||
case BrickGame::BoardSpace::ShadowHint:
|
case BrickGame::BoardSpace::ShadowHint:
|
||||||
inside_color = m_shadow_color;
|
inside_color = m_shadow_color;
|
||||||
outside_color = m_hint_block_color;
|
outside_color = m_show_shadow_hint ? m_hint_block_color : m_shadow_color;
|
||||||
break;
|
break;
|
||||||
case BrickGame::BoardSpace::Off:
|
case BrickGame::BoardSpace::Off:
|
||||||
inside_color = m_shadow_color;
|
inside_color = m_shadow_color;
|
||||||
|
|
|
@ -26,6 +26,7 @@ public:
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
void toggle_pause();
|
void toggle_pause();
|
||||||
|
void set_show_shadow_hint(bool);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BrickGame(StringView app_name);
|
BrickGame(StringView app_name);
|
||||||
|
@ -48,6 +49,7 @@ private:
|
||||||
GameState m_state {};
|
GameState m_state {};
|
||||||
NonnullOwnPtr<Bricks> m_brick_game;
|
NonnullOwnPtr<Bricks> m_brick_game;
|
||||||
unsigned m_high_score {};
|
unsigned m_high_score {};
|
||||||
|
bool m_show_shadow_hint { true };
|
||||||
|
|
||||||
Color m_back_color { Color::from_rgb(0x8fbc8f) };
|
Color m_back_color { Color::from_rgb(0x8fbc8f) };
|
||||||
Color m_front_color { Color::Black };
|
Color m_front_color { Color::Black };
|
||||||
|
|
|
@ -59,6 +59,11 @@ 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) {
|
||||||
|
game->set_show_shadow_hint(action.is_checked());
|
||||||
|
}));
|
||||||
|
show_shadow_piece_action->set_checked(true);
|
||||||
|
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&) {
|
||||||
GUI::Application::the()->quit();
|
GUI::Application::the()->quit();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue