From 7fd049c22e8c12db9702caf2d95626919657af9d Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sun, 28 Feb 2021 00:22:24 +0100 Subject: [PATCH] Remove last remnants of gCurrentFontSpriteBase --- src/openrct2-ui/interface/InGameConsole.cpp | 3 +- src/openrct2-ui/interface/Widget.cpp | 21 ++++---- src/openrct2-ui/scripting/CustomListView.cpp | 2 +- src/openrct2-ui/windows/Changelog.cpp | 3 -- src/openrct2-ui/windows/Dropdown.cpp | 7 ++- .../windows/EditorInventionsList.cpp | 28 +++++----- .../windows/EditorObjectSelection.cpp | 27 ++++------ .../windows/EditorObjectiveOptions.cpp | 10 ++-- src/openrct2-ui/windows/Error.cpp | 6 +-- src/openrct2-ui/windows/Finances.cpp | 2 +- src/openrct2-ui/windows/Guest.cpp | 4 +- src/openrct2-ui/windows/GuestList.cpp | 10 ++-- src/openrct2-ui/windows/InstallTrack.cpp | 4 +- src/openrct2-ui/windows/LoadSave.cpp | 11 ++-- src/openrct2-ui/windows/Multiplayer.cpp | 16 +++--- src/openrct2-ui/windows/NetworkStatus.cpp | 3 +- src/openrct2-ui/windows/NewRide.cpp | 2 +- src/openrct2-ui/windows/ObjectLoadError.cpp | 2 +- src/openrct2-ui/windows/Options.cpp | 2 +- src/openrct2-ui/windows/Park.cpp | 2 +- src/openrct2-ui/windows/Player.cpp | 4 +- src/openrct2-ui/windows/Ride.cpp | 8 +-- src/openrct2-ui/windows/RideList.cpp | 4 +- src/openrct2-ui/windows/ScenarioSelect.cpp | 17 +++--- src/openrct2-ui/windows/Scenery.cpp | 3 +- src/openrct2-ui/windows/ServerList.cpp | 4 +- src/openrct2-ui/windows/ShortcutKeys.cpp | 4 +- src/openrct2-ui/windows/Staff.cpp | 2 +- src/openrct2-ui/windows/StaffList.cpp | 4 +- src/openrct2-ui/windows/TextInput.cpp | 8 ++- src/openrct2-ui/windows/Themes.cpp | 3 +- src/openrct2-ui/windows/TileInspector.cpp | 17 +++--- .../windows/TitleCommandEditor.cpp | 14 ++--- src/openrct2-ui/windows/TitleEditor.cpp | 2 +- src/openrct2-ui/windows/Tooltip.cpp | 11 ++-- src/openrct2-ui/windows/TopToolbar.cpp | 1 - src/openrct2-ui/windows/TrackList.cpp | 8 +-- src/openrct2/drawing/Drawing.String.cpp | 54 +++++++++---------- src/openrct2/drawing/Drawing.cpp | 2 - src/openrct2/drawing/Drawing.h | 18 +++---- src/openrct2/drawing/Text.cpp | 22 +++----- src/openrct2/drawing/Text.h | 2 +- src/openrct2/interface/Chat.cpp | 15 ++---- src/openrct2/paint/Paint.cpp | 4 +- .../paint/tile_element/Paint.Banner.cpp | 2 - .../paint/tile_element/Paint.Entrance.cpp | 4 -- .../paint/tile_element/Paint.LargeScenery.cpp | 2 - .../paint/tile_element/Paint.Path.cpp | 2 - .../paint/tile_element/Paint.Wall.cpp | 2 - src/openrct2/world/MoneyEffect.cpp | 1 - 50 files changed, 169 insertions(+), 240 deletions(-) diff --git a/src/openrct2-ui/interface/InGameConsole.cpp b/src/openrct2-ui/interface/InGameConsole.cpp index 266635beca..ec761503c7 100644 --- a/src/openrct2-ui/interface/InGameConsole.cpp +++ b/src/openrct2-ui/interface/InGameConsole.cpp @@ -276,7 +276,6 @@ void InGameConsole::Draw(rct_drawpixelinfo* dpi) const return; // Set font - gCurrentFontSpriteBase = InGameconsoleGetFontSpriteBase(); uint8_t textColour = NOT_TRANSLUCENT(ThemeGetColour(WC_CONSOLE, 1)); const int32_t lineHeight = InGameConsoleGetLineHeight(); const int32_t maxLines = GetNumVisibleLines(); @@ -330,7 +329,7 @@ void InGameConsole::Draw(rct_drawpixelinfo* dpi) const // Draw current line lineBuffer = colourFormatStr + _consoleCurrentLine; - gfx_draw_string_no_formatting(dpi, lineBuffer.c_str(), TEXT_COLOUR_255, screenCoords); + gfx_draw_string_no_formatting(dpi, screenCoords, lineBuffer.c_str(), { TEXT_COLOUR_255, InGameconsoleGetFontSpriteBase() }); // Draw caret if (_consoleCaretTicks < CONSOLE_CARET_FLASH_THRESHOLD) diff --git a/src/openrct2-ui/interface/Widget.cpp b/src/openrct2-ui/interface/Widget.cpp index 5c4812870f..957450ea75 100644 --- a/src/openrct2-ui/interface/Widget.cpp +++ b/src/openrct2-ui/interface/Widget.cpp @@ -333,7 +333,7 @@ static void WidgetTextCentred(rct_drawpixelinfo* dpi, rct_window* w, rct_widgeti return; // Get the colour - uint8_t colour = w->colours[widget->colour]; + colour_t colour = w->colours[widget->colour]; colour &= ~(COLOUR_FLAG_TRANSLUCENT); if (WidgetIsDisabled(w, widgetIndex)) colour |= COLOUR_FLAG_INSET; @@ -362,7 +362,7 @@ static void WidgetTextCentred(rct_drawpixelinfo* dpi, rct_window* w, rct_widgeti } else { - DrawTextEllipsised(dpi, coords, widget->width() - 2, stringId, ft, colour, TextAlignment::CENTRE); + DrawTextEllipsised(dpi, coords, widget->width() - 2, stringId, ft, { colour, TextAlignment::CENTRE }); } } @@ -563,7 +563,7 @@ static void WidgetCaptionDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widgeti } topLeft.x += width / 2; DrawTextEllipsised( - dpi, topLeft, width, widget->text, Formatter::Common(), COLOUR_WHITE | COLOUR_FLAG_OUTLINE, TextAlignment::CENTRE); + dpi, topLeft, width, widget->text, Formatter::Common(), { COLOUR_WHITE | COLOUR_FLAG_OUTLINE, TextAlignment::CENTRE }); } /** @@ -600,7 +600,7 @@ static void WidgetCloseboxDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widget if (WidgetIsDisabled(w, widgetIndex)) colour |= COLOUR_FLAG_INSET; - DrawTextEllipsised(dpi, topLeft, widget->width() - 2, widget->text, Formatter::Common(), colour, TextAlignment::CENTRE); + DrawTextEllipsised(dpi, topLeft, widget->width() - 2, widget->text, Formatter::Common(), { colour, TextAlignment::CENTRE }); } /** @@ -671,8 +671,6 @@ static void WidgetScrollDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widgetin bottomRight.x--; bottomRight.y--; - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; - // Horizontal scrollbar if (scroll->flags & HSCROLLBAR_VISIBLE) WidgetHScrollbarDraw( @@ -1105,8 +1103,6 @@ static void WidgetTextBoxDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widgeti // gfx_fill_rect_inset(dpi, l, t, r, b, colour, 0x20 | (!active ? 0x40 : 0x00)); gfx_fill_rect_inset(dpi, { topLeft, bottomRight }, colour, INSET_RECT_F_60); - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; - // Figure out where the text should be positioned vertically. topLeft.y = w->windowPos.y + widget->textTop(); @@ -1115,8 +1111,9 @@ static void WidgetTextBoxDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widgeti if (w->widgets[widgetIndex].text != 0) { safe_strcpy(wrapped_string, w->widgets[widgetIndex].string, 512); - gfx_wrap_string(wrapped_string, bottomRight.x - topLeft.x - 5, &no_lines); - gfx_draw_string_no_formatting(dpi, wrapped_string, w->colours[1], { topLeft.x + 2, topLeft.y }); + gfx_wrap_string(wrapped_string, bottomRight.x - topLeft.x - 5, FontSpriteBase::MEDIUM, &no_lines); + gfx_draw_string_no_formatting( + dpi, { topLeft.x + 2, topLeft.y }, wrapped_string, { w->colours[1], FontSpriteBase::MEDIUM }); } return; } @@ -1125,9 +1122,9 @@ static void WidgetTextBoxDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widgeti // String length needs to add 12 either side of box // +13 for cursor when max length. - gfx_wrap_string(wrapped_string, bottomRight.x - topLeft.x - 5 - 6, &no_lines); + gfx_wrap_string(wrapped_string, bottomRight.x - topLeft.x - 5 - 6, FontSpriteBase::MEDIUM, &no_lines); - gfx_draw_string_no_formatting(dpi, wrapped_string, w->colours[1], { topLeft.x + 2, topLeft.y }); + gfx_draw_string_no_formatting(dpi, { topLeft.x + 2, topLeft.y }, wrapped_string, { w->colours[1], FontSpriteBase::MEDIUM }); size_t string_length = get_string_size(wrapped_string) - 1; diff --git a/src/openrct2-ui/scripting/CustomListView.cpp b/src/openrct2-ui/scripting/CustomListView.cpp index ca36bcbd76..96611dbfb7 100644 --- a/src/openrct2-ui/scripting/CustomListView.cpp +++ b/src/openrct2-ui/scripting/CustomListView.cpp @@ -758,7 +758,7 @@ void CustomListView::PaintCell( auto ft = Formatter(); ft.Add(STR_STRING); ft.Add(text); - DrawTextEllipsised(dpi, pos, size.width, stringId, ft, COLOUR_BLACK); + DrawTextEllipsised(dpi, pos, size.width, stringId, ft, {}); } std::optional CustomListView::GetItemIndexAt(const ScreenCoordsXY& pos) diff --git a/src/openrct2-ui/windows/Changelog.cpp b/src/openrct2-ui/windows/Changelog.cpp index 1ecd96981c..7e5cbeb216 100644 --- a/src/openrct2-ui/windows/Changelog.cpp +++ b/src/openrct2-ui/windows/Changelog.cpp @@ -213,8 +213,6 @@ static void window_changelog_paint(rct_window* w, rct_drawpixelinfo* dpi) static void window_changelog_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, [[maybe_unused]] int32_t scrollIndex) { - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; - const int32_t lineHeight = font_get_line_height(FontSpriteBase::MEDIUM); ScreenCoordsXY screenCoords(3, 3 - lineHeight); @@ -241,7 +239,6 @@ static void window_changelog_process_changelog_text(const std::string& text) // To get the last substring (or only, if delimiter is not found) _changelogLines.push_back(text.substr(prev)); - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; _changelogLongestLineWidth = 0; for (const auto& line : _changelogLines) { diff --git a/src/openrct2-ui/windows/Dropdown.cpp b/src/openrct2-ui/windows/Dropdown.cpp index e670fe6f4e..fe313ec380 100644 --- a/src/openrct2-ui/windows/Dropdown.cpp +++ b/src/openrct2-ui/windows/Dropdown.cpp @@ -118,7 +118,6 @@ void WindowDropdownShowText(const ScreenCoordsXY& screenPos, int32_t extray, uin for (size_t i = 0; i < num_items; i++) { format_string(buffer, 256, gDropdownItemsFormat[i], static_cast(&gDropdownItemsArgs[i])); - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; string_width = gfx_get_string_width(buffer, FontSpriteBase::MEDIUM); max_string_width = std::max(string_width, max_string_width); } @@ -287,7 +286,7 @@ void WindowDropdownClose() static void window_dropdown_paint(rct_window* w, rct_drawpixelinfo* dpi) { - int32_t cell_x, cell_y, l, t, r, b, item, image, colour; + int32_t cell_x, cell_y, l, t, r, b, item, image; WindowDrawWidgets(w, dpi); @@ -362,7 +361,7 @@ static void window_dropdown_paint(rct_window* w, rct_drawpixelinfo* dpi) } // Calculate colour - colour = NOT_TRANSLUCENT(w->colours[0]); + colour_t colour = NOT_TRANSLUCENT(w->colours[0]); if (i == highlightedIndex) colour = COLOUR_WHITE; if (Dropdown::IsDisabled(i)) @@ -373,7 +372,7 @@ static void window_dropdown_paint(rct_window* w, rct_drawpixelinfo* dpi) ScreenCoordsXY screenCoords = { w->windowPos.x + 2 + (cell_x * _dropdown_item_width), w->windowPos.y + 2 + (cell_y * _dropdown_item_height) }; Formatter ft(reinterpret_cast(&gDropdownItemsArgs[i])); - DrawTextEllipsised(dpi, screenCoords, w->width - 5, item, ft, colour); + DrawTextEllipsised(dpi, screenCoords, w->width - 5, item, ft, { colour }); } } } diff --git a/src/openrct2-ui/windows/EditorInventionsList.cpp b/src/openrct2-ui/windows/EditorInventionsList.cpp index 87bfca53f9..f532f1db8e 100644 --- a/src/openrct2-ui/windows/EditorInventionsList.cpp +++ b/src/openrct2-ui/windows/EditorInventionsList.cpp @@ -561,7 +561,7 @@ static void window_editor_inventions_list_paint(rct_window* w, rct_drawpixelinfo width = w->width - w->widgets[WIDX_RESEARCH_ORDER_SCROLL].right - 6; auto [drawString, ft] = window_editor_inventions_list_prepare_name(researchItem, false); - DrawTextEllipsised(dpi, screenPos, width, drawString, ft, COLOUR_BLACK, TextAlignment::CENTRE); + DrawTextEllipsised(dpi, screenPos, width, drawString, ft, { TextAlignment::CENTRE }); screenPos.y += 15; // Item category @@ -613,22 +613,19 @@ static void window_editor_inventions_list_scrollpaint(rct_window* w, rct_drawpix if (researchItem.Equals(&_editorInventionsListDraggedItem)) continue; - uint8_t colour; + // TODO: this parameter by itself produces very light text. + // It needs a {BLACK} token in the string to work properly. + colour_t colour = COLOUR_BLACK; + FontSpriteBase fontSpriteBase = FontSpriteBase::MEDIUM; + if (researchItem.IsAlwaysResearched()) { if (w->research_item == &researchItem && _editorInventionsListDraggedItem.IsNull()) - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM_EXTRA_DARK; + fontSpriteBase = FontSpriteBase::MEDIUM_EXTRA_DARK; else - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM_DARK; + fontSpriteBase = FontSpriteBase::MEDIUM_DARK; colour = w->colours[1] | COLOUR_FLAG_INSET; } - else - { - // TODO: this parameter by itself produces very light text. - // It needs a {BLACK} token in the string to work properly. - colour = COLOUR_BLACK; - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; - } const rct_string_id itemNameId = researchItem.GetName(); @@ -642,19 +639,22 @@ static void window_editor_inventions_list_scrollpaint(rct_window* w, rct_drawpix auto ft = Formatter(); ft.Add(rideTypeName); DrawTextEllipsised( - dpi, { 1, itemY }, columnSplitOffset - 11, STR_INVENTIONS_LIST_RIDE_AND_VEHICLE_NAME, ft, colour); + dpi, { 1, itemY }, columnSplitOffset - 11, STR_INVENTIONS_LIST_RIDE_AND_VEHICLE_NAME, ft, + { colour, fontSpriteBase }); // Draw vehicle name ft = Formatter(); ft.Add(itemNameId); - DrawTextEllipsised(dpi, { columnSplitOffset + 1, itemY }, columnSplitOffset - 11, STR_BLACK_STRING, ft, colour); + DrawTextEllipsised( + dpi, { columnSplitOffset + 1, itemY }, columnSplitOffset - 11, STR_BLACK_STRING, ft, + { colour, fontSpriteBase }); } else { // Scenery group, flat ride or shop auto ft = Formatter(); ft.Add(itemNameId); - DrawTextEllipsised(dpi, { 1, itemY }, boxWidth, STR_BLACK_STRING, ft, colour); + DrawTextEllipsised(dpi, { 1, itemY }, boxWidth, STR_BLACK_STRING, ft, { colour, fontSpriteBase }); } } } diff --git a/src/openrct2-ui/windows/EditorObjectSelection.cpp b/src/openrct2-ui/windows/EditorObjectSelection.cpp index 5bbe1921d4..f6fef734f7 100644 --- a/src/openrct2-ui/windows/EditorObjectSelection.cpp +++ b/src/openrct2-ui/windows/EditorObjectSelection.cpp @@ -1018,7 +1018,7 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf : STR_NONE; ft.Add(stringId); auto screenPos = w->windowPos + ScreenCoordsXY{ widget->left + 1, widget->top + 1 }; - DrawTextEllipsised(dpi, screenPos, widget->width(), STR_OBJECTS_SORT_TYPE, ft, w->colours[1]); + DrawTextEllipsised(dpi, screenPos, widget->width(), STR_OBJECTS_SORT_TYPE, ft, { w->colours[1] }); } widget = &w->widgets[WIDX_LIST_SORT_RIDE]; if (widget->type != WindowWidgetType::Empty) @@ -1028,7 +1028,7 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf : STR_NONE; ft.Add(stringId); auto screenPos = w->windowPos + ScreenCoordsXY{ widget->left + 1, widget->top + 1 }; - DrawTextEllipsised(dpi, screenPos, widget->width(), STR_OBJECTS_SORT_RIDE, ft, w->colours[1]); + DrawTextEllipsised(dpi, screenPos, widget->width(), STR_OBJECTS_SORT_RIDE, ft, { w->colours[1] }); } if (w->selected_list_item == -1 || _loadedObject == nullptr) @@ -1056,7 +1056,7 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf auto ft = Formatter(); ft.Add(STR_STRING); ft.Add(listItem->repositoryItem->Name.c_str()); - DrawTextEllipsised(dpi, screenPos, width, STR_WINDOW_COLOUR_2_STRINGID, ft, COLOUR_BLACK, TextAlignment::CENTRE); + DrawTextEllipsised(dpi, screenPos, width, STR_WINDOW_COLOUR_2_STRINGID, ft, { TextAlignment::CENTRE }); } // Draw description of object @@ -1117,7 +1117,7 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf ft.Add(authorsString.c_str()); DrawTextEllipsised( dpi, { w->windowPos.x + w->width - 5, screenPos.y }, w->width - w->widgets[WIDX_LIST].right - 4, - STR_WINDOW_COLOUR_2_STRINGID, ft, COLOUR_BLACK, TextAlignment::RIGHT); + STR_WINDOW_COLOUR_2_STRINGID, ft, { TextAlignment::RIGHT }); } } /** @@ -1126,7 +1126,6 @@ static void window_editor_object_selection_paint(rct_window* w, rct_drawpixelinf */ static void window_editor_object_selection_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t scrollIndex) { - int32_t colour, colour2; ScreenCoordsXY screenCoords; bool ridePage = (get_selected_object_type(w) == ObjectType::Ride); @@ -1155,9 +1154,8 @@ static void window_editor_object_selection_scrollpaint(rct_window* w, rct_drawpi if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) && (*listItem.flags & OBJECT_SELECTION_FLAG_SELECTED)) { screenCoords.x = 2; - FontSpriteBase fontSpriteBase = highlighted ? FontSpriteBase::MEDIUM_EXTRA_DARK : FontSpriteBase::MEDIUM_DARK; - gCurrentFontSpriteBase = fontSpriteBase; - colour2 = NOT_TRANSLUCENT(w->colours[1]); + FontSpriteBase fontSpriteBase = highlighted ? FontSpriteBase::MEDIUM_EXTRA_DARK : FontSpriteBase::MEDIUM_DARK; + colour_t colour2 = NOT_TRANSLUCENT(w->colours[1]); if (*listItem.flags & (OBJECT_SELECTION_FLAG_IN_USE | OBJECT_SELECTION_FLAG_ALWAYS_REQUIRED)) colour2 |= COLOUR_FLAG_INSET; @@ -1171,15 +1169,12 @@ static void window_editor_object_selection_scrollpaint(rct_window* w, rct_drawpi auto bufferWithColour = strcpy(gCommonStringFormatBuffer, highlighted ? "{WINDOW_COLOUR_2}" : "{BLACK}"); auto buffer = strchr(bufferWithColour, '\0'); + colour_t colour = COLOUR_BLACK; + FontSpriteBase fontSpriteBase = FontSpriteBase::MEDIUM; if (*listItem.flags & OBJECT_SELECTION_FLAG_6) { colour = w->colours[1] & 0x7F; - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM_DARK; - } - else - { - colour = COLOUR_BLACK; - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; + fontSpriteBase = FontSpriteBase::MEDIUM_DARK; } int32_t width_limit = w->widgets[WIDX_LIST].width() - screenCoords.x; @@ -1192,7 +1187,7 @@ static void window_editor_object_selection_scrollpaint(rct_window* w, rct_drawpi safe_strcpy(buffer, language_get_string(rideTypeStringId), 256 - (buffer - bufferWithColour)); auto ft = Formatter(); ft.Add(gCommonStringFormatBuffer); - DrawTextEllipsised(dpi, screenCoords, width_limit - 15, STR_STRING, ft, colour); + DrawTextEllipsised(dpi, screenCoords, width_limit - 15, STR_STRING, ft, { colour, fontSpriteBase }); screenCoords.x = w->widgets[WIDX_LIST_SORT_RIDE].left - w->widgets[WIDX_LIST].left; } @@ -1207,7 +1202,7 @@ static void window_editor_object_selection_scrollpaint(rct_window* w, rct_drawpi } auto ft = Formatter(); ft.Add(gCommonStringFormatBuffer); - DrawTextEllipsised(dpi, screenCoords, width_limit, STR_STRING, ft, colour); + DrawTextEllipsised(dpi, screenCoords, width_limit, STR_STRING, ft, { colour, fontSpriteBase }); } screenCoords.y += SCROLLABLE_ROW_HEIGHT; } diff --git a/src/openrct2-ui/windows/EditorObjectiveOptions.cpp b/src/openrct2-ui/windows/EditorObjectiveOptions.cpp index 20aa1636b8..cf7037e82a 100644 --- a/src/openrct2-ui/windows/EditorObjectiveOptions.cpp +++ b/src/openrct2-ui/windows/EditorObjectiveOptions.cpp @@ -890,7 +890,7 @@ static void window_editor_objective_options_main_paint(rct_window* w, rct_drawpi auto ft = Formatter(); ft.Add(STR_STRING); ft.Add(parkName); - DrawTextEllipsised(dpi, screenCoords, width, STR_WINDOW_PARK_NAME, ft, COLOUR_BLACK); + DrawTextEllipsised(dpi, screenCoords, width, STR_WINDOW_PARK_NAME, ft); } // Scenario name @@ -900,7 +900,7 @@ static void window_editor_objective_options_main_paint(rct_window* w, rct_drawpi auto ft = Formatter(); ft.Add(STR_STRING); ft.Add(gS6Info.name); - DrawTextEllipsised(dpi, screenCoords, width, STR_WINDOW_SCENARIO_NAME, ft, COLOUR_BLACK); + DrawTextEllipsised(dpi, screenCoords, width, STR_WINDOW_SCENARIO_NAME, ft); // Scenario details label screenCoords = w->windowPos + ScreenCoordsXY{ 8, w->widgets[WIDX_DETAILS].top }; @@ -1099,11 +1099,11 @@ static void window_editor_objective_options_rides_scrollpaint(rct_window* w, rct { if (ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE) { - gCurrentFontSpriteBase = stringId == STR_WINDOW_COLOUR_2_STRINGID ? FontSpriteBase::MEDIUM_EXTRA_DARK - : FontSpriteBase::MEDIUM_DARK; + FontSpriteBase fontSpriteBase = stringId == STR_WINDOW_COLOUR_2_STRINGID ? FontSpriteBase::MEDIUM_EXTRA_DARK + : FontSpriteBase::MEDIUM_DARK; gfx_draw_string( dpi, { 2, y }, static_cast(CheckBoxMarkString), - { static_cast(w->colours[1] & 0x7F) }); + { static_cast(w->colours[1] & 0x7F), fontSpriteBase }); } // Ride name diff --git a/src/openrct2-ui/windows/Error.cpp b/src/openrct2-ui/windows/Error.cpp index ba7ce0a172..f531feb90d 100644 --- a/src/openrct2-ui/windows/Error.cpp +++ b/src/openrct2-ui/windows/Error.cpp @@ -83,12 +83,10 @@ rct_window* window_error_open(std::string_view title, std::string_view message) if (buffer.size() <= 1) return nullptr; - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; width = gfx_get_string_width_new_lined(buffer.data(), FontSpriteBase::MEDIUM); width = std::clamp(width, 64, 196); - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; - gfx_wrap_string(buffer.data(), width + 1, &numLines); + gfx_wrap_string(buffer.data(), width + 1, FontSpriteBase::MEDIUM, &numLines); _window_error_num_lines = numLines; width = width + 3; @@ -160,5 +158,5 @@ static void window_error_paint(rct_window* w, rct_drawpixelinfo* dpi) l = w->windowPos.x + (w->width + 1) / 2 - 1; t = w->windowPos.y + 1; - draw_string_centred_raw(dpi, { l, t }, _window_error_num_lines, _window_error_text.data()); + draw_string_centred_raw(dpi, { l, t }, _window_error_num_lines, _window_error_text.data(), FontSpriteBase::MEDIUM); } diff --git a/src/openrct2-ui/windows/Finances.cpp b/src/openrct2-ui/windows/Finances.cpp index 4924ec3e53..3b4c2ef5f6 100644 --- a/src/openrct2-ui/windows/Finances.cpp +++ b/src/openrct2-ui/windows/Finances.cpp @@ -1099,7 +1099,7 @@ static void window_finances_marketing_paint(rct_window* w, rct_drawpixelinfo* dp } // Advertisement - DrawTextEllipsised(dpi, screenCoords + ScreenCoordsXY{ 4, 0 }, 296, MarketingCampaignNames[i][1], ft, COLOUR_BLACK); + DrawTextEllipsised(dpi, screenCoords + ScreenCoordsXY{ 4, 0 }, 296, MarketingCampaignNames[i][1], ft); // Duration uint16_t weeksRemaining = campaign->WeeksLeft; diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index 148ac757d0..fe16272cb2 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -978,7 +978,7 @@ void window_guest_overview_paint(rct_window* w, rct_drawpixelinfo* dpi) auto ft = Formatter(); peep->FormatActionTo(ft); int32_t width = widget->width(); - DrawTextEllipsised(dpi, screenPos, width, STR_BLACK_STRING, ft, COLOUR_BLACK, TextAlignment::CENTRE); + DrawTextEllipsised(dpi, screenPos, width, STR_BLACK_STRING, ft, { TextAlignment::CENTRE }); } // Draw the marquee thought @@ -1585,7 +1585,7 @@ void window_guest_rides_paint(rct_window* w, rct_drawpixelinfo* dpi) ft.Add(STR_PEEP_FAVOURITE_RIDE_NOT_AVAILABLE); } - DrawTextEllipsised(dpi, screenCoords, w->width - 14, STR_FAVOURITE_RIDE, ft, COLOUR_BLACK); + DrawTextEllipsised(dpi, screenCoords, w->width - 14, STR_FAVOURITE_RIDE, ft); } /** diff --git a/src/openrct2-ui/windows/GuestList.cpp b/src/openrct2-ui/windows/GuestList.cpp index aa183e553f..831cc2e363 100644 --- a/src/openrct2-ui/windows/GuestList.cpp +++ b/src/openrct2-ui/windows/GuestList.cpp @@ -472,7 +472,7 @@ public: { Formatter ft(_filterArguments.args); - DrawTextEllipsised(&dpi, screenCoords, 310, format, ft, COLOUR_BLACK); + DrawTextEllipsised(&dpi, screenCoords, 310, format, ft); } // Number of guests (list items) @@ -677,7 +677,7 @@ private: } auto ft = Formatter(); peep->FormatNameTo(ft); - DrawTextEllipsised(&dpi, { 0, y }, 113, format, ft, COLOUR_BLACK); + DrawTextEllipsised(&dpi, { 0, y }, 113, format, ft); switch (_selectedView) { @@ -692,7 +692,7 @@ private: // Action ft = Formatter(); peep->FormatActionTo(ft); - DrawTextEllipsised(&dpi, { 133, y }, 314, format, ft, COLOUR_BLACK); + DrawTextEllipsised(&dpi, { 133, y }, 314, format, ft); break; case GuestViewType::Thoughts: // For each thought @@ -707,7 +707,7 @@ private: ft = Formatter(); peep_thought_set_format_args(&thought, ft); - DrawTextEllipsised(&dpi, { 118, y }, 329, format, ft, COLOUR_BLACK); + DrawTextEllipsised(&dpi, { 118, y }, 329, format, ft); break; } break; @@ -749,7 +749,7 @@ private: // Draw action Formatter ft(group.Arguments.args); - DrawTextEllipsised(&dpi, { 0, y }, 414, format, ft, COLOUR_BLACK); + DrawTextEllipsised(&dpi, { 0, y }, 414, format, ft); // Draw guest count ft = Formatter(); diff --git a/src/openrct2-ui/windows/InstallTrack.cpp b/src/openrct2-ui/windows/InstallTrack.cpp index 780e692f82..c6f241b05b 100644 --- a/src/openrct2-ui/windows/InstallTrack.cpp +++ b/src/openrct2-ui/windows/InstallTrack.cpp @@ -220,7 +220,7 @@ static void window_install_track_paint(rct_window* w, rct_drawpixelinfo* dpi) { // Scenery not available DrawTextEllipsised( - dpi, screenPos, 308, STR_DESIGN_INCLUDES_SCENERY_WHICH_IS_UNAVAILABLE, {}, COLOUR_BLACK, TextAlignment::CENTRE); + dpi, screenPos, 308, STR_DESIGN_INCLUDES_SCENERY_WHICH_IS_UNAVAILABLE, {}, { TextAlignment::CENTRE }); screenPos.y -= LIST_ROW_HEIGHT; } } @@ -317,7 +317,7 @@ static void window_install_track_paint(rct_window* w, rct_drawpixelinfo* dpi) auto ft = Formatter(); ft.Add(STR_RIDE_LENGTH_ENTRY); ft.Add(td6->ride_length); - DrawTextEllipsised(dpi, screenPos, 214, STR_TRACK_LIST_RIDE_LENGTH, ft, COLOUR_BLACK); + DrawTextEllipsised(dpi, screenPos, 214, STR_TRACK_LIST_RIDE_LENGTH, ft); screenPos.y += LIST_ROW_HEIGHT; } diff --git a/src/openrct2-ui/windows/LoadSave.cpp b/src/openrct2-ui/windows/LoadSave.cpp index 5ed23c8926..bf2f68c314 100644 --- a/src/openrct2-ui/windows/LoadSave.cpp +++ b/src/openrct2-ui/windows/LoadSave.cpp @@ -692,7 +692,7 @@ static void window_loadsave_paint(rct_window* w, rct_drawpixelinfo* dpi) if (_shortenedDirectory[0] == '\0') { - shorten_path(_shortenedDirectory, sizeof(_shortenedDirectory), _directory, w->width - 8); + shorten_path(_shortenedDirectory, sizeof(_shortenedDirectory), _directory, w->width - 8, FontSpriteBase::MEDIUM); } // Format text @@ -703,7 +703,7 @@ static void window_loadsave_paint(rct_window* w, rct_drawpixelinfo* dpi) // Draw path text auto ft = Formatter(); ft.Add(Platform::StrDecompToPrecomp(buffer.data())); - DrawTextEllipsised(dpi, { w->windowPos.x + 4, w->windowPos.y + 20 }, w->width - 8, STR_STRING, ft, COLOUR_BLACK); + DrawTextEllipsised(dpi, { w->windowPos.x + 4, w->windowPos.y + 20 }, w->width - 8, STR_STRING, ft); // Name button text rct_string_id id = STR_NONE; @@ -770,7 +770,7 @@ static void window_loadsave_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, i ft.Add(STR_STRING); ft.Add(_listItems[i].name.c_str()); int32_t max_file_width = w->widgets[WIDX_SORT_NAME].width() - 10; - DrawTextEllipsised(dpi, { 10, y }, max_file_width, stringId, ft, COLOUR_BLACK); + DrawTextEllipsised(dpi, { 10, y }, max_file_width, stringId, ft); // Print formatted modified date, if this is a file if (_listItems[i].type == TYPE_FILE) @@ -778,13 +778,12 @@ static void window_loadsave_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, i ft = Formatter(); ft.Add(STR_STRING); ft.Add(_listItems[i].date_formatted.c_str()); - DrawTextEllipsised( - dpi, { dateAnchor - DATE_TIME_GAP, y }, maxDateWidth, stringId, ft, COLOUR_BLACK, TextAlignment::RIGHT); + DrawTextEllipsised(dpi, { dateAnchor - DATE_TIME_GAP, y }, maxDateWidth, stringId, ft, { TextAlignment::RIGHT }); ft = Formatter(); ft.Add(STR_STRING); ft.Add(_listItems[i].time_formatted.c_str()); - DrawTextEllipsised(dpi, { dateAnchor + DATE_TIME_GAP, y }, maxTimeWidth, stringId, ft, COLOUR_BLACK); + DrawTextEllipsised(dpi, { dateAnchor + DATE_TIME_GAP, y }, maxTimeWidth, stringId, ft); } } } diff --git a/src/openrct2-ui/windows/Multiplayer.cpp b/src/openrct2-ui/windows/Multiplayer.cpp index 9f1b61e714..a17bdf19cb 100644 --- a/src/openrct2-ui/windows/Multiplayer.cpp +++ b/src/openrct2-ui/windows/Multiplayer.cpp @@ -336,8 +336,6 @@ static ScreenCoordsXY window_multiplayer_information_get_size() return _windowInformationSize; } - // Reset font sprite base and compute line height - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; int32_t lineHeight = font_get_line_height(FontSpriteBase::MEDIUM); // Base dimensions. @@ -348,7 +346,7 @@ static ScreenCoordsXY window_multiplayer_information_get_size() // Server name is displayed word-wrapped, so figure out how high it will be. { utf8* buffer = _strdup(network_get_server_name()); - gfx_wrap_string(buffer, width, &numLines); + gfx_wrap_string(buffer, width, FontSpriteBase::MEDIUM, &numLines); free(buffer); height += ++numLines * lineHeight + (LIST_ROW_HEIGHT / 2); } @@ -358,7 +356,7 @@ static ScreenCoordsXY window_multiplayer_information_get_size() if (!str_is_null_or_empty(descString)) { utf8* buffer = _strdup(descString); - gfx_wrap_string(buffer, width, &numLines); + gfx_wrap_string(buffer, width, FontSpriteBase::MEDIUM, &numLines); free(buffer); height += ++numLines * lineHeight + (LIST_ROW_HEIGHT / 2); } @@ -602,7 +600,7 @@ static void window_multiplayer_players_scrollpaint(rct_window* w, rct_drawpixeli buffer += network_get_player_name(i); } screenCoords.x = 0; - gfx_clip_string(buffer.data(), 230); + gfx_clip_string(buffer.data(), 230, FontSpriteBase::MEDIUM); gfx_draw_string(dpi, screenCoords, buffer.c_str(), { colour }); // Draw group name @@ -613,7 +611,7 @@ static void window_multiplayer_players_scrollpaint(rct_window* w, rct_drawpixeli buffer += "{BLACK}"; screenCoords.x = 173; buffer += network_get_group_name(group); - gfx_clip_string(buffer.data(), 80); + gfx_clip_string(buffer.data(), 80, FontSpriteBase::MEDIUM); gfx_draw_string(dpi, screenCoords, buffer.c_str(), { colour }); } @@ -628,7 +626,7 @@ static void window_multiplayer_players_scrollpaint(rct_window* w, rct_drawpixeli { ft.Add(STR_ACTION_NA); } - DrawTextEllipsised(dpi, { 256, screenCoords.y }, 100, STR_BLACK_STRING, ft, COLOUR_BLACK); + DrawTextEllipsised(dpi, { 256, screenCoords.y }, 100, STR_BLACK_STRING, ft); // Draw ping buffer.resize(0); @@ -845,7 +843,7 @@ static void window_multiplayer_groups_paint(rct_window* w, rct_drawpixelinfo* dp ft.Add(buffer.c_str()); DrawTextEllipsised( dpi, w->windowPos + ScreenCoordsXY{ widget->midX() - 5, widget->top }, widget->width() - 8, STR_STRING, ft, - COLOUR_BLACK, TextAlignment::CENTRE); + { TextAlignment::CENTRE }); } auto screenPos = w->windowPos @@ -869,7 +867,7 @@ static void window_multiplayer_groups_paint(rct_window* w, rct_drawpixelinfo* dp ft.Add(buffer.c_str()); DrawTextEllipsised( dpi, w->windowPos + ScreenCoordsXY{ widget->midX() - 5, widget->top }, widget->width() - 8, STR_STRING, ft, - COLOUR_BLACK, TextAlignment::CENTRE); + { TextAlignment::CENTRE }); } } diff --git a/src/openrct2-ui/windows/NetworkStatus.cpp b/src/openrct2-ui/windows/NetworkStatus.cpp index 42aa242eca..af556fb4c0 100644 --- a/src/openrct2-ui/windows/NetworkStatus.cpp +++ b/src/openrct2-ui/windows/NetworkStatus.cpp @@ -155,12 +155,11 @@ static void window_network_status_invalidate(rct_window* w) static void window_network_status_paint(rct_window* w, rct_drawpixelinfo* dpi) { WindowDrawWidgets(w, dpi); - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; thread_local std::string buffer; buffer.assign("{BLACK}"); buffer += window_network_status_text; - gfx_clip_string(buffer.data(), w->widgets[WIDX_BACKGROUND].right - 50); + gfx_clip_string(buffer.data(), w->widgets[WIDX_BACKGROUND].right - 50, FontSpriteBase::MEDIUM); ScreenCoordsXY screenCoords(w->windowPos.x + (w->width / 2), w->windowPos.y + (w->height / 2)); screenCoords.x -= gfx_get_string_width(buffer, FontSpriteBase::MEDIUM) / 2; gfx_draw_string(dpi, screenCoords, buffer.c_str()); diff --git a/src/openrct2-ui/windows/NewRide.cpp b/src/openrct2-ui/windows/NewRide.cpp index ce3fd445fd..11739f1077 100644 --- a/src/openrct2-ui/windows/NewRide.cpp +++ b/src/openrct2-ui/windows/NewRide.cpp @@ -911,7 +911,7 @@ static void window_new_ride_paint_ride_information( const char* drawString = availabilityString; ft = Formatter(); ft.Add(drawString); - DrawTextEllipsised(dpi, screenPos + ScreenCoordsXY{ 0, 39 }, WW - 2, STR_AVAILABLE_VEHICLES, ft, COLOUR_BLACK); + DrawTextEllipsised(dpi, screenPos + ScreenCoordsXY{ 0, 39 }, WW - 2, STR_AVAILABLE_VEHICLES, ft); } ft = Formatter(); diff --git a/src/openrct2-ui/windows/ObjectLoadError.cpp b/src/openrct2-ui/windows/ObjectLoadError.cpp index 409c1d710a..eb75214192 100644 --- a/src/openrct2-ui/windows/ObjectLoadError.cpp +++ b/src/openrct2-ui/windows/ObjectLoadError.cpp @@ -547,7 +547,7 @@ static void window_object_load_error_paint(rct_window* w, rct_drawpixelinfo* dpi ft = Formatter(); ft.Add(STR_OBJECT_ERROR_WINDOW_FILE); ft.Add(file_path.c_str()); - DrawTextEllipsised(dpi, { w->windowPos.x + 5, w->windowPos.y + 43 }, WW - 5, STR_BLACK_STRING, ft, COLOUR_BLACK); + DrawTextEllipsised(dpi, { w->windowPos.x + 5, w->windowPos.y + 43 }, WW - 5, STR_BLACK_STRING, ft); } static void window_object_load_error_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t scrollIndex) diff --git a/src/openrct2-ui/windows/Options.cpp b/src/openrct2-ui/windows/Options.cpp index 8318367360..c8b8b6269a 100644 --- a/src/openrct2-ui/windows/Options.cpp +++ b/src/openrct2-ui/windows/Options.cpp @@ -2140,7 +2140,7 @@ static void window_options_advanced_paint(rct_window* w, rct_drawpixelinfo* dpi) uint32_t padding = widgetHeight > lineHeight ? (widgetHeight - lineHeight) / 2 : 0; ScreenCoordsXY screenCoords = { w->windowPos.x + pathWidget.left + 1, w->windowPos.y + pathWidget.top + static_cast(padding) }; - DrawTextEllipsised(dpi, screenCoords, 277, STR_STRING, ft, w->colours[1]); + DrawTextEllipsised(dpi, screenCoords, 277, STR_STRING, ft, { w->colours[1] }); } static OpenRCT2String window_options_advanced_tooltip( diff --git a/src/openrct2-ui/windows/Park.cpp b/src/openrct2-ui/windows/Park.cpp index a1e89b52ce..42b175c1b9 100644 --- a/src/openrct2-ui/windows/Park.cpp +++ b/src/openrct2-ui/windows/Park.cpp @@ -729,7 +729,7 @@ static void window_park_entrance_paint(rct_window* w, rct_drawpixelinfo* dpi) labelWidget = &window_park_entrance_widgets[WIDX_STATUS]; DrawTextEllipsised( dpi, w->windowPos + ScreenCoordsXY{ labelWidget->midX(), labelWidget->top }, labelWidget->width(), STR_BLACK_STRING, ft, - COLOUR_BLACK, TextAlignment::CENTRE); + { TextAlignment::CENTRE }); } /** diff --git a/src/openrct2-ui/windows/Player.cpp b/src/openrct2-ui/windows/Player.cpp index 36e7fd77b7..c7c659ffbf 100644 --- a/src/openrct2-ui/windows/Player.cpp +++ b/src/openrct2-ui/windows/Player.cpp @@ -338,7 +338,7 @@ void window_player_overview_paint(rct_window* w, rct_drawpixelinfo* dpi) DrawTextEllipsised( dpi, w->windowPos + ScreenCoordsXY{ widget->midX() - 5, widget->top }, widget->width() - 8, STR_STRING, ft, - COLOUR_BLACK, TextAlignment::CENTRE); + { TextAlignment::CENTRE }); } // Draw ping @@ -364,7 +364,7 @@ void window_player_overview_paint(rct_window* w, rct_drawpixelinfo* dpi) { ft.Add(STR_ACTION_NA); } - DrawTextEllipsised(dpi, screenCoords, width, STR_LAST_ACTION_RAN, ft, COLOUR_BLACK, TextAlignment::CENTRE); + DrawTextEllipsised(dpi, screenCoords, width, STR_LAST_ACTION_RAN, ft, { TextAlignment::CENTRE }); if (w->viewport != nullptr && w->var_492 != -1) { diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 78f59eef57..4b33d09e25 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -2678,7 +2678,7 @@ static void window_ride_main_paint(rct_window* w, rct_drawpixelinfo* dpi) rct_string_id rideStatus = window_ride_get_status(w, ft); DrawTextEllipsised( dpi, w->windowPos + ScreenCoordsXY{ (widget->left + widget->right) / 2, widget->top }, widget->width(), rideStatus, ft, - COLOUR_BLACK, TextAlignment::CENTRE); + { TextAlignment::CENTRE }); } #pragma endregion @@ -4891,7 +4891,7 @@ static void window_ride_colour_paint(rct_window* w, rct_drawpixelinfo* dpi) } } - DrawTextEllipsised(dpi, { w->windowPos.x + 3, w->windowPos.y + 103 }, 97, STR_STATION_STYLE, {}, COLOUR_BLACK); + DrawTextEllipsised(dpi, { w->windowPos.x + 3, w->windowPos.y + 103 }, 97, STR_STATION_STYLE, {}); } } @@ -5688,7 +5688,7 @@ static void window_ride_measurements_paint(rct_window* w, rct_drawpixelinfo* dpi ft.Add(0); ft.Add(0); ft.Add(0); - DrawTextEllipsised(dpi, screenCoords, 308, STR_RIDE_TIME, ft, COLOUR_BLACK); + DrawTextEllipsised(dpi, screenCoords, 308, STR_RIDE_TIME, ft); screenCoords.y += LIST_ROW_HEIGHT; } @@ -5726,7 +5726,7 @@ static void window_ride_measurements_paint(rct_window* w, rct_drawpixelinfo* dpi ft.Add(0); ft.Add(0); ft.Add(0); - DrawTextEllipsised(dpi, screenCoords, 308, STR_RIDE_LENGTH, ft, COLOUR_BLACK); + DrawTextEllipsised(dpi, screenCoords, 308, STR_RIDE_LENGTH, ft); screenCoords.y += LIST_ROW_HEIGHT; diff --git a/src/openrct2-ui/windows/RideList.cpp b/src/openrct2-ui/windows/RideList.cpp index b725b11541..0e21adc62b 100644 --- a/src/openrct2-ui/windows/RideList.cpp +++ b/src/openrct2-ui/windows/RideList.cpp @@ -594,7 +594,7 @@ static void window_ride_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, // Ride name auto ft = Formatter(); ride->FormatNameTo(ft); - DrawTextEllipsised(dpi, { 0, y - 1 }, 159, format, ft, COLOUR_BLACK); + DrawTextEllipsised(dpi, { 0, y - 1 }, 159, format, ft); // Ride information ft = Formatter(); @@ -746,7 +746,7 @@ static void window_ride_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, ft.Rewind(); ft.Add(formatSecondary); } - DrawTextEllipsised(dpi, { 160, y - 1 }, 157, format, ft, COLOUR_BLACK); + DrawTextEllipsised(dpi, { 160, y - 1 }, 157, format, ft); y += SCROLLABLE_ROW_HEIGHT; } } diff --git a/src/openrct2-ui/windows/ScenarioSelect.cpp b/src/openrct2-ui/windows/ScenarioSelect.cpp index 07e0b9cd54..b9850eb422 100644 --- a/src/openrct2-ui/windows/ScenarioSelect.cpp +++ b/src/openrct2-ui/windows/ScenarioSelect.cpp @@ -438,6 +438,7 @@ static void window_scenarioselect_paint(rct_window* w, rct_drawpixelinfo* dpi) WindowDrawWidgets(w, dpi); format = ScenarioSelectUseSmallFont() ? STR_SMALL_WINDOW_COLOUR_2_STRINGID : STR_WINDOW_COLOUR_2_STRINGID; + FontSpriteBase fontSpriteBase = ScenarioSelectUseSmallFont() ? FontSpriteBase::SMALL : FontSpriteBase::MEDIUM; // Text for each tab for (uint32_t i = 0; i < std::size(ScenarioOriginStringIds); i++) @@ -457,7 +458,7 @@ static void window_scenarioselect_paint(rct_window* w, rct_drawpixelinfo* dpi) } ScreenCoordsXY stringCoords(widget->midX() + w->windowPos.x, widget->midY() + w->windowPos.y - 3); - DrawTextWrapped(dpi, stringCoords, 87, format, ft, { COLOUR_AQUAMARINE, TextAlignment::CENTRE }); + DrawTextWrapped(dpi, stringCoords, 87, format, ft, { COLOUR_AQUAMARINE, fontSpriteBase, TextAlignment::CENTRE }); } // Return if no scenario highlighted @@ -471,7 +472,7 @@ static void window_scenarioselect_paint(rct_window* w, rct_drawpixelinfo* dpi) + ScreenCoordsXY{ window_scenarioselect_widgets[WIDX_SCENARIOLIST].right + 4, window_scenarioselect_widgets[WIDX_TABCONTENT].top + 5 }; DrawTextEllipsised( - dpi, screenPos + ScreenCoordsXY{ 85, 0 }, 170, STR_SCENARIO_LOCKED, {}, COLOUR_BLACK, TextAlignment::CENTRE); + dpi, screenPos + ScreenCoordsXY{ 85, 0 }, 170, STR_SCENARIO_LOCKED, {}, { TextAlignment::CENTRE }); DrawTextWrapped(dpi, screenPos + ScreenCoordsXY{ 0, 15 }, 170, STR_SCENARIO_LOCKED_DESC); } return; @@ -482,8 +483,7 @@ static void window_scenarioselect_paint(rct_window* w, rct_drawpixelinfo* dpi) { utf8 path[MAX_PATH]; - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; - shorten_path(path, sizeof(path), scenario->path, w->width - 6); + shorten_path(path, sizeof(path), scenario->path, w->width - 6, FontSpriteBase::MEDIUM); const utf8* pathPtr = path; DrawTextBasic( @@ -499,7 +499,7 @@ static void window_scenarioselect_paint(rct_window* w, rct_drawpixelinfo* dpi) ft.Add(STR_STRING); ft.Add(scenario->name); DrawTextEllipsised( - dpi, screenPos + ScreenCoordsXY{ 85, 0 }, 170, STR_WINDOW_COLOUR_2_STRINGID, ft, COLOUR_BLACK, TextAlignment::CENTRE); + dpi, screenPos + ScreenCoordsXY{ 85, 0 }, 170, STR_WINDOW_COLOUR_2_STRINGID, ft, { TextAlignment::CENTRE }); screenPos.y += 15; // Scenario details @@ -607,11 +607,8 @@ static void window_scenarioselect_scrollpaint(rct_window* w, rct_drawpixelinfo* ft.Add(STR_STRING); ft.Add(buffer); colour_t colour = isDisabled ? w->colours[1] | COLOUR_FLAG_INSET : COLOUR_BLACK; - if (isDisabled) - { - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM_DARK; - } - DrawTextBasic(dpi, { wide ? 270 : 210, y + 1 }, format, ft, { colour, TextAlignment::CENTRE }); + FontSpriteBase fontSpriteBase = isDisabled ? FontSpriteBase::MEDIUM_DARK : FontSpriteBase::MEDIUM; + DrawTextBasic(dpi, { wide ? 270 : 210, y + 1 }, format, ft, { colour, fontSpriteBase, TextAlignment::CENTRE }); // Check if scenario is completed if (isCompleted) diff --git a/src/openrct2-ui/windows/Scenery.cpp b/src/openrct2-ui/windows/Scenery.cpp index 8b6c53e17b..e7cdd31ead 100644 --- a/src/openrct2-ui/windows/Scenery.cpp +++ b/src/openrct2-ui/windows/Scenery.cpp @@ -1178,8 +1178,7 @@ void window_scenery_paint(rct_window* w, rct_drawpixelinfo* dpi) auto ft = Formatter(); ft.Add(sceneryEntry != nullptr ? sceneryEntry->name : static_cast(STR_UNKNOWN_OBJECT_TYPE)); - DrawTextEllipsised( - dpi, { w->windowPos.x + 3, w->windowPos.y + w->height - 13 }, w->width - 19, STR_BLACK_STRING, ft, COLOUR_BLACK); + DrawTextEllipsised(dpi, { w->windowPos.x + 3, w->windowPos.y + w->height - 13 }, w->width - 19, STR_BLACK_STRING, ft); } /** diff --git a/src/openrct2-ui/windows/ServerList.cpp b/src/openrct2-ui/windows/ServerList.cpp index 375c1ec030..6c616acefc 100644 --- a/src/openrct2-ui/windows/ServerList.cpp +++ b/src/openrct2-ui/windows/ServerList.cpp @@ -442,7 +442,7 @@ static void window_server_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi w->widgets[WIDX_LIST].tooltip = STR_NETWORK_VERSION_TIP; } - int32_t colour = w->colours[1]; + colour_t colour = w->colours[1]; if (serverDetails.Favourite) { colour = COLOUR_YELLOW; @@ -475,7 +475,7 @@ static void window_server_list_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi // Finally, draw the server information. auto ft = Formatter(); ft.Add(serverInfoToShow); - DrawTextEllipsised(dpi, screenCoords + ScreenCoordsXY{ 0, 3 }, spaceAvailableForInfo, STR_STRING, ft, colour); + DrawTextEllipsised(dpi, screenCoords + ScreenCoordsXY{ 0, 3 }, spaceAvailableForInfo, STR_STRING, ft, { colour }); int32_t right = width - 7 - SCROLLBAR_WIDTH; diff --git a/src/openrct2-ui/windows/ShortcutKeys.cpp b/src/openrct2-ui/windows/ShortcutKeys.cpp index b917fc0dc0..40e0709605 100644 --- a/src/openrct2-ui/windows/ShortcutKeys.cpp +++ b/src/openrct2-ui/windows/ShortcutKeys.cpp @@ -526,14 +526,14 @@ private: ft.Add(STR_STRING); ft.Add(shortcut.CustomString.c_str()); } - DrawTextEllipsised(&dpi, { 0, y - 1 }, bindingOffset, format, ft, COLOUR_BLACK); + DrawTextEllipsised(&dpi, { 0, y - 1 }, bindingOffset, format, ft); if (!shortcut.Binding.empty()) { ft = Formatter(); ft.Add(STR_STRING); ft.Add(shortcut.Binding.c_str()); - DrawTextEllipsised(&dpi, { bindingOffset, y - 1 }, 150, format, ft, COLOUR_BLACK); + DrawTextEllipsised(&dpi, { bindingOffset, y - 1 }, 150, format, ft); } } }; diff --git a/src/openrct2-ui/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp index 2281885092..74aca4b496 100644 --- a/src/openrct2-ui/windows/Staff.cpp +++ b/src/openrct2-ui/windows/Staff.cpp @@ -943,7 +943,7 @@ void window_staff_overview_paint(rct_window* w, rct_drawpixelinfo* dpi) rct_widget* widget = &w->widgets[WIDX_BTM_LABEL]; auto screenPos = w->windowPos + ScreenCoordsXY{ widget->midX(), widget->top }; int32_t width = widget->width(); - DrawTextEllipsised(dpi, screenPos, width, STR_BLACK_STRING, ft, COLOUR_BLACK, TextAlignment::CENTRE); + DrawTextEllipsised(dpi, screenPos, width, STR_BLACK_STRING, ft, { TextAlignment::CENTRE }); } /** diff --git a/src/openrct2-ui/windows/StaffList.cpp b/src/openrct2-ui/windows/StaffList.cpp index 6decbf44d8..788f5e0c4f 100644 --- a/src/openrct2-ui/windows/StaffList.cpp +++ b/src/openrct2-ui/windows/StaffList.cpp @@ -407,11 +407,11 @@ public: auto ft = Formatter(); peep->FormatNameTo(ft); - DrawTextEllipsised(&dpi, { 0, y }, nameColumnSize, format, ft, COLOUR_BLACK); + DrawTextEllipsised(&dpi, { 0, y }, nameColumnSize, format, ft); ft = Formatter(); peep->FormatActionTo(ft); - DrawTextEllipsised(&dpi, { actionOffset, y }, actionColumnSize, format, ft, COLOUR_BLACK); + DrawTextEllipsised(&dpi, { actionOffset, y }, actionColumnSize, format, ft); // True if a patrol path is set for the worker if (gStaffModes[peep->StaffId] == StaffMode::Patrol) diff --git a/src/openrct2-ui/windows/TextInput.cpp b/src/openrct2-ui/windows/TextInput.cpp index 4f41c58d31..42da994c76 100644 --- a/src/openrct2-ui/windows/TextInput.cpp +++ b/src/openrct2-ui/windows/TextInput.cpp @@ -215,14 +215,12 @@ public: screenCoords.y += 25; - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; - char wrapped_string[TEXT_INPUT_SIZE]; safe_strcpy(wrapped_string, _buffer.data(), TEXT_INPUT_SIZE); // String length needs to add 12 either side of box // +13 for cursor when max length. - gfx_wrap_string(wrapped_string, WW - (24 + 13), &no_lines); + gfx_wrap_string(wrapped_string, WW - (24 + 13), FontSpriteBase::MEDIUM, &no_lines); gfx_fill_rect_inset( &dpi, { { windowPos.x + 10, screenCoords.y }, { windowPos.x + WW - 10, screenCoords.y + 10 * (no_lines + 1) + 3 } }, @@ -239,7 +237,7 @@ public: for (int32_t line = 0; line <= no_lines; line++) { screenCoords.x = windowPos.x + 12; - gfx_draw_string_no_formatting(&dpi, wrap_pointer, colours[1], screenCoords); + gfx_draw_string_no_formatting(&dpi, screenCoords, wrap_pointer, { colours[1], FontSpriteBase::MEDIUM }); size_t string_length = get_string_size(wrap_pointer) - 1; @@ -309,7 +307,7 @@ public: // String length needs to add 12 either side of box +13 for cursor when max length. int32_t numLines{}; - gfx_wrap_string(wrappedString.data(), WW - (24 + 13), &numLines); + gfx_wrap_string(wrappedString.data(), WW - (24 + 13), FontSpriteBase::MEDIUM, &numLines); return numLines * 10 + WH; } diff --git a/src/openrct2-ui/windows/Themes.cpp b/src/openrct2-ui/windows/Themes.cpp index ec6190dabd..b37bfff16b 100644 --- a/src/openrct2-ui/windows/Themes.cpp +++ b/src/openrct2-ui/windows/Themes.cpp @@ -833,7 +833,7 @@ void window_themes_paint(rct_window* w, rct_drawpixelinfo* dpi) auto width = w->windowPos.x + window_themes_widgets[WIDX_THEMES_PRESETS_DROPDOWN].left - window_themes_widgets[WIDX_THEMES_PRESETS].left - 4; - DrawTextEllipsised(dpi, screenPos, width, STR_STRING, ft, w->colours[1]); + DrawTextEllipsised(dpi, screenPos, width, STR_STRING, ft, { w->colours[1] }); } } @@ -911,7 +911,6 @@ void window_themes_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t sc gfx_fill_rect_inset(dpi, { topLeft, bottomRight }, w->colours[1], INSET_RECT_F_E0); if (colour & COLOUR_FLAG_TRANSLUCENT) { - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM_DARK; gfx_draw_string( dpi, topLeft, static_cast(CheckBoxMarkString), { static_cast(w->colours[1] & 0x7F), FontSpriteBase::MEDIUM_DARK }); diff --git a/src/openrct2-ui/windows/TileInspector.cpp b/src/openrct2-ui/windows/TileInspector.cpp index 2b29cdcd9b..ffe859e430 100644 --- a/src/openrct2-ui/windows/TileInspector.cpp +++ b/src/openrct2-ui/windows/TileInspector.cpp @@ -1712,40 +1712,37 @@ static void window_tile_inspector_paint(rct_window* w, rct_drawpixelinfo* dpi) { WindowDrawWidgets(w, dpi); - // Set medium font size - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; - // Draw column headers rct_widget* widget; if ((widget = &w->widgets[WIDX_COLUMN_TYPE])->type != WindowWidgetType::Empty) { DrawTextEllipsised( dpi, { w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width(), - STR_TILE_INSPECTOR_ELEMENT_TYPE, {}, w->colours[1]); + STR_TILE_INSPECTOR_ELEMENT_TYPE, {}, { w->colours[1] }); } if ((widget = &w->widgets[WIDX_COLUMN_BASEHEIGHT])->type != WindowWidgetType::Empty) { DrawTextEllipsised( dpi, { w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width(), - STR_TILE_INSPECTOR_BASE_HEIGHT_SHORT, {}, w->colours[1]); + STR_TILE_INSPECTOR_BASE_HEIGHT_SHORT, {}, { w->colours[1] }); } if ((widget = &w->widgets[WIDX_COLUMN_CLEARANCEHEIGHT])->type != WindowWidgetType::Empty) { DrawTextEllipsised( dpi, { w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width(), - STR_TILE_INSPECTOR_CLEARANGE_HEIGHT_SHORT, {}, w->colours[1]); + STR_TILE_INSPECTOR_CLEARANGE_HEIGHT_SHORT, {}, { w->colours[1] }); } if ((widget = &w->widgets[WIDX_COLUMN_GHOSTFLAG])->type != WindowWidgetType::Empty) { DrawTextEllipsised( dpi, { w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width(), - STR_TILE_INSPECTOR_FLAG_GHOST_SHORT, {}, w->colours[1]); + STR_TILE_INSPECTOR_FLAG_GHOST_SHORT, {}, { w->colours[1] }); } if ((widget = &w->widgets[WIDX_COLUMN_LASTFLAG])->type != WindowWidgetType::Empty) { DrawTextEllipsised( dpi, { w->windowPos.x + widget->left + 1, w->windowPos.y + widget->top + 1 }, widget->width(), - STR_TILE_INSPECTOR_FLAG_LAST_SHORT, {}, w->colours[1]); + STR_TILE_INSPECTOR_FLAG_LAST_SHORT, {}, { w->colours[1] }); } ScreenCoordsXY screenCoords(w->windowPos.x, w->windowPos.y); @@ -2247,7 +2244,6 @@ static void window_tile_inspector_scrollpaint(rct_window* w, rct_drawpixelinfo* const TileElement* tileElement = map_get_first_element_at(windowTileInspectorToolMap); - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; do { if (tileElement == nullptr) @@ -2333,8 +2329,7 @@ static void window_tile_inspector_scrollpaint(rct_window* w, rct_drawpixelinfo* auto ft = Formatter(); ft.Add(STR_STRING); ft.Add(typeName); - DrawTextEllipsised( - dpi, screenCoords + ScreenCoordsXY{ COL_X_TYPE + 3, 0 }, COL_X_BH, stringFormat, ft, COLOUR_BLACK); // 3px padding + DrawTextEllipsised(dpi, screenCoords + ScreenCoordsXY{ COL_X_TYPE + 3, 0 }, COL_X_BH, stringFormat, ft); // 3px padding // Base height ft = Formatter(); diff --git a/src/openrct2-ui/windows/TitleCommandEditor.cpp b/src/openrct2-ui/windows/TitleCommandEditor.cpp index fd545f0f73..bcbe613cc4 100644 --- a/src/openrct2-ui/windows/TitleCommandEditor.cpp +++ b/src/openrct2-ui/windows/TitleCommandEditor.cpp @@ -770,7 +770,7 @@ static void window_title_command_editor_paint(rct_window* w, rct_drawpixelinfo* DrawTextEllipsised( dpi, { w->windowPos.x + w->widgets[WIDX_COMMAND].left + 1, w->windowPos.y + w->widgets[WIDX_COMMAND].top }, w->widgets[WIDX_COMMAND_DROPDOWN].left - w->widgets[WIDX_COMMAND].left - 4, command_info.nameStringId, {}, - w->colours[1]); + { w->colours[1] }); // Label (e.g. "Location:") DrawTextBasic(dpi, w->windowPos + ScreenCoordsXY{ WS, BY2 - 14 }, command_info.descStringId, {}, { w->colours[1] }); @@ -780,7 +780,7 @@ static void window_title_command_editor_paint(rct_window* w, rct_drawpixelinfo* DrawTextEllipsised( dpi, { w->windowPos.x + w->widgets[WIDX_INPUT].left + 1, w->windowPos.y + w->widgets[WIDX_INPUT].top }, w->widgets[WIDX_INPUT_DROPDOWN].left - w->widgets[WIDX_INPUT].left - 4, SpeedNames[_command.Speed - 1], {}, - w->colours[1]); + { w->colours[1] }); } if (_command.Type == TitleScript::Follow) { @@ -803,7 +803,7 @@ static void window_title_command_editor_paint(rct_window* w, rct_drawpixelinfo* { w->windowPos + ScreenCoordsXY{ w->widgets[WIDX_VIEWPORT].right, w->widgets[WIDX_VIEWPORT].bottom } } }); DrawTextEllipsised( dpi, { w->windowPos.x + w->widgets[WIDX_VIEWPORT].left + 2, w->windowPos.y + w->widgets[WIDX_VIEWPORT].top + 1 }, - w->widgets[WIDX_VIEWPORT].width() - 2, spriteString, ft, colour); + w->widgets[WIDX_VIEWPORT].width() - 2, spriteString, ft, { colour }); } else if (_command.Type == TitleScript::Load) { @@ -812,7 +812,7 @@ static void window_title_command_editor_paint(rct_window* w, rct_drawpixelinfo* DrawTextEllipsised( dpi, { w->windowPos.x + w->widgets[WIDX_INPUT].left + 1, w->windowPos.y + w->widgets[WIDX_INPUT].top }, w->widgets[WIDX_INPUT_DROPDOWN].left - w->widgets[WIDX_INPUT].left - 4, - STR_TITLE_COMMAND_EDITOR_NO_SAVE_SELECTED, {}, w->colours[1]); + STR_TITLE_COMMAND_EDITOR_NO_SAVE_SELECTED, {}, { w->colours[1] }); } else { @@ -820,7 +820,7 @@ static void window_title_command_editor_paint(rct_window* w, rct_drawpixelinfo* ft.Add(_sequence->Saves[_command.SaveIndex].c_str()); DrawTextEllipsised( dpi, { w->windowPos.x + w->widgets[WIDX_INPUT].left + 1, w->windowPos.y + w->widgets[WIDX_INPUT].top }, - w->widgets[WIDX_INPUT_DROPDOWN].left - w->widgets[WIDX_INPUT].left - 4, STR_STRING, ft, w->colours[1]); + w->widgets[WIDX_INPUT_DROPDOWN].left - w->widgets[WIDX_INPUT].left - 4, STR_STRING, ft, { w->colours[1] }); } } else if (_command.Type == TitleScript::LoadSc) @@ -830,7 +830,7 @@ static void window_title_command_editor_paint(rct_window* w, rct_drawpixelinfo* DrawTextEllipsised( dpi, { w->windowPos.x + w->widgets[WIDX_INPUT].left + 1, w->windowPos.y + w->widgets[WIDX_INPUT].top }, w->widgets[WIDX_INPUT_DROPDOWN].left - w->widgets[WIDX_INPUT].left - 4, - STR_TITLE_COMMAND_EDITOR_NO_SCENARIO_SELECTED, {}, w->colours[1]); + STR_TITLE_COMMAND_EDITOR_NO_SCENARIO_SELECTED, {}, { w->colours[1] }); } else { @@ -849,7 +849,7 @@ static void window_title_command_editor_paint(rct_window* w, rct_drawpixelinfo* ft.Add(name); DrawTextEllipsised( dpi, { w->windowPos.x + w->widgets[WIDX_INPUT].left + 1, w->windowPos.y + w->widgets[WIDX_INPUT].top }, - w->widgets[WIDX_INPUT_DROPDOWN].left - w->widgets[WIDX_INPUT].left - 4, nameString, ft, w->colours[1]); + w->widgets[WIDX_INPUT_DROPDOWN].left - w->widgets[WIDX_INPUT].left - 4, nameString, ft, { w->colours[1] }); } } } diff --git a/src/openrct2-ui/windows/TitleEditor.cpp b/src/openrct2-ui/windows/TitleEditor.cpp index 03ebcdd0ec..703eac7486 100644 --- a/src/openrct2-ui/windows/TitleEditor.cpp +++ b/src/openrct2-ui/windows/TitleEditor.cpp @@ -819,7 +819,7 @@ static void window_title_editor_paint(rct_window* w, rct_drawpixelinfo* dpi) auto width = w->windowPos.x + window_title_editor_widgets[WIDX_TITLE_EDITOR_PRESETS_DROPDOWN].left - window_title_editor_widgets[WIDX_TITLE_EDITOR_PRESETS].left - 4; - DrawTextEllipsised(dpi, screenPos, width, STR_STRING, ft, w->colours[1]); + DrawTextEllipsised(dpi, screenPos, width, STR_STRING, ft, { w->colours[1] }); break; } case WINDOW_TITLE_EDITOR_TAB_SAVES: diff --git a/src/openrct2-ui/windows/Tooltip.cpp b/src/openrct2-ui/windows/Tooltip.cpp index 9d818e3054..f388ba217a 100644 --- a/src/openrct2-ui/windows/Tooltip.cpp +++ b/src/openrct2-ui/windows/Tooltip.cpp @@ -56,15 +56,12 @@ static int32_t FormatTextForTooltip(const OpenRCT2String& message) OpenRCT2String formattedMessage{ STR_STRING_TOOLTIP, Formatter() }; formattedMessage.args.Add(tempBuffer); format_string(_tooltipText, sizeof(_tooltipText), formattedMessage.str, formattedMessage.args.Data()); - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; - auto textWidth = gfx_get_string_width_new_lined(_tooltipText, FontSpriteBase::MEDIUM); + auto textWidth = gfx_get_string_width_new_lined(_tooltipText, FontSpriteBase::SMALL); textWidth = std::min(textWidth, 196); - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; - int32_t numLines; - textWidth = gfx_wrap_string(_tooltipText, textWidth + 1, &numLines); + textWidth = gfx_wrap_string(_tooltipText, textWidth + 1, FontSpriteBase::SMALL, &numLines); _tooltipNumLines = numLines; return textWidth; } @@ -77,7 +74,7 @@ void window_tooltip_show(const OpenRCT2String& message, ScreenCoordsXY screenCoo int32_t textWidth = FormatTextForTooltip(message); int32_t width = textWidth + 3; - int32_t height = ((_tooltipNumLines + 1) * font_get_line_height(FontSpriteBase::MEDIUM)) + 4; + int32_t height = ((_tooltipNumLines + 1) * font_get_line_height(FontSpriteBase::SMALL)) + 4; window_tooltip_widgets[WIDX_BACKGROUND].right = width; window_tooltip_widgets[WIDX_BACKGROUND].bottom = height; @@ -192,5 +189,5 @@ static void window_tooltip_paint(rct_window* w, rct_drawpixelinfo* dpi) // Text left = w->windowPos.x + ((w->width + 1) / 2) - 1; top = w->windowPos.y + 1; - draw_string_centred_raw(dpi, { left, top }, _tooltipNumLines, _tooltipText); + draw_string_centred_raw(dpi, { left, top }, _tooltipNumLines, _tooltipText, FontSpriteBase::SMALL); } diff --git a/src/openrct2-ui/windows/TopToolbar.cpp b/src/openrct2-ui/windows/TopToolbar.cpp index afa27e894d..ac478ad968 100644 --- a/src/openrct2-ui/windows/TopToolbar.cpp +++ b/src/openrct2-ui/windows/TopToolbar.cpp @@ -981,7 +981,6 @@ static void window_top_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi) // Draw number of players. auto ft = Formatter(); ft.Add(network_get_num_players()); - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; DrawTextBasic( dpi, screenPos + ScreenCoordsXY{ 23, 1 }, STR_COMMA16, ft, { COLOUR_WHITE | COLOUR_FLAG_OUTLINE, TextAlignment::RIGHT }); diff --git a/src/openrct2-ui/windows/TrackList.cpp b/src/openrct2-ui/windows/TrackList.cpp index 2736712d71..42585dcba6 100644 --- a/src/openrct2-ui/windows/TrackList.cpp +++ b/src/openrct2-ui/windows/TrackList.cpp @@ -541,7 +541,7 @@ static void window_track_list_paint(rct_window* w, rct_drawpixelinfo* dpi) && !(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER)) { // Vehicle design not available - DrawTextEllipsised(dpi, screenPos, 368, STR_VEHICLE_DESIGN_UNAVAILABLE, {}, COLOUR_BLACK, TextAlignment::CENTRE); + DrawTextEllipsised(dpi, screenPos, 368, STR_VEHICLE_DESIGN_UNAVAILABLE, {}, { TextAlignment::CENTRE }); screenPos.y -= SCROLLABLE_ROW_HEIGHT; } @@ -551,7 +551,7 @@ static void window_track_list_paint(rct_window* w, rct_drawpixelinfo* dpi) { // Scenery not available DrawTextEllipsised( - dpi, screenPos, 368, STR_DESIGN_INCLUDES_SCENERY_WHICH_IS_UNAVAILABLE, {}, COLOUR_BLACK, TextAlignment::CENTRE); + dpi, screenPos, 368, STR_DESIGN_INCLUDES_SCENERY_WHICH_IS_UNAVAILABLE, {}, { TextAlignment::CENTRE }); screenPos.y -= SCROLLABLE_ROW_HEIGHT; } } @@ -559,7 +559,7 @@ static void window_track_list_paint(rct_window* w, rct_drawpixelinfo* dpi) // Track design name auto ft = Formatter(); ft.Add(_trackDesigns[trackIndex].name); - DrawTextEllipsised(dpi, screenPos, 368, STR_TRACK_PREVIEW_NAME_FORMAT, ft, COLOUR_BLACK, TextAlignment::CENTRE); + DrawTextEllipsised(dpi, screenPos, 368, STR_TRACK_PREVIEW_NAME_FORMAT, ft, { TextAlignment::CENTRE }); // Information screenPos = w->windowPos + ScreenCoordsXY{ widget->left + 1, widget->bottom + 2 }; @@ -606,7 +606,7 @@ static void window_track_list_paint(rct_window* w, rct_drawpixelinfo* dpi) ft = Formatter(); ft.Add(STR_RIDE_LENGTH_ENTRY); ft.Add(_loadedTrackDesign->ride_length); - DrawTextEllipsised(dpi, screenPos, 214, STR_TRACK_LIST_RIDE_LENGTH, ft, COLOUR_BLACK); + DrawTextEllipsised(dpi, screenPos, 214, STR_TRACK_LIST_RIDE_LENGTH, ft); screenPos.y += LIST_ROW_HEIGHT; } diff --git a/src/openrct2/drawing/Drawing.String.cpp b/src/openrct2/drawing/Drawing.String.cpp index 97b6c1a655..789643e616 100644 --- a/src/openrct2/drawing/Drawing.String.cpp +++ b/src/openrct2/drawing/Drawing.String.cpp @@ -95,7 +95,7 @@ int32_t gfx_get_string_width_no_formatting(std::string_view text, FontSpriteBase * buffer (esi) * width (edi) */ -int32_t gfx_clip_string(utf8* text, int32_t width) +int32_t gfx_clip_string(utf8* text, int32_t width, FontSpriteBase fontSpriteBase) { if (width < 6) { @@ -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, gCurrentFontSpriteBase); + auto clippedWidth = gfx_get_string_width(text, fontSpriteBase); 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, gCurrentFontSpriteBase); + auto currentWidth = gfx_get_string_width(buffer, fontSpriteBase); 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, gCurrentFontSpriteBase); + return gfx_get_string_width(text, fontSpriteBase); } /** @@ -170,7 +170,7 @@ int32_t gfx_clip_string(utf8* text, int32_t width) * num_lines (edi) - out * font_height (ebx) - out */ -int32_t gfx_wrap_string(utf8* text, int32_t width, int32_t* outNumLines) +int32_t gfx_wrap_string(utf8* text, int32_t width, FontSpriteBase fontSpriteBase, int32_t* outNumLines) { constexpr size_t NULL_INDEX = std::numeric_limits::max(); thread_local std::string buffer; @@ -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], gCurrentFontSpriteBase); + auto lineWidth = gfx_get_string_width(&buffer[currentLineIndex], fontSpriteBase); 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], gCurrentFontSpriteBase); + lineWidth = gfx_get_string_width(&buffer[currentLineIndex], fontSpriteBase); 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], gCurrentFontSpriteBase); + auto lineWidth = gfx_get_string_width(&buffer[currentLineIndex], fontSpriteBase); 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], gCurrentFontSpriteBase); + auto lineWidth = gfx_get_string_width(&buffer[currentLineIndex], fontSpriteBase); maxWidth = std::max(maxWidth, lineWidth); } @@ -268,7 +268,6 @@ int32_t gfx_wrap_string(utf8* text, int32_t width, int32_t* outNumLines) void gfx_draw_string_left_centred( rct_drawpixelinfo* dpi, rct_string_id format, void* args, colour_t colour, const ScreenCoordsXY& coords) { - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; char* buffer = gCommonStringFormatBuffer; format_string(buffer, 256, format, args); int32_t height = string_get_height_raw(buffer, FontSpriteBase::MEDIUM); @@ -330,17 +329,17 @@ static void colour_char_window(uint8_t colour, const uint16_t* current_font_flag * text : esi * dpi : edi */ -void draw_string_centred_raw(rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, int32_t numLines, char* text) +void draw_string_centred_raw( + rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, int32_t numLines, char* text, FontSpriteBase fontSpriteBase) { ScreenCoordsXY screenCoords(dpi->x, dpi->y); - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; - gfx_draw_string(dpi, screenCoords, "", { COLOUR_BLACK }); + gfx_draw_string(dpi, screenCoords, "", { COLOUR_BLACK, fontSpriteBase }); screenCoords = coords; for (int32_t i = 0; i <= numLines; i++) { - int32_t width = gfx_get_string_width(text, FontSpriteBase::MEDIUM); - gfx_draw_string(dpi, screenCoords - ScreenCoordsXY{ width / 2, 0 }, text, { TEXT_COLOUR_254 }); + int32_t width = gfx_get_string_width(text, fontSpriteBase); + gfx_draw_string(dpi, screenCoords - ScreenCoordsXY{ width / 2, 0 }, text, { TEXT_COLOUR_254, fontSpriteBase }); const utf8* ch = text; const utf8* nextCh = nullptr; @@ -351,7 +350,7 @@ void draw_string_centred_raw(rct_drawpixelinfo* dpi, const ScreenCoordsXY& coord } text = const_cast(ch + 1); - screenCoords.y += font_get_line_height(FontSpriteBase::MEDIUM); + screenCoords.y += font_get_line_height(fontSpriteBase); } } @@ -431,12 +430,10 @@ void gfx_draw_string_centred_wrapped_partial( utf8* buffer = gCommonStringFormatBuffer; ScreenCoordsXY screenCoords(dpi->x, dpi->y); - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; gfx_draw_string(dpi, screenCoords, "", { colour }); format_string(buffer, 256, format, args); - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; - gfx_wrap_string(buffer, width, &numLines); + gfx_wrap_string(buffer, width, FontSpriteBase::MEDIUM, &numLines); lineHeight = font_get_line_height(FontSpriteBase::MEDIUM); int32_t numCharactersDrawn = 0; @@ -931,13 +928,14 @@ static void ttf_process_initial_colour(int32_t colour, text_draw_info* info) } void ttf_draw_string( - rct_drawpixelinfo* dpi, const_utf8string text, int32_t colour, const ScreenCoordsXY& coords, bool noFormatting) + rct_drawpixelinfo* dpi, const_utf8string text, int32_t colour, const ScreenCoordsXY& coords, bool noFormatting, + FontSpriteBase fontSpriteBase) { if (text == nullptr) return; text_draw_info info; - info.font_sprite_base = gCurrentFontSpriteBase; + info.font_sprite_base = fontSpriteBase; info.flags = 0; info.startX = coords.x; info.startY = coords.y; @@ -959,8 +957,6 @@ void ttf_draw_string( ttf_process_string(dpi, text, &info); std::memcpy(text_palette, info.palette, sizeof(info.palette)); - gCurrentFontSpriteBase = info.font_sprite_base; - gLastDrawStringX = info.x; gLastDrawStringY = info.y; } @@ -999,10 +995,10 @@ static int32_t ttf_get_string_width(std::string_view text, FontSpriteBase fontSp */ void gfx_draw_string_with_y_offsets( rct_drawpixelinfo* dpi, const utf8* text, int32_t colour, const ScreenCoordsXY& coords, const int8_t* yOffsets, - bool forceSpriteFont) + bool forceSpriteFont, FontSpriteBase fontSpriteBase) { text_draw_info info; - info.font_sprite_base = gCurrentFontSpriteBase; + info.font_sprite_base = fontSpriteBase; info.flags = 0; info.startX = coords.x; info.startY = coords.y; @@ -1022,18 +1018,16 @@ void gfx_draw_string_with_y_offsets( ttf_process_string(dpi, text, &info); std::memcpy(text_palette, info.palette, sizeof(info.palette)); - gCurrentFontSpriteBase = info.font_sprite_base; - gLastDrawStringX = info.x; gLastDrawStringY = info.y; } -void shorten_path(utf8* buffer, size_t bufferSize, const utf8* path, int32_t availableWidth) +void shorten_path(utf8* buffer, size_t bufferSize, const utf8* path, int32_t availableWidth, FontSpriteBase fontSpriteBase) { size_t length = strlen(path); // Return full string if it fits - if (gfx_get_string_width(const_cast(path), gCurrentFontSpriteBase) <= availableWidth) + if (gfx_get_string_width(const_cast(path), fontSpriteBase) <= availableWidth) { safe_strcpy(buffer, path, bufferSize); return; @@ -1062,7 +1056,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, gCurrentFontSpriteBase) <= availableWidth) + if (gfx_get_string_width(buffer, fontSpriteBase) <= availableWidth) { return; } diff --git a/src/openrct2/drawing/Drawing.cpp b/src/openrct2/drawing/Drawing.cpp index 9b6dbb996e..dcf73912a1 100644 --- a/src/openrct2/drawing/Drawing.cpp +++ b/src/openrct2/drawing/Drawing.cpp @@ -85,8 +85,6 @@ void PaletteMap::Copy(size_t dstIndex, const PaletteMap& src, size_t srcIndex, s thread_local int32_t gLastDrawStringX; thread_local int32_t gLastDrawStringY; -thread_local FontSpriteBase gCurrentFontSpriteBase; - uint8_t gGamePalette[256 * 4]; uint32_t gPaletteEffectFrame; diff --git a/src/openrct2/drawing/Drawing.h b/src/openrct2/drawing/Drawing.h index b8b4ae4896..605807383a 100644 --- a/src/openrct2/drawing/Drawing.h +++ b/src/openrct2/drawing/Drawing.h @@ -653,8 +653,6 @@ void FASTCALL BlitPixels(const uint8_t* src, uint8_t* dst, const PaletteMap& pal #define MAX_SCROLLING_TEXT_MODES 38 -extern thread_local FontSpriteBase gCurrentFontSpriteBase; - extern GamePalette gPalette; extern uint8_t gGamePalette[256 * 4]; extern uint32_t gPaletteEffectFrame; @@ -737,27 +735,29 @@ void FASTCALL gfx_draw_sprite_raw_masked_software( // string void gfx_draw_string(rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, const_utf8string buffer, TextPaint textPaint = {}); void gfx_draw_string_no_formatting( - rct_drawpixelinfo* dpi, const_utf8string buffer, uint8_t colour, const ScreenCoordsXY& coords); + rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, const_utf8string buffer, TextPaint textPaint); void gfx_draw_string_left_centred( rct_drawpixelinfo* dpi, rct_string_id format, void* args, colour_t colour, const ScreenCoordsXY& coords); -void draw_string_centred_raw(rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, int32_t numLines, char* text); +void draw_string_centred_raw( + rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, int32_t numLines, char* text, FontSpriteBase fontSpriteBase); void gfx_draw_string_centred_wrapped_partial( rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, int32_t width, colour_t colour, rct_string_id format, void* args, int32_t ticks); void gfx_draw_string_with_y_offsets( rct_drawpixelinfo* dpi, const utf8* text, int32_t colour, const ScreenCoordsXY& coords, const int8_t* yOffsets, - bool forceSpriteFont); + bool forceSpriteFont, FontSpriteBase fontSpriteBase); -int32_t gfx_wrap_string(char* buffer, int32_t width, int32_t* num_lines); +int32_t gfx_wrap_string(char* buffer, int32_t width, FontSpriteBase fontSpriteBase, int32_t* num_lines); 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); +int32_t gfx_clip_string(char* buffer, int32_t width, FontSpriteBase fontSpriteBase); +void shorten_path(utf8* buffer, size_t bufferSize, const utf8* path, int32_t availableWidth, FontSpriteBase fontSpriteBase); void ttf_draw_string( - rct_drawpixelinfo* dpi, const_utf8string text, int32_t colour, const ScreenCoordsXY& coords, bool noFormatting); + rct_drawpixelinfo* dpi, const_utf8string text, int32_t colour, const ScreenCoordsXY& coords, bool noFormatting, + FontSpriteBase fontSpriteBase); // scrolling text void scrolling_text_initialise_bitmaps(); diff --git a/src/openrct2/drawing/Text.cpp b/src/openrct2/drawing/Text.cpp index 234fa22483..c095a02e8f 100644 --- a/src/openrct2/drawing/Text.cpp +++ b/src/openrct2/drawing/Text.cpp @@ -23,16 +23,13 @@ StaticLayout::StaticLayout(utf8string source, const TextPaint& paint, int32_t wi Buffer = source; Paint = paint; - gCurrentFontSpriteBase = paint.SpriteBase; - MaxWidth = gfx_wrap_string(Buffer, width, &LineCount); + MaxWidth = gfx_wrap_string(Buffer, width, paint.SpriteBase, &LineCount); LineCount += 1; - LineHeight = font_get_line_height(gCurrentFontSpriteBase); + LineHeight = font_get_line_height(paint.SpriteBase); } void StaticLayout::Draw(rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords) { - gCurrentFontSpriteBase = Paint.SpriteBase; - TextPaint tempPaint = Paint; auto lineCoords = coords; @@ -91,7 +88,7 @@ static void DrawText( break; } - ttf_draw_string(dpi, text, paint.Colour, alignedCoords, noFormatting); + ttf_draw_string(dpi, text, paint.Colour, alignedCoords, noFormatting, paint.SpriteBase); if (paint.UnderlineText == TextUnderline::On) { @@ -118,7 +115,6 @@ static void DrawText( void DrawTextBasic( rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, rct_string_id format, const void* args, TextPaint textPaint) { - gCurrentFontSpriteBase = textPaint.SpriteBase; DrawText(dpi, coords, textPaint, format, args); } @@ -130,14 +126,11 @@ void DrawTextBasic( void DrawTextEllipsised( rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, int32_t width, rct_string_id format, const Formatter& ft, - colour_t colour, TextAlignment alignment, bool underline) + TextPaint textPaint) { - TextPaint textPaint = { colour, FontSpriteBase::MEDIUM, underline ? TextUnderline::On : TextUnderline::Off, alignment }; - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; - utf8 buffer[512]; format_string(buffer, sizeof(buffer), format, ft.Data()); - gfx_clip_string(buffer, width); + gfx_clip_string(buffer, width, textPaint.SpriteBase); DrawText(dpi, coords, textPaint, buffer); } @@ -148,9 +141,8 @@ void gfx_draw_string(rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, const } void gfx_draw_string_no_formatting( - rct_drawpixelinfo* dpi, const_utf8string buffer, uint8_t colour, const ScreenCoordsXY& coords) + rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, const_utf8string buffer, TextPaint textPaint) { - TextPaint textPaint = { colour, gCurrentFontSpriteBase, TextUnderline::Off, TextAlignment::LEFT }; DrawText(dpi, coords, textPaint, buffer, true); } @@ -161,8 +153,6 @@ int32_t DrawTextWrapped( utf8 buffer[512]; format_string(buffer, sizeof(buffer), format, args); - gCurrentFontSpriteBase = textPaint.SpriteBase; - StaticLayout layout(buffer, textPaint, width); if (textPaint.Alignment == TextAlignment::CENTRE) diff --git a/src/openrct2/drawing/Text.h b/src/openrct2/drawing/Text.h index 5ac596db7c..7c32cfed44 100644 --- a/src/openrct2/drawing/Text.h +++ b/src/openrct2/drawing/Text.h @@ -151,7 +151,7 @@ void DrawTextBasic( rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, rct_string_id format, const void* args, TextPaint textPaint = {}); void DrawTextEllipsised( rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, int32_t width, rct_string_id format, const Formatter& ft, - colour_t colour, TextAlignment alignment = TextAlignment::LEFT, bool underline = false); + TextPaint textPaint = {}); int32_t DrawTextWrapped( rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, int32_t width, rct_string_id format, const Formatter& ft = {}, TextPaint textPaint = {}); diff --git a/src/openrct2/interface/Chat.cpp b/src/openrct2/interface/Chat.cpp index bc5f04c470..0a50e66ebd 100644 --- a/src/openrct2/interface/Chat.cpp +++ b/src/openrct2/interface/Chat.cpp @@ -275,8 +275,7 @@ static int32_t chat_history_draw_string( FormatStringToBuffer(gCommonStringFormatBuffer, sizeof(gCommonStringFormatBuffer), "{OUTLINE}{WHITE}{STRING}", text); int32_t numLines; - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; - gfx_wrap_string(buffer, width, &numLines); + gfx_wrap_string(buffer, width, FontSpriteBase::MEDIUM, &numLines); auto lineHeight = font_get_line_height(FontSpriteBase::MEDIUM); int32_t expectedY = screenCoords.y - (numLines * lineHeight); @@ -299,18 +298,14 @@ static int32_t chat_history_draw_string( // Almost the same as gfx_draw_string_left_wrapped int32_t chat_string_wrapped_get_height(void* args, int32_t width) { - int32_t lineHeight, lineY, numLines; - - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; - char* buffer = gCommonStringFormatBuffer; format_string(buffer, 256, STR_STRING, args); - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; - gfx_wrap_string(buffer, width, &numLines); - lineHeight = font_get_line_height(FontSpriteBase::MEDIUM); + int32_t numLines; + gfx_wrap_string(buffer, width, FontSpriteBase::MEDIUM, &numLines); + int32_t lineHeight = font_get_line_height(FontSpriteBase::MEDIUM); - lineY = 0; + int32_t lineY = 0; for (int32_t line = 0; line <= numLines; ++line) { buffer = get_string_end(buffer) + 1; diff --git a/src/openrct2/paint/Paint.cpp b/src/openrct2/paint/Paint.cpp index d66e4be3c1..0bb434b384 100644 --- a/src/openrct2/paint/Paint.cpp +++ b/src/openrct2/paint/Paint.cpp @@ -952,7 +952,6 @@ void PaintDrawMoneyStructs(rct_drawpixelinfo* dpi, paint_string_struct* ps) { char buffer[256]{}; format_string(buffer, sizeof(buffer), ps->string_id, &ps->args); - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; // Use sprite font unless the currency contains characters unsupported by the sprite font auto forceSpriteFont = false; @@ -963,6 +962,7 @@ void PaintDrawMoneyStructs(rct_drawpixelinfo* dpi, paint_string_struct* ps) } gfx_draw_string_with_y_offsets( - dpi, buffer, COLOUR_BLACK, { ps->x, ps->y }, reinterpret_cast(ps->y_offsets), forceSpriteFont); + dpi, buffer, COLOUR_BLACK, { ps->x, ps->y }, reinterpret_cast(ps->y_offsets), forceSpriteFont, + FontSpriteBase::MEDIUM); } while ((ps = ps->next) != nullptr); } diff --git a/src/openrct2/paint/tile_element/Paint.Banner.cpp b/src/openrct2/paint/tile_element/Paint.Banner.cpp index aa57fcfb06..6a388f068c 100644 --- a/src/openrct2/paint/tile_element/Paint.Banner.cpp +++ b/src/openrct2/paint/tile_element/Paint.Banner.cpp @@ -113,8 +113,6 @@ void banner_paint(paint_session* session, uint8_t direction, int32_t height, con format_string(gCommonStringFormatBuffer, sizeof(gCommonStringFormatBuffer), STR_BANNER_TEXT_FORMAT, ft.Data()); } - gCurrentFontSpriteBase = FontSpriteBase::TINY; - 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); diff --git a/src/openrct2/paint/tile_element/Paint.Entrance.cpp b/src/openrct2/paint/tile_element/Paint.Entrance.cpp index d122844212..c4165deac0 100644 --- a/src/openrct2/paint/tile_element/Paint.Entrance.cpp +++ b/src/openrct2/paint/tile_element/Paint.Entrance.cpp @@ -183,8 +183,6 @@ static void ride_entrance_exit_paint(paint_session* session, uint8_t direction, format_string(entrance_string, sizeof(entrance_string), STR_BANNER_TEXT_FORMAT, ft.Data()); } - gCurrentFontSpriteBase = FontSpriteBase::TINY; - uint16_t stringWidth = gfx_get_string_width(entrance_string, FontSpriteBase::TINY); uint16_t scroll = stringWidth > 0 ? (gCurrentTicks / 2) % stringWidth : 0; @@ -291,8 +289,6 @@ static void park_entrance_paint(paint_session* session, uint8_t direction, int32 format_string(park_name, sizeof(park_name), STR_BANNER_TEXT_FORMAT, ft.Data()); } - gCurrentFontSpriteBase = FontSpriteBase::TINY; - uint16_t stringWidth = gfx_get_string_width(park_name, FontSpriteBase::TINY); uint16_t scroll = stringWidth > 0 ? (gCurrentTicks / 2) % stringWidth : 0; diff --git a/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp b/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp index 5702e898ad..fedcc4adb2 100644 --- a/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp +++ b/src/openrct2/paint/tile_element/Paint.LargeScenery.cpp @@ -440,8 +440,6 @@ void large_scenery_paint(paint_session* session, uint8_t direction, uint16_t hei format_string(signString, sizeof(signString), STR_SCROLLING_SIGN_TEXT, ft.Data()); } - gCurrentFontSpriteBase = FontSpriteBase::TINY; - uint16_t stringWidth = gfx_get_string_width(signString, FontSpriteBase::TINY); uint16_t scroll = stringWidth > 0 ? (gCurrentTicks / 2) % stringWidth : 0; PaintAddImageAsChild( diff --git a/src/openrct2/paint/tile_element/Paint.Path.cpp b/src/openrct2/paint/tile_element/Paint.Path.cpp index d607a28993..00cff7b966 100644 --- a/src/openrct2/paint/tile_element/Paint.Path.cpp +++ b/src/openrct2/paint/tile_element/Paint.Path.cpp @@ -470,8 +470,6 @@ static void sub_6A4101( format_string(gCommonStringFormatBuffer, sizeof(gCommonStringFormatBuffer), STR_BANNER_TEXT_FORMAT, ft.Data()); } - gCurrentFontSpriteBase = FontSpriteBase::TINY; - uint16_t stringWidth = gfx_get_string_width(gCommonStringFormatBuffer, FontSpriteBase::TINY); uint16_t scroll = stringWidth > 0 ? (gCurrentTicks / 2) % stringWidth : 0; diff --git a/src/openrct2/paint/tile_element/Paint.Wall.cpp b/src/openrct2/paint/tile_element/Paint.Wall.cpp index 43a71026d7..de9d78e352 100644 --- a/src/openrct2/paint/tile_element/Paint.Wall.cpp +++ b/src/openrct2/paint/tile_element/Paint.Wall.cpp @@ -446,8 +446,6 @@ void fence_paint(paint_session* session, uint8_t direction, int32_t height, cons format_string(signString, sizeof(signString), STR_SCROLLING_SIGN_TEXT, ft.Data()); } - gCurrentFontSpriteBase = FontSpriteBase::TINY; - uint16_t stringWidth = gfx_get_string_width(signString, FontSpriteBase::TINY); uint16_t scroll = stringWidth > 0 ? (gCurrentTicks / 2) % stringWidth : 0; diff --git a/src/openrct2/world/MoneyEffect.cpp b/src/openrct2/world/MoneyEffect.cpp index 1c344d126d..944f75c309 100644 --- a/src/openrct2/world/MoneyEffect.cpp +++ b/src/openrct2/world/MoneyEffect.cpp @@ -54,7 +54,6 @@ void MoneyEffect::CreateAt(money32 value, const CoordsXYZ& effectPos, bool verti auto [stringId, newValue] = moneyEffect->GetStringId(); char buffer[128]; format_string(buffer, 128, stringId, &newValue); - gCurrentFontSpriteBase = FontSpriteBase::MEDIUM; offsetX = -(gfx_get_string_width(buffer, FontSpriteBase::MEDIUM) / 2); } moneyEffect->OffsetX = offsetX;