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

Minesweeper: Add "Custom game..." difficulty

This adds a dialog window which allows us to customize the size of the
board and the amount of mines that will be placed.
The current max amount of mines is 50% of the total number of cells
due to the fact that the generator algorithm takes too long to create a
board for higher percentages of mines.
This commit is contained in:
Pedro Pereira 2021-11-02 21:35:58 +00:00 committed by Linus Groh
parent 42071f69cf
commit 557075465c
5 changed files with 201 additions and 0 deletions

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "CustomGameDialog.h"
#include "Field.h"
#include <LibConfig/Client.h>
#include <LibGUI/Action.h>
@ -131,6 +132,10 @@ int main(int argc, char** argv)
difficulty_menu.add_action(GUI::Action::create("&Madwoman", { Mod_Ctrl, Key_M }, [&](auto&) {
field.set_field_size(32, 60, 350);
}));
difficulty_menu.add_separator();
difficulty_menu.add_action(GUI::Action::create("&Custom game...", { Mod_Ctrl, Key_C }, [&](auto&) {
CustomGameDialog::show(window, field);
}));
auto& help_menu = window->add_menu("&Help");
help_menu.add_action(GUI::CommonActions::make_about_action("Minesweeper", app_icon, window));