forked from rosebudai/OpenRCT2-Web
Rename functions in Drawing.String.h to adhere to code style rules
This commit is contained in:
16 files changed
+74
-76
No files matched your search
@@ -1195,7 +1195,7 @@ namespace OpenRCT2::Ui
|
||||
if (widget.text != 0)
|
||||
{
|
||||
u8string wrappedString;
|
||||
GfxWrapString(widget.string, bottomRight.x - topLeft.x - 5, FontStyle::medium, &wrappedString, nullptr);
|
||||
wrapString(widget.string, bottomRight.x - topLeft.x - 5, FontStyle::medium, &wrappedString, nullptr);
|
||||
DrawTextNoFormatting(rt, { topLeft.x + 2, topLeft.y }, wrappedString, { w.colours[1] });
|
||||
}
|
||||
return;
|
||||
@@ -1204,7 +1204,7 @@ namespace OpenRCT2::Ui
|
||||
// String length needs to add 12 either side of box
|
||||
// +13 for cursor when max length.
|
||||
u8string wrappedString;
|
||||
GfxWrapString(*textInput->Buffer, bottomRight.x - topLeft.x - 5 - 6, FontStyle::medium, &wrappedString, nullptr);
|
||||
wrapString(*textInput->Buffer, bottomRight.x - topLeft.x - 5 - 6, FontStyle::medium, &wrappedString, nullptr);
|
||||
|
||||
DrawTextNoFormatting(rt, { topLeft.x + 2, topLeft.y }, wrappedString, { w.colours[1] });
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ namespace OpenRCT2::Scripting
|
||||
DukValue measureText(const std::string& text)
|
||||
{
|
||||
auto width = Drawing::getStringWidth(text, FontStyle::medium);
|
||||
auto height = Drawing::StringGetHeightRaw(text.c_str(), FontStyle::medium);
|
||||
auto height = Drawing::getStringHeightRaw(text.c_str(), FontStyle::medium);
|
||||
return ToDuk<ScreenSize>(_ctx, { width, height });
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
WindowDrawWidgets(*this, rt);
|
||||
|
||||
auto screenCoords = windowPos + ScreenCoordsXY{ (width + 1) / 2 - 1, kPadding - 1 };
|
||||
DrawStringCentredRaw(rt, screenCoords, _numLines, _text.data(), FontStyle::medium);
|
||||
drawStringCentredRaw(rt, screenCoords, _numLines, _text.data(), FontStyle::medium);
|
||||
}
|
||||
|
||||
void onPeriodicUpdate() override
|
||||
@@ -127,12 +127,12 @@ namespace OpenRCT2::Ui::Windows
|
||||
windowMgr->CloseByClass(WindowClass::error);
|
||||
|
||||
// How wide is the error string?
|
||||
int32_t width = Drawing::GfxGetStringWidthNewLined(buffer.data(), FontStyle::medium);
|
||||
int32_t width = Drawing::getStringWidthNewlined(buffer.data(), FontStyle::medium);
|
||||
width = std::clamp(width + 2 * kPadding, kMinWidth, kMaxWidth);
|
||||
|
||||
// How high is the error string?
|
||||
int32_t numLines{};
|
||||
Drawing::GfxWrapString(buffer, width + 1, FontStyle::medium, &buffer, &numLines);
|
||||
Drawing::wrapString(buffer, width + 1, FontStyle::medium, &buffer, &numLines);
|
||||
int32_t height = (numLines + 1) * FontGetLineHeight(FontStyle::medium) + (2 * kPadding);
|
||||
|
||||
// Position error message around the cursor
|
||||
|
||||
@@ -256,7 +256,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
// Text
|
||||
auto screenCoords = windowPos + ScreenCoordsXY{ middleOutsetWidget.midX(), middleOutsetWidget.top + 11 };
|
||||
int32_t itemWidth = middleOutsetWidget.width() - 63;
|
||||
DrawNewsTicker(
|
||||
drawNewsTicker(
|
||||
rt, screenCoords, itemWidth, Drawing::Colour::brightGreen, STR_BOTTOM_TOOLBAR_NEWS_TEXT, newsItem->text,
|
||||
newsItem->ticks);
|
||||
|
||||
|
||||
@@ -744,7 +744,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
const auto& widget = widgets[WIDX_PARENT_FOLDER];
|
||||
const auto pathWidth = widget.left - 8;
|
||||
const auto shortPath = ShortenPath(_directory, pathWidth, FontStyle::medium);
|
||||
const auto shortPath = shortenPath(_directory, pathWidth, FontStyle::medium);
|
||||
|
||||
// Format text
|
||||
std::string buffer;
|
||||
|
||||
@@ -476,7 +476,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
// Server name is displayed word-wrapped, so figure out how high it will be.
|
||||
{
|
||||
int32_t numLines;
|
||||
GfxWrapString(Network::GetServerName(), baseWidth, FontStyle::medium, nullptr, &numLines);
|
||||
wrapString(Network::GetServerName(), baseWidth, FontStyle::medium, nullptr, &numLines);
|
||||
baseHeight += (numLines + 1) * lineHeight + (kListRowHeight / 2);
|
||||
}
|
||||
|
||||
@@ -485,7 +485,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (!descString.empty())
|
||||
{
|
||||
int32_t numLines;
|
||||
GfxWrapString(descString, baseWidth, FontStyle::medium, nullptr, &numLines);
|
||||
wrapString(descString, baseWidth, FontStyle::medium, nullptr, &numLines);
|
||||
baseHeight += (numLines + 1) * lineHeight + (kListRowHeight / 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
_buffer.assign("{WHITE}");
|
||||
_buffer += _windowNetworkStatusText;
|
||||
Drawing::GfxClipString(_buffer.data(), widgets[WIDX_BACKGROUND].right - 50, FontStyle::medium);
|
||||
Drawing::clipString(_buffer.data(), widgets[WIDX_BACKGROUND].right - 50, FontStyle::medium);
|
||||
|
||||
ScreenCoordsXY screenCoords(windowPos.x + (width / 2), windowPos.y + (height / 2));
|
||||
screenCoords.x -= Drawing::getStringWidth(_buffer, FontStyle::medium) / 2;
|
||||
|
||||
@@ -363,7 +363,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
// Scenario path
|
||||
if (Config::Get().general.debuggingTools)
|
||||
{
|
||||
const auto shortPath = ShortenPath(scenario->Path, width - 6 - kTabWidth, FontStyle::medium);
|
||||
const auto shortPath = shortenPath(scenario->Path, width - 6 - kTabWidth, FontStyle::medium);
|
||||
|
||||
auto ft = Formatter();
|
||||
ft.Add<utf8*>(shortPath.c_str());
|
||||
|
||||
@@ -222,7 +222,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
// String length needs to add 12 either side of box
|
||||
// +13 for cursor when max length.
|
||||
u8string wrappedString;
|
||||
GfxWrapString(
|
||||
wrapString(
|
||||
u8string_view{ _buffer.data(), _buffer.size() }, kWindowSize.width - (24 + 13), FontStyle::medium,
|
||||
&wrappedString, &no_lines);
|
||||
|
||||
@@ -313,7 +313,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
// String length needs to add 12 either side of box +13 for cursor when max length.
|
||||
int32_t numLines{};
|
||||
GfxWrapString(text, kWindowSize.width - (24 + 13), FontStyle::medium, nullptr, &numLines);
|
||||
wrapString(text, kWindowSize.width - (24 + 13), FontStyle::medium, nullptr, &numLines);
|
||||
|
||||
const auto textHeight = numLines * 10;
|
||||
return kWindowSize.height + textHeight + getTitleBarDiffNormal();
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
// Text
|
||||
left = windowPos.x + ((width + 1) / 2) - 1;
|
||||
top = windowPos.y + 1;
|
||||
DrawStringCentredRaw(rt, { left, top }, _tooltipNumLines, _tooltipText.data(), FontStyle::small);
|
||||
drawStringCentredRaw(rt, { left, top }, _tooltipNumLines, _tooltipText.data(), FontStyle::small);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -145,11 +145,11 @@ namespace OpenRCT2::Ui::Windows
|
||||
formattedMessage.args.Add<const char*>(tempString.c_str());
|
||||
const u8string tooltipTextUnwrapped = FormatStringIDLegacy(formattedMessage.str, formattedMessage.args.Data());
|
||||
|
||||
auto textWidth = GfxGetStringWidthNewLined(tooltipTextUnwrapped, FontStyle::small);
|
||||
auto textWidth = getStringWidthNewlined(tooltipTextUnwrapped, FontStyle::small);
|
||||
textWidth = std::min(textWidth, 196);
|
||||
|
||||
int32_t numLines;
|
||||
textWidth = GfxWrapString(tooltipTextUnwrapped, textWidth + 1, FontStyle::small, &_tooltipText, &numLines);
|
||||
textWidth = wrapString(tooltipTextUnwrapped, textWidth + 1, FontStyle::small, &_tooltipText, &numLines);
|
||||
_tooltipNumLines = numLines;
|
||||
return textWidth;
|
||||
}
|
||||
|
||||
@@ -480,7 +480,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
// Show track file path (in debug mode)
|
||||
if (Config::Get().general.debuggingTools)
|
||||
{
|
||||
const auto shortPath = ShortenPath(path, width, FontStyle::medium);
|
||||
const auto shortPath = shortenPath(path, width, FontStyle::medium);
|
||||
auto ft = Formatter();
|
||||
ft.Add<utf8*>(shortPath.c_str());
|
||||
DrawTextBasic(
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRCT2::Drawing
|
||||
*
|
||||
* rct2: 0x006C23B1
|
||||
*/
|
||||
int32_t GfxGetStringWidthNewLined(std::string_view text, FontStyle fontStyle)
|
||||
int32_t getStringWidthNewlined(std::string_view text, FontStyle fontStyle)
|
||||
{
|
||||
u8string buffer;
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace OpenRCT2::Drawing
|
||||
* buffer (esi)
|
||||
* width (edi)
|
||||
*/
|
||||
int32_t GfxClipString(utf8* text, int32_t width, FontStyle fontStyle)
|
||||
int32_t clipString(utf8* text, int32_t width, FontStyle fontStyle)
|
||||
{
|
||||
if (width < 6)
|
||||
{
|
||||
@@ -146,8 +146,7 @@ namespace OpenRCT2::Drawing
|
||||
* num_lines (edi) - out
|
||||
* font_height (ebx) - out
|
||||
*/
|
||||
int32_t GfxWrapString(
|
||||
u8string_view text, int32_t width, FontStyle fontStyle, u8string* outWrappedText, int32_t* outNumLines)
|
||||
int32_t wrapString(u8string_view text, int32_t width, FontStyle fontStyle, u8string* outWrappedText, int32_t* outNumLines)
|
||||
{
|
||||
constexpr size_t kNullIndex = std::numeric_limits<size_t>::max();
|
||||
u8string buffer;
|
||||
@@ -247,7 +246,7 @@ namespace OpenRCT2::Drawing
|
||||
/**
|
||||
* Changes the palette so that the next character changes colour
|
||||
*/
|
||||
static void ColourCharacter(TextColour colour, bool withOutline, TextColours& textPalette)
|
||||
static void colourCharacter(TextColour colour, bool withOutline, TextColours& textPalette)
|
||||
{
|
||||
auto mapping = getTextColourMapping(colour);
|
||||
|
||||
@@ -264,7 +263,7 @@ namespace OpenRCT2::Drawing
|
||||
* Changes the palette so that the next character changes colour
|
||||
* This is specific to changing to a predefined window related colour
|
||||
*/
|
||||
static void ColourCharacterWindow(OpenRCT2::Drawing::Colour colour, bool withOutline, TextColours& textPalette)
|
||||
static void colourCharacterWindow(OpenRCT2::Drawing::Colour colour, bool withOutline, TextColours& textPalette)
|
||||
{
|
||||
TextColours mapping = {
|
||||
getColourMap(colour).colour11,
|
||||
@@ -291,7 +290,7 @@ namespace OpenRCT2::Drawing
|
||||
* text : esi
|
||||
* rt : edi
|
||||
*/
|
||||
void DrawStringCentredRaw(
|
||||
void drawStringCentredRaw(
|
||||
RenderTarget& rt, const ScreenCoordsXY& coords, int32_t numLines, const utf8* text, FontStyle fontStyle)
|
||||
{
|
||||
ScreenCoordsXY screenCoords(rt.x, rt.y);
|
||||
@@ -316,7 +315,7 @@ namespace OpenRCT2::Drawing
|
||||
}
|
||||
}
|
||||
|
||||
int32_t StringGetHeightRaw(std::string_view text, FontStyle fontStyle)
|
||||
int32_t getStringHeightRaw(std::string_view text, FontStyle fontStyle)
|
||||
{
|
||||
int32_t height = 0;
|
||||
if (fontStyle <= FontStyle::medium)
|
||||
@@ -386,7 +385,7 @@ namespace OpenRCT2::Drawing
|
||||
* width : bp
|
||||
* ticks : ebp >> 16
|
||||
*/
|
||||
void DrawNewsTicker(
|
||||
void drawNewsTicker(
|
||||
RenderTarget& rt, const ScreenCoordsXY& coords, int32_t width, OpenRCT2::Drawing::Colour colour, StringId format,
|
||||
u8string_view args, int32_t ticks)
|
||||
{
|
||||
@@ -396,7 +395,7 @@ namespace OpenRCT2::Drawing
|
||||
DrawTextBasic(rt, screenCoords, "", { colour });
|
||||
|
||||
u8string wrappedString;
|
||||
GfxWrapString(FormatStringID(format, args), width, FontStyle::small, &wrappedString, &numLines);
|
||||
wrapString(FormatStringID(format, args), width, FontStyle::small, &wrappedString, &numLines);
|
||||
lineHeight = FontGetLineHeight(FontStyle::small);
|
||||
|
||||
int32_t numCharactersDrawn = 0;
|
||||
@@ -444,7 +443,7 @@ namespace OpenRCT2::Drawing
|
||||
}
|
||||
}
|
||||
|
||||
static void TTFDrawCharacterSprite(RenderTarget& rt, int32_t codepoint, TextDrawInfo* info)
|
||||
static void drawCharacterSprite(RenderTarget& rt, int32_t codepoint, TextDrawInfo* info)
|
||||
{
|
||||
int32_t characterWidth = FontSpriteGetCodepointWidth(info->fontStyle, codepoint);
|
||||
auto sprite = FontSpriteGetCodepointSprite(info->fontStyle, codepoint);
|
||||
@@ -469,18 +468,18 @@ namespace OpenRCT2::Drawing
|
||||
info->x += characterWidth;
|
||||
}
|
||||
|
||||
static void TTFDrawStringRawSprite(RenderTarget& rt, std::string_view text, TextDrawInfo* info)
|
||||
static void drawStringRawSprite(RenderTarget& rt, std::string_view text, TextDrawInfo* info)
|
||||
{
|
||||
CodepointView codepoints(text);
|
||||
for (auto codepoint : codepoints)
|
||||
{
|
||||
TTFDrawCharacterSprite(rt, codepoint, info);
|
||||
drawCharacterSprite(rt, codepoint, info);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef DISABLE_TTF
|
||||
|
||||
static void TTFDrawStringRawTTF(RenderTarget& rt, std::string_view text, TextDrawInfo* info)
|
||||
static void drawStringRawTTF(RenderTarget& rt, std::string_view text, TextDrawInfo* info)
|
||||
{
|
||||
if (!TTFInitialise())
|
||||
return;
|
||||
@@ -488,7 +487,7 @@ namespace OpenRCT2::Drawing
|
||||
TTFFontDescriptor* fontDesc = TTFGetFontFromSpriteBase(info->fontStyle);
|
||||
if (fontDesc->font == nullptr)
|
||||
{
|
||||
TTFDrawStringRawSprite(rt, text, info);
|
||||
drawStringRawSprite(rt, text, info);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -516,7 +515,7 @@ namespace OpenRCT2::Drawing
|
||||
|
||||
#endif // DISABLE_TTF
|
||||
|
||||
static void TTFProcessFormatCode(RenderTarget& rt, const FmtString::Token& token, TextDrawInfo* info)
|
||||
static void processFormatCode(RenderTarget& rt, const FmtString::Token& token, TextDrawInfo* info)
|
||||
{
|
||||
switch (token.kind)
|
||||
{
|
||||
@@ -548,17 +547,17 @@ namespace OpenRCT2::Drawing
|
||||
break;
|
||||
case FormatToken::colourWindow1:
|
||||
{
|
||||
ColourCharacterWindow(gCurrentWindowColours[0], info->colourFlags.has(ColourFlag::withOutline), info->palette);
|
||||
colourCharacterWindow(gCurrentWindowColours[0], info->colourFlags.has(ColourFlag::withOutline), info->palette);
|
||||
break;
|
||||
}
|
||||
case FormatToken::colourWindow2:
|
||||
{
|
||||
ColourCharacterWindow(gCurrentWindowColours[1], info->colourFlags.has(ColourFlag::withOutline), info->palette);
|
||||
colourCharacterWindow(gCurrentWindowColours[1], info->colourFlags.has(ColourFlag::withOutline), info->palette);
|
||||
break;
|
||||
}
|
||||
case FormatToken::colourWindow3:
|
||||
{
|
||||
ColourCharacterWindow(gCurrentWindowColours[2], info->colourFlags.has(ColourFlag::withOutline), info->palette);
|
||||
colourCharacterWindow(gCurrentWindowColours[2], info->colourFlags.has(ColourFlag::withOutline), info->palette);
|
||||
break;
|
||||
}
|
||||
case FormatToken::inlineSprite:
|
||||
@@ -579,14 +578,14 @@ namespace OpenRCT2::Drawing
|
||||
if (FormatTokenIsColour(token.kind))
|
||||
{
|
||||
auto colourIndex = FormatTokenToTextColour(token.kind);
|
||||
ColourCharacter(colourIndex, info->colourFlags.has(ColourFlag::withOutline), info->palette);
|
||||
colourCharacter(colourIndex, info->colourFlags.has(ColourFlag::withOutline), info->palette);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef DISABLE_TTF
|
||||
static bool ShouldUseSpriteForCodepoint(char32_t codepoint)
|
||||
static bool shouldUseSpriteForCodepoint(char32_t codepoint)
|
||||
{
|
||||
switch (codepoint)
|
||||
{
|
||||
@@ -616,7 +615,7 @@ namespace OpenRCT2::Drawing
|
||||
}
|
||||
#endif // DISABLE_TTF
|
||||
|
||||
static void TTFProcessStringLiteral(RenderTarget& rt, std::string_view text, TextDrawInfo* info)
|
||||
static void processStringLiteral(RenderTarget& rt, std::string_view text, TextDrawInfo* info)
|
||||
{
|
||||
#ifndef DISABLE_TTF
|
||||
bool isTTF = info->textDrawFlags.has(TextDrawFlag::ttf);
|
||||
@@ -626,7 +625,7 @@ namespace OpenRCT2::Drawing
|
||||
|
||||
if (!isTTF)
|
||||
{
|
||||
TTFDrawStringRawSprite(rt, text, info);
|
||||
drawStringRawSprite(rt, text, info);
|
||||
}
|
||||
#ifndef DISABLE_TTF
|
||||
else
|
||||
@@ -636,7 +635,7 @@ namespace OpenRCT2::Drawing
|
||||
for (auto it = codepoints.begin(); it != codepoints.end(); it++)
|
||||
{
|
||||
auto codepoint = *it;
|
||||
if (ShouldUseSpriteForCodepoint(codepoint))
|
||||
if (shouldUseSpriteForCodepoint(codepoint))
|
||||
{
|
||||
if (ttfRunIndex.has_value())
|
||||
{
|
||||
@@ -649,7 +648,7 @@ namespace OpenRCT2::Drawing
|
||||
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
||||
#endif
|
||||
auto len = it.GetIndex() - ttfRunIndex.value();
|
||||
TTFDrawStringRawTTF(rt, text.substr(ttfRunIndex.value(), len), info);
|
||||
drawStringRawTTF(rt, text.substr(ttfRunIndex.value(), len), info);
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
@@ -657,7 +656,7 @@ namespace OpenRCT2::Drawing
|
||||
}
|
||||
|
||||
// Draw the sprite font glyph
|
||||
TTFDrawCharacterSprite(rt, codepoint, info);
|
||||
drawCharacterSprite(rt, codepoint, info);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -672,24 +671,24 @@ namespace OpenRCT2::Drawing
|
||||
{
|
||||
// Final TTF run
|
||||
auto len = text.size() - *ttfRunIndex;
|
||||
TTFDrawStringRawTTF(rt, text.substr(ttfRunIndex.value(), len), info);
|
||||
drawStringRawTTF(rt, text.substr(ttfRunIndex.value(), len), info);
|
||||
}
|
||||
}
|
||||
#endif // DISABLE_TTF
|
||||
}
|
||||
|
||||
static void TTFProcessStringCodepoint(RenderTarget& rt, codepoint_t codepoint, TextDrawInfo* info)
|
||||
static void processStringCodepoint(RenderTarget& rt, codepoint_t codepoint, TextDrawInfo* info)
|
||||
{
|
||||
char buffer[8]{};
|
||||
UTF8WriteCodepoint(buffer, codepoint);
|
||||
TTFProcessStringLiteral(rt, buffer, info);
|
||||
processStringLiteral(rt, buffer, info);
|
||||
}
|
||||
|
||||
static void TTFProcessString(RenderTarget& rt, std::string_view text, TextDrawInfo* info)
|
||||
static void processString(RenderTarget& rt, std::string_view text, TextDrawInfo* info)
|
||||
{
|
||||
if (info->textDrawFlags.has(TextDrawFlag::noFormatting))
|
||||
{
|
||||
TTFProcessStringLiteral(rt, text, info);
|
||||
processStringLiteral(rt, text, info);
|
||||
info->maxX = std::max(info->maxX, info->x);
|
||||
info->maxY = std::max(info->maxY, info->y);
|
||||
}
|
||||
@@ -700,16 +699,16 @@ namespace OpenRCT2::Drawing
|
||||
{
|
||||
if (token.IsLiteral())
|
||||
{
|
||||
TTFProcessStringLiteral(rt, token.text, info);
|
||||
processStringLiteral(rt, token.text, info);
|
||||
}
|
||||
else if (token.IsCodepoint())
|
||||
{
|
||||
auto codepoint = token.GetCodepoint();
|
||||
TTFProcessStringCodepoint(rt, codepoint, info);
|
||||
processStringCodepoint(rt, codepoint, info);
|
||||
}
|
||||
else
|
||||
{
|
||||
TTFProcessFormatCode(rt, token, info);
|
||||
processFormatCode(rt, token, info);
|
||||
}
|
||||
info->maxX = std::max(info->maxX, info->x);
|
||||
info->maxY = std::max(info->maxY, info->y);
|
||||
@@ -717,14 +716,14 @@ namespace OpenRCT2::Drawing
|
||||
}
|
||||
}
|
||||
|
||||
static void TTFProcessInitialColour(ColourWithFlags colour, TextDrawInfo* info)
|
||||
static void processInitialColour(ColourWithFlags colour, TextDrawInfo* info)
|
||||
{
|
||||
if (colour.colour != OpenRCT2::Drawing::kColourNull)
|
||||
{
|
||||
info->colourFlags = colour.flags;
|
||||
if (!colour.flags.has(ColourFlag::inset))
|
||||
{
|
||||
ColourCharacterWindow(colour.colour, info->colourFlags.has(ColourFlag::withOutline), info->palette);
|
||||
colourCharacterWindow(colour.colour, info->colourFlags.has(ColourFlag::withOutline), info->palette);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -775,8 +774,8 @@ namespace OpenRCT2::Drawing
|
||||
}
|
||||
|
||||
info.palette = gTextPalette;
|
||||
TTFProcessInitialColour(colour, &info);
|
||||
TTFProcessString(rt, text, &info);
|
||||
processInitialColour(colour, &info);
|
||||
processString(rt, text, &info);
|
||||
gTextPalette = info.palette;
|
||||
|
||||
rt.lastStringPos = { info.x, info.y };
|
||||
@@ -805,7 +804,7 @@ namespace OpenRCT2::Drawing
|
||||
}
|
||||
|
||||
RenderTarget dummy{};
|
||||
TTFProcessString(dummy, text, &info);
|
||||
processString(dummy, text, &info);
|
||||
|
||||
return info.maxX;
|
||||
}
|
||||
@@ -814,7 +813,7 @@ namespace OpenRCT2::Drawing
|
||||
*
|
||||
* rct2: 0x00682F28
|
||||
*/
|
||||
void GfxDrawStringWithYOffsets(
|
||||
void drawStringWithYOffsets(
|
||||
RenderTarget& rt, const utf8* text, ColourWithFlags colour, const ScreenCoordsXY& coords, const int8_t* yOffsets,
|
||||
bool forceSpriteFont, FontStyle fontStyle)
|
||||
{
|
||||
@@ -834,14 +833,14 @@ namespace OpenRCT2::Drawing
|
||||
}
|
||||
|
||||
info.palette = gTextPalette;
|
||||
TTFProcessInitialColour(colour, &info);
|
||||
TTFProcessString(rt, text, &info);
|
||||
processInitialColour(colour, &info);
|
||||
processString(rt, text, &info);
|
||||
gTextPalette = info.palette;
|
||||
|
||||
rt.lastStringPos = { info.x, info.y };
|
||||
}
|
||||
|
||||
u8string ShortenPath(const u8string& path, int32_t availableWidth, FontStyle fontStyle)
|
||||
u8string shortenPath(const u8string& path, int32_t availableWidth, FontStyle fontStyle)
|
||||
{
|
||||
if (getStringWidth(path, fontStyle) <= availableWidth)
|
||||
{
|
||||
|
||||
@@ -51,21 +51,20 @@ namespace OpenRCT2::Drawing
|
||||
const int8_t* yOffset{};
|
||||
};
|
||||
|
||||
void DrawStringCentredRaw(
|
||||
void drawStringCentredRaw(
|
||||
RenderTarget& rt, const ScreenCoordsXY& coords, int32_t numLines, const utf8* text, FontStyle fontStyle);
|
||||
void DrawNewsTicker(
|
||||
void drawNewsTicker(
|
||||
RenderTarget& rt, const ScreenCoordsXY& coords, int32_t width, Colour colour, StringId format, u8string_view args,
|
||||
int32_t ticks);
|
||||
void GfxDrawStringWithYOffsets(
|
||||
void drawStringWithYOffsets(
|
||||
RenderTarget& rt, const utf8* text, ColourWithFlags colour, const ScreenCoordsXY& coords, const int8_t* yOffsets,
|
||||
bool forceSpriteFont, FontStyle fontStyle);
|
||||
|
||||
int32_t GfxWrapString(
|
||||
u8string_view text, int32_t width, FontStyle fontStyle, u8string* outWrappedText, int32_t* outNumLines);
|
||||
int32_t GfxGetStringWidthNewLined(std::string_view text, FontStyle fontStyle);
|
||||
int32_t StringGetHeightRaw(std::string_view text, FontStyle fontStyle);
|
||||
int32_t GfxClipString(char* buffer, int32_t width, FontStyle fontStyle);
|
||||
u8string ShortenPath(const u8string& path, int32_t availableWidth, FontStyle fontStyle);
|
||||
int32_t wrapString(u8string_view text, int32_t width, FontStyle fontStyle, u8string* outWrappedText, int32_t* outNumLines);
|
||||
int32_t getStringWidthNewlined(std::string_view text, FontStyle fontStyle);
|
||||
int32_t getStringHeightRaw(std::string_view text, FontStyle fontStyle);
|
||||
int32_t clipString(char* buffer, int32_t width, FontStyle fontStyle);
|
||||
u8string shortenPath(const u8string& path, int32_t availableWidth, FontStyle fontStyle);
|
||||
void TTFDrawString(
|
||||
RenderTarget& rt, u8string_view text, ColourWithFlags colour, const ScreenCoordsXY& coords, bool noFormatting,
|
||||
FontStyle fontStyle, TextDarkness darkness);
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
StaticLayout(u8string_view source, const TextPaint& paint, int32_t width)
|
||||
: Paint(paint)
|
||||
{
|
||||
MaxWidth = GfxWrapString(source, width, paint.FontStyle, &Buffer, &LineCount);
|
||||
MaxWidth = wrapString(source, width, paint.FontStyle, &Buffer, &LineCount);
|
||||
LineCount += 1;
|
||||
LineHeight = FontGetLineHeight(paint.FontStyle);
|
||||
}
|
||||
@@ -146,7 +146,7 @@ void DrawTextEllipsised(
|
||||
{
|
||||
utf8 buffer[512];
|
||||
FormatStringLegacy(buffer, sizeof(buffer), format, ft.Data());
|
||||
GfxClipString(buffer, width, textPaint.FontStyle);
|
||||
clipString(buffer, width, textPaint.FontStyle);
|
||||
DrawText(rt, coords, buffer, textPaint);
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ void DrawTextEllipsised(
|
||||
{
|
||||
utf8 buffer[512]{};
|
||||
string.copy(buffer, std::min(string.length(), sizeof(buffer) - 1));
|
||||
GfxClipString(buffer, width, textPaint.FontStyle);
|
||||
clipString(buffer, width, textPaint.FontStyle);
|
||||
DrawText(rt, coords, string, textPaint);
|
||||
}
|
||||
|
||||
|
||||
@@ -294,7 +294,7 @@ static int32_t ChatHistoryDrawString(RenderTarget& rt, const char* text, const S
|
||||
{
|
||||
int32_t numLines;
|
||||
u8string wrappedString;
|
||||
GfxWrapString(FormatString("{OUTLINE}{WHITE}{STRING}", text), width, FontStyle::medium, &wrappedString, &numLines);
|
||||
wrapString(FormatString("{OUTLINE}{WHITE}{STRING}", text), width, FontStyle::medium, &wrappedString, &numLines);
|
||||
auto lineHeight = FontGetLineHeight(FontStyle::medium);
|
||||
|
||||
int32_t expectedY = screenCoords.y - (numLines * lineHeight);
|
||||
@@ -319,7 +319,7 @@ static int32_t ChatHistoryDrawString(RenderTarget& rt, const char* text, const S
|
||||
int32_t ChatStringWrappedGetHeight(u8string_view args, int32_t width)
|
||||
{
|
||||
int32_t numLines;
|
||||
GfxWrapString(FormatStringID(STR_STRING, args), width, FontStyle::medium, nullptr, &numLines);
|
||||
wrapString(FormatStringID(STR_STRING, args), width, FontStyle::medium, nullptr, &numLines);
|
||||
const int32_t lineHeight = FontGetLineHeight(FontStyle::medium);
|
||||
return lineHeight * (numLines + 1);
|
||||
}
|
||||
@@ -1099,7 +1099,7 @@ void PaintDrawMoneyStructs(RenderTarget& rt, PaintStringStruct* ps)
|
||||
forceSpriteFont = true;
|
||||
}
|
||||
|
||||
GfxDrawStringWithYOffsets(
|
||||
drawStringWithYOffsets(
|
||||
rt, buffer, { Drawing::Colour::black }, ps->ScreenPos, reinterpret_cast<int8_t*>(ps->y_offsets), forceSpriteFont,
|
||||
FontStyle::medium);
|
||||
} while ((ps = ps->NextEntry) != nullptr);
|
||||
|
||||
Reference in new issue
Block a user