diff --git a/src/openrct2-ui/interface/Graph.cpp b/src/openrct2-ui/interface/Graph.cpp index 0421fd2e8f..4dbad6c4e0 100644 --- a/src/openrct2-ui/interface/Graph.cpp +++ b/src/openrct2-ui/interface/Graph.cpp @@ -38,9 +38,9 @@ namespace OpenRCT2::Graph // Draw Y label text char buffer[64]{}; FormatStringToBuffer(buffer, sizeof(buffer), fmt, curLabel); - DrawText( - rt, { internalBounds.GetLeft() - kYTickMarkPadding, curScreenPos }, { FontStyle::small, TextAlignment::right }, - buffer); + DrawTextBasic( + rt, { internalBounds.GetLeft() - kYTickMarkPadding, curScreenPos }, buffer, + { FontStyle::small, TextAlignment::right }); // Draw Y label tick mark Rectangle::fill( rt, { { internalBounds.GetLeft() - 5, curScreenPos + 5 }, { internalBounds.GetLeft(), curScreenPos + 5 } }, @@ -102,7 +102,7 @@ namespace OpenRCT2::Graph kDashLength, PaletteIndex::pi10); GfxDrawDashedLine(rt, { { bounds.GetLeft(), coords.y }, coords }, kDashLength, PaletteIndex::pi10); - DrawText(rt, coords - ScreenCoordsXY{ 0, 16 }, { textCol, TextAlignment::centre }, text); + DrawTextBasic(rt, coords - ScreenCoordsXY{ 0, 16 }, text, { textCol, TextAlignment::centre }); Rectangle::fill(rt, { { coords - ScreenCoordsXY{ 2, 2 } }, coords + ScreenCoordsXY{ 2, 2 } }, PaletteIndex::pi10); Rectangle::fill(rt, { { coords - ScreenCoordsXY{ 1, 1 } }, { coords + ScreenCoordsXY{ 1, 1 } } }, PaletteIndex::pi21); diff --git a/src/openrct2-ui/interface/InGameConsole.cpp b/src/openrct2-ui/interface/InGameConsole.cpp index 28a24806bc..59116c9db5 100644 --- a/src/openrct2-ui/interface/InGameConsole.cpp +++ b/src/openrct2-ui/interface/InGameConsole.cpp @@ -342,19 +342,19 @@ void InGameConsole::Draw(RenderTarget& rt) const // as opposed to a desaturated grey if (textColour.colour == OpenRCT2::Drawing::Colour::black) { - DrawText(rt, screenCoords, { textColour, style }, "{BLACK}"); - DrawText(rt, screenCoords, { OpenRCT2::Drawing::kColourNull, style }, _consoleLines[index].first.c_str(), true); + DrawTextBasic(rt, screenCoords, "{BLACK}", { textColour, style }); + DrawTextNoFormatting(rt, screenCoords, _consoleLines[index].first, { kColourNull, style }); } else { - DrawText(rt, screenCoords, { textColour, style }, _consoleLines[index].first.c_str(), true); + DrawTextNoFormatting(rt, screenCoords, _consoleLines[index].first, { textColour, style }); } } else { std::string lineColour = FormatTokenToStringWithBraces(_consoleLines[index].second); - DrawText(rt, screenCoords, { textColour, style }, lineColour.c_str()); - DrawText(rt, screenCoords, { OpenRCT2::Drawing::kColourNull, style }, _consoleLines[index].first.c_str(), true); + DrawTextBasic(rt, screenCoords, lineColour, { textColour, style }); + DrawTextNoFormatting(rt, screenCoords, _consoleLines[index].first, { OpenRCT2::Drawing::kColourNull, style }); } screenCoords.y += lineHeight; @@ -365,12 +365,12 @@ void InGameConsole::Draw(RenderTarget& rt) const // Draw current line if (textColour.colour == OpenRCT2::Drawing::Colour::black) { - DrawText(rt, screenCoords, { textColour, style }, "{BLACK}"); - DrawText(rt, screenCoords, { OpenRCT2::Drawing::kColourNull, style }, _consoleCurrentLine.c_str(), true); + DrawTextBasic(rt, screenCoords, "{BLACK}", { textColour, style }); + DrawTextNoFormatting(rt, screenCoords, _consoleCurrentLine, { OpenRCT2::Drawing::kColourNull, style }); } else { - DrawText(rt, screenCoords, { textColour, style }, _consoleCurrentLine.c_str(), true); + DrawTextNoFormatting(rt, screenCoords, _consoleCurrentLine, { textColour, style }); } // Draw caret diff --git a/src/openrct2-ui/interface/Widget.cpp b/src/openrct2-ui/interface/Widget.cpp index 69d02ee3e7..3ccaed2c73 100644 --- a/src/openrct2-ui/interface/Widget.cpp +++ b/src/openrct2-ui/interface/Widget.cpp @@ -647,7 +647,7 @@ namespace OpenRCT2::Ui if (widgetIsDisabled(w, widgetIndex)) colour.flags.set(ColourFlag::inset, true); - DrawText(rt, crossMidPoint, { colour, TextAlignment::centre }, widget.string); + DrawTextBasic(rt, crossMidPoint, widget.string, { colour, TextAlignment::centre }); } /** @@ -679,9 +679,9 @@ namespace OpenRCT2::Ui // fill it when checkbox is pressed if (widgetIsPressed(w, widgetIndex)) { - DrawText( - rt, { midLeft - ScreenCoordsXY{ 0, 5 } }, { colour.withFlag(ColourFlag::translucent, false) }, - kCheckMarkString); + DrawTextBasic( + rt, { midLeft - ScreenCoordsXY{ 0, 5 } }, kCheckMarkString, + { colour.withFlag(ColourFlag::translucent, false) }); } // draw the text @@ -804,7 +804,7 @@ namespace OpenRCT2::Ui : Rectangle::BorderStyle::outset; Rectangle::fillInset(rt, { { l, t }, { l + (kScrollBarWidth - 1), b } }, colour, borderStyle); - DrawText(rt, { l + 1, t }, {}, kBlackLeftArrowString); + DrawTextBasic(rt, { l + 1, t }, kBlackLeftArrowString); } // Thumb @@ -823,7 +823,7 @@ namespace OpenRCT2::Ui : Rectangle::BorderStyle::outset; Rectangle::fillInset(rt, { { r - (kScrollBarWidth - 1), t }, { r, b } }, colour, borderStyle); - DrawText(rt, { r - 6, t }, {}, kBlackRightArrowString); + DrawTextBasic(rt, { r - 6, t }, kBlackRightArrowString); } } @@ -849,7 +849,7 @@ namespace OpenRCT2::Ui Rectangle::fillInset( rt, { { l, t }, { r, t + (kScrollBarWidth - 1) } }, colour, ((scroll.flags & VSCROLLBAR_UP_PRESSED) ? Rectangle::BorderStyle::inset : Rectangle::BorderStyle::outset)); - DrawText(rt, { l + 1, t - 1 }, {}, kBlackUpArrowString); + DrawTextBasic(rt, { l + 1, t - 1 }, kBlackUpArrowString); // Thumb Rectangle::fillInset( @@ -863,7 +863,7 @@ namespace OpenRCT2::Ui Rectangle::fillInset( rt, { { l, b - (kScrollBarWidth - 1) }, { r, b } }, colour, ((scroll.flags & VSCROLLBAR_DOWN_PRESSED) ? Rectangle::BorderStyle::inset : Rectangle::BorderStyle::outset)); - DrawText(rt, { l + 1, b - (kScrollBarWidth - 1) }, {}, kBlackDownArrowString); + DrawTextBasic(rt, { l + 1, b - (kScrollBarWidth - 1) }, kBlackDownArrowString); } /** @@ -1195,7 +1195,7 @@ namespace OpenRCT2::Ui { u8string wrappedString; GfxWrapString(widget.string, bottomRight.x - topLeft.x - 5, FontStyle::medium, &wrappedString, nullptr); - DrawText(rt, { topLeft.x + 2, topLeft.y }, { w.colours[1] }, wrappedString.c_str(), true); + DrawTextNoFormatting(rt, { topLeft.x + 2, topLeft.y }, wrappedString, { w.colours[1] }); } return; } @@ -1205,7 +1205,7 @@ namespace OpenRCT2::Ui u8string wrappedString; GfxWrapString(*textInput->Buffer, bottomRight.x - topLeft.x - 5 - 6, FontStyle::medium, &wrappedString, nullptr); - DrawText(rt, { topLeft.x + 2, topLeft.y }, { w.colours[1] }, wrappedString.c_str(), true); + DrawTextNoFormatting(rt, { topLeft.x + 2, topLeft.y }, wrappedString, { w.colours[1] }); // Make a trimmed view of the string for measuring the width. int32_t curX = topLeft.x diff --git a/src/openrct2-ui/scripting/ScGraphicsContext.hpp b/src/openrct2-ui/scripting/ScGraphicsContext.hpp index 3457fe549a..2598080656 100644 --- a/src/openrct2-ui/scripting/ScGraphicsContext.hpp +++ b/src/openrct2-ui/scripting/ScGraphicsContext.hpp @@ -239,7 +239,7 @@ namespace OpenRCT2::Scripting void text(const std::string& text, int32_t x, int32_t y) { - DrawText(_rt, { x, y }, { static_cast(_colour.value_or(0)) }, text.c_str()); + DrawTextBasic(_rt, { x, y }, text, { static_cast(_colour.value_or(0)) }); } }; } // namespace OpenRCT2::Scripting diff --git a/src/openrct2-ui/windows/Changelog.cpp b/src/openrct2-ui/windows/Changelog.cpp index 5fe275e59c..f6a8b18d89 100644 --- a/src/openrct2-ui/windows/Changelog.cpp +++ b/src/openrct2-ui/windows/Changelog.cpp @@ -187,7 +187,7 @@ namespace OpenRCT2::Ui::Windows if (screenCoords.y + lineHeight < rt.y || screenCoords.y >= rt.y + rt.height) continue; - DrawText(rt, screenCoords, { colours[0] }, line.c_str()); + DrawTextBasic(rt, screenCoords, line, { colours[0] }); } } diff --git a/src/openrct2-ui/windows/CustomCurrency.cpp b/src/openrct2-ui/windows/CustomCurrency.cpp index 7d4eca8ec6..278701b58b 100644 --- a/src/openrct2-ui/windows/CustomCurrency.cpp +++ b/src/openrct2-ui/windows/CustomCurrency.cpp @@ -210,7 +210,8 @@ namespace OpenRCT2::Ui::Windows screenCoords = windowPos + ScreenCoordsXY{ widgets[WIDX_SYMBOL_TEXT].left + 1, widgets[WIDX_SYMBOL_TEXT].top }; - DrawText(rt, screenCoords, { colours[1] }, CurrencyDescriptors[EnumValue(CurrencyType::custom)].symbol_unicode); + DrawTextBasic( + rt, screenCoords, CurrencyDescriptors[EnumValue(CurrencyType::custom)].symbol_unicode, { colours[1] }); auto drawPos = windowPos + ScreenCoordsXY{ widgets[WIDX_AFFIX_DROPDOWN].left + 1, widgets[WIDX_AFFIX_DROPDOWN].top }; diff --git a/src/openrct2-ui/windows/EditorObjectSelection.cpp b/src/openrct2-ui/windows/EditorObjectSelection.cpp index 11803c7db1..2f23399979 100644 --- a/src/openrct2-ui/windows/EditorObjectSelection.cpp +++ b/src/openrct2-ui/windows/EditorObjectSelection.cpp @@ -764,7 +764,7 @@ namespace OpenRCT2::Ui::Windows if (*listItem.flags & (ObjectSelectionFlags::InUse | ObjectSelectionFlags::AlwaysRequired)) colour2.flags.set(ColourFlag::inset, true); - DrawText(rt, screenCoords, { colour2, FontStyle::medium, darkness }, kCheckMarkString); + DrawTextBasic(rt, screenCoords, kCheckMarkString, { colour2, FontStyle::medium, darkness }); } screenCoords.x = gLegacyScene == LegacyScene::trackDesignsManager ? 0 : 15; diff --git a/src/openrct2-ui/windows/EditorScenarioOptions.cpp b/src/openrct2-ui/windows/EditorScenarioOptions.cpp index 8aeda7ea3d..13b22b3b25 100644 --- a/src/openrct2-ui/windows/EditorScenarioOptions.cpp +++ b/src/openrct2-ui/windows/EditorScenarioOptions.cpp @@ -2371,9 +2371,9 @@ namespace OpenRCT2::Ui::Windows if (currentRide->flags.has(RideFlag::indestructible)) { auto darkness = stringId == STR_WINDOW_COLOUR_2_STRINGID ? TextDarkness::extraDark : TextDarkness::dark; - DrawText( - rt, { 2, y }, { colours[1].withFlag(ColourFlag::translucent, false), FontStyle::medium, darkness }, - kCheckMarkString); + DrawTextBasic( + rt, { 2, y }, kCheckMarkString, + { colours[1].withFlag(ColourFlag::translucent, false), FontStyle::medium, darkness }); } // Ride name diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index d62b4f135d..2c8bc4b11c 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -1875,7 +1875,7 @@ namespace OpenRCT2::Ui::Windows FormatStringLegacy(buffer2, sizeof(buffer2), STR_PEEP_DEBUG_NEXT_SLOPE, ft2.Data()); String::safeConcat(buffer, buffer2, sizeof(buffer)); } - DrawText(rt, screenCoords, {}, buffer); + DrawTextBasic(rt, screenCoords, buffer); } screenCoords.y += kListRowHeight; { diff --git a/src/openrct2-ui/windows/Multiplayer.cpp b/src/openrct2-ui/windows/Multiplayer.cpp index 51ada6cd21..497cd31f65 100644 --- a/src/openrct2-ui/windows/Multiplayer.cpp +++ b/src/openrct2-ui/windows/Multiplayer.cpp @@ -292,8 +292,7 @@ namespace OpenRCT2::Ui::Windows _buffer += Network::GetPlayerName(player); } screenCoords.x = 0; - GfxClipString(_buffer.data(), 230, FontStyle::medium); - DrawText(rt, screenCoords, { colour }, _buffer.c_str()); + DrawTextEllipsised(rt, screenCoords, 230, _buffer, { colour }); // Draw group name _buffer.resize(0); @@ -303,8 +302,7 @@ namespace OpenRCT2::Ui::Windows _buffer += "{BLACK}"; screenCoords.x = 173; _buffer += Network::GetGroupName(group); - GfxClipString(_buffer.data(), 80, FontStyle::medium); - DrawText(rt, screenCoords, { colour }, _buffer.c_str()); + DrawTextEllipsised(rt, screenCoords, 80, _buffer, { colour }); } // Draw last action @@ -341,7 +339,7 @@ namespace OpenRCT2::Ui::Windows _buffer += pingBuffer; screenCoords.x = 356; - DrawText(rt, screenCoords, { colour }, _buffer.c_str()); + DrawTextBasic(rt, screenCoords, _buffer, { colour }); } screenCoords.y += kScrollableRowHeight; listPosition++; @@ -421,7 +419,7 @@ namespace OpenRCT2::Ui::Windows if (Network::CanPerformAction(groupindex, static_cast(i))) { screenCoords.x = 0; - DrawText(rt, screenCoords, {}, u8"{WINDOW_COLOUR_2}✓"); + DrawTextBasic(rt, screenCoords, u8"{WINDOW_COLOUR_2}✓"); } } diff --git a/src/openrct2-ui/windows/NetworkStatus.cpp b/src/openrct2-ui/windows/NetworkStatus.cpp index 848c11394d..a54288b1b5 100644 --- a/src/openrct2-ui/windows/NetworkStatus.cpp +++ b/src/openrct2-ui/windows/NetworkStatus.cpp @@ -97,7 +97,7 @@ namespace OpenRCT2::Ui::Windows ScreenCoordsXY screenCoords(windowPos.x + (width / 2), windowPos.y + (height / 2)); screenCoords.x -= GfxGetStringWidth(_buffer, FontStyle::medium) / 2; - DrawText(rt, screenCoords, { Drawing::Colour::black }, _buffer.c_str()); + DrawTextBasic(rt, screenCoords, _buffer, { Drawing::Colour::black }); } void setCloseCallBack(CloseCallback callback) diff --git a/src/openrct2-ui/windows/ObjectLoadError.cpp b/src/openrct2-ui/windows/ObjectLoadError.cpp index 7d0f9c437c..cf4c1ee135 100644 --- a/src/openrct2-ui/windows/ObjectLoadError.cpp +++ b/src/openrct2-ui/windows/ObjectLoadError.cpp @@ -544,10 +544,7 @@ namespace OpenRCT2::Ui::Windows const auto& entry = _invalidEntries[i]; - auto name = entry.GetName(); - char buffer[256]; - String::set(buffer, sizeof(buffer), name.data(), name.size()); - DrawText(rt, screenCoords, { Drawing::Colour::darkGreen }, buffer); + DrawTextBasic(rt, screenCoords, entry.GetName(), { Colour::darkGreen }); if (entry.Generation == ObjectGeneration::DAT) { diff --git a/src/openrct2-ui/windows/Player.cpp b/src/openrct2-ui/windows/Player.cpp index f21c1df955..ec632f61a1 100644 --- a/src/openrct2-ui/windows/Player.cpp +++ b/src/openrct2-ui/windows/Player.cpp @@ -451,7 +451,7 @@ namespace OpenRCT2::Ui::Windows DrawTextBasic(rt, screenCoords, STR_WINDOW_COLOUR_2_STRINGID, ft); char ping[64]; snprintf(ping, 64, "%d ms", Network::GetPlayerPing(player)); - DrawText(rt, screenCoords + ScreenCoordsXY(30, 0), { colours[2] }, ping); + DrawTextBasic(rt, screenCoords + ScreenCoordsXY(30, 0), ping, { colours[2] }); // Draw last action screenCoords = windowPos + ScreenCoordsXY{ width / 2, height - 13 }; diff --git a/src/openrct2-ui/windows/ServerList.cpp b/src/openrct2-ui/windows/ServerList.cpp index 7943b5ad5a..6d751fc15d 100644 --- a/src/openrct2-ui/windows/ServerList.cpp +++ b/src/openrct2-ui/windows/ServerList.cpp @@ -418,7 +418,7 @@ namespace OpenRCT2::Ui::Windows // Draw number of players screenCoords.x = right - numPlayersStringWidth; - DrawText(rt, screenCoords + ScreenCoordsXY{ 0, 3 }, { colours[1] }, players); + DrawTextBasic(rt, screenCoords + ScreenCoordsXY{ 0, 3 }, players, { colours[1] }); screenCoords.y += kItemHeight; } diff --git a/src/openrct2-ui/windows/TextInput.cpp b/src/openrct2-ui/windows/TextInput.cpp index ed432e08da..3f28bdd38a 100644 --- a/src/openrct2-ui/windows/TextInput.cpp +++ b/src/openrct2-ui/windows/TextInput.cpp @@ -244,7 +244,7 @@ namespace OpenRCT2::Ui::Windows for (int32_t line = 0; line <= no_lines; line++) { screenCoords.x = windowPos.x + 12; - DrawText(rt, screenCoords, { colours[1], FontStyle::medium, TextAlignment::left }, wrapPointer, true); + DrawTextNoFormatting(rt, screenCoords, wrapPointer, { colours[1], FontStyle::medium, TextAlignment::left }); size_t string_length = GetStringSize(wrapPointer) - 1; if (!cur_drawn && (textInput->SelectionStart <= char_count + string_length)) diff --git a/src/openrct2-ui/windows/Themes.cpp b/src/openrct2-ui/windows/Themes.cpp index 641e7600fd..e8aa9c6488 100644 --- a/src/openrct2-ui/windows/Themes.cpp +++ b/src/openrct2-ui/windows/Themes.cpp @@ -802,8 +802,8 @@ namespace OpenRCT2::Ui::Windows Rectangle::FillBrightness::dark, Rectangle::FillMode::dontLightenWhenInset); if (colour.flags.has(ColourFlag::translucent)) { - DrawText( - rt, topLeft, { colours[1].colour, FontStyle::medium, TextDarkness::dark }, kCheckMarkString); + DrawTextBasic( + rt, topLeft, kCheckMarkString, { colours[1].colour, FontStyle::medium, TextDarkness::dark }); } } } diff --git a/src/openrct2-ui/windows/TileInspector.cpp b/src/openrct2-ui/windows/TileInspector.cpp index 0405c71eec..b51ad10eaa 100644 --- a/src/openrct2-ui/windows/TileInspector.cpp +++ b/src/openrct2-ui/windows/TileInspector.cpp @@ -1070,8 +1070,8 @@ static uint64_t PageDisabledWidgets[] = { } else { - DrawText(rt, screenCoords + ScreenCoordsXY(43 - 7, yOffset), { colours[1] }, "-"); - DrawText(rt, screenCoords + ScreenCoordsXY(113 - 7, yOffset), { colours[1] }, "-"); + DrawTextBasic(rt, screenCoords + ScreenCoordsXY(43 - 7, yOffset), "-", { colours[1] }); + DrawTextBasic(rt, screenCoords + ScreenCoordsXY(113 - 7, yOffset), "-", { colours[1] }); } if (windowTileInspectorSelectedIndex != -1) diff --git a/src/openrct2-ui/windows/TitleVersion.cpp b/src/openrct2-ui/windows/TitleVersion.cpp index feafa0b9f1..5090fec6b6 100644 --- a/src/openrct2-ui/windows/TitleVersion.cpp +++ b/src/openrct2-ui/windows/TitleVersion.cpp @@ -27,12 +27,12 @@ namespace OpenRCT2::Ui::Windows { // Write name and version information const auto whiteOutline = ColourWithFlags{ Drawing::Colour::white }.withFlag(ColourFlag::withOutline, true); - DrawText(rt, windowPos, { whiteOutline }, gVersionInfoFull); + DrawTextBasic(rt, windowPos, gVersionInfoFull, { whiteOutline }); width = GfxGetStringWidth(gVersionInfoFull, FontStyle::medium); // Write platform information constexpr const char platformInfo[] = OPENRCT2_PLATFORM " (" OPENRCT2_ARCHITECTURE ")"; - DrawText(rt, windowPos + ScreenCoordsXY(0, kListRowHeight), { whiteOutline }, platformInfo); + DrawTextBasic(rt, windowPos + ScreenCoordsXY(0, kListRowHeight), platformInfo, { whiteOutline }); width = std::max(width, GfxGetStringWidth(platformInfo, FontStyle::medium)) + kTextOffset; } }; diff --git a/src/openrct2/drawing/Drawing.String.cpp b/src/openrct2/drawing/Drawing.String.cpp index b90db17946..db2ef3c35a 100644 --- a/src/openrct2/drawing/Drawing.String.cpp +++ b/src/openrct2/drawing/Drawing.String.cpp @@ -271,7 +271,7 @@ void GfxDrawStringLeftCentred( auto bufferPtr = buffer; FormatStringLegacy(bufferPtr, sizeof(buffer), format, args); int32_t height = StringGetHeightRaw(bufferPtr, FontStyle::medium); - DrawText(rt, coords - ScreenCoordsXY{ 0, (height / 2) }, { colour }, bufferPtr); + DrawTextBasic(rt, coords - ScreenCoordsXY{ 0, (height / 2) }, bufferPtr, { colour }); } /** @@ -325,13 +325,13 @@ void DrawStringCentredRaw( RenderTarget& rt, const ScreenCoordsXY& coords, int32_t numLines, const utf8* text, FontStyle fontStyle) { ScreenCoordsXY screenCoords(rt.x, rt.y); - DrawText(rt, screenCoords, { OpenRCT2::Drawing::Colour::black, fontStyle }, ""); + DrawTextBasic(rt, screenCoords, "", { Colour::black, fontStyle }); screenCoords = coords; for (int32_t i = 0; i <= numLines; i++) { int32_t width = GfxGetStringWidth(text, fontStyle); - DrawText(rt, screenCoords - ScreenCoordsXY{ width / 2, 0 }, { OpenRCT2::Drawing::kColourNull, fontStyle }, text); + DrawTextBasic(rt, screenCoords - ScreenCoordsXY{ width / 2, 0 }, text, { kColourNull, fontStyle }); const utf8* ch = text; const utf8* nextCh = nullptr; @@ -423,7 +423,7 @@ void DrawNewsTicker( int32_t numLines, lineHeight, lineY; ScreenCoordsXY screenCoords(rt.x, rt.y); - DrawText(rt, screenCoords, { colour }, ""); + DrawTextBasic(rt, screenCoords, "", { colour }); u8string wrappedString; GfxWrapString(FormatStringID(format, args), width, FontStyle::small, &wrappedString, &numLines); @@ -462,7 +462,8 @@ void DrawNewsTicker( } screenCoords = { coords.x - halfWidth, lineY }; - DrawText(rt, screenCoords, { OpenRCT2::Drawing::kColourNull, FontStyle::small }, buffer); + DrawTextBasic(rt, screenCoords, buffer, kColourNull, FontStyle::small + }); if (numCharactersDrawn > numCharactersToDraw) { diff --git a/src/openrct2/drawing/Drawing.cpp b/src/openrct2/drawing/Drawing.cpp index 7aa91d1445..22d57dd266 100644 --- a/src/openrct2/drawing/Drawing.cpp +++ b/src/openrct2/drawing/Drawing.cpp @@ -935,8 +935,8 @@ void DebugRT(RenderTarget& rt) GfxDrawLine(rt, { topLeft, topLeft + ScreenCoordsXY{ 4, 0 } }, PaletteIndex::pi136); const auto str = std::to_string(rt.x); - DrawText(rt, ScreenCoordsXY{ rt.x, rt.y }, { Colour::white, FontStyle::tiny }, str.c_str()); + DrawTextBasic(rt, ScreenCoordsXY{ rt.x, rt.y }, str, { Colour::white, FontStyle::tiny }); const auto str2 = std::to_string(rt.y); - DrawText(rt, ScreenCoordsXY{ rt.x, rt.y + 6 }, { Colour::white, FontStyle::tiny }, str2.c_str()); + DrawTextBasic(rt, ScreenCoordsXY{ rt.x, rt.y + 6 }, str2, { Colour::white, FontStyle::tiny }); } diff --git a/src/openrct2/drawing/Text.cpp b/src/openrct2/drawing/Text.cpp index e35634e9f4..2e68fa050a 100644 --- a/src/openrct2/drawing/Text.cpp +++ b/src/openrct2/drawing/Text.cpp @@ -56,7 +56,7 @@ public: const utf8* buffer = Buffer.data(); for (int32_t line = 0; line < LineCount; ++line) { - DrawText(rt, lineCoords, tempPaint, buffer); + DrawTextBasic(rt, lineCoords, buffer, tempPaint); tempPaint.Colour = OpenRCT2::Drawing::kColourNull; buffer = GetStringEnd(buffer) + 1; lineCoords.y += LineHeight; @@ -79,7 +79,8 @@ public: } }; -void DrawText(RenderTarget& rt, const ScreenCoordsXY& coords, const TextPaint& paint, u8string_view text, bool noFormatting) +static void DrawText( + RenderTarget& rt, const ScreenCoordsXY& coords, const TextPaint& paint, u8string_view text, bool noFormatting = false) { int32_t width = noFormatting ? GfxGetStringWidthNoFormatting(text, paint.FontStyle) : GfxGetStringWidth(text, paint.FontStyle); @@ -113,6 +114,11 @@ void DrawText(RenderTarget& rt, const ScreenCoordsXY& coords, const TextPaint& p } } +void DrawTextNoFormatting(RenderTarget& rt, const ScreenCoordsXY& coords, u8string_view string, TextPaint textPaint) +{ + DrawText(rt, coords, textPaint, string, true); +} + void DrawTextBasic(RenderTarget& rt, const ScreenCoordsXY& coords, StringId format, TextPaint textPaint) { DrawTextBasic(rt, coords, LanguageGetString(format), textPaint); diff --git a/src/openrct2/drawing/Text.h b/src/openrct2/drawing/Text.h index 24f5dceeba..10f4dd160b 100644 --- a/src/openrct2/drawing/Text.h +++ b/src/openrct2/drawing/Text.h @@ -210,6 +210,8 @@ struct TextPaint } }; +void DrawTextNoFormatting(OpenRCT2::Drawing::RenderTarget& rt, const ScreenCoordsXY& coords, u8string_view string, TextPaint textPaint = {}); + void DrawTextBasic( OpenRCT2::Drawing::RenderTarget& rt, const ScreenCoordsXY& coords, StringId format, TextPaint textPaint = {}); void DrawTextBasic( diff --git a/src/openrct2/interface/Chat.cpp b/src/openrct2/interface/Chat.cpp index 3a051c366e..f1338108dd 100644 --- a/src/openrct2/interface/Chat.cpp +++ b/src/openrct2/interface/Chat.cpp @@ -306,7 +306,7 @@ static int32_t ChatHistoryDrawString(RenderTarget& rt, const char* text, const S int32_t lineY = screenCoords.y; for (int32_t line = 0; line <= numLines; ++line) { - DrawText(rt, { screenCoords.x, lineY - (numLines * lineHeight) }, { OpenRCT2::Drawing::kColourNull }, bufferPtr); + DrawTextBasic(rt, { screenCoords.x, lineY - (numLines * lineHeight) }, bufferPtr, { OpenRCT2::Drawing::kColourNull }); bufferPtr = GetStringEnd(bufferPtr) + 1; lineY += lineHeight; } diff --git a/src/openrct2/paint/Painter.cpp b/src/openrct2/paint/Painter.cpp index 15b1e935c1..b2ee660c53 100644 --- a/src/openrct2/paint/Painter.cpp +++ b/src/openrct2/paint/Painter.cpp @@ -95,7 +95,7 @@ void Painter::PaintReplayNotice(RenderTarget& rt, const char* text) screenCoords.x = screenCoords.x - stringWidth; if (((getGameState().currentTicks >> 1) & 0xF) > 4) - DrawText(rt, screenCoords, { OpenRCT2::Drawing::Colour::saturatedRed }, buffer); + DrawTextBasic(rt, screenCoords, buffer, { OpenRCT2::Drawing::Colour::saturatedRed }); // Make area dirty so the text doesn't get drawn over the last GfxSetDirtyBlocks({ screenCoords, screenCoords + ScreenCoordsXY{ stringWidth, 16 } }); @@ -132,7 +132,7 @@ void Painter::PaintFPS(RenderTarget& rt) screenCoords.y = kTopToolbarHeight + 3; } - DrawText(rt, screenCoords, { OpenRCT2::Drawing::Colour::white }, buffer); + DrawTextBasic(rt, screenCoords, buffer, { OpenRCT2::Drawing::Colour::white }); // Make area dirty so the text doesn't get drawn over the last GfxSetDirtyBlocks({ { screenCoords - ScreenCoordsXY{ 16, 4 } }, { rt.lastStringPos.x + 16, screenCoords.y + 16 } });