Replace GfxDrawString() with DrawText()

This commit is contained in:
Harry-Hopkinson 2024-05-09 15:40:51 +00:00
parent d58673105d
commit dab714d4a6
21 changed files with 44 additions and 66 deletions

View File

@ -323,7 +323,7 @@ void InGameConsole::Draw(DrawPixelInfo& dpi) const
{ {
const size_t index = i + _consoleScrollPos; const size_t index = i + _consoleScrollPos;
lineBuffer = _colourFormatStr + _consoleLines[index]; lineBuffer = _colourFormatStr + _consoleLines[index];
GfxDrawString(dpi, screenCoords, lineBuffer.c_str(), { textColour, InGameConsoleGetFontStyle() }); DrawText(dpi, screenCoords, { textColour, InGameConsoleGetFontStyle() }, lineBuffer.c_str());
screenCoords.y += lineHeight; screenCoords.y += lineHeight;
} }

View File

@ -15,7 +15,6 @@
#include <openrct2/Context.h> #include <openrct2/Context.h>
#include <openrct2/Input.h> #include <openrct2/Input.h>
#include <openrct2/config/Config.h> #include <openrct2/config/Config.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/localisation/Formatter.h> #include <openrct2/localisation/Formatter.h>
#include <openrct2/localisation/Formatting.h> #include <openrct2/localisation/Formatting.h>
#include <openrct2/localisation/Localisation.h> #include <openrct2/localisation/Localisation.h>
@ -643,9 +642,9 @@ static void WidgetCheckboxDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex wi
// fill it when checkbox is pressed // fill it when checkbox is pressed
if (WidgetIsPressed(w, widgetIndex)) if (WidgetIsPressed(w, widgetIndex))
{ {
GfxDrawString( DrawText(
dpi, { midLeft - ScreenCoordsXY{ 0, 5 } }, static_cast<const char*>(CheckBoxMarkString), dpi, { midLeft - ScreenCoordsXY{ 0, 5 } }, { static_cast<colour_t>(NOT_TRANSLUCENT(colour)) },
{ static_cast<colour_t>(NOT_TRANSLUCENT(colour)) }); static_cast<const char*>(CheckBoxMarkString));
} }
// draw the text // draw the text
@ -745,7 +744,7 @@ static void WidgetHScrollbarDraw(
uint8_t flags = (scroll.flags & HSCROLLBAR_LEFT_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0; uint8_t flags = (scroll.flags & HSCROLLBAR_LEFT_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0;
GfxFillRectInset(dpi, { { l, t }, { l + (kScrollBarWidth - 1), b } }, colour, flags); GfxFillRectInset(dpi, { { l, t }, { l + (kScrollBarWidth - 1), b } }, colour, flags);
GfxDrawString(dpi, { l + 1, t }, static_cast<const char*>(BlackLeftArrowString), {}); DrawText(dpi, { l + 1, t }, {}, static_cast<const char*>(BlackLeftArrowString));
} }
// Thumb // Thumb
@ -762,7 +761,7 @@ static void WidgetHScrollbarDraw(
uint8_t flags = (scroll.flags & HSCROLLBAR_RIGHT_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0; uint8_t flags = (scroll.flags & HSCROLLBAR_RIGHT_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0;
GfxFillRectInset(dpi, { { r - (kScrollBarWidth - 1), t }, { r, b } }, colour, flags); GfxFillRectInset(dpi, { { r - (kScrollBarWidth - 1), t }, { r, b } }, colour, flags);
GfxDrawString(dpi, { r - 6, t }, static_cast<const char*>(BlackRightArrowString), {}); DrawText(dpi, { r - 6, t }, {}, static_cast<const char*>(BlackRightArrowString));
} }
} }
@ -782,7 +781,7 @@ static void WidgetVScrollbarDraw(
GfxFillRectInset( GfxFillRectInset(
dpi, { { l, t }, { r, t + (kScrollBarWidth - 1) } }, colour, dpi, { { l, t }, { r, t + (kScrollBarWidth - 1) } }, colour,
((scroll.flags & VSCROLLBAR_UP_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0)); ((scroll.flags & VSCROLLBAR_UP_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0));
GfxDrawString(dpi, { l + 1, t - 1 }, static_cast<const char*>(BlackUpArrowString), {}); DrawText(dpi, { l + 1, t - 1 }, {}, static_cast<const char*>(BlackUpArrowString));
// Thumb // Thumb
GfxFillRectInset( GfxFillRectInset(
@ -795,7 +794,7 @@ static void WidgetVScrollbarDraw(
GfxFillRectInset( GfxFillRectInset(
dpi, { { l, b - (kScrollBarWidth - 1) }, { r, b } }, colour, dpi, { { l, b - (kScrollBarWidth - 1) }, { r, b } }, colour,
((scroll.flags & VSCROLLBAR_DOWN_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0)); ((scroll.flags & VSCROLLBAR_DOWN_PRESSED) ? INSET_RECT_FLAG_BORDER_INSET : 0));
GfxDrawString(dpi, { l + 1, b - (kScrollBarWidth - 1) }, static_cast<const char*>(BlackDownArrowString), {}); DrawText(dpi, { l + 1, b - (kScrollBarWidth - 1) }, {}, static_cast<const char*>(BlackDownArrowString));
} }
/** /**

View File

@ -13,7 +13,6 @@
# include "CustomImages.h" # include "CustomImages.h"
# include <openrct2/drawing/Drawing.h>
# include <openrct2/scripting/Duktape.hpp> # include <openrct2/scripting/Duktape.hpp>
namespace OpenRCT2::Scripting namespace OpenRCT2::Scripting
@ -235,7 +234,7 @@ namespace OpenRCT2::Scripting
void text(const std::string& text, int32_t x, int32_t y) void text(const std::string& text, int32_t x, int32_t y)
{ {
GfxDrawString(_dpi, { x, y }, text.c_str(), { _colour.value_or(0) }); DrawText(_dpi, { x, y }, { _colour.value_or(0) }, text.c_str());
} }
}; };
} // namespace OpenRCT2::Scripting } // namespace OpenRCT2::Scripting

View File

@ -16,7 +16,6 @@
#include <openrct2/Version.h> #include <openrct2/Version.h>
#include <openrct2/core/FileSystem.hpp> #include <openrct2/core/FileSystem.hpp>
#include <openrct2/core/String.hpp> #include <openrct2/core/String.hpp>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/localisation/Formatting.h> #include <openrct2/localisation/Formatting.h>
#include <openrct2/localisation/Localisation.h> #include <openrct2/localisation/Localisation.h>
#include <openrct2/platform/Platform.h> #include <openrct2/platform/Platform.h>
@ -202,7 +201,7 @@ static Widget _windowChangelogWidgets[] = {
if (screenCoords.y + lineHeight < dpi.y || screenCoords.y >= dpi.y + dpi.height) if (screenCoords.y + lineHeight < dpi.y || screenCoords.y >= dpi.y + dpi.height)
continue; continue;
GfxDrawString(dpi, screenCoords, line.c_str(), { colours[0] }); DrawText(dpi, screenCoords, { colours[0] }, line.c_str());
} }
} }

View File

@ -12,7 +12,6 @@
#include <openrct2-ui/windows/Window.h> #include <openrct2-ui/windows/Window.h>
#include <openrct2/config/Config.h> #include <openrct2/config/Config.h>
#include <openrct2/core/String.hpp> #include <openrct2/core/String.hpp>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/interface/Colour.h> #include <openrct2/interface/Colour.h>
#include <openrct2/localisation/Currency.h> #include <openrct2/localisation/Currency.h>
#include <openrct2/localisation/Formatter.h> #include <openrct2/localisation/Formatter.h>
@ -211,8 +210,7 @@ static Widget window_custom_currency_widgets[] = {
+ ScreenCoordsXY{ window_custom_currency_widgets[WIDX_SYMBOL_TEXT].left + 1, + ScreenCoordsXY{ window_custom_currency_widgets[WIDX_SYMBOL_TEXT].left + 1,
window_custom_currency_widgets[WIDX_SYMBOL_TEXT].top }; window_custom_currency_widgets[WIDX_SYMBOL_TEXT].top };
GfxDrawString( DrawText(dpi, screenCoords, { colours[1] }, CurrencyDescriptors[EnumValue(CurrencyType::Custom)].symbol_unicode);
dpi, screenCoords, CurrencyDescriptors[EnumValue(CurrencyType::Custom)].symbol_unicode, { colours[1] });
auto drawPos = windowPos auto drawPos = windowPos
+ ScreenCoordsXY{ window_custom_currency_widgets[WIDX_AFFIX_DROPDOWN].left + 1, + ScreenCoordsXY{ window_custom_currency_widgets[WIDX_AFFIX_DROPDOWN].left + 1,

View File

@ -22,7 +22,6 @@
#include <openrct2/config/Config.h> #include <openrct2/config/Config.h>
#include <openrct2/core/Path.hpp> #include <openrct2/core/Path.hpp>
#include <openrct2/core/String.hpp> #include <openrct2/core/String.hpp>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/localisation/Formatter.h> #include <openrct2/localisation/Formatter.h>
#include <openrct2/localisation/Localisation.h> #include <openrct2/localisation/Localisation.h>
#include <openrct2/object/MusicObject.h> #include <openrct2/object/MusicObject.h>
@ -754,9 +753,9 @@ static std::vector<Widget> _window_editor_object_selection_widgets = {
if (*listItem.flags & (ObjectSelectionFlags::InUse | ObjectSelectionFlags::AlwaysRequired)) if (*listItem.flags & (ObjectSelectionFlags::InUse | ObjectSelectionFlags::AlwaysRequired))
colour2 |= COLOUR_FLAG_INSET; colour2 |= COLOUR_FLAG_INSET;
GfxDrawString( DrawText(
dpi, screenCoords, static_cast<const char*>(CheckBoxMarkString), dpi, screenCoords, { static_cast<colour_t>(colour2), FontStyle::Medium, darkness },
{ static_cast<colour_t>(colour2), FontStyle::Medium, darkness }); static_cast<const char*>(CheckBoxMarkString));
} }
screenCoords.x = gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER ? 0 : 15; screenCoords.x = gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER ? 0 : 15;

View File

@ -16,7 +16,6 @@
#include <openrct2/GameState.h> #include <openrct2/GameState.h>
#include <openrct2/OpenRCT2.h> #include <openrct2/OpenRCT2.h>
#include <openrct2/actions/ParkSetNameAction.h> #include <openrct2/actions/ParkSetNameAction.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/drawing/Font.h> #include <openrct2/drawing/Font.h>
#include <openrct2/interface/Colour.h> #include <openrct2/interface/Colour.h>
#include <openrct2/localisation/Date.h> #include <openrct2/localisation/Date.h>
@ -1170,9 +1169,9 @@ static uint64_t window_editor_objective_options_page_hold_down_widgets[] = {
if (currentRide->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE) if (currentRide->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE)
{ {
auto darkness = stringId == STR_WINDOW_COLOUR_2_STRINGID ? TextDarkness::ExtraDark : TextDarkness::Dark; auto darkness = stringId == STR_WINDOW_COLOUR_2_STRINGID ? TextDarkness::ExtraDark : TextDarkness::Dark;
GfxDrawString( DrawText(
dpi, { 2, y }, static_cast<const char*>(CheckBoxMarkString), dpi, { 2, y }, { static_cast<colour_t>(colours[1] & 0x7F), FontStyle::Medium, darkness },
{ static_cast<colour_t>(colours[1] & 0x7F), FontStyle::Medium, darkness }); static_cast<const char*>(CheckBoxMarkString));
} }
// Ride name // Ride name

View File

@ -1865,7 +1865,7 @@ static_assert(_guestWindowPageWidgets.size() == WINDOW_GUEST_PAGE_COUNT);
OpenRCT2::FormatStringLegacy(buffer2, sizeof(buffer2), STR_PEEP_DEBUG_NEXT_SLOPE, ft2.Data()); OpenRCT2::FormatStringLegacy(buffer2, sizeof(buffer2), STR_PEEP_DEBUG_NEXT_SLOPE, ft2.Data());
SafeStrCat(buffer, buffer2, sizeof(buffer)); SafeStrCat(buffer, buffer2, sizeof(buffer));
} }
GfxDrawString(dpi, screenCoords, buffer, {}); DrawText(dpi, screenCoords, {}, buffer);
} }
screenCoords.y += kListRowHeight; screenCoords.y += kListRowHeight;
{ {

View File

@ -14,7 +14,6 @@
#include <openrct2/actions/NetworkModifyGroupAction.h> #include <openrct2/actions/NetworkModifyGroupAction.h>
#include <openrct2/config/Config.h> #include <openrct2/config/Config.h>
#include <openrct2/core/String.hpp> #include <openrct2/core/String.hpp>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/localisation/Localisation.h> #include <openrct2/localisation/Localisation.h>
#include <openrct2/network/network.h> #include <openrct2/network/network.h>
#include <openrct2/sprites.h> #include <openrct2/sprites.h>
@ -781,7 +780,7 @@ static constexpr StringId WindowMultiplayerPageTitles[] = {
} }
screenCoords.x = 0; screenCoords.x = 0;
GfxClipString(_buffer.data(), 230, FontStyle::Medium); GfxClipString(_buffer.data(), 230, FontStyle::Medium);
GfxDrawString(dpi, screenCoords, _buffer.c_str(), { colour }); DrawText(dpi, screenCoords, { colour }, _buffer.c_str());
// Draw group name // Draw group name
_buffer.resize(0); _buffer.resize(0);
@ -792,7 +791,7 @@ static constexpr StringId WindowMultiplayerPageTitles[] = {
screenCoords.x = 173; screenCoords.x = 173;
_buffer += NetworkGetGroupName(group); _buffer += NetworkGetGroupName(group);
GfxClipString(_buffer.data(), 80, FontStyle::Medium); GfxClipString(_buffer.data(), 80, FontStyle::Medium);
GfxDrawString(dpi, screenCoords, _buffer.c_str(), { colour }); DrawText(dpi, screenCoords, { colour }, _buffer.c_str());
} }
// Draw last action // Draw last action
@ -829,7 +828,7 @@ static constexpr StringId WindowMultiplayerPageTitles[] = {
_buffer += pingBuffer; _buffer += pingBuffer;
screenCoords.x = 356; screenCoords.x = 356;
GfxDrawString(dpi, screenCoords, _buffer.c_str(), { colour }); DrawText(dpi, screenCoords, { colour }, _buffer.c_str());
} }
screenCoords.y += kScrollableRowHeight; screenCoords.y += kScrollableRowHeight;
listPosition++; listPosition++;
@ -909,7 +908,7 @@ static constexpr StringId WindowMultiplayerPageTitles[] = {
if (NetworkCanPerformAction(groupindex, static_cast<NetworkPermission>(i))) if (NetworkCanPerformAction(groupindex, static_cast<NetworkPermission>(i)))
{ {
screenCoords.x = 0; screenCoords.x = 0;
GfxDrawString(dpi, screenCoords, u8"{WINDOW_COLOUR_2}✓", {}); DrawText(dpi, screenCoords, {}, u8"{WINDOW_COLOUR_2}✓");
} }
} }

View File

@ -9,7 +9,6 @@
#include <openrct2-ui/interface/Widget.h> #include <openrct2-ui/interface/Widget.h>
#include <openrct2-ui/windows/Window.h> #include <openrct2-ui/windows/Window.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/localisation/Localisation.h> #include <openrct2/localisation/Localisation.h>
#include <openrct2/network/network.h> #include <openrct2/network/network.h>
#include <openrct2/util/Util.h> #include <openrct2/util/Util.h>
@ -106,7 +105,7 @@ static Widget window_network_status_widgets[] = {
GfxClipString(_buffer.data(), widgets[WIDX_BACKGROUND].right - 50, FontStyle::Medium); GfxClipString(_buffer.data(), widgets[WIDX_BACKGROUND].right - 50, FontStyle::Medium);
ScreenCoordsXY screenCoords(windowPos.x + (width / 2), windowPos.y + (height / 2)); ScreenCoordsXY screenCoords(windowPos.x + (width / 2), windowPos.y + (height / 2));
screenCoords.x -= GfxGetStringWidth(_buffer, FontStyle::Medium) / 2; screenCoords.x -= GfxGetStringWidth(_buffer, FontStyle::Medium) / 2;
GfxDrawString(dpi, screenCoords, _buffer.c_str()); DrawText(dpi, screenCoords, { COLOUR_BLACK }, _buffer.c_str());
} }
void SetCloseCallBack(close_callback onClose) void SetCloseCallBack(close_callback onClose)

View File

@ -538,7 +538,7 @@ static Widget window_object_load_error_widgets[] = {
auto name = entry.GetName(); auto name = entry.GetName();
char buffer[256]; char buffer[256];
String::Set(buffer, sizeof(buffer), name.data(), name.size()); String::Set(buffer, sizeof(buffer), name.data(), name.size());
GfxDrawString(dpi, screenCoords, buffer, { COLOUR_DARK_GREEN }); DrawText(dpi, screenCoords, { COLOUR_DARK_GREEN }, buffer);
if (entry.Generation == ObjectGeneration::DAT) if (entry.Generation == ObjectGeneration::DAT)
{ {

View File

@ -13,7 +13,6 @@
#include <openrct2/Input.h> #include <openrct2/Input.h>
#include <openrct2/actions/PlayerKickAction.h> #include <openrct2/actions/PlayerKickAction.h>
#include <openrct2/actions/PlayerSetGroupAction.h> #include <openrct2/actions/PlayerSetGroupAction.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/localisation/Formatter.h> #include <openrct2/localisation/Formatter.h>
#include <openrct2/network/NetworkAction.h> #include <openrct2/network/NetworkAction.h>
#include <openrct2/network/network.h> #include <openrct2/network/network.h>
@ -456,7 +455,7 @@ static Widget *window_player_page_widgets[] = {
DrawTextBasic(dpi, screenCoords, STR_WINDOW_COLOUR_2_STRINGID, ft); DrawTextBasic(dpi, screenCoords, STR_WINDOW_COLOUR_2_STRINGID, ft);
char ping[64]; char ping[64];
snprintf(ping, 64, "%d ms", NetworkGetPlayerPing(player)); snprintf(ping, 64, "%d ms", NetworkGetPlayerPing(player));
GfxDrawString(dpi, screenCoords + ScreenCoordsXY(30, 0), ping, { colours[2] }); DrawText(dpi, screenCoords + ScreenCoordsXY(30, 0), { colours[2] }, ping);
// Draw last action // Draw last action
screenCoords = windowPos + ScreenCoordsXY{ width / 2, height - 13 }; screenCoords = windowPos + ScreenCoordsXY{ width / 2, height - 13 };

View File

@ -16,7 +16,6 @@
# include <openrct2/Context.h> # include <openrct2/Context.h>
# include <openrct2/config/Config.h> # include <openrct2/config/Config.h>
# include <openrct2/core/Json.hpp> # include <openrct2/core/Json.hpp>
# include <openrct2/drawing/Drawing.h>
# include <openrct2/interface/Colour.h> # include <openrct2/interface/Colour.h>
# include <openrct2/localisation/Formatter.h> # include <openrct2/localisation/Formatter.h>
# include <openrct2/localisation/Localisation.h> # include <openrct2/localisation/Localisation.h>
@ -424,7 +423,7 @@ static Widget _serverListWidgets[] = {
// Draw number of players // Draw number of players
screenCoords.x = right - numPlayersStringWidth; screenCoords.x = right - numPlayersStringWidth;
GfxDrawString(dpi, screenCoords + ScreenCoordsXY{ 0, 3 }, players, { colours[1] }); DrawText(dpi, screenCoords + ScreenCoordsXY{ 0, 3 }, { colours[1] }, players);
screenCoords.y += ITEM_HEIGHT; screenCoords.y += ITEM_HEIGHT;
} }

View File

@ -15,7 +15,6 @@
#include <openrct2/Context.h> #include <openrct2/Context.h>
#include <openrct2/Game.h> #include <openrct2/Game.h>
#include <openrct2/Input.h> #include <openrct2/Input.h>
#include <openrct2/drawing/Drawing.h>
#include <openrct2/localisation/Formatter.h> #include <openrct2/localisation/Formatter.h>
#include <openrct2/localisation/Localisation.h> #include <openrct2/localisation/Localisation.h>
#include <openrct2/platform/Platform.h> #include <openrct2/platform/Platform.h>
@ -810,9 +809,10 @@ static WindowClass window_themes_tab_7_classes[] = {
GfxFillRectInset(dpi, { topLeft, bottomRight }, colours[1], INSET_RECT_F_E0); GfxFillRectInset(dpi, { topLeft, bottomRight }, colours[1], INSET_RECT_F_E0);
if (colour & COLOUR_FLAG_TRANSLUCENT) if (colour & COLOUR_FLAG_TRANSLUCENT)
{ {
GfxDrawString( DrawText(
dpi, topLeft, static_cast<const char*>(CheckBoxMarkString), dpi, topLeft,
{ static_cast<colour_t>(colours[1] & 0x7F), FontStyle::Medium, TextDarkness::Dark }); { static_cast<colour_t>(colours[1] & 0x7F), FontStyle::Medium, TextDarkness::Dark },
static_cast<const char*>(CheckBoxMarkString));
} }
} }
} }

View File

@ -1031,8 +1031,8 @@ static uint64_t PageDisabledWidgets[] = {
ScreenCoordsXY screenCoords(windowPos.x, windowPos.y); ScreenCoordsXY screenCoords(windowPos.x, windowPos.y);
// Draw coordinates // Draw coordinates
GfxDrawString(dpi, screenCoords + ScreenCoordsXY(5, 24), "X:", { colours[1] }); DrawText(dpi, screenCoords + ScreenCoordsXY(5, 24), { colours[1] }, "X:");
GfxDrawString(dpi, screenCoords + ScreenCoordsXY(74, 24), "Y:", { colours[1] }); DrawText(dpi, screenCoords + ScreenCoordsXY(74, 24), { colours[1] }, "Y:");
if (_tileSelected) if (_tileSelected)
{ {
auto tileCoords = TileCoordsXY{ _toolMap }; auto tileCoords = TileCoordsXY{ _toolMap };
@ -1048,8 +1048,8 @@ static uint64_t PageDisabledWidgets[] = {
} }
else else
{ {
GfxDrawString(dpi, screenCoords + ScreenCoordsXY(43 - 7, 24), "-", { colours[1] }); DrawText(dpi, screenCoords + ScreenCoordsXY(43 - 7, 24), { colours[1] }, "-");
GfxDrawString(dpi, screenCoords + ScreenCoordsXY(113 - 7, 24), "-", { colours[1] }); DrawText(dpi, screenCoords + ScreenCoordsXY(113 - 7, 24), { colours[1] }, "-");
} }
if (windowTileInspectorSelectedIndex != -1) if (windowTileInspectorSelectedIndex != -1)

View File

@ -7,8 +7,6 @@
* OpenRCT2 is licensed under the GNU General Public License version 3. * OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/ *****************************************************************************/
#include "../drawing/Drawing.h"
#include "../Context.h" #include "../Context.h"
#include "../common.h" #include "../common.h"
#include "../config/Config.h" #include "../config/Config.h"
@ -264,7 +262,7 @@ void GfxDrawStringLeftCentred(DrawPixelInfo& dpi, StringId format, void* args, c
auto bufferPtr = buffer; auto bufferPtr = buffer;
FormatStringLegacy(bufferPtr, sizeof(buffer), format, args); FormatStringLegacy(bufferPtr, sizeof(buffer), format, args);
int32_t height = StringGetHeightRaw(bufferPtr, FontStyle::Medium); int32_t height = StringGetHeightRaw(bufferPtr, FontStyle::Medium);
GfxDrawString(dpi, coords - ScreenCoordsXY{ 0, (height / 2) }, bufferPtr, { colour }); DrawText(dpi, coords - ScreenCoordsXY{ 0, (height / 2) }, { colour }, bufferPtr);
} }
/** /**
@ -326,13 +324,13 @@ void DrawStringCentredRaw(
DrawPixelInfo& dpi, const ScreenCoordsXY& coords, int32_t numLines, const utf8* text, FontStyle fontStyle) DrawPixelInfo& dpi, const ScreenCoordsXY& coords, int32_t numLines, const utf8* text, FontStyle fontStyle)
{ {
ScreenCoordsXY screenCoords(dpi.x, dpi.y); ScreenCoordsXY screenCoords(dpi.x, dpi.y);
GfxDrawString(dpi, screenCoords, "", { COLOUR_BLACK, fontStyle }); DrawText(dpi, screenCoords, { COLOUR_BLACK, fontStyle }, "");
screenCoords = coords; screenCoords = coords;
for (int32_t i = 0; i <= numLines; i++) for (int32_t i = 0; i <= numLines; i++)
{ {
int32_t width = GfxGetStringWidth(text, fontStyle); int32_t width = GfxGetStringWidth(text, fontStyle);
GfxDrawString(dpi, screenCoords - ScreenCoordsXY{ width / 2, 0 }, text, { TEXT_COLOUR_254, fontStyle }); DrawText(dpi, screenCoords - ScreenCoordsXY{ width / 2, 0 }, { TEXT_COLOUR_254, fontStyle }, text);
const utf8* ch = text; const utf8* ch = text;
const utf8* nextCh = nullptr; const utf8* nextCh = nullptr;
@ -424,7 +422,7 @@ void DrawNewsTicker(
int32_t numLines, lineHeight, lineY; int32_t numLines, lineHeight, lineY;
ScreenCoordsXY screenCoords(dpi.x, dpi.y); ScreenCoordsXY screenCoords(dpi.x, dpi.y);
GfxDrawString(dpi, screenCoords, "", { colour }); DrawText(dpi, screenCoords, { colour }, "");
u8string wrappedString; u8string wrappedString;
GfxWrapString(FormatStringID(format, args), width, FontStyle::Small, &wrappedString, &numLines); GfxWrapString(FormatStringID(format, args), width, FontStyle::Small, &wrappedString, &numLines);
@ -463,7 +461,7 @@ void DrawNewsTicker(
} }
screenCoords = { coords.x - halfWidth, lineY }; screenCoords = { coords.x - halfWidth, lineY };
GfxDrawString(dpi, screenCoords, buffer, { TEXT_COLOUR_254, FontStyle::Small }); DrawText(dpi, screenCoords, { TEXT_COLOUR_254, FontStyle::Small }, buffer);
if (numCharactersDrawn > numCharactersToDraw) if (numCharactersDrawn > numCharactersToDraw)
{ {

View File

@ -577,8 +577,6 @@ void FASTCALL GfxDrawSpriteRawMaskedSoftware(
DrawPixelInfo& dpi, const ScreenCoordsXY& scrCoords, const ImageId maskImage, const ImageId colourImage); DrawPixelInfo& dpi, const ScreenCoordsXY& scrCoords, const ImageId maskImage, const ImageId colourImage);
// string // string
void GfxDrawString(DrawPixelInfo& dpi, const ScreenCoordsXY& coords, const_utf8string buffer, TextPaint textPaint = {});
void GfxDrawStringLeftCentred(DrawPixelInfo& dpi, StringId format, void* args, colour_t colour, const ScreenCoordsXY& coords); void GfxDrawStringLeftCentred(DrawPixelInfo& dpi, StringId format, void* args, colour_t colour, const ScreenCoordsXY& coords);
void DrawStringCentredRaw( void DrawStringCentredRaw(
DrawPixelInfo& dpi, const ScreenCoordsXY& coords, int32_t numLines, const utf8* text, FontStyle fontStyle); DrawPixelInfo& dpi, const ScreenCoordsXY& coords, int32_t numLines, const utf8* text, FontStyle fontStyle);

View File

@ -140,11 +140,6 @@ void DrawTextEllipsised(
DrawText(dpi, coords, textPaint, buffer); DrawText(dpi, coords, textPaint, buffer);
} }
void GfxDrawString(DrawPixelInfo& dpi, const ScreenCoordsXY& coords, const_utf8string buffer, TextPaint textPaint)
{
DrawText(dpi, coords, textPaint, buffer);
}
int32_t DrawTextWrapped(DrawPixelInfo& dpi, const ScreenCoordsXY& coords, int32_t width, StringId format) int32_t DrawTextWrapped(DrawPixelInfo& dpi, const ScreenCoordsXY& coords, int32_t width, StringId format)
{ {
Formatter ft{}; Formatter ft{};

View File

@ -287,7 +287,7 @@ static int32_t ChatHistoryDrawString(DrawPixelInfo& dpi, const char* text, const
int32_t lineY = screenCoords.y; int32_t lineY = screenCoords.y;
for (int32_t line = 0; line <= numLines; ++line) for (int32_t line = 0; line <= numLines; ++line)
{ {
GfxDrawString(dpi, { screenCoords.x, lineY - (numLines * lineHeight) }, bufferPtr, { TEXT_COLOUR_254 }); DrawText(dpi, { screenCoords.x, lineY - (numLines * lineHeight) }, { TEXT_COLOUR_254 }, bufferPtr);
bufferPtr = GetStringEnd(bufferPtr) + 1; bufferPtr = GetStringEnd(bufferPtr) + 1;
lineY += lineHeight; lineY += lineHeight;
} }

View File

@ -14,7 +14,6 @@
#include "../OpenRCT2.h" #include "../OpenRCT2.h"
#include "../ReplayManager.h" #include "../ReplayManager.h"
#include "../config/Config.h" #include "../config/Config.h"
#include "../drawing/Drawing.h"
#include "../drawing/IDrawingEngine.h" #include "../drawing/IDrawingEngine.h"
#include "../interface/Chat.h" #include "../interface/Chat.h"
#include "../interface/InteractiveConsole.h" #include "../interface/InteractiveConsole.h"
@ -97,7 +96,7 @@ void Painter::PaintReplayNotice(DrawPixelInfo& dpi, const char* text)
screenCoords.x = screenCoords.x - stringWidth; screenCoords.x = screenCoords.x - stringWidth;
if (((GetGameState().CurrentTicks >> 1) & 0xF) > 4) if (((GetGameState().CurrentTicks >> 1) & 0xF) > 4)
GfxDrawString(dpi, screenCoords, buffer, { COLOUR_SATURATED_RED }); DrawText(dpi, screenCoords, { COLOUR_SATURATED_RED }, buffer);
// Make area dirty so the text doesn't get drawn over the last // Make area dirty so the text doesn't get drawn over the last
GfxSetDirtyBlocks({ screenCoords, screenCoords + ScreenCoordsXY{ stringWidth, 16 } }); GfxSetDirtyBlocks({ screenCoords, screenCoords + ScreenCoordsXY{ stringWidth, 16 } });
@ -129,7 +128,7 @@ void Painter::PaintFPS(DrawPixelInfo& dpi)
// Draw Text // Draw Text
int32_t stringWidth = GfxGetStringWidth(buffer, FontStyle::Medium); int32_t stringWidth = GfxGetStringWidth(buffer, FontStyle::Medium);
screenCoords.x = screenCoords.x - (stringWidth / 2); screenCoords.x = screenCoords.x - (stringWidth / 2);
GfxDrawString(dpi, screenCoords, buffer); DrawText(dpi, screenCoords, { COLOUR_WHITE }, buffer);
// Make area dirty so the text doesn't get drawn over the last // Make area dirty so the text doesn't get drawn over the last
GfxSetDirtyBlocks({ { screenCoords - ScreenCoordsXY{ 16, 4 } }, { dpi.lastStringPos.x + 16, 16 } }); GfxSetDirtyBlocks({ { screenCoords - ScreenCoordsXY{ 16, 4 } }, { dpi.lastStringPos.x + 16, 16 } });

View File

@ -18,7 +18,6 @@
#include "../../audio/audio.h" #include "../../audio/audio.h"
#include "../../config/Config.h" #include "../../config/Config.h"
#include "../../core/Console.hpp" #include "../../core/Console.hpp"
#include "../../drawing/Drawing.h"
#include "../../interface/Screenshot.h" #include "../../interface/Screenshot.h"
#include "../../interface/Viewport.h" #include "../../interface/Viewport.h"
#include "../../interface/Window.h" #include "../../interface/Window.h"
@ -442,7 +441,7 @@ void DrawOpenRCT2(DrawPixelInfo& dpi, const ScreenCoordsXY& screenCoords)
// Write name and version information // Write name and version information
buffer += gVersionInfoFull; buffer += gVersionInfoFull;
GfxDrawString(dpi, screenCoords + ScreenCoordsXY(5, 5 - 13), buffer.c_str(), { COLOUR_BLACK }); DrawText(dpi, screenCoords + ScreenCoordsXY(5, 5 - 13), { COLOUR_BLACK }, buffer.c_str());
int16_t width = static_cast<int16_t>(GfxGetStringWidth(buffer, FontStyle::Medium)); int16_t width = static_cast<int16_t>(GfxGetStringWidth(buffer, FontStyle::Medium));
// Write platform information // Write platform information
@ -452,7 +451,7 @@ void DrawOpenRCT2(DrawPixelInfo& dpi, const ScreenCoordsXY& screenCoords)
buffer.append(OPENRCT2_ARCHITECTURE); buffer.append(OPENRCT2_ARCHITECTURE);
buffer.append(")"); buffer.append(")");
GfxDrawString(dpi, screenCoords + ScreenCoordsXY(5, 5), buffer.c_str(), { COLOUR_BLACK }); DrawText(dpi, screenCoords + ScreenCoordsXY(5, 5), { COLOUR_BLACK }, buffer.c_str());
width = std::max(width, static_cast<int16_t>(GfxGetStringWidth(buffer, FontStyle::Medium))); width = std::max(width, static_cast<int16_t>(GfxGetStringWidth(buffer, FontStyle::Medium)));
// Invalidate screen area // Invalidate screen area