Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
StatsTextPlayback.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "FontRuntime.hpp"
8
9#include <map>
10#include <tuple>
11
12namespace monopoly::statsui
13{
14 enum class TextAlignment { Left, Center, Right };
15 struct TextRun
16 {
17 std::string text;
18 int x{}, y{}, width{}, height{};
19 int size{8}, weight{500};
20 std::uint32_t colour{0x00FFFFFFU};
22 bool wrap{}, shrink{};
23 int singleLineY{-1};
24 int maxLines{};
25 int wrappedX{-1};
26 bool operator==(const TextRun&) const = default;
27 };
29 {
31 {
32 std::string player, turn, description;
33 bool operator==(const HistoryRow&) const = default;
34 };
35 int key{}, x{}, y{}, width{}, height{};
36 std::uint16_t priority{};
37 bool opaque{};
38 std::optional<Rect> blackRect;
39 std::vector<TextRun> text;
40 std::vector<HistoryRow> history;
42 bool operator==(const TextSurface&) const = default;
43 };
44
45 // Source-derived plans expose layout/data separately from glyph rasterization.
46 [[nodiscard]] std::expected<std::vector<TextSurface>, std::string>
50 int city, int monetarySystem, display::Screen2D view,
51 const data::ResourceSnapshot& resources);
52
53 [[nodiscard]] std::expected<data::LegacyBitmapRGBA8, std::string>
55 int* historyScrollLimit = nullptr, bool modernAA = false);
56
58 {
59 public:
60 [[nodiscard]] std::expected<void, std::string> sync(
64 int city, int monetarySystem, display::Screen2D view,
66 void reset() noexcept;
67 [[nodiscard]] std::size_t objectCount() const noexcept { return published_.size(); }
68 [[nodiscard]] int historyScrollLimit() const noexcept { return historyScrollLimit_; }
69 private:
70 struct Published { data::DataId id{}; std::uint16_t priority{}; };
71 std::map<std::tuple<int, int, int>, data::DataId> surfaces_;
72 std::vector<Published> published_;
73 std::vector<TextSurface> current_;
74 std::optional<fonts::Settings> fontSettings_;
75 int historyScrollLimit_{};
76 bool modernAA_{};
77 };
78}
fonts::Runtime & font
std::uint16_t priority
unsigned state
unsigned index
data::DataTag future
int historyScrollLimit() const noexcept
std::expected< void, std::string > sync(const State &state, const rules::GameState &gameState, const PlayerPlaybackInputs &inputs, const CalculatorUIState &calculator, const FutureImmunityState &future, const AccountState &accounts, int city, int monetarySystem, display::Screen2D view, fonts::Runtime *font, engine::SequencePlayback &playback, bool modernAA=false)
std::size_t objectCount() const noexcept
std::uint32_t DataId
Definition DataBanks.hpp:10
std::expected< std::vector< TextSurface >, std::string > planStatsTextSurfaces(const State &state, const rules::GameState &game, const PlayerPlaybackInputs &inputs, const CalculatorUIState &calculator, const FutureImmunityState &future, const AccountState &accounts, int city, int system, display::Screen2D view, const data::ResourceSnapshot &resources)
std::expected< data::LegacyBitmapRGBA8, std::string > renderStatsTextSurface(const TextSurface &surface, fonts::Runtime &font, int *historyScrollLimit, bool modernAA)
bool operator==(const TextRun &) const =default
bool operator==(const HistoryRow &) const =default
std::vector< HistoryRow > history
bool operator==(const TextSurface &) const =default