mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
2048: Evil AI settings entry
This commit is contained in:
parent
3e8220dec2
commit
4434e900af
Notes:
sideshowbarker
2024-07-18 17:52:38 +09:00
Author: https://github.com/dmitrii-ubskii Commit: https://github.com/SerenityOS/serenity/commit/4434e900af9 Pull-request: https://github.com/SerenityOS/serenity/pull/7146 Reviewed-by: https://github.com/bugaevc ✅ Reviewed-by: https://github.com/linusg
3 changed files with 10 additions and 0 deletions
|
@ -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; };
|
||||
|
|
|
@ -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 };
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue