mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:17:44 +00:00
Solitaire: Add setting for number of cards to be drawn
Klondike Solitaire has a couple more modes, but this adds modes for 1- and 3-card draws.
This commit is contained in:
parent
3a45bf5254
commit
e310b9cd0d
3 changed files with 58 additions and 6 deletions
|
@ -8,6 +8,7 @@
|
|||
#include <Games/Solitaire/SolitaireGML.h>
|
||||
#include <LibCore/Timer.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/ActionGroup.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/Icon.h>
|
||||
#include <LibGUI/Menu.h>
|
||||
|
@ -86,13 +87,32 @@ int main(int argc, char** argv)
|
|||
timer->stop();
|
||||
};
|
||||
|
||||
GUI::ActionGroup draw_settng_actions;
|
||||
draw_settng_actions.set_exclusive(true);
|
||||
|
||||
auto single_card_draw_action = GUI::Action::create_checkable("&Single Card Draw", [&](auto&) {
|
||||
game.setup(Solitaire::Mode::SingleCardDraw);
|
||||
});
|
||||
single_card_draw_action->set_checked(true);
|
||||
single_card_draw_action->set_status_tip("Draw one card at a time");
|
||||
draw_settng_actions.add_action(single_card_draw_action);
|
||||
|
||||
auto three_card_draw_action = GUI::Action::create_checkable("&Three Card Draw", [&](auto&) {
|
||||
game.setup(Solitaire::Mode::ThreeCardDraw);
|
||||
});
|
||||
three_card_draw_action->set_status_tip("Draw three cards at a time");
|
||||
draw_settng_actions.add_action(three_card_draw_action);
|
||||
|
||||
auto menubar = GUI::Menubar::construct();
|
||||
auto& game_menu = menubar->add_menu("&Game");
|
||||
|
||||
game_menu.add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, [&](auto&) {
|
||||
game.setup();
|
||||
game.setup(game.mode());
|
||||
}));
|
||||
game_menu.add_separator();
|
||||
game_menu.add_action(single_card_draw_action);
|
||||
game_menu.add_action(three_card_draw_action);
|
||||
game_menu.add_separator();
|
||||
game_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }));
|
||||
|
||||
auto& help_menu = menubar->add_menu("&Help");
|
||||
|
@ -103,7 +123,7 @@ int main(int argc, char** argv)
|
|||
window->set_menubar(move(menubar));
|
||||
window->set_icon(app_icon.bitmap_for_size(16));
|
||||
window->show();
|
||||
game.setup();
|
||||
game.setup(game.mode());
|
||||
|
||||
return app->exec();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue