mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:07:45 +00:00
2048: Intialize settings window with current values
Currently, each time you open the settings window in 2048, it displays the default values rather than the current values. This is confusing, so display the current values instead.
This commit is contained in:
parent
63a1be1406
commit
f02a13c884
3 changed files with 17 additions and 8 deletions
|
@ -39,9 +39,14 @@ int main(int argc, char** argv)
|
|||
auto config = Core::ConfigFile::get_for_app("2048");
|
||||
|
||||
size_t board_size = config->read_num_entry("", "board_size", 4);
|
||||
u32 target_tile = config->read_num_entry("", "target_tile", 0);
|
||||
u32 target_tile = config->read_num_entry("", "target_tile", 2048);
|
||||
bool evil_ai = config->read_bool_entry("", "evil_ai", false);
|
||||
|
||||
if ((target_tile & (target_tile - 1)) != 0) {
|
||||
// If the target tile is not a power of 2, reset to its default value.
|
||||
target_tile = 2048;
|
||||
}
|
||||
|
||||
config->write_num_entry("", "board_size", board_size);
|
||||
config->write_num_entry("", "target_tile", target_tile);
|
||||
config->write_bool_entry("", "evil_ai", evil_ai);
|
||||
|
@ -94,7 +99,7 @@ int main(int argc, char** argv)
|
|||
Vector<Game> redo_stack;
|
||||
|
||||
auto change_settings = [&] {
|
||||
auto size_dialog = GameSizeDialog::construct(window);
|
||||
auto size_dialog = GameSizeDialog::construct(window, board_size, target_tile, evil_ai);
|
||||
if (size_dialog->exec() || size_dialog->result() != GUI::Dialog::ExecOK)
|
||||
return;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue