/* * Copyright (c) 2022, Sam Atkins * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include namespace Cards { ErrorOr> make_cards_settings_action(GUI::Window* parent = nullptr); class CardGame : public GUI::Frame , public Config::Listener { public: virtual ~CardGame() = default; Gfx::Color background_color() const; void set_background_color(Gfx::Color); NonnullRefPtrVector& stacks() { return m_stacks; } NonnullRefPtrVector const& stacks() const { return m_stacks; } CardStack& stack_at_location(int location) { return m_stacks[location]; } template ErrorOr add_stack(Args&&... args) { auto stack = TRY(try_make_ref_counted(forward(args)...)); return m_stacks.try_append(move(stack)); } void mark_intersecting_stacks_dirty(Card const& intersecting_card); bool is_moving_cards() const { return !m_moving_cards.is_empty(); } NonnullRefPtrVector& moving_cards() { return m_moving_cards; } NonnullRefPtrVector const& moving_cards() const { return m_moving_cards; } Gfx::IntRect moving_cards_bounds() const; RefPtr moving_cards_source_stack() const { return m_moving_cards_source_stack; } void pick_up_cards_from_stack(CardStack&, Gfx::IntPoint click_location, CardStack::MovementRule); RefPtr find_stack_to_drop_on(CardStack::MovementRule) const; void drop_cards_on_stack(CardStack&, CardStack::MovementRule); void clear_moving_cards(); bool is_previewing_card() const { return !m_previewed_card_stack.is_null(); } void preview_card(CardStack&, Gfx::IntPoint click_location); void clear_card_preview(); void dump_layout() const; protected: CardGame(); private: virtual void config_string_did_change(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value) override; NonnullRefPtrVector m_stacks; NonnullRefPtrVector m_moving_cards; RefPtr m_moving_cards_source_stack; RefPtr m_previewed_card_stack; }; }