Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
ModernIBarSkin.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "BitmapRuntime.hpp"
4#include "IBarLayout.hpp"
6#include <functional>
7#include <string_view>
8#include <utility>
9#include <map>
10#include <optional>
11#include <tuple>
12
13namespace monopoly::ibar
14{
15 // Pixel substitution only. Rules, hit rectangles and CNK clocks remain owned
16 // by the retail-equivalent IBar playback. Unsupported languages fall back.
18 {
19 public:
20 using TextRasterizer = std::function<std::expected<data::LegacyBitmapRGBA8,
21 std::string>(std::string_view)>;
23 : language_(language), text_(std::move(text)) {}
24 using TokenImageProvider = std::function<std::shared_ptr<const data::LegacyBitmapRGBA8>(std::uint8_t token)>;
26 { tokenImages_ = std::move(provider); cache_.clear(); }
28 {
29 std::string name;
30 std::uint8_t group{}; // canonical SquareGroup: streets0..7, railroad8, utility9
31 std::string purchaseText; // already formatted canonical amount; optional
32 };
33 using DescriptorProvider = std::function<std::optional<PropertyDescriptor>(unsigned)>;
34 // Provider uses IBar board-order index, never TRANS_PROP ordering.
35 // Reconfiguration invalidates cached captions after city/currency changes.
37 { properties_ = std::move(provider); propertyText_ = std::move(text); cache_.clear(); }
38 struct DeedFill { int x{}, y{}, width{}, height{}; std::uint32_t color{}; };
39 struct DeedText
40 {
41 std::string text;
43 std::uint32_t color{};
45 };
48 {
49 std::vector<DeedFill> fills; std::vector<DeedText> text;
50 // Exact measured USA front only; recover its actual monochrome art.
51 std::optional<DeedArtwork> artwork;
52 };
53 // Local presentation rect for the current purchase overlay; hover and CNK timing stay authored.
54 using DeedPlacementProvider = std::function<std::optional<std::array<float,4>>(
57 { deedPlacement_ = std::move(provider); cache_.clear(); }
58 using DeedTextRasterizer = std::function<std::expected<data::LegacyBitmapRGBA8,std::string>(
59 std::string_view, int, bool, bool)>;
60 // Exact live root IDs only; the caller owns edition/currency/title proof.
61 // Payload strings and amounts come directly from EuropeanDeed::Plan.
62 void configureDeedDescriptors(std::map<data::DataId,DeedDescriptor> descriptors,
64 { deeds_ = std::move(descriptors); deedText_ = std::move(rasterizer); cache_.clear(); }
66 {
67 std::string title, body;
68 std::uint32_t nativeWidth{400}, nativeHeight{240};
69 };
71 {
72 std::array<float,4> localRect;
73 bool occluded{}; // Only while an actual deed consumer occupies this panel.
74 };
75 using IdleCardPresentationProvider = std::function<std::optional<IdleCardPresentation>(
76 data::DataId,std::uint16_t,const sequence::Matrix2D& sequenceToWorld)>;
78 { idleCardPresentation_=std::move(provider);cache_.clear(); }
80 void configureDrawCardDescriptors(std::map<data::DataId,DrawCardDescriptor> descriptors,
82 { drawCards_ = std::move(descriptors); drawText_ = std::move(rasterizer); cache_.clear(); }
83 // Re-evaluated for every button/token/deed/draw/property substitution, including cache hits.
84 // An absent predicate preserves the existing caller-qualified behavior.
85 void configurePresentationContext(std::function<bool()> predicate)
86 { presentationContext_ = std::move(predicate); }
87 // Optional3x blended labels for the five qualified action families.
89 { actionText_=std::move(rasterizer);cache_.clear(); }
92 { layout_ = std::move(provider); cache_.clear(); }
93 [[nodiscard]] bool supports(data::DataId root) const noexcept;
94 // Exact auction token owners require root priority and native column provenance.
95 [[nodiscard]] bool supportsAuctionToken(data::DataId root) const noexcept;
96 // Only the measured background leaves change; animated siblings remain retail.
97 [[nodiscard]] bool supportsCardFaceIn(data::DataId root) const noexcept;
98 // Exact USA action transition UAPs may retain native geometry/printed
99 // captions with a chrome tint when the settled band path cannot apply.
100 [[nodiscard]] std::shared_ptr<const data::BitmapRuntimeAsset> substitute(
101 data::DataId root, std::shared_ptr<const data::BitmapRuntimeAsset> original,
102 bool principal = true,
103 std::optional<sequence::Matrix2D> rasterToWorld = {},
104 std::optional<std::uint16_t> priority = {},
105 std::optional<sequence::Matrix2D> sequenceToWorld = {});
106 private:
107 data::LanguageId language_;
108 TextRasterizer text_;
109 TextRasterizer actionText_;
110 TokenImageProvider tokenImages_;
111 LayoutProvider layout_;
112 std::function<bool()> presentationContext_;
113 std::map<data::DataId,DeedDescriptor> deeds_;
114 DeedTextRasterizer deedText_;
115 DeedPlacementProvider deedPlacement_;
116 std::map<data::DataId,DrawCardDescriptor> drawCards_;
117 DeedTextRasterizer drawText_;
118 IdleCardPresentationProvider idleCardPresentation_;
119 DescriptorProvider properties_;
120 TextRasterizer propertyText_;
121 using Key = std::tuple<data::DataId, std::uint32_t, std::uint32_t, bool, std::array<float,9>, int,
122 std::optional<std::array<float,4>>, const data::BitmapRuntimeAsset*>;
123 struct CachedArtwork
124 {
125 std::shared_ptr<const data::BitmapRuntimeAsset> replacement;
126 // Keeps native artwork identity alive so allocator address reuse cannot
127 // produce a stale derivative. Bounded together with the128 entries.
128 std::shared_ptr<const data::BitmapRuntimeAsset> original;
129 };
130 std::map<Key, CachedArtwork> cache_;
131 };
132}
std::size_t root
std::string_view text
std::uint16_t priority
unsigned index
int token
ModernIBarSkin(data::LanguageId language, TextRasterizer text)
void configureDeedPlacementProvider(DeedPlacementProvider provider)
std::shared_ptr< const data::BitmapRuntimeAsset > substitute(data::DataId root, std::shared_ptr< const data::BitmapRuntimeAsset > original, bool principal=true, std::optional< sequence::Matrix2D > rasterToWorld={}, std::optional< std::uint16_t > priority={}, std::optional< sequence::Matrix2D > sequenceToWorld={})
void configurePresentationContext(std::function< bool()> predicate)
void configureTokenImages(TokenImageProvider provider)
std::function< std::optional< std::array< float, 4 > >(data::DataId, std::uint16_t priority, const sequence::Matrix2D &rasterToWorld)> DeedPlacementProvider
void configurePropertyDescriptors(DescriptorProvider provider, TextRasterizer text)
void configureLayoutProvider(LayoutProvider provider)
std::function< std::shared_ptr< const data::LegacyBitmapRGBA8 >(std::uint8_t token)> TokenImageProvider
bool supportsIdleCardPresentation(data::DataId root) const noexcept
bool supports(data::DataId root) const noexcept
void configureActionText(TextRasterizer rasterizer)
std::function< layout::ActionButtonLayout()> LayoutProvider
void configureDrawCardDescriptors(std::map< data::DataId, DrawCardDescriptor > descriptors, DeedTextRasterizer rasterizer)
std::function< std::optional< PropertyDescriptor >(unsigned)> DescriptorProvider
void configureDeedDescriptors(std::map< data::DataId, DeedDescriptor > descriptors, DeedTextRasterizer rasterizer)
std::function< std::expected< data::LegacyBitmapRGBA8, std::string >(std::string_view, int, bool, bool)> DeedTextRasterizer
void configureIdleCardPresentation(IdleCardPresentationProvider provider)
std::function< std::optional< IdleCardPresentation >(data::DataId, std::uint16_t, const sequence::Matrix2D &sequenceToWorld)> IdleCardPresentationProvider
bool supportsAuctionToken(data::DataId root) const noexcept
bool supportsCardFaceIn(data::DataId root) const noexcept
std::function< std::expected< data::LegacyBitmapRGBA8, std::string >(std::string_view)> TextRasterizer
std::uint32_t DataId
Definition DataBanks.hpp:10