Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
ModernMenuSkin.hpp
Go to the documentation of this file.
1#pragma once
2#include "BitmapRuntime.hpp"
3#include <functional>
4#include <map>
5#include <tuple>
6#include <string_view>
7#include <utility>
8
9namespace monopoly::menu
10{
11 // Immutable USA/en-US presentation. CNK clocks and input remain authored;
12 // qualified token previews alone carry an explicit presentation rectangle.
14 {
15 public:
16 using TextRasterizer = std::function<std::expected<data::LegacyBitmapRGBA8,
17 std::string>(std::string_view)>;
18 // Authored preview frame0..27, or frame255 for the thumbnail.
19 using TokenImageProvider = std::function<std::shared_ptr<const data::LegacyBitmapRGBA8>(
20 std::uint8_t token, std::uint8_t frame)>;
22 // Live original USA/city0/system13 qualification for cash/stage art;
23 // absent means retail. Re-evaluated before cached derivatives are used.
24 void configureTradeCashPresentation(std::function<bool()> qualified);
26 TextRasterizer text) : edition_(edition), language_(language), text_(std::move(text)) {}
27 void configureBackground(std::shared_ptr<const data::LegacyBitmapRGBA8> image);
28 [[nodiscard]] bool supports(data::DataId root) const noexcept;
29 [[nodiscard]] std::shared_ptr<const data::BitmapRuntimeAsset> substitute(
30 data::DataId root, std::shared_ptr<const data::BitmapRuntimeAsset> original,
31 bool principal = true);
32 private:
33 data::BoardEdition edition_;
34 data::LanguageId language_;
35 TextRasterizer text_;
36 TokenImageProvider tokenImages_;
37 std::function<bool()> tradeCashPresentation_;
38 std::shared_ptr<const data::LegacyBitmapRGBA8> background_;
39 using Key = std::tuple<data::DataId, const data::BitmapRuntimeAsset*, bool>;
40 struct Entry
41 {
42 std::shared_ptr<const data::BitmapRuntimeAsset> original, replacement;
43 std::uint64_t lastUsed{};
44 };
45 std::map<Key, Entry> cache_;
46 std::size_t cachedBytes_{};
47 std::uint64_t cacheClock_{};
48 };
49}
std::size_t root
std::string_view text
LegacyBitmapRGBA8 image
unsigned index
int token
std::size_t frame
void configureTokenImages(TokenImageProvider provider)
void configureBackground(std::shared_ptr< const data::LegacyBitmapRGBA8 > image)
bool supports(data::DataId root) const noexcept
std::shared_ptr< const data::BitmapRuntimeAsset > substitute(data::DataId root, std::shared_ptr< const data::BitmapRuntimeAsset > original, bool principal=true)
std::function< std::shared_ptr< const data::LegacyBitmapRGBA8 >(std::uint8_t token, std::uint8_t frame)> TokenImageProvider
ModernMenuSkin(data::BoardEdition edition, data::LanguageId language, TextRasterizer text)
void configureTradeCashPresentation(std::function< bool()> qualified)
std::function< std::expected< data::LegacyBitmapRGBA8, std::string >(std::string_view)> TextRasterizer
std::uint32_t DataId
Definition DataBanks.hpp:10