mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
Solitaire: Add Auto-Collect gameplay option
Add the option for players to enable automatic collection of eligible cards to their foundation pile with a single click of that card.
This commit is contained in:
parent
d4e425e52e
commit
95ff65e211
Notes:
sideshowbarker
2024-07-18 04:34:31 +09:00
Author: https://github.com/fluxth Commit: https://github.com/SerenityOS/serenity/commit/95ff65e211b Pull-request: https://github.com/SerenityOS/serenity/pull/9618 Reviewed-by: https://github.com/trflynn89 ✅
3 changed files with 19 additions and 0 deletions
|
@ -260,6 +260,9 @@ void Game::mousedown_event(GUI::MouseEvent& event)
|
|||
remember_flip_for_undo(top_card);
|
||||
}
|
||||
} else if (m_focused_cards.is_empty()) {
|
||||
if (is_auto_collecting() && attempt_to_move_card_to_foundations(to_check))
|
||||
break;
|
||||
|
||||
to_check.add_all_grabbed_cards(click_location, m_focused_cards);
|
||||
m_mouse_down_location = click_location;
|
||||
to_check.set_focused(true);
|
||||
|
|
|
@ -40,6 +40,9 @@ public:
|
|||
void setup(Mode);
|
||||
void perform_undo();
|
||||
|
||||
bool is_auto_collecting() const { return m_auto_collect; }
|
||||
void set_auto_collect(bool collect) { m_auto_collect = collect; }
|
||||
|
||||
Function<void(uint32_t)> on_score_update;
|
||||
Function<void()> on_game_start;
|
||||
Function<void(GameOverReason, uint32_t)> on_game_end;
|
||||
|
@ -208,6 +211,8 @@ private:
|
|||
|
||||
uint32_t m_score { 0 };
|
||||
uint8_t m_passes_left_before_punishment { 0 };
|
||||
|
||||
bool m_auto_collect { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -186,6 +186,15 @@ int main(int argc, char** argv)
|
|||
three_card_draw_action->set_status_tip("Draw three cards at a time");
|
||||
draw_setting_actions.add_action(three_card_draw_action);
|
||||
|
||||
game.set_auto_collect(Config::read_bool("Solitaire", "Settings", "AutoCollect", false));
|
||||
auto toggle_auto_collect_action = GUI::Action::create_checkable("Auto-&Collect", [&](auto& action) {
|
||||
auto checked = action.is_checked();
|
||||
game.set_auto_collect(checked);
|
||||
Config::write_bool("Solitaire", "Settings", "AutoCollect", checked);
|
||||
});
|
||||
toggle_auto_collect_action->set_checked(game.is_auto_collecting());
|
||||
toggle_auto_collect_action->set_status_tip("Auto-collect to foundation piles");
|
||||
|
||||
auto& game_menu = window->add_menu("&Game");
|
||||
|
||||
game_menu.add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, [&](auto&) {
|
||||
|
@ -201,6 +210,8 @@ int main(int argc, char** argv)
|
|||
game_menu.add_action(single_card_draw_action);
|
||||
game_menu.add_action(three_card_draw_action);
|
||||
game_menu.add_separator();
|
||||
game_menu.add_action(toggle_auto_collect_action);
|
||||
game_menu.add_separator();
|
||||
game_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
|
||||
|
||||
auto& help_menu = window->add_menu("&Help");
|
||||
|
|
Loading…
Reference in a new issue