mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:57:44 +00:00
Spider: Make the last move undoable
The lets the user undo the last card move. Card moves which cause cards to be moved to the waste stack cannot be undone.
This commit is contained in:
parent
6d18164ab0
commit
c97421eabe
3 changed files with 73 additions and 0 deletions
|
@ -239,6 +239,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
game.setup(mode);
|
||||
})));
|
||||
TRY(game_menu->try_add_separator());
|
||||
auto undo_action = GUI::CommonActions::make_undo_action([&](auto&) {
|
||||
game.perform_undo();
|
||||
});
|
||||
undo_action->set_enabled(false);
|
||||
TRY(game_menu->try_add_action(undo_action));
|
||||
TRY(game_menu->try_add_separator());
|
||||
TRY(game_menu->try_add_action(single_suit_action));
|
||||
TRY(game_menu->try_add_action(two_suit_action));
|
||||
TRY(game_menu->try_add_separator());
|
||||
|
@ -274,6 +280,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->set_icon(app_icon.bitmap_for_size(16));
|
||||
window->show();
|
||||
|
||||
game.on_undo_availability_change = [&](bool undo_available) {
|
||||
undo_action->set_enabled(undo_available);
|
||||
};
|
||||
|
||||
game.setup(mode);
|
||||
|
||||
return app->exec();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue