diff --git a/Userland/Games/Chess/ChessWidget.cpp b/Userland/Games/Chess/ChessWidget.cpp index 9f72e584140..a54f1965df0 100644 --- a/Userland/Games/Chess/ChessWidget.cpp +++ b/Userland/Games/Chess/ChessWidget.cpp @@ -24,6 +24,8 @@ #include #include +namespace Chess { + ErrorOr> ChessWidget::try_create() { auto widget = TRY(AK::adopt_nonnull_ref_or_enomem(new (nothrow) ChessWidget)); @@ -43,7 +45,7 @@ void ChessWidget::paint_event(GUI::PaintEvent& event) GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); - painter.fill_rect(frame_inner_rect(), Color::Black); + painter.fill_rect(frame_inner_rect(), Gfx::Color::Black); painter.translate(frame_thickness() + widget_offset_x, frame_thickness() + widget_offset_y); @@ -74,8 +76,8 @@ void ChessWidget::paint_event(GUI::PaintEvent& event) auto const piece = active_board.get_piece(sq); if (m_highlight_checks && last_move.is_check && piece.type == Chess::Type::King && piece.color == active_board.turn()) { Array colors = { - Gfx::ColorStop { .color = Color::Red, .position = 0.16f }, - Gfx::ColorStop { .color = Color::Transparent, .position = .66f } + Gfx::ColorStop { .color = Gfx::Color::Red, .position = 0.16f }, + Gfx::ColorStop { .color = Gfx::Color::Transparent, .position = .66f } }; painter.fill_rect_with_radial_gradient(tile_rect, colors, tile_rect.center() - tile_rect.top_left(), tile_rect.size()); @@ -445,11 +447,11 @@ void ChessWidget::set_board_theme(StringView name) // FIXME: Add some kind of themes.json // The following Colors have been taken from lichess.org, but i'm pretty sure they took them from chess.com. if (name == "Beige") { - m_board_theme = { "Beige"sv, Color::from_rgb(0xb58863), Color::from_rgb(0xf0d9b5) }; + m_board_theme = { "Beige"sv, Gfx::Color::from_rgb(0xb58863), Gfx::Color::from_rgb(0xf0d9b5) }; } else if (name == "Green") { - m_board_theme = { "Green"sv, Color::from_rgb(0x86a666), Color::from_rgb(0xffffdd) }; + m_board_theme = { "Green"sv, Gfx::Color::from_rgb(0x86a666), Gfx::Color::from_rgb(0xffffdd) }; } else if (name == "Blue") { - m_board_theme = { "Blue"sv, Color::from_rgb(0x8ca2ad), Color::from_rgb(0xdee3e6) }; + m_board_theme = { "Blue"sv, Gfx::Color::from_rgb(0x8ca2ad), Gfx::Color::from_rgb(0xdee3e6) }; } else { set_board_theme("Beige"sv); } @@ -893,3 +895,5 @@ void ChessWidget::config_bool_did_change(StringView domain, StringView group, St update(); } } + +} diff --git a/Userland/Games/Chess/ChessWidget.h b/Userland/Games/Chess/ChessWidget.h index 8577b062bba..a952a8f2e47 100644 --- a/Userland/Games/Chess/ChessWidget.h +++ b/Userland/Games/Chess/ChessWidget.h @@ -18,6 +18,8 @@ #include #include +namespace Chess { + class PGNParseError { public: PGNParseError() = default; @@ -86,8 +88,8 @@ public: struct BoardTheme { StringView name; - Color dark_square_color; - Color light_square_color; + Gfx::Color dark_square_color; + Gfx::Color light_square_color; }; BoardTheme const& board_theme() const { return m_board_theme; } @@ -155,11 +157,11 @@ private: size_t m_playback_move_number { 0 }; BoardMarking m_current_marking; Vector m_board_markings; - BoardTheme m_board_theme { "Beige"sv, Color::from_rgb(0xb58863), Color::from_rgb(0xf0d9b5) }; - Color m_move_highlight_color { Color::from_argb(0x66ccee00) }; - Color m_marking_primary_color { Color::from_argb(0x66ff0000) }; - Color m_marking_alternate_color { Color::from_argb(0x66ffaa00) }; - Color m_marking_secondary_color { Color::from_argb(0x6655dd55) }; + BoardTheme m_board_theme { "Beige"sv, Gfx::Color::from_rgb(0xb58863), Gfx::Color::from_rgb(0xf0d9b5) }; + Gfx::Color m_move_highlight_color { Gfx::Color::from_argb(0x66ccee00) }; + Gfx::Color m_marking_primary_color { Gfx::Color::from_argb(0x66ff0000) }; + Gfx::Color m_marking_alternate_color { Gfx::Color::from_argb(0x66ffaa00) }; + Gfx::Color m_marking_secondary_color { Gfx::Color::from_argb(0x6655dd55) }; Chess::Color m_side { Chess::Color::White }; HashMap> m_pieces; bool m_any_piece_images_are_missing { false }; @@ -173,3 +175,5 @@ private: bool m_coordinates { true }; bool m_highlight_checks { true }; }; + +} diff --git a/Userland/Games/Chess/PromotionDialog.cpp b/Userland/Games/Chess/PromotionDialog.cpp index c0b015f3273..affb21146e7 100644 --- a/Userland/Games/Chess/PromotionDialog.cpp +++ b/Userland/Games/Chess/PromotionDialog.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, the SerenityOS developers. + * Copyright (c) 2020-2024, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ @@ -9,6 +9,8 @@ #include #include +namespace Chess { + PromotionDialog::PromotionDialog(ChessWidget& chess_widget) : Dialog(chess_widget.window()) , m_selected_piece(Chess::Type::None) @@ -37,3 +39,5 @@ void PromotionDialog::event(Core::Event& event) { Dialog::event(event); } + +} diff --git a/Userland/Games/Chess/PromotionDialog.h b/Userland/Games/Chess/PromotionDialog.h index a3d93b10928..54a349ca73b 100644 --- a/Userland/Games/Chess/PromotionDialog.h +++ b/Userland/Games/Chess/PromotionDialog.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, the SerenityOS developers. + * Copyright (c) 2020-2024, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause */ @@ -9,6 +9,8 @@ #include "ChessWidget.h" #include +namespace Chess { + class PromotionDialog final : public GUI::Dialog { C_OBJECT(PromotionDialog) public: @@ -20,3 +22,5 @@ private: Chess::Type m_selected_piece; }; + +} diff --git a/Userland/Games/Chess/main.cpp b/Userland/Games/Chess/main.cpp index c97f8fde6ac..e202bfef589 100644 --- a/Userland/Games/Chess/main.cpp +++ b/Userland/Games/Chess/main.cpp @@ -64,7 +64,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-chess"sv)); auto window = GUI::Window::construct(); - auto widget = TRY(ChessWidget::try_create()); + auto widget = TRY(Chess::ChessWidget::try_create()); window->set_main_widget(widget); auto engines = TRY(available_engines());