Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
ChatRuntime.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "Actions.hpp"
4#include "RuleTypes.hpp"
5#include "UIMessages.hpp"
6
7#include <array>
8#include <cstddef>
9#include <cstdint>
10#include <string>
11#include <string_view>
12
13namespace monopoly::chat
14{
15 inline constexpr std::size_t HistoryCapacity = 512;
16 inline constexpr std::size_t MaxInputCharacters = 255;
17 inline constexpr std::size_t InputHistoryCapacity = 100;
18 inline constexpr std::array<int, 6> FluffCategoryLineCounts{
19 19, 21, 18, 19, 14, 8};
20 inline constexpr std::array<std::int64_t, 6> FluffCategoryMessageStarts{
21 1, 21, 43, 62, 82, 97};
22
33 struct State
34 {
35 std::array<Entry, HistoryCapacity> history{};
36 std::size_t first{};
37 std::size_t count{};
38 std::size_t outputOffset{};
39 std::size_t wrappedOutputLines{};
40 std::size_t outputLinesInWindow{};
41 std::uint64_t historyRevision{};
44 bool followLatest{true};
45 std::u16string draft{};
46 std::array<std::u16string, InputHistoryCapacity> inputHistory{};
47 std::size_t inputHistoryCount{};
48 std::size_t inputHistoryOffset{};
49 std::uint32_t recipientMask = (1u << rules::MaxPlayers) - 1u;
50 std::uint32_t eligibleRecipients{};
51 int windowX{10};
52 int windowY{10};
53 int windowWidth{246};
54 int windowHeight{99};
59 int fontSize{7};
62 int fluffWindowX{265};
63 int fluffWindowY{10};
72 std::size_t fluffCategory{};
73 bool boxActive{};
74 bool shaded{};
76 bool fluffOpen{};
81 bool moving{};
82 bool sizing{};
83 bool scrolling{};
84 };
85
86 // Refresh from UI state before RULE ingress or local input. Entry names
87 // are captured on arrival, as CHAT_ReceiveMessage formatted its history.
89 // Published by the measured FontRuntime layout, never guessed from points.
90 void setOutputLayoutMetrics(std::size_t wrappedLines, int fontHeight,
91 std::size_t visibleLines) noexcept;
92 void setFluffSelectionText(std::int64_t cannedTextId, std::u16string_view text);
93 void reset() noexcept;
94 void toggle() noexcept;
98 [[nodiscard]] bool processInput(
99 const uimsg::Message& message,
100 rules::PlayerNumber sender,
102 bool networkMode);
103 [[nodiscard]] bool processRuleMessage(const actions::Message& message);
106 std::size_t line,
107 rules::PlayerNumber sender,
109 bool networkMode);
110 [[nodiscard]] bool buildTextAction(
111 rules::PlayerNumber from,
112 rules::PlayerNumber to,
113 std::u16string_view text,
114 actions::Message& result);
115 [[nodiscard]] bool sendText(
116 rules::PlayerNumber from,
117 rules::PlayerNumber to,
118 std::u16string_view text);
120 [[nodiscard]] const Entry* entryAt(std::size_t index) noexcept;
121}
std::string_view text
unsigned index
bool processInput(const uimsg::Message &message, rules::PlayerNumber sender, std::uint32_t eligibleRecipients, bool networkMode)
std::uint32_t recipientMask() noexcept
bool buildTextAction(rules::PlayerNumber from, rules::PlayerNumber to, std::u16string_view text, actions::Message &result)
constexpr std::size_t HistoryCapacity
std::uint32_t eligibleRecipients() noexcept
bool activateFluffLine(std::size_t line, rules::PlayerNumber sender, std::uint32_t eligibleRecipients, bool networkMode)
const State & stateReadOnly() noexcept
constexpr std::size_t MaxInputCharacters
std::int64_t selectedFluffMessageId() noexcept
void setPlayerNames(const rules::GameState &gameState)
void toggle() noexcept
void reset() noexcept
constexpr std::array< int, 6 > FluffCategoryLineCounts
constexpr std::size_t InputHistoryCapacity
void setOutputLayoutMetrics(std::size_t wrappedLines, int height, std::size_t visibleLines) noexcept
void setRecipientMask(std::uint32_t mask) noexcept
const Entry * entryAt(std::size_t index) noexcept
void setFluffSelectionText(std::int64_t cannedTextId, std::u16string_view text)
bool sendText(rules::PlayerNumber from, rules::PlayerNumber to, std::u16string_view text)
constexpr std::array< std::int64_t, 6 > FluffCategoryMessageStarts
bool processRuleMessage(const actions::Message &message)
std::uint8_t PlayerNumber
Definition RuleTypes.hpp:12
constexpr PlayerNumber SpectatorPlayer
Definition RuleTypes.hpp:22
constexpr PlayerNumber MaxPlayers
Definition RuleTypes.hpp:14
constexpr PlayerNumber AllPlayers
Definition RuleTypes.hpp:17
std::wstring displayName
rules::PlayerNumber from
std::u16string text
std::int64_t cannedTextId
rules::PlayerNumber to
std::size_t inputHistoryCount
std::uint32_t eligibleRecipients
std::u16string draft
std::size_t inputHistoryOffset
std::size_t wrappedOutputLines
std::array< Entry, HistoryCapacity > history
std::uint64_t historyRevision
std::size_t outputLinesInWindow
std::array< std::u16string, InputHistoryCapacity > inputHistory
std::uint32_t recipientMask
std::size_t fluffCategory