Remove gCurrentFontSpriteBase from some functions

This commit is contained in:
Gymnasiast 2021-02-27 18:15:44 +01:00
parent 826f6c7442
commit 503273793a
No known key found for this signature in database
GPG Key ID: DBFFF47AB2CA3EDD
27 changed files with 75 additions and 70 deletions

View File

@ -26,10 +26,14 @@ using namespace OpenRCT2::Ui;
static InGameConsole _inGameConsole;
static FontSpriteBase InGameconsoleGetFontSpriteBase()
{
return (gConfigInterface.console_small_font ? FontSpriteBase::SMALL : FontSpriteBase::MEDIUM);
}
static int32_t InGameConsoleGetLineHeight()
{
auto fontSpriteBase = (gConfigInterface.console_small_font ? FontSpriteBase::SMALL : FontSpriteBase::MEDIUM);
return font_get_line_height(fontSpriteBase);
return font_get_line_height(InGameconsoleGetFontSpriteBase());
}
InGameConsole::InGameConsole()
@ -146,7 +150,7 @@ void InGameConsole::RefreshCaret(size_t position)
_selectionStart = position;
char tempString[TEXT_INPUT_SIZE] = { 0 };
std::memcpy(tempString, &_consoleCurrentLine, _selectionStart);
_caretScreenPosX = gfx_get_string_width_no_formatting(tempString);
_caretScreenPosX = gfx_get_string_width_no_formatting(tempString, InGameconsoleGetFontSpriteBase());
}
void InGameConsole::Scroll(int32_t linesToScroll)
@ -272,7 +276,7 @@ void InGameConsole::Draw(rct_drawpixelinfo* dpi) const
return;
// Set font
gCurrentFontSpriteBase = (gConfigInterface.console_small_font ? FontSpriteBase::SMALL : FontSpriteBase::MEDIUM);
gCurrentFontSpriteBase = InGameconsoleGetFontSpriteBase();
uint8_t textColour = NOT_TRANSLUCENT(ThemeGetColour(WC_CONSOLE, 1));
const int32_t lineHeight = InGameConsoleGetLineHeight();
const int32_t maxLines = GetNumVisibleLines();

View File

@ -484,7 +484,7 @@ static void WidgetGroupboxDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widget
auto ft = Formatter();
ft.Add<utf8*>(buffer);
DrawTextBasic(dpi, { l, t }, STR_STRING, ft, { colour });
textRight = l + gfx_get_string_width(buffer) + 1;
textRight = l + gfx_get_string_width(buffer, FontSpriteBase::MEDIUM) + 1;
}
// Border
@ -1134,7 +1134,7 @@ static void WidgetTextBoxDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widgeti
// Make a copy of the string for measuring the width.
char temp_string[TEXT_INPUT_SIZE] = { 0 };
std::memcpy(temp_string, wrapped_string, std::min(string_length, gTextInput->SelectionStart));
int32_t cur_x = topLeft.x + gfx_get_string_width_no_formatting(temp_string) + 3;
int32_t cur_x = topLeft.x + gfx_get_string_width_no_formatting(temp_string, FontSpriteBase::MEDIUM) + 3;
int32_t width = 6;
if (static_cast<uint32_t>(gTextInput->SelectionStart) < strlen(gTextBoxInput))
@ -1143,7 +1143,7 @@ static void WidgetTextBoxDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widgeti
// of the character that the cursor is under.
temp_string[1] = '\0';
temp_string[0] = gTextBoxInput[gTextInput->SelectionStart];
width = std::max(gfx_get_string_width_no_formatting(temp_string) - 2, 4);
width = std::max(gfx_get_string_width_no_formatting(temp_string, FontSpriteBase::MEDIUM) - 2, 4);
}
if (gTextBoxFrameNo <= 15)

View File

@ -714,7 +714,7 @@ void CustomListView::PaintSeperator(
// Get string dimensions
format_string(gCommonStringFormatBuffer, sizeof(gCommonStringFormatBuffer), STR_STRING, ft.Data());
int32_t categoryStringHalfWidth = (gfx_get_string_width(gCommonStringFormatBuffer) / 2) + 4;
int32_t categoryStringHalfWidth = (gfx_get_string_width(gCommonStringFormatBuffer, FontSpriteBase::MEDIUM) / 2) + 4;
int32_t strLeft = centreX - categoryStringHalfWidth;
int32_t strRight = centreX + categoryStringHalfWidth;

View File

@ -245,7 +245,7 @@ static void window_changelog_process_changelog_text(const std::string& text)
_changelogLongestLineWidth = 0;
for (const auto& line : _changelogLines)
{
auto width = gfx_get_string_width(line.c_str());
auto width = gfx_get_string_width(line.c_str(), FontSpriteBase::MEDIUM);
_changelogLongestLineWidth = std::max(width, _changelogLongestLineWidth);
}
}

View File

@ -130,7 +130,7 @@ static void window_debug_paint_invalidate(rct_window* w)
auto stringIdx = w->widgets[widgetIndex].text;
auto string = ls.GetString(stringIdx);
Guard::ArgumentNotNull(string);
auto width = gfx_get_string_width(string);
auto width = gfx_get_string_width(string, FontSpriteBase::MEDIUM);
newWidth = std::max<int16_t>(width, newWidth);
}

View File

@ -119,7 +119,7 @@ void WindowDropdownShowText(const ScreenCoordsXY& screenPos, int32_t extray, uin
{
format_string(buffer, 256, gDropdownItemsFormat[i], static_cast<void*>(&gDropdownItemsArgs[i]));
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
string_width = gfx_get_string_width(buffer);
string_width = gfx_get_string_width(buffer, FontSpriteBase::MEDIUM);
max_string_width = std::max(string_width, max_string_width);
}

View File

@ -689,7 +689,7 @@ static void window_editor_inventions_list_drag_open(ResearchItem* researchItem)
format_string(ptr, 256, stringId, nullptr);
}
auto stringWidth = gfx_get_string_width(buffer);
auto stringWidth = gfx_get_string_width(buffer, FontSpriteBase::MEDIUM);
window_editor_inventions_list_drag_widgets[0].right = stringWidth;
auto* w = WindowCreate(

View File

@ -84,7 +84,7 @@ rct_window* window_error_open(std::string_view title, std::string_view message)
return nullptr;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
width = gfx_get_string_width_new_lined(buffer.data());
width = gfx_get_string_width_new_lined(buffer.data(), FontSpriteBase::MEDIUM);
width = std::clamp(width, 64, 196);
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;

View File

@ -643,7 +643,7 @@ static void window_loadsave_compute_max_date_width()
// Check how this date is represented (e.g. 2000-02-20, or 00/02/20)
std::string date = Platform::FormatShortDate(long_time);
maxDateWidth = gfx_get_string_width(date.c_str()) + DATE_TIME_GAP;
maxDateWidth = gfx_get_string_width(date.c_str(), FontSpriteBase::MEDIUM) + DATE_TIME_GAP;
// Some locales do not use leading zeros for months and days, so let's try October, too.
tm.tm_mon = 10;
@ -652,11 +652,11 @@ static void window_loadsave_compute_max_date_width()
// Again, check how this date is represented (e.g. 2000-10-20, or 00/10/20)
date = Platform::FormatShortDate(long_time);
maxDateWidth = std::max(maxDateWidth, gfx_get_string_width(date.c_str()) + DATE_TIME_GAP);
maxDateWidth = std::max(maxDateWidth, gfx_get_string_width(date.c_str(), FontSpriteBase::MEDIUM) + DATE_TIME_GAP);
// Time appears to be universally represented with two digits for minutes, so 12:00 or 00:00 should be representable.
std::string time = Platform::FormatTime(long_time);
maxTimeWidth = gfx_get_string_width(time.c_str()) + DATE_TIME_GAP;
maxTimeWidth = gfx_get_string_width(time.c_str(), FontSpriteBase::MEDIUM) + DATE_TIME_GAP;
}
static void window_loadsave_invalidate(rct_window* w)

View File

@ -433,9 +433,9 @@ static void window_network_information_paint(rct_window* w, rct_drawpixelinfo* d
// Draw text.
gfx_draw_string(dpi, textBuffer, PALETTE_INDEX_10, screenCoords + ScreenCoordsXY(10, 0));
gfx_get_string_width(textBuffer);
gfx_get_string_width(textBuffer, FontSpriteBase::MEDIUM);
screenCoords.x += gfx_get_string_width(textBuffer) + 20;
screenCoords.x += gfx_get_string_width(textBuffer, FontSpriteBase::MEDIUM) + 20;
}
}
}

View File

@ -162,6 +162,6 @@ static void window_network_status_paint(rct_window* w, rct_drawpixelinfo* dpi)
buffer += window_network_status_text;
gfx_clip_string(buffer.data(), w->widgets[WIDX_BACKGROUND].right - 50);
ScreenCoordsXY screenCoords(w->windowPos.x + (w->width / 2), w->windowPos.y + (w->height / 2));
screenCoords.x -= gfx_get_string_width(buffer) / 2;
screenCoords.x -= gfx_get_string_width(buffer, FontSpriteBase::MEDIUM) / 2;
gfx_draw_string(dpi, buffer.c_str(), COLOUR_BLACK, screenCoords);
}

View File

@ -110,6 +110,11 @@ static void window_scenarioselect_invalidate(rct_window *w);
static void window_scenarioselect_paint(rct_window *w, rct_drawpixelinfo *dpi);
static void window_scenarioselect_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int32_t scrollIndex);
static bool ScenarioSelectUseSmallFont()
{
return ThemeGetFlags() & UITHEME_FLAG_USE_ALTERNATIVE_SCENARIO_SELECT_FONT;
}
static rct_window_event_list window_scenarioselect_events([](auto& events)
{
events.close = &window_scenarioselect_close;
@ -432,8 +437,7 @@ static void window_scenarioselect_paint(rct_window* w, rct_drawpixelinfo* dpi)
WindowDrawWidgets(w, dpi);
format = (ThemeGetFlags() & UITHEME_FLAG_USE_ALTERNATIVE_SCENARIO_SELECT_FONT) ? STR_SMALL_WINDOW_COLOUR_2_STRINGID
: STR_WINDOW_COLOUR_2_STRINGID;
format = ScenarioSelectUseSmallFont() ? STR_SMALL_WINDOW_COLOUR_2_STRINGID : STR_WINDOW_COLOUR_2_STRINGID;
// Text for each tab
for (uint32_t i = 0; i < std::size(ScenarioOriginStringIds); i++)
@ -550,12 +554,8 @@ static void window_scenarioselect_scrollpaint(rct_window* w, rct_drawpixelinfo*
uint8_t paletteIndex = ColourMapA[w->colours[1]].mid_light;
gfx_clear(dpi, paletteIndex);
rct_string_id highlighted_format = (ThemeGetFlags() & UITHEME_FLAG_USE_ALTERNATIVE_SCENARIO_SELECT_FONT)
? STR_WHITE_STRING
: STR_WINDOW_COLOUR_2_STRINGID;
rct_string_id unhighlighted_format = (ThemeGetFlags() & UITHEME_FLAG_USE_ALTERNATIVE_SCENARIO_SELECT_FONT)
? STR_WHITE_STRING
: STR_BLACK_STRING;
rct_string_id highlighted_format = ScenarioSelectUseSmallFont() ? STR_WHITE_STRING : STR_WINDOW_COLOUR_2_STRINGID;
rct_string_id unhighlighted_format = ScenarioSelectUseSmallFont() ? STR_WHITE_STRING : STR_BLACK_STRING;
bool wide = gConfigGeneral.scenario_select_mode == SCENARIO_SELECT_MODE_ORIGIN || _titleEditor;
@ -655,7 +655,7 @@ static void draw_category_heading(
// Get string dimensions
utf8* buffer = gCommonStringFormatBuffer;
format_string(buffer, 256, stringId, nullptr);
int32_t categoryStringHalfWidth = (gfx_get_string_width(buffer) / 2) + 4;
int32_t categoryStringHalfWidth = (gfx_get_string_width(buffer, FontSpriteBase::MEDIUM) / 2) + 4;
int32_t strLeft = centreX - categoryStringHalfWidth;
int32_t strRight = centreX + categoryStringHalfWidth;

View File

@ -460,7 +460,7 @@ static void window_server_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi
{
snprintf(players, sizeof(players), "%d/%d", serverDetails.Players, serverDetails.MaxPlayers);
}
const int16_t numPlayersStringWidth = gfx_get_string_width(players);
const int16_t numPlayersStringWidth = gfx_get_string_width(players, FontSpriteBase::MEDIUM);
// How much space we have for the server info depends on the size of everything rendered after.
const int16_t spaceAvailableForInfo = width - numPlayersStringWidth - SCROLLBAR_WIDTH - 35;

View File

@ -248,7 +248,7 @@ public:
// Make a copy of the string for measuring the width.
char temp_string[TEXT_INPUT_SIZE] = { 0 };
std::memcpy(temp_string, wrap_pointer, gTextInput->SelectionStart - char_count);
cursorX = windowPos.x + 13 + gfx_get_string_width_no_formatting(temp_string);
cursorX = windowPos.x + 13 + gfx_get_string_width_no_formatting(temp_string, FontSpriteBase::MEDIUM);
cursorY = screenCoords.y;
int32_t textWidth = 6;
@ -259,7 +259,7 @@ public:
utf8 tmp[5] = { 0 }; // This is easier than setting temp_string[0..5]
uint32_t codepoint = utf8_get_next(_buffer.data() + gTextInput->SelectionStart, nullptr);
utf8_write_codepoint(tmp, codepoint);
textWidth = std::max(gfx_get_string_width_no_formatting(tmp) - 2, 4);
textWidth = std::max(gfx_get_string_width_no_formatting(tmp, FontSpriteBase::MEDIUM) - 2, 4);
}
if (_cursorBlink > 15)
@ -316,7 +316,7 @@ public:
private:
static void DrawIMEComposition(rct_drawpixelinfo& dpi, int32_t cursorX, int32_t cursorY)
{
int compositionWidth = gfx_get_string_width(gTextInput->ImeBuffer);
int compositionWidth = gfx_get_string_width(gTextInput->ImeBuffer, FontSpriteBase::MEDIUM);
ScreenCoordsXY screenCoords(cursorX - (compositionWidth / 2), cursorY + 13);
int width = compositionWidth;
int height = 10;

View File

@ -58,7 +58,7 @@ static int32_t FormatTextForTooltip(const OpenRCT2String& message)
format_string(_tooltipText, sizeof(_tooltipText), formattedMessage.str, formattedMessage.args.Data());
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
auto textWidth = gfx_get_string_width_new_lined(_tooltipText);
auto textWidth = gfx_get_string_width_new_lined(_tooltipText, FontSpriteBase::MEDIUM);
textWidth = std::min(textWidth, 196);
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;

View File

@ -36,13 +36,13 @@ enum : uint32_t
TEXT_DRAW_FLAG_NO_DRAW = 1u << 31
};
static int32_t ttf_get_string_width(std::string_view text, bool noFormatting);
static int32_t ttf_get_string_width(std::string_view text, FontSpriteBase fontSpriteBase, bool noFormatting);
/**
*
* rct2: 0x006C23B1
*/
int32_t gfx_get_string_width_new_lined(std::string_view text)
int32_t gfx_get_string_width_new_lined(std::string_view text, FontSpriteBase fontSpriteBase)
{
thread_local std::string buffer;
buffer.clear();
@ -53,7 +53,7 @@ int32_t gfx_get_string_width_new_lined(std::string_view text)
{
if (token.kind == FormatToken::Newline || token.kind == FormatToken::NewlineSmall)
{
auto width = gfx_get_string_width(buffer);
auto width = gfx_get_string_width(buffer, fontSpriteBase);
if (!maxWidth || maxWidth > width)
{
maxWidth = width;
@ -67,7 +67,7 @@ int32_t gfx_get_string_width_new_lined(std::string_view text)
}
if (!maxWidth)
{
maxWidth = gfx_get_string_width(buffer);
maxWidth = gfx_get_string_width(buffer, fontSpriteBase);
}
return *maxWidth;
}
@ -78,14 +78,14 @@ int32_t gfx_get_string_width_new_lined(std::string_view text)
* rct2: 0x006C2321
* buffer (esi)
*/
int32_t gfx_get_string_width(std::string_view text)
int32_t gfx_get_string_width(std::string_view text, FontSpriteBase fontSpriteBase)
{
return ttf_get_string_width(text, false);
return ttf_get_string_width(text, fontSpriteBase, false);
}
int32_t gfx_get_string_width_no_formatting(std::string_view text)
int32_t gfx_get_string_width_no_formatting(std::string_view text, FontSpriteBase fontSpriteBase)
{
return ttf_get_string_width(text, true);
return ttf_get_string_width(text, fontSpriteBase, true);
}
/**
@ -104,7 +104,7 @@ int32_t gfx_clip_string(utf8* text, int32_t width)
}
// If width of the full string is less than allowed width then we don't need to clip
auto clippedWidth = gfx_get_string_width(text);
auto clippedWidth = gfx_get_string_width(text, gCurrentFontSpriteBase);
if (clippedWidth <= width)
{
return clippedWidth;
@ -126,7 +126,7 @@ int32_t gfx_clip_string(utf8* text, int32_t width)
// Add the ellipsis before checking the width
buffer.append("...");
auto currentWidth = gfx_get_string_width(buffer);
auto currentWidth = gfx_get_string_width(buffer, gCurrentFontSpriteBase);
if (currentWidth < width)
{
bestLength = buffer.size();
@ -154,7 +154,7 @@ int32_t gfx_clip_string(utf8* text, int32_t width)
buffer.append(cb);
}
}
return gfx_get_string_width(text);
return gfx_get_string_width(text, gCurrentFontSpriteBase);
}
/**
@ -194,7 +194,7 @@ int32_t gfx_wrap_string(utf8* text, int32_t width, int32_t* outNumLines)
utf8_write_codepoint(cb, codepoint);
buffer.append(cb);
auto lineWidth = gfx_get_string_width(&buffer[currentLineIndex]);
auto lineWidth = gfx_get_string_width(&buffer[currentLineIndex], gCurrentFontSpriteBase);
if (lineWidth <= width || (splitIndex == NULL_INDEX && bestSplitIndex == NULL_INDEX))
{
if (codepoint == ' ')
@ -218,7 +218,7 @@ int32_t gfx_wrap_string(utf8* text, int32_t width, int32_t* outNumLines)
buffer.insert(buffer.begin() + splitIndex, '\0');
// Recalculate the line length after splitting
lineWidth = gfx_get_string_width(&buffer[currentLineIndex]);
lineWidth = gfx_get_string_width(&buffer[currentLineIndex], gCurrentFontSpriteBase);
maxWidth = std::max(maxWidth, lineWidth);
numLines++;
@ -238,7 +238,7 @@ int32_t gfx_wrap_string(utf8* text, int32_t width, int32_t* outNumLines)
{
buffer.push_back('\0');
auto lineWidth = gfx_get_string_width(&buffer[currentLineIndex]);
auto lineWidth = gfx_get_string_width(&buffer[currentLineIndex], gCurrentFontSpriteBase);
maxWidth = std::max(maxWidth, lineWidth);
numLines++;
@ -253,7 +253,7 @@ int32_t gfx_wrap_string(utf8* text, int32_t width, int32_t* outNumLines)
}
{
// Final line width calculation
auto lineWidth = gfx_get_string_width(&buffer[currentLineIndex]);
auto lineWidth = gfx_get_string_width(&buffer[currentLineIndex], gCurrentFontSpriteBase);
maxWidth = std::max(maxWidth, lineWidth);
}
@ -339,7 +339,7 @@ void draw_string_centred_raw(rct_drawpixelinfo* dpi, const ScreenCoordsXY& coord
for (int32_t i = 0; i <= numLines; i++)
{
int32_t width = gfx_get_string_width(text);
int32_t width = gfx_get_string_width(text, gCurrentFontSpriteBase);
gfx_draw_string(dpi, text, TEXT_COLOUR_254, screenCoords - ScreenCoordsXY{ width / 2, 0 });
const utf8* ch = text;
@ -445,7 +445,7 @@ void gfx_draw_string_centred_wrapped_partial(
lineY = coords.y - ((numLines * lineHeight) / 2);
for (int32_t line = 0; line <= numLines; line++)
{
int32_t halfWidth = gfx_get_string_width(buffer) / 2;
int32_t halfWidth = gfx_get_string_width(buffer, gCurrentFontSpriteBase) / 2;
FmtString fmt(buffer);
for (const auto& token : fmt)
@ -965,10 +965,10 @@ void ttf_draw_string(
gLastDrawStringY = info.y;
}
static int32_t ttf_get_string_width(std::string_view text, bool noFormatting)
static int32_t ttf_get_string_width(std::string_view text, FontSpriteBase fontSpriteBase, bool noFormatting)
{
text_draw_info info;
info.font_sprite_base = gCurrentFontSpriteBase;
info.font_sprite_base = fontSpriteBase;
info.flags = 0;
info.startX = 0;
info.startY = 0;
@ -1033,7 +1033,7 @@ void shorten_path(utf8* buffer, size_t bufferSize, const utf8* path, int32_t ava
size_t length = strlen(path);
// Return full string if it fits
if (gfx_get_string_width(const_cast<char*>(path)) <= availableWidth)
if (gfx_get_string_width(const_cast<char*>(path), gCurrentFontSpriteBase) <= availableWidth)
{
safe_strcpy(buffer, path, bufferSize);
return;
@ -1062,7 +1062,7 @@ void shorten_path(utf8* buffer, size_t bufferSize, const utf8* path, int32_t ava
} while (path[begin] != *PATH_SEPARATOR && path[begin] != '/');
safe_strcpy(buffer + 3, path + begin, bufferSize - 3);
if (gfx_get_string_width(buffer) <= availableWidth)
if (gfx_get_string_width(buffer, gCurrentFontSpriteBase) <= availableWidth)
{
return;
}

View File

@ -750,9 +750,9 @@ void gfx_draw_string_with_y_offsets(
bool forceSpriteFont);
int32_t gfx_wrap_string(char* buffer, int32_t width, int32_t* num_lines);
int32_t gfx_get_string_width(std::string_view text);
int32_t gfx_get_string_width_new_lined(std::string_view text);
int32_t gfx_get_string_width_no_formatting(std::string_view text);
int32_t gfx_get_string_width(std::string_view text, FontSpriteBase fontSpriteBase);
int32_t gfx_get_string_width_new_lined(std::string_view text, FontSpriteBase fontSpriteBase);
int32_t gfx_get_string_width_no_formatting(std::string_view text, FontSpriteBase fontSpriteBase);
int32_t string_get_height_raw(std::string_view text, FontSpriteBase fontBase);
int32_t gfx_clip_string(char* buffer, int32_t width);
void shorten_path(utf8* buffer, size_t bufferSize, const utf8* path, int32_t availableWidth);

View File

@ -75,7 +75,8 @@ int32_t StaticLayout::GetLineCount()
static void DrawText(
rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, const TextPaint& paint, const_utf8string text, bool noFormatting)
{
int32_t width = noFormatting ? gfx_get_string_width_no_formatting(text) : gfx_get_string_width(text);
int32_t width = noFormatting ? gfx_get_string_width_no_formatting(text, paint.SpriteBase)
: gfx_get_string_width(text, paint.SpriteBase);
auto alignedCoords = coords;
switch (paint.Alignment)

View File

@ -195,10 +195,10 @@ void chat_draw(rct_drawpixelinfo* dpi, uint8_t chatBackgroundColor)
gfx_set_dirty_blocks({ screenCoords, { screenCoords + ScreenCoordsXY{ _chatWidth, inputLineHeight + 15 } } });
// TODO: Show caret if the input text has multiple lines
if (_chatCaretTicks < 15 && gfx_get_string_width(lineBuffer) < (_chatWidth - 10))
if (_chatCaretTicks < 15 && gfx_get_string_width(lineBuffer, FontSpriteBase::MEDIUM) < (_chatWidth - 10))
{
lineBuffer.assign(_chatCurrentLine, _chatTextInputSession->SelectionStart);
int32_t caretX = screenCoords.x + gfx_get_string_width(lineBuffer);
int32_t caretX = screenCoords.x + gfx_get_string_width(lineBuffer, FontSpriteBase::MEDIUM);
int32_t caretY = screenCoords.y + 14;
gfx_fill_rect(dpi, { { caretX, caretY }, { caretX + 6, caretY + 1 } }, PALETTE_INDEX_56);

View File

@ -87,7 +87,7 @@ void Painter::PaintReplayNotice(rct_drawpixelinfo* dpi, const char* text)
char buffer[64]{};
FormatStringToBuffer(buffer, sizeof(buffer), "{MEDIUMFONT}{OUTLINE}{RED}{STRING}", text);
auto stringWidth = gfx_get_string_width(buffer);
auto stringWidth = gfx_get_string_width(buffer, FontSpriteBase::MEDIUM);
screenCoords.x = screenCoords.x - stringWidth;
if (((gCurrentTicks >> 1) & 0xF) > 4)
@ -107,7 +107,7 @@ void Painter::PaintFPS(rct_drawpixelinfo* dpi)
FormatStringToBuffer(buffer, sizeof(buffer), "{MEDIUMFONT}{OUTLINE}{WHITE}{INT32}", _currentFPS);
// Draw Text
int32_t stringWidth = gfx_get_string_width(buffer);
int32_t stringWidth = gfx_get_string_width(buffer, FontSpriteBase::MEDIUM);
screenCoords.x = screenCoords.x - (stringWidth / 2);
gfx_draw_string(dpi, buffer, 0, screenCoords);

View File

@ -115,7 +115,7 @@ void banner_paint(paint_session* session, uint8_t direction, int32_t height, con
gCurrentFontSpriteBase = FontSpriteBase::TINY;
uint16_t string_width = gfx_get_string_width(gCommonStringFormatBuffer);
uint16_t string_width = gfx_get_string_width(gCommonStringFormatBuffer, FontSpriteBase::TINY);
uint16_t scroll = (gCurrentTicks / 2) % string_width;
auto scrollIndex = scrolling_text_setup(session, STR_BANNER_TEXT_FORMAT, ft, scroll, scrollingMode, COLOUR_BLACK);
PaintAddImageAsChild(

View File

@ -185,7 +185,7 @@ static void ride_entrance_exit_paint(paint_session* session, uint8_t direction,
gCurrentFontSpriteBase = FontSpriteBase::TINY;
uint16_t stringWidth = gfx_get_string_width(entrance_string);
uint16_t stringWidth = gfx_get_string_width(entrance_string, FontSpriteBase::TINY);
uint16_t scroll = stringWidth > 0 ? (gCurrentTicks / 2) % stringWidth : 0;
PaintAddImageAsChild(
@ -293,7 +293,7 @@ static void park_entrance_paint(paint_session* session, uint8_t direction, int32
gCurrentFontSpriteBase = FontSpriteBase::TINY;
uint16_t stringWidth = gfx_get_string_width(park_name);
uint16_t stringWidth = gfx_get_string_width(park_name, FontSpriteBase::TINY);
uint16_t scroll = stringWidth > 0 ? (gCurrentTicks / 2) % stringWidth : 0;
if (entrance->scrolling_mode == SCROLLING_MODE_NONE)

View File

@ -442,7 +442,7 @@ void large_scenery_paint(paint_session* session, uint8_t direction, uint16_t hei
gCurrentFontSpriteBase = FontSpriteBase::TINY;
uint16_t stringWidth = gfx_get_string_width(signString);
uint16_t stringWidth = gfx_get_string_width(signString, FontSpriteBase::TINY);
uint16_t scroll = stringWidth > 0 ? (gCurrentTicks / 2) % stringWidth : 0;
PaintAddImageAsChild(
session, scrolling_text_setup(session, STR_SCROLLING_SIGN_TEXT, ft, scroll, scrollMode, textColour), 0, 0, 1, 1, 21,

View File

@ -472,7 +472,7 @@ static void sub_6A4101(
gCurrentFontSpriteBase = FontSpriteBase::TINY;
uint16_t stringWidth = gfx_get_string_width(gCommonStringFormatBuffer);
uint16_t stringWidth = gfx_get_string_width(gCommonStringFormatBuffer, FontSpriteBase::TINY);
uint16_t scroll = stringWidth > 0 ? (gCurrentTicks / 2) % stringWidth : 0;
PaintAddImageAsChild(

View File

@ -448,7 +448,7 @@ void fence_paint(paint_session* session, uint8_t direction, int32_t height, cons
gCurrentFontSpriteBase = FontSpriteBase::TINY;
uint16_t stringWidth = gfx_get_string_width(signString);
uint16_t stringWidth = gfx_get_string_width(signString, FontSpriteBase::TINY);
uint16_t scroll = stringWidth > 0 ? (gCurrentTicks / 2) % stringWidth : 0;
PaintAddImageAsChild(

View File

@ -443,7 +443,7 @@ void DrawOpenRCT2(rct_drawpixelinfo* dpi, const ScreenCoordsXY& screenCoords)
gfx_draw_string(dpi, buffer.c_str(), COLOUR_BLACK, screenCoords + ScreenCoordsXY(5, 5 - 13));
// Invalidate screen area
int16_t width = static_cast<int16_t>(gfx_get_string_width(buffer));
int16_t width = static_cast<int16_t>(gfx_get_string_width(buffer, FontSpriteBase::MEDIUM));
gfx_set_dirty_blocks(
{ screenCoords, screenCoords + ScreenCoordsXY{ width, 30 } }); // 30 is an arbitrary height to catch both strings

View File

@ -55,7 +55,7 @@ void MoneyEffect::CreateAt(money32 value, const CoordsXYZ& effectPos, bool verti
char buffer[128];
format_string(buffer, 128, stringId, &newValue);
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
offsetX = -(gfx_get_string_width(buffer) / 2);
offsetX = -(gfx_get_string_width(buffer, FontSpriteBase::MEDIUM) / 2);
}
moneyEffect->OffsetX = offsetX;
moneyEffect->Wiggle = 0;