diff --git a/Userland/Games/Snake/Game.h b/Userland/Games/Snake/Game.h index e6255706587f0b..413001dca9e094 100644 --- a/Userland/Games/Snake/Game.h +++ b/Userland/Games/Snake/Game.h @@ -34,6 +34,7 @@ class Game Function on_score_update; void set_skin_color(Color); + Gfx::Color get_skin_color() const { return m_snake_color; } void set_skin_name(DeprecatedString); void set_skin(NonnullOwnPtr skin); diff --git a/Userland/Games/Snake/main.cpp b/Userland/Games/Snake/main.cpp index d6a3c6a604cced..7ff0efb749634f 100644 --- a/Userland/Games/Snake/main.cpp +++ b/Userland/Games/Snake/main.cpp @@ -108,11 +108,12 @@ ErrorOr serenity_main(Main::Arguments arguments) auto was_paused = game.is_paused(); if (!was_paused) game.pause(); - auto dialog = GUI::ColorPicker::construct(Gfx::Color::White, window); - if (dialog->exec() == GUI::Dialog::ExecResult::OK) { + auto dialog = GUI::ColorPicker::construct(game.get_skin_color(), window); + dialog->on_color_changed = [&game](Gfx::Color color) { + game.set_skin_color(color); + }; + if (dialog->exec() == GUI::Dialog::ExecResult::OK) Config::write_u32("Snake"sv, "Snake"sv, "BaseColor"sv, dialog->color().value()); - game.set_skin_color(dialog->color()); - } if (!was_paused) game.start(); });