diff --git a/Userland/Games/FlappyBug/CMakeLists.txt b/Userland/Games/FlappyBug/CMakeLists.txt index 27ea98dede..755e4dc3eb 100644 --- a/Userland/Games/FlappyBug/CMakeLists.txt +++ b/Userland/Games/FlappyBug/CMakeLists.txt @@ -10,4 +10,4 @@ set(SOURCES ) serenity_app(FlappyBug ICON app-flappybug) -target_link_libraries(FlappyBug LibGUI) +target_link_libraries(FlappyBug LibGUI LibConfig) diff --git a/Userland/Games/FlappyBug/main.cpp b/Userland/Games/FlappyBug/main.cpp index f5f6b90fbd..0acc47d6c6 100644 --- a/Userland/Games/FlappyBug/main.cpp +++ b/Userland/Games/FlappyBug/main.cpp @@ -5,7 +5,7 @@ */ #include "Game.h" -#include +#include #include #include #include @@ -22,9 +22,10 @@ int main(int argc, char** argv) } auto app = GUI::Application::construct(argc, argv); - auto config = Core::ConfigFile::open_for_app("FlappyBug", Core::ConfigFile::AllowWriting::Yes); - if (pledge("stdio rpath wpath cpath recvfd sendfd", nullptr) < 0) { + Config::pledge_domains("FlappyBug"); + + if (pledge("stdio rpath recvfd sendfd", nullptr) < 0) { perror("pledge"); return 1; } @@ -34,17 +35,12 @@ int main(int argc, char** argv) return 1; } - if (unveil(config->filename().characters(), "crw") < 0) { - perror("unveil"); - return 1; - } - if (unveil(nullptr, nullptr) < 0) { perror("unveil"); return 1; } - u32 high_score = static_cast(config->read_num_entry("Game", "HighScore", 0)); + u32 high_score = Config::read_i32("FlappyBug", "Game", "HighScore", 0); auto window = GUI::Window::construct(); window->resize(FlappyBug::Game::game_width, FlappyBug::Game::game_height); @@ -59,12 +55,9 @@ int main(int argc, char** argv) if (score <= high_score) return high_score; - config->write_num_entry("Game", "HighScore", static_cast(score)); + Config::write_i32("FlappyBug", "Game", "HighScore", score); high_score = score; - if (!config->sync()) - GUI::MessageBox::show(window, "Configuration could not be saved", "Error", GUI::MessageBox::Type::Error); - return high_score; };