mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:17:35 +00:00
MasterWord: Check guesses against the word list
Previously guesses were not checked which allowed guesses like 'aaaaa' to be entered. Currently there's an option to set if a guess should be checked against the dictionary and rejected if it doesn't exist there. Additionally settings from Game menu have been moved to its own entry - Settings.
This commit is contained in:
parent
1297f81ddf
commit
01c7158ffe
3 changed files with 61 additions and 17 deletions
|
@ -59,7 +59,15 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, [&](auto&) {
|
||||
game->reset();
|
||||
})));
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("Set &Word Length", [&](auto&) {
|
||||
|
||||
TRY(game_menu->try_add_separator());
|
||||
TRY(game_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
|
||||
auto settings_menu = TRY(window->try_add_menu("&Settings"));
|
||||
|
||||
TRY(settings_menu->try_add_action(GUI::Action::create("Set &Word Length", [&](auto&) {
|
||||
auto word_length = Config::read_i32("MasterWord", "", "word_length", 5);
|
||||
auto word_length_string = String::number(word_length);
|
||||
if (GUI::InputBox::show(window, word_length_string, "Word length:", "MasterWord") == GUI::InputBox::ExecResult::OK && !word_length_string.is_empty()) {
|
||||
|
@ -75,7 +83,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
window->resize(game->game_size());
|
||||
}
|
||||
})));
|
||||
TRY(game_menu->try_add_action(GUI::Action::create("Set &Number Of Guesses", [&](auto&) {
|
||||
TRY(settings_menu->try_add_action(GUI::Action::create("Set &Number Of Guesses", [&](auto&) {
|
||||
auto max_guesses = Config::read_i32("MasterWord", "", "max_guesses", 5);
|
||||
auto max_guesses_string = String::number(max_guesses);
|
||||
if (GUI::InputBox::show(window, max_guesses_string, "Maximum number of guesses:", "MasterWord") == GUI::InputBox::ExecResult::OK && !max_guesses_string.is_empty()) {
|
||||
|
@ -92,10 +100,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
}
|
||||
})));
|
||||
|
||||
TRY(game_menu->try_add_separator());
|
||||
TRY(game_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the()->quit();
|
||||
})));
|
||||
auto toggle_check_guesses = GUI::Action::create_checkable("Check &Guesses in dictionary", [&](auto& action) {
|
||||
auto checked = action.is_checked();
|
||||
game->set_check_guesses_in_dictionary(checked);
|
||||
Config::write_bool("MasterWord", "", "check_guesses_in_dictionary", checked);
|
||||
});
|
||||
toggle_check_guesses->set_checked(game->is_checking_guesses());
|
||||
TRY(settings_menu->try_add_action(toggle_check_guesses));
|
||||
|
||||
auto theme_menu = TRY(window->try_add_menu("&Theme"));
|
||||
auto system_theme_action = GUI::Action::create("&System", [&](auto&) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue