diff --git a/Userland/Games/Solitaire/main.cpp b/Userland/Games/Solitaire/main.cpp index ec62f497a9..c53630cd35 100644 --- a/Userland/Games/Solitaire/main.cpp +++ b/Userland/Games/Solitaire/main.cpp @@ -50,6 +50,7 @@ int main(int argc, char** argv) window->set_title("Solitaire"); auto mode = static_cast(config->read_num_entry("Settings", "Mode", static_cast(Solitaire::Mode::SingleCardDraw))); + auto high_score = static_cast(config->read_num_entry("Game", "HighScore", 0)); auto update_mode = [&](Solitaire::Mode new_mode) { mode = new_mode; @@ -58,6 +59,13 @@ int main(int argc, char** argv) GUI::MessageBox::show(window, "Configuration could not be saved", "Error", GUI::MessageBox::Type::Error); }; + auto update_high_score = [&](u32 new_high_score) { + high_score = new_high_score; + config->write_num_entry("Game", "HighScore", static_cast(high_score)); + if (!config->sync()) + GUI::MessageBox::show(window, "Configuration could not be saved", "Error", GUI::MessageBox::Type::Error); + }; + if (mode >= Solitaire::Mode::__Count) update_mode(Solitaire::Mode::SingleCardDraw); @@ -84,6 +92,9 @@ int main(int argc, char** argv) game.on_score_update = [&](uint32_t score) { statusbar.set_text(0, String::formatted("Score: {}", score)); + + if (score > high_score) + update_high_score(score); }; uint64_t seconds_elapsed = 0;