19 constexpr std::uint32_t
Black = 0x00000000U;
20 class FontSettingsGuard
final
23 explicit FontSettingsGuard(fonts::Runtime& runtime)
29 (
void)runtime_.setSize(settings_.size);
30 runtime_.setWeight(settings_.weight);
31 runtime_.setItalic(settings_.italic);
32 runtime_.setUnderline(settings_.underline);
33 runtime_.setStrikeOut(settings_.strikeOut);
37 fonts::Runtime& runtime_;
38 fonts::Settings settings_;
45 static_cast<std::size_t
>(result.width) * result.height * 4U, 0
U);
52 std::string_view
text,
56 if (
text.empty())
return {};
71 std::expected<void, std::string> ScoreTextPlayback::ensureSurface(
75 if (surfaces_[player])
return {};
85 const std::array<ScoreTextState, rules::MaxPlayers>&
textStates,
92 const int scale =
modern ? 3 : 1;
96 [](
const auto& player) { return player.visible; });
98 return std::unexpected(
"IBar score text font runtime is unavailable");
106 if (published_[player].visible && surfaces_[player])
109 *surfaces_[player], TextPriority, false}))
110 return std::unexpected(
"IBar score text stop command rejected");
112 published_[player] = {};
121 monetarySystem,
true, edition);
122 if (!cash)
return std::unexpected(cash.error());
124 std::wstring_view(
textStates[player].printedName));
129 const std::string
key =
name +
'\n' + *cash +
'\n' +
133 !cache_[player] || *cache_[player] !=
key;
139 if (
const auto size =
fontRuntime->setSize((
large ? 11 : 7) * scale); !size)
140 return std::unexpected(size.error().detail);
149 return std::unexpected(size.error().detail);
157 const auto updated =
modern
158 ?
playback.runtimeBitmaps().update(*surfaces_[player], std::move(
image),
160 :
playback.runtimeBitmaps().update(*surfaces_[player], std::move(
image));
161 if (!updated)
return std::unexpected(updated.error());
162 cache_[player] =
key;
165 const Published
next{
169 if (!published_[player].visible)
173 if (!program)
return std::unexpected(program.error().detail);
174 if (
playback.commands().pendingCount() >
176 return std::unexpected(
"sequence command queue cannot fit IBar score text start");
178 *program, TextPriority, {},
180 return std::unexpected(
"IBar score text start command rejected");
182 else if (published_[player].
x !=
next.x ||
183 published_[player].y !=
next.y)
187 return std::unexpected(
"IBar score text move command rejected");
195 published_[player] =
next;
202 surfaces_.fill(std::nullopt);
203 cache_.fill(std::nullopt);
decision::EconomicActionPlan plan
std::expected< void, std::string > sync(const ScoreStripPlan &plan, const std::array< ScoreTextState, rules::MaxPlayers > &textStates, int monetarySystem, data::BoardEdition edition, fonts::Runtime *fontRuntime, engine::SequencePlayback &playback, bool presentation=false)
static constexpr std::size_t Capacity
static std::expected< std::shared_ptr< const SequenceProgram >, RuntimeError > rawBitmap(data::DataId id, data::LegacyDataType sourceType, DescriptionLimits limits={})
std::expected< void, std::string > blitStraightRGBA8(LegacyBitmapRGBA8 &destination, const LegacyBitmapRGBA8 &source, std::int32_t destinationX, std::int32_t destinationY, BitmapBlitMode mode)
std::expected< std::string, Error > transcodeUtf8(std::u16string_view text)
constexpr int ScoreBoxLargeWidth
constexpr std::uint16_t ScoreBoxPriority
std::expected< std::string, std::string > format(std::int64_t defaultValue, int monetarySystem, bool printSymbol, data::BoardEdition edition)
constexpr PlayerNumber MaxPlayers
SequenceTransform moveXYTransform(std::int32_t x, std::int32_t y) noexcept
MoveSequenceCommand makeMoveXY(data::DataId dataId, std::uint16_t priority, std::int32_t x, std::int32_t y) noexcept