Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
PlayerSelectionPlayback.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "PlayerSetupFlow.hpp"
4#include "Display.hpp"
7#include "FontRuntime.hpp"
8
9#include <expected>
10#include <map>
11#include <optional>
12#include <string>
13#include <string_view>
14#include <vector>
15
16namespace monopoly::fonts { class Runtime; }
17
19{
31
38
39 namespace detail
40 {
41 // UDPsel.cpp owns a distinct space-only wrapper; do not route rule text
42 // through FontRuntime::wrap(), which intentionally follows UDChat quirks.
43 [[nodiscard]] std::expected<std::vector<std::string>, std::string> wrapRuleDescription(
44 fonts::Runtime& font, std::string_view text, int maxPixelWidth, std::size_t maxLines);
45 }
46
47 // Owner-thread renderer. No sequence is substituted when a retail asset
48 // is absent; sync returns the resource error and remains retryable.
50 {
51 public:
52 [[nodiscard]] std::expected<void, std::string> sync(
54 void reset() noexcept;
55 [[nodiscard]] bool ready() const noexcept { return ready_; }
57 { return playerNameRasterizations_; }
58 // Retail hotspots become active when incoming objects start, not when
59 // their clocks settle. Outgoing objects never remain interactive.
60 [[nodiscard]] bool interactable() const noexcept { return interactable_; }
61 [[nodiscard]] std::optional<ui::playersetup::Phase> takeStartedPhase() noexcept
62 {
63 const auto result = startedPhase_;
64 startedPhase_.reset();
65 return result;
66 }
67 [[nodiscard]] std::span<const RuleHit> ruleHits() const noexcept { return ruleHits_; }
70 private:
71 struct Live
72 {
73 data::DataId id{}, idle{}, out{};
74 std::uint16_t priority{};
75 int x{}, y{};
76 bool animating{}, leaving{};
77 bool loop{};
78 };
79 std::map<int, Live> live_;
80 std::map<int, data::DataId> surfaces_;
81 struct CachedPlayerName
82 {
83 std::wstring text;
84 std::shared_ptr<const data::BitmapRuntimeAsset> asset;
85 };
86 // At most the eight visible profile names; retain immutable owners so
87 // externally replaced surfaces cannot masquerade as a cache hit.
88 std::map<int, CachedPlayerName> textCache_;
89 std::optional<fonts::Settings> textCacheFont_;
90 std::shared_ptr<const data::ResourceSnapshot> textCacheResources_;
91 data::BoardEdition textCacheBoard_{};
92 std::size_t textCachePage_{}, textCacheCount_{};
93 std::uint64_t playerNameRasterizations_{};
94 std::vector<RuleHit> ruleHits_;
95 ui::playersetup::Rect restoreRect_{}, shortRect_{};
97 bool ready_{};
98 bool interactable_{};
99 std::optional<ui::playersetup::Phase> startedPhase_;
100 std::uint64_t pressSerial_{};
101 };
102}
std::string_view text
fonts::Runtime & font
std::uint16_t priority
unsigned index
data::DataId idle
data::DataId out
std::expected< void, std::string > sync(const RenderState &, fonts::Runtime *, engine::SequencePlayback &)
std::optional< ui::playersetup::Phase > takeStartedPhase() noexcept
std::span< const RuleHit > ruleHits() const noexcept
std::uint32_t DataId
Definition DataBanks.hpp:10
std::expected< std::vector< std::string >, std::string > wrapRuleDescription(fonts::Runtime &font, std::string_view value, int maxPixelWidth, std::size_t maxLines)