Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
ChatTextPlayback.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "ChatRuntime.hpp"
5
6#include <array>
7#include <expected>
8#include <optional>
9#include <string>
10#include <vector>
11#include <unordered_map>
12
13namespace monopoly::fonts { class Runtime; }
14namespace monopoly::data { class LanguageCatalog; }
15
16namespace monopoly::chat
17{
18 // L_Type.h ALPHA_OPAQUE06_25 .. ALPHA_OPAQUE100_0 use integer truncation.
19 [[nodiscard]] constexpr std::uint8_t alphaForIndex(int index) noexcept
20 { return static_cast<std::uint8_t>((index < 0 ? 0 : index > 16 ? 16 : index) * 255 / 16); }
21
23 {
24 std::vector<std::string> outputLines;
25 std::vector<std::string> fluffLines;
26 std::string title;
27 std::string fluffTitle;
28 std::string editText;
29 std::u16string selectedFluffText;
31 std::size_t visibleOutputLines{};
32 std::size_t outputOffset{};
33 };
34
35 // Measured text only, independently exercisable without GPU or windows.
36 [[nodiscard]] std::expected<TextLayout, std::string> buildTextLayout(
37 const State& state, const rules::GameState& gameState,
39 const data::LanguageCatalog& language);
40
42 {
43 public:
44 [[nodiscard]] std::expected<void, std::string> sync(
48 void reset() noexcept;
49 // Main background/text, then Fluff background/text.
50 [[nodiscard]] std::optional<data::DataId> surfaceId(std::size_t index) const noexcept
51 { return index < surfaces_.size() ? surfaces_[index].id : std::nullopt; }
52
53 private:
54 struct Surface
55 {
56 std::optional<data::DataId> id;
57 std::uint32_t width{}, height{};
58 int x{}, y{};
59 bool visible{};
60 };
61 std::array<Surface, 4> surfaces_{};
62 std::optional<std::string> contentKey_;
63 std::unordered_map<data::DataTag, std::shared_ptr<const data::BitmapRuntimeAsset>> tiles_;
64 };
65}
data::DataId id
std::uint32_t height
std::uint32_t width
unsigned state
unsigned index
std::expected< void, std::string > sync(const State &state, const rules::GameState &gameState, rules::PlayerNumber sender, fonts::Runtime *fontRuntime, engine::SequencePlayback &playback)
std::optional< data::DataId > surfaceId(std::size_t index) const noexcept
constexpr std::uint8_t alphaForIndex(int index) noexcept
std::expected< TextLayout, std::string > buildTextLayout(const State &state, const rules::GameState &gameState, rules::PlayerNumber sender, fonts::Runtime &fontRuntime, const data::LanguageCatalog &language)
std::uint8_t PlayerNumber
Definition RuleTypes.hpp:12
std::vector< std::string > fluffLines
std::vector< std::string > outputLines