diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2023-01-05 17:46:47 +0000 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-01-06 16:03:50 +0100 |
commit | c79110d5bf6d89980e38bd96424b213a67fb5a77 (patch) | |
tree | 8d224212299f68888f4442e389611164ec3ed599 | |
parent | 306676792c7a964ad612a6ec1c11c3cf914736a0 (diff) | |
download | serenity-c79110d5bf6d89980e38bd96424b213a67fb5a77.zip |
Solitaire: Save and load u32 config values as u32s
This removes a bunch of awkward i32 casts. Being able to read/write enum
types directly would be even nicer, but I'm not going there right
now. :^)
-rw-r--r-- | Userland/Games/Solitaire/main.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Userland/Games/Solitaire/main.cpp b/Userland/Games/Solitaire/main.cpp index 9d63096416..f2f5e8b0dd 100644 --- a/Userland/Games/Solitaire/main.cpp +++ b/Userland/Games/Solitaire/main.cpp @@ -49,19 +49,19 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto window = TRY(GUI::Window::try_create()); window->set_title("Solitaire"); - auto mode = static_cast<Solitaire::Mode>(Config::read_i32("Solitaire"sv, "Settings"sv, "Mode"sv, static_cast<int>(Solitaire::Mode::SingleCardDraw))); + auto mode = static_cast<Solitaire::Mode>(Config::read_u32("Solitaire"sv, "Settings"sv, "Mode"sv, to_underlying(Solitaire::Mode::SingleCardDraw))); auto update_mode = [&](Solitaire::Mode new_mode) { mode = new_mode; - Config::write_i32("Solitaire"sv, "Settings"sv, "Mode"sv, static_cast<int>(mode)); + Config::write_u32("Solitaire"sv, "Settings"sv, "Mode"sv, to_underlying(mode)); }; auto high_score = [&]() { switch (mode) { case Solitaire::Mode::SingleCardDraw: - return static_cast<u32>(Config::read_i32("Solitaire"sv, "HighScores"sv, "SingleCardDraw"sv, 0)); + return Config::read_u32("Solitaire"sv, "HighScores"sv, "SingleCardDraw"sv, 0); case Solitaire::Mode::ThreeCardDraw: - return static_cast<u32>(Config::read_i32("Solitaire"sv, "HighScores"sv, "ThreeCardDraw"sv, 0)); + return Config::read_u32("Solitaire"sv, "HighScores"sv, "ThreeCardDraw"sv, 0); default: VERIFY_NOT_REACHED(); } @@ -70,10 +70,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto update_high_score = [&](u32 new_high_score) { switch (mode) { case Solitaire::Mode::SingleCardDraw: - Config::write_i32("Solitaire"sv, "HighScores"sv, "SingleCardDraw"sv, static_cast<int>(new_high_score)); + Config::write_u32("Solitaire"sv, "HighScores"sv, "SingleCardDraw"sv, new_high_score); break; case Solitaire::Mode::ThreeCardDraw: - Config::write_i32("Solitaire"sv, "HighScores"sv, "ThreeCardDraw"sv, static_cast<int>(new_high_score)); + Config::write_u32("Solitaire"sv, "HighScores"sv, "ThreeCardDraw"sv, new_high_score); break; default: VERIFY_NOT_REACHED(); |