1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:17:44 +00:00

Chess: Added option to toggle showing moves

This commit is contained in:
lucastarche 2021-03-27 18:07:52 -03:00 committed by Andreas Kling
parent 42f7f9d0f8
commit 17b7779271
2 changed files with 13 additions and 0 deletions

View file

@ -94,6 +94,7 @@ int main(int argc, char** argv)
widget.set_piece_set(config->read_entry("Style", "PieceSet", "stelar7"));
widget.set_board_theme(config->read_entry("Style", "BoardTheme", "Beige"));
widget.set_coordinates(config->read_bool_entry("Style", "Coordinates", true));
widget.set_show_available_moves(config->read_bool_entry("Style", "ShowAvailableMoves", true));
auto menubar = GUI::MenuBar::construct();
auto& app_menu = menubar->add_menu("Game");
@ -199,6 +200,15 @@ int main(int argc, char** argv)
coordinates_action->set_checked(widget.coordinates());
style_menu.add_action(coordinates_action);
auto show_available_moves_action = GUI::Action::create_checkable("Show Available Moves", [&](auto& action) {
widget.set_show_available_moves(action.is_checked());
widget.update();
config->write_bool_entry("Style", "ShowAvailableMoves", action.is_checked());
config->sync();
});
show_available_moves_action->set_checked(widget.show_available_moves());
style_menu.add_action(show_available_moves_action);
auto& engine_menu = menubar->add_menu("Engine");
GUI::ActionGroup engines_action_group;