1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:07:34 +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

@ -0,0 +1,32 @@
/*
* Copyright (c) 2021, Pedro Pereira <pmh.pereira@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGUI/Button.h>
#include <LibGUI/Dialog.h>
#include <LibGUI/SpinBox.h>
class Field;
class CustomGameDialog : public GUI::Dialog {
C_OBJECT(CustomGameDialog);
public:
static int show(GUI::Window* parent_window, Field& field);
private:
CustomGameDialog(GUI::Window* parent_window);
virtual ~CustomGameDialog() override;
void set_max_mines();
RefPtr<GUI::Button> m_ok_button;
RefPtr<GUI::Button> m_cancel_button;
RefPtr<GUI::SpinBox> m_columns_spinbox;
RefPtr<GUI::SpinBox> m_rows_spinbox;
RefPtr<GUI::SpinBox> m_mines_spinbox;
};