diff options
author | Dmitrii Ubskii <ubskydm@gmail.com> | 2021-05-15 17:35:48 +0300 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-05-18 08:51:56 +0100 |
commit | 4434e900af947fd4374eff734621a5991abcc4be (patch) | |
tree | 9f881f0c0c341b302e32b8886a1794fc0e933a61 /Userland/Games/2048 | |
parent | 3e8220dec261f43cfcf71809238d5ab8ee2482cd (diff) | |
download | serenity-4434e900af947fd4374eff734621a5991abcc4be.zip |
2048: Evil AI settings entry
Diffstat (limited to 'Userland/Games/2048')
-rw-r--r-- | Userland/Games/2048/GameSizeDialog.cpp | 4 | ||||
-rw-r--r-- | Userland/Games/2048/GameSizeDialog.h | 2 | ||||
-rw-r--r-- | Userland/Games/2048/main.cpp | 4 |
3 files changed, 10 insertions, 0 deletions
diff --git a/Userland/Games/2048/GameSizeDialog.cpp b/Userland/Games/2048/GameSizeDialog.cpp index f86d2fe978..3053bd4cff 100644 --- a/Userland/Games/2048/GameSizeDialog.cpp +++ b/Userland/Games/2048/GameSizeDialog.cpp @@ -57,6 +57,10 @@ GameSizeDialog::GameSizeDialog(GUI::Window* parent) tile_value_label.set_text(String::number(target_tile())); }; + auto& evil_ai_checkbox = main_widget.add<GUI::CheckBox>("Evil AI"); + evil_ai_checkbox.set_checked(m_evil_ai); + evil_ai_checkbox.on_checked = [this](auto checked) { m_evil_ai = checked; }; + auto& temp_checkbox = main_widget.add<GUI::CheckBox>("Temporary"); temp_checkbox.set_checked(m_temporary); temp_checkbox.on_checked = [this](auto checked) { m_temporary = checked; }; diff --git a/Userland/Games/2048/GameSizeDialog.h b/Userland/Games/2048/GameSizeDialog.h index 46ac33504b..6a3d982634 100644 --- a/Userland/Games/2048/GameSizeDialog.h +++ b/Userland/Games/2048/GameSizeDialog.h @@ -16,10 +16,12 @@ public: size_t board_size() const { return m_board_size; } u32 target_tile() const { return 1u << m_target_tile_power; } + bool evil_ai() const { return m_evil_ai; } bool temporary() const { return m_temporary; } private: size_t m_board_size { 4 }; size_t m_target_tile_power { 11 }; + bool m_evil_ai { false }; bool m_temporary { true }; }; diff --git a/Userland/Games/2048/main.cpp b/Userland/Games/2048/main.cpp index 5ffb7c1f30..97a3440a0e 100644 --- a/Userland/Games/2048/main.cpp +++ b/Userland/Games/2048/main.cpp @@ -40,9 +40,11 @@ int main(int argc, char** argv) size_t board_size = config->read_num_entry("", "board_size", 4); u32 target_tile = config->read_num_entry("", "target_tile", 0); + bool evil_ai = config->read_bool_entry("", "evil_ai", false); config->write_num_entry("", "board_size", board_size); config->write_num_entry("", "target_tile", target_tile); + config->write_bool_entry("", "evil_ai", evil_ai); config->sync(); @@ -98,11 +100,13 @@ int main(int argc, char** argv) board_size = size_dialog->board_size(); target_tile = size_dialog->target_tile(); + evil_ai = size_dialog->evil_ai(); if (!size_dialog->temporary()) { config->write_num_entry("", "board_size", board_size); config->write_num_entry("", "target_tile", target_tile); + config->write_bool_entry("", "evil_ai", evil_ai); if (!config->sync()) { GUI::MessageBox::show(window, "Configuration could not be synced", "Error", GUI::MessageBox::Type::Error); |