summaryrefslogtreecommitdiff
path: root/Userland/Games
diff options
context:
space:
mode:
authorKarol Baraniecki <karol@baraniecki.eu>2023-04-08 01:37:25 +0200
committerJelle Raaijmakers <jelle@gmta.nl>2023-04-09 00:44:45 +0200
commit439076df8afd1438ab0691a2b6497f0e4c748d6f (patch)
tree008e9163e22a638b7c0aefdfc0bc9a036f29c5f7 /Userland/Games
parentf3f14a7ef15f466bdefa0d72a04ea1ed6f87627d (diff)
downloadserenity-439076df8afd1438ab0691a2b6497f0e4c748d6f.zip
BrickGame: Add a menu option to disable the shadow drop hint
Diffstat (limited to 'Userland/Games')
-rw-r--r--Userland/Games/BrickGame/BrickGame.cpp8
-rw-r--r--Userland/Games/BrickGame/BrickGame.h2
-rw-r--r--Userland/Games/BrickGame/main.cpp5
3 files changed, 14 insertions, 1 deletions
diff --git a/Userland/Games/BrickGame/BrickGame.cpp b/Userland/Games/BrickGame/BrickGame.cpp
index 6efc263043..754a687c7d 100644
--- a/Userland/Games/BrickGame/BrickGame.cpp
+++ b/Userland/Games/BrickGame/BrickGame.cpp
@@ -471,6 +471,12 @@ void BrickGame::toggle_pause()
update();
}
+void BrickGame::set_show_shadow_hint(bool should_show)
+{
+ m_show_shadow_hint = should_show;
+ repaint();
+}
+
void BrickGame::timer_event(Core::TimerEvent&)
{
switch (m_brick_game->state()) {
@@ -547,7 +553,7 @@ void BrickGame::paint_cell(GUI::Painter& painter, Gfx::IntRect rect, BrickGame::
break;
case BrickGame::BoardSpace::ShadowHint:
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;
case BrickGame::BoardSpace::Off:
inside_color = m_shadow_color;
diff --git a/Userland/Games/BrickGame/BrickGame.h b/Userland/Games/BrickGame/BrickGame.h
index a98521b049..b898db6028 100644
--- a/Userland/Games/BrickGame/BrickGame.h
+++ b/Userland/Games/BrickGame/BrickGame.h
@@ -26,6 +26,7 @@ public:
void reset();
void toggle_pause();
+ void set_show_shadow_hint(bool);
private:
BrickGame(StringView app_name);
@@ -48,6 +49,7 @@ private:
GameState m_state {};
NonnullOwnPtr<Bricks> m_brick_game;
unsigned m_high_score {};
+ bool m_show_shadow_hint { true };
Color m_back_color { Color::from_rgb(0x8fbc8f) };
Color m_front_color { Color::Black };
diff --git a/Userland/Games/BrickGame/main.cpp b/Userland/Games/BrickGame/main.cpp
index ca238b94ac..47284fcaa7 100644
--- a/Userland/Games/BrickGame/main.cpp
+++ b/Userland/Games/BrickGame/main.cpp
@@ -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&) {
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_action(GUI::CommonActions::make_quit_action([](auto&) {
GUI::Application::the()->quit();