From 5620437c998fcb40e0077ee868ff46797e9c48b9 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sun, 22 Mar 2026 15:07:04 +0100 Subject: [PATCH] Rename functions in Drawing.String.h to adhere to code style rules --- src/openrct2-ui/interface/Widget.cpp | 4 +- .../scripting/ScGraphicsContext.hpp | 2 +- src/openrct2-ui/windows/Error.cpp | 6 +- src/openrct2-ui/windows/GameBottomToolbar.cpp | 2 +- src/openrct2-ui/windows/LoadSave.cpp | 2 +- src/openrct2-ui/windows/Multiplayer.cpp | 4 +- src/openrct2-ui/windows/NetworkStatus.cpp | 2 +- src/openrct2-ui/windows/ScenarioSelect.cpp | 2 +- src/openrct2-ui/windows/TextInput.cpp | 4 +- src/openrct2-ui/windows/Tooltip.cpp | 6 +- src/openrct2-ui/windows/TrackList.cpp | 2 +- src/openrct2/drawing/Drawing.String.cpp | 85 +++++++++---------- src/openrct2/drawing/Drawing.String.h | 17 ++-- src/openrct2/drawing/Text.cpp | 6 +- src/openrct2/interface/Chat.cpp | 4 +- src/openrct2/paint/Paint.cpp | 2 +- 16 files changed, 74 insertions(+), 76 deletions(-) diff --git a/src/openrct2-ui/interface/Widget.cpp b/src/openrct2-ui/interface/Widget.cpp index 8d4dbf025b..7b42ee80ef 100644 --- a/src/openrct2-ui/interface/Widget.cpp +++ b/src/openrct2-ui/interface/Widget.cpp @@ -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] }); diff --git a/src/openrct2-ui/scripting/ScGraphicsContext.hpp b/src/openrct2-ui/scripting/ScGraphicsContext.hpp index 330997782d..02e454884f 100644 --- a/src/openrct2-ui/scripting/ScGraphicsContext.hpp +++ b/src/openrct2-ui/scripting/ScGraphicsContext.hpp @@ -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(_ctx, { width, height }); } diff --git a/src/openrct2-ui/windows/Error.cpp b/src/openrct2-ui/windows/Error.cpp index 6df2c89d20..ccceeec7f4 100644 --- a/src/openrct2-ui/windows/Error.cpp +++ b/src/openrct2-ui/windows/Error.cpp @@ -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 diff --git a/src/openrct2-ui/windows/GameBottomToolbar.cpp b/src/openrct2-ui/windows/GameBottomToolbar.cpp index cc8674232a..85b0b3a667 100644 --- a/src/openrct2-ui/windows/GameBottomToolbar.cpp +++ b/src/openrct2-ui/windows/GameBottomToolbar.cpp @@ -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); diff --git a/src/openrct2-ui/windows/LoadSave.cpp b/src/openrct2-ui/windows/LoadSave.cpp index d165ab95d1..c20c5dd70a 100644 --- a/src/openrct2-ui/windows/LoadSave.cpp +++ b/src/openrct2-ui/windows/LoadSave.cpp @@ -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; diff --git a/src/openrct2-ui/windows/Multiplayer.cpp b/src/openrct2-ui/windows/Multiplayer.cpp index bc9c1e125f..edaf16da9b 100644 --- a/src/openrct2-ui/windows/Multiplayer.cpp +++ b/src/openrct2-ui/windows/Multiplayer.cpp @@ -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); } diff --git a/src/openrct2-ui/windows/NetworkStatus.cpp b/src/openrct2-ui/windows/NetworkStatus.cpp index b602464b8b..c6947c0944 100644 --- a/src/openrct2-ui/windows/NetworkStatus.cpp +++ b/src/openrct2-ui/windows/NetworkStatus.cpp @@ -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; diff --git a/src/openrct2-ui/windows/ScenarioSelect.cpp b/src/openrct2-ui/windows/ScenarioSelect.cpp index 9a29dc7337..4d5d2dd16b 100644 --- a/src/openrct2-ui/windows/ScenarioSelect.cpp +++ b/src/openrct2-ui/windows/ScenarioSelect.cpp @@ -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(shortPath.c_str()); diff --git a/src/openrct2-ui/windows/TextInput.cpp b/src/openrct2-ui/windows/TextInput.cpp index b765f3e5c3..86f078e748 100644 --- a/src/openrct2-ui/windows/TextInput.cpp +++ b/src/openrct2-ui/windows/TextInput.cpp @@ -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(); diff --git a/src/openrct2-ui/windows/Tooltip.cpp b/src/openrct2-ui/windows/Tooltip.cpp index d4efd4d552..4a028b110d 100644 --- a/src/openrct2-ui/windows/Tooltip.cpp +++ b/src/openrct2-ui/windows/Tooltip.cpp @@ -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(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; } diff --git a/src/openrct2-ui/windows/TrackList.cpp b/src/openrct2-ui/windows/TrackList.cpp index f3b39032ea..e8245e85d8 100644 --- a/src/openrct2-ui/windows/TrackList.cpp +++ b/src/openrct2-ui/windows/TrackList.cpp @@ -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(shortPath.c_str()); DrawTextBasic( diff --git a/src/openrct2/drawing/Drawing.String.cpp b/src/openrct2/drawing/Drawing.String.cpp index eb4760c174..4d5395b5e9 100644 --- a/src/openrct2/drawing/Drawing.String.cpp +++ b/src/openrct2/drawing/Drawing.String.cpp @@ -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::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) { diff --git a/src/openrct2/drawing/Drawing.String.h b/src/openrct2/drawing/Drawing.String.h index b06cf6172b..f2b4f4fd66 100644 --- a/src/openrct2/drawing/Drawing.String.h +++ b/src/openrct2/drawing/Drawing.String.h @@ -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); diff --git a/src/openrct2/drawing/Text.cpp b/src/openrct2/drawing/Text.cpp index fbb86c156f..284369e82f 100644 --- a/src/openrct2/drawing/Text.cpp +++ b/src/openrct2/drawing/Text.cpp @@ -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); } diff --git a/src/openrct2/interface/Chat.cpp b/src/openrct2/interface/Chat.cpp index ff3f36805b..fa79e7f733 100644 --- a/src/openrct2/interface/Chat.cpp +++ b/src/openrct2/interface/Chat.cpp @@ -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); } diff --git a/src/openrct2/paint/Paint.cpp b/src/openrct2/paint/Paint.cpp index 685712a32b..14790feae7 100644 --- a/src/openrct2/paint/Paint.cpp +++ b/src/openrct2/paint/Paint.cpp @@ -1099,7 +1099,7 @@ void PaintDrawMoneyStructs(RenderTarget& rt, PaintStringStruct* ps) forceSpriteFont = true; } - GfxDrawStringWithYOffsets( + drawStringWithYOffsets( rt, buffer, { Drawing::Colour::black }, ps->ScreenPos, reinterpret_cast(ps->y_offsets), forceSpriteFont, FontStyle::medium); } while ((ps = ps->NextEntry) != nullptr);