From 163a74e3e2f73bca7f68e34fc087a735a120eaff Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Sat, 20 Aug 2022 14:18:12 +0100 Subject: [PATCH] Spider: Migrate to CardGame --- Userland/Games/Spider/Game.cpp | 6 +++--- Userland/Games/Spider/Game.h | 5 +++-- Userland/Games/Spider/Spider.gml | 1 - Userland/Games/Spider/main.cpp | 4 +++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Userland/Games/Spider/Game.cpp b/Userland/Games/Spider/Game.cpp index 1bd5bb5928..7d57d0b98d 100644 --- a/Userland/Games/Spider/Game.cpp +++ b/Userland/Games/Spider/Game.cpp @@ -196,7 +196,7 @@ void Game::detect_victory() void Game::paint_event(GUI::PaintEvent& event) { - static Gfx::Color s_background_color = palette().color(background_role()); + Gfx::Color background_color = this->background_color(); GUI::Frame::paint_event(event); @@ -206,11 +206,11 @@ void Game::paint_event(GUI::PaintEvent& event) if (!m_focused_cards.is_empty()) { for (auto& focused_card : m_focused_cards) - focused_card.clear(painter, s_background_color); + focused_card.clear(painter, background_color); } for (auto& stack : m_stacks) { - stack.draw(painter, s_background_color); + stack.draw(painter, background_color); } if (!m_focused_cards.is_empty()) { diff --git a/Userland/Games/Spider/Game.h b/Userland/Games/Spider/Game.h index b11156b6d0..263d464088 100644 --- a/Userland/Games/Spider/Game.h +++ b/Userland/Games/Spider/Game.h @@ -1,6 +1,7 @@ /* * Copyright (c) 2021, Jamie Mansfield * Copyright (c) 2022, the SerenityOS developers. + * Copyright (c) 2022, Sam Atkins * * SPDX-License-Identifier: BSD-2-Clause */ @@ -8,8 +9,8 @@ #pragma once #include +#include #include -#include using Cards::Card; using Cards::CardStack; @@ -28,7 +29,7 @@ enum class GameOverReason { Quit, }; -class Game final : public GUI::Frame { +class Game final : public Cards::CardGame { C_OBJECT(Game) public: static constexpr int width = 10 + 10 * Card::width + 90 + 10; diff --git a/Userland/Games/Spider/Spider.gml b/Userland/Games/Spider/Spider.gml index 1ed45a5299..12c560b0ce 100644 --- a/Userland/Games/Spider/Spider.gml +++ b/Userland/Games/Spider/Spider.gml @@ -5,7 +5,6 @@ @Spider::Game { name: "game" fill_with_background_color: true - background_color: "green" } @GUI::Statusbar { diff --git a/Userland/Games/Spider/main.cpp b/Userland/Games/Spider/main.cpp index 86b346c406..8dca996dc1 100644 --- a/Userland/Games/Spider/main.cpp +++ b/Userland/Games/Spider/main.cpp @@ -1,6 +1,7 @@ /* * Copyright (c) 2021, Jamie Mansfield * Copyright (c) 2021, Mustafa Quraish + * Copyright (c) 2022, Sam Atkins * * SPDX-License-Identifier: BSD-2-Clause */ @@ -44,7 +45,8 @@ ErrorOr serenity_main(Main::Arguments arguments) auto app = TRY(GUI::Application::try_create(arguments)); auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-spider"sv)); - Config::pledge_domain("Spider"); + Config::pledge_domains({ "Games", "Spider" }); + Config::monitor_domain("Games"); TRY(Core::System::pledge("stdio recvfd sendfd rpath"));