diff options
author | Jookia <166291@gmail.com> | 2019-07-01 15:54:57 +1000 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-07-01 09:51:03 +0200 |
commit | 9dbf453015f4d06b054a697b57d289630578ee37 (patch) | |
tree | b1ed61d8c29837b9560a3b2e91594211e5ba555a /Games/Minesweeper/main.cpp | |
parent | d2b6f79835ce3778cd6d589fc9273a4429eecdc6 (diff) | |
download | serenity-9dbf453015f4d06b054a697b57d289630578ee37.zip |
Minesweeper: Allow single-click chording
This is how other Minesweeper games I've played usually behave.
Single-click chording can be disabled from the menu or config file.
Diffstat (limited to 'Games/Minesweeper/main.cpp')
-rw-r--r-- | Games/Minesweeper/main.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Games/Minesweeper/main.cpp b/Games/Minesweeper/main.cpp index 113117399c..81a6926537 100644 --- a/Games/Minesweeper/main.cpp +++ b/Games/Minesweeper/main.cpp @@ -49,15 +49,29 @@ int main(int argc, char** argv) { auto config = CConfigFile::get_for_app("Minesweeper"); + bool single_chording = config->read_num_entry("Minesweeper", "SingleChording", false); int mine_count = config->read_num_entry("Game", "MineCount", 10); int rows = config->read_num_entry("Game", "Rows", 9); int columns = config->read_num_entry("Game", "Columns", 9); field->set_field_size(rows, columns, mine_count); + field->set_single_chording(single_chording); } auto menubar = make<GMenuBar>(); auto app_menu = make<GMenu>("Minesweeper"); + + RefPtr<GAction> chord_toggler_action; + chord_toggler_action = GAction::create("Single-click chording", [&](const GAction&) { + bool toggled = !field->is_single_chording(); + field->set_single_chording(toggled); + chord_toggler_action->set_checked(toggled); + }); + chord_toggler_action->set_checkable(true); + chord_toggler_action->set_checked(field->is_single_chording()); + app_menu->add_action(*chord_toggler_action); + app_menu->add_separator(); + app_menu->add_action(GAction::create("Quit", { Mod_Alt, Key_F4 }, [](const GAction&) { GApplication::the().quit(0); return; |