Turn font sprite base into a strong enum

This commit is contained in:
Gymnasiast 2021-02-27 12:40:20 +01:00
parent 582037bbf3
commit 2477933c51
No known key found for this signature in database
GPG Key ID: DBFFF47AB2CA3EDD
40 changed files with 149 additions and 138 deletions

View File

@ -28,7 +28,7 @@ static InGameConsole _inGameConsole;
static int32_t InGameConsoleGetLineHeight()
{
auto fontSpriteBase = (gConfigInterface.console_small_font ? FONT_SPRITE_BASE_SMALL : FONT_SPRITE_BASE_MEDIUM);
auto fontSpriteBase = (gConfigInterface.console_small_font ? FontSpriteBase::SMALL : FontSpriteBase::MEDIUM);
return font_get_line_height(fontSpriteBase);
}
@ -272,7 +272,7 @@ void InGameConsole::Draw(rct_drawpixelinfo* dpi) const
return;
// Set font
gCurrentFontSpriteBase = (gConfigInterface.console_small_font ? FONT_SPRITE_BASE_SMALL : FONT_SPRITE_BASE_MEDIUM);
gCurrentFontSpriteBase = (gConfigInterface.console_small_font ? FontSpriteBase::SMALL : FontSpriteBase::MEDIUM);
uint8_t textColour = NOT_TRANSLUCENT(ThemeGetColour(WC_CONSOLE, 1));
const int32_t lineHeight = InGameConsoleGetLineHeight();
const int32_t maxLines = GetNumVisibleLines();

View File

@ -631,7 +631,7 @@ static void WidgetCheckboxDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widget
// fill it when checkbox is pressed
if (WidgetIsPressed(w, widgetIndex))
{
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
gfx_draw_string(
dpi, static_cast<const char*>(CheckBoxMarkString), NOT_TRANSLUCENT(colour), { midLeft - ScreenCoordsXY{ 0, 5 } });
}
@ -671,7 +671,7 @@ static void WidgetScrollDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widgetin
bottomRight.x--;
bottomRight.y--;
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
// Horizontal scrollbar
if (scroll->flags & HSCROLLBAR_VISIBLE)
@ -1087,7 +1087,7 @@ void WidgetSetCheckboxValue(rct_window* w, rct_widgetindex widgetIndex, int32_t
static void WidgetTextBoxDraw(rct_drawpixelinfo* dpi, rct_window* w, rct_widgetindex widgetIndex)
{
int32_t no_lines = 0;
int32_t font_height = 0;
FontSpriteBase font_height = FontSpriteBase::SMALL;
char wrapped_string[TEXT_INPUT_SIZE];
// Get the widget
@ -1106,7 +1106,7 @@ 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 = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
// Figure out where the text should be positioned vertically.
topLeft.y = w->windowPos.y + widget->textTop();

View File

@ -188,7 +188,7 @@ static void window_about_openrct2_paint(rct_window* w, rct_drawpixelinfo* dpi)
{
window_about_openrct2_common_paint(w, dpi);
int32_t lineHeight = font_get_line_height(FONT_SPRITE_BASE_MEDIUM);
int32_t lineHeight = font_get_line_height(FontSpriteBase::MEDIUM);
ScreenCoordsXY aboutCoords(
w->windowPos.x + (w->width / 2), w->windowPos.y + w->widgets[WIDX_PAGE_BACKGROUND].top + lineHeight);
@ -270,7 +270,7 @@ static void window_about_rct2_paint(rct_window* w, rct_drawpixelinfo* dpi)
auto screenCoords = ScreenCoordsXY{ w->windowPos.x + 200, yPage + 5 };
int32_t lineHeight = font_get_line_height(FONT_SPRITE_BASE_MEDIUM);
int32_t lineHeight = font_get_line_height(FontSpriteBase::MEDIUM);
// Credits
gfx_draw_string_centred(dpi, STR_COPYRIGHT_CS, screenCoords, COLOUR_BLACK, nullptr);

View File

@ -187,7 +187,7 @@ static void window_changelog_scrollgetsize(
{
*width = _changelogLongestLineWidth + 4;
const int32_t lineHeight = font_get_line_height(FONT_SPRITE_BASE_MEDIUM);
const int32_t lineHeight = font_get_line_height(FontSpriteBase::MEDIUM);
*height = static_cast<int32_t>(_changelogLines.size() * lineHeight);
}
@ -213,9 +213,9 @@ 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 = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
const int32_t lineHeight = font_get_line_height(FONT_SPRITE_BASE_MEDIUM);
const int32_t lineHeight = font_get_line_height(FontSpriteBase::MEDIUM);
ScreenCoordsXY screenCoords(3, 3 - lineHeight);
for (const auto& line : _changelogLines)
@ -241,7 +241,7 @@ 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 = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
_changelogLongestLineWidth = 0;
for (const auto& line : _changelogLines)
{

View File

@ -118,7 +118,7 @@ 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<void*>(&gDropdownItemsArgs[i]));
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
string_width = gfx_get_string_width(buffer);
max_string_width = std::max(string_width, max_string_width);
}

View File

@ -617,9 +617,9 @@ static void window_editor_inventions_list_scrollpaint(rct_window* w, rct_drawpix
if (researchItem.IsAlwaysResearched())
{
if (w->research_item == &researchItem && _editorInventionsListDraggedItem.IsNull())
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM_EXTRA_DARK;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM_EXTRA_DARK;
else
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM_DARK;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM_DARK;
colour = w->colours[1] | COLOUR_FLAG_INSET;
}
else
@ -627,7 +627,7 @@ static void window_editor_inventions_list_scrollpaint(rct_window* w, rct_drawpix
// TODO: this parameter by itself produces very light text.
// It needs a {BLACK} token in the string to work properly.
colour = COLOUR_BLACK;
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
}
const rct_string_id itemNameId = researchItem.GetName();

View File

@ -1156,7 +1156,7 @@ 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;
gCurrentFontSpriteBase = highlighted ? FONT_SPRITE_BASE_MEDIUM_EXTRA_DARK : FONT_SPRITE_BASE_MEDIUM_DARK;
gCurrentFontSpriteBase = highlighted ? FontSpriteBase::MEDIUM_EXTRA_DARK : FontSpriteBase::MEDIUM_DARK;
colour2 = NOT_TRANSLUCENT(w->colours[1]);
if (*listItem.flags & (OBJECT_SELECTION_FLAG_IN_USE | OBJECT_SELECTION_FLAG_ALWAYS_REQUIRED))
colour2 |= COLOUR_FLAG_INSET;
@ -1172,12 +1172,12 @@ static void window_editor_object_selection_scrollpaint(rct_window* w, rct_drawpi
if (*listItem.flags & OBJECT_SELECTION_FLAG_6)
{
colour = w->colours[1] & 0x7F;
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM_DARK;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM_DARK;
}
else
{
colour = COLOUR_BLACK;
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
}
int32_t width_limit = w->widgets[WIDX_LIST].width() - screenCoords.x;

View File

@ -1100,8 +1100,8 @@ 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 ? FONT_SPRITE_BASE_MEDIUM_EXTRA_DARK
: FONT_SPRITE_BASE_MEDIUM_DARK;
gCurrentFontSpriteBase = stringId == STR_WINDOW_COLOUR_2_STRINGID ? FontSpriteBase::MEDIUM_EXTRA_DARK
: FontSpriteBase::MEDIUM_DARK;
gfx_draw_string(dpi, static_cast<const char*>(CheckBoxMarkString), w->colours[1] & 0x7F, { 2, y });
}

View File

@ -56,7 +56,8 @@ rct_window* window_error_open(rct_string_id title, rct_string_id message, const
rct_window* window_error_open(std::string_view title, std::string_view message)
{
int32_t numLines, fontHeight, width, height, maxY;
int32_t numLines, width, height, maxY;
FontSpriteBase fontHeight;
rct_window* w;
window_close_by_class(WC_ERROR);
@ -83,16 +84,16 @@ rct_window* window_error_open(std::string_view title, std::string_view message)
if (buffer.size() <= 1)
return nullptr;
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
width = gfx_get_string_width_new_lined(buffer.data());
width = std::clamp(width, 64, 196);
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
gfx_wrap_string(buffer.data(), width + 1, &numLines, &fontHeight);
_window_error_num_lines = numLines;
width = width + 3;
height = (numLines + 1) * font_get_line_height(FONT_SPRITE_BASE_MEDIUM) + 4;
height = (numLines + 1) * font_get_line_height(FontSpriteBase::MEDIUM) + 4;
window_error_widgets[WIDX_BACKGROUND].right = width;
window_error_widgets[WIDX_BACKGROUND].bottom = height;

View File

@ -109,7 +109,7 @@ rct_window* window_game_bottom_toolbar_open()
int32_t screenHeight = context_get_height();
// Figure out how much line height we have to work with.
uint32_t line_height = font_get_line_height(FONT_SPRITE_BASE_MEDIUM);
uint32_t line_height = font_get_line_height(FontSpriteBase::MEDIUM);
uint32_t toolbar_height = line_height * 2 + 12;
rct_window* window = WindowCreate(
@ -222,7 +222,7 @@ static OpenRCT2String window_game_bottom_toolbar_tooltip(
static void window_game_bottom_toolbar_invalidate(rct_window* w)
{
// Figure out how much line height we have to work with.
uint32_t line_height = font_get_line_height(FONT_SPRITE_BASE_MEDIUM);
uint32_t line_height = font_get_line_height(FontSpriteBase::MEDIUM);
// Reset dimensions as appropriate -- in case we're switching languages.
w->height = line_height * 2 + 12;
@ -397,7 +397,7 @@ static void window_game_bottom_toolbar_draw_left_panel(rct_drawpixelinfo* dpi, r
w->windowPos.y + window_game_bottom_toolbar_widgets[WIDX_LEFT_OUTSET].bottom - 1, w->colours[1], INSET_RECT_F_30);
// Figure out how much line height we have to work with.
uint32_t line_height = font_get_line_height(FONT_SPRITE_BASE_MEDIUM);
uint32_t line_height = font_get_line_height(FontSpriteBase::MEDIUM);
// Draw money
if (!(gParkFlags & PARK_FLAGS_NO_MONEY))
@ -508,7 +508,7 @@ static void window_game_bottom_toolbar_draw_right_panel(rct_drawpixelinfo* dpi,
ft.Data());
// Figure out how much line height we have to work with.
uint32_t line_height = font_get_line_height(FONT_SPRITE_BASE_MEDIUM);
uint32_t line_height = font_get_line_height(FontSpriteBase::MEDIUM);
// Temperature
screenCoords = { w->windowPos.x + window_game_bottom_toolbar_widgets[WIDX_RIGHT_OUTSET].left + 15,
@ -663,7 +663,7 @@ static void window_game_bottom_toolbar_draw_middle_panel(rct_drawpixelinfo* dpi,
INSET_RECT_F_30);
// Figure out how much line height we have to work with.
uint32_t line_height = font_get_line_height(FONT_SPRITE_BASE_MEDIUM);
uint32_t line_height = font_get_line_height(FontSpriteBase::MEDIUM);
ScreenCoordsXY middleWidgetCoords(
w->windowPos.x + middleOutsetWidget->midX(), w->windowPos.y + middleOutsetWidget->top + line_height + 1);

View File

@ -1260,7 +1260,7 @@ void window_guest_stats_update(rct_window* w)
static void window_guest_stats_bars_paint(
int32_t value, int32_t x, int32_t y, rct_window* w, rct_drawpixelinfo* dpi, int32_t colour, bool blinkFlag)
{
if (font_get_line_height(FONT_SPRITE_BASE_MEDIUM) > 10)
if (font_get_line_height(FontSpriteBase::MEDIUM) > 10)
{
y += 1;
}

View File

@ -337,13 +337,14 @@ static ScreenCoordsXY window_multiplayer_information_get_size()
}
// Reset font sprite base and compute line height
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
int32_t lineHeight = font_get_line_height(FONT_SPRITE_BASE_MEDIUM);
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
int32_t lineHeight = font_get_line_height(FontSpriteBase::MEDIUM);
// Base dimensions.
const int32_t width = 450;
int32_t height = 55;
int32_t numLines, fontSpriteBase;
int32_t numLines;
FontSpriteBase fontSpriteBase;
// Server name is displayed word-wrapped, so figure out how high it will be.
{

View File

@ -139,7 +139,7 @@ static void window_music_credits_mouseup(rct_window* w, rct_widgetindex widgetIn
*/
static void window_music_credits_scrollgetsize(rct_window* w, int32_t scrollIndex, int32_t* width, int32_t* height)
{
int32_t lineHeight = font_get_line_height(FONT_SPRITE_BASE_MEDIUM);
int32_t lineHeight = font_get_line_height(FontSpriteBase::MEDIUM);
*height = static_cast<int32_t>(std::size(music_credits) + std::size(music_credits_rct2)) * lineHeight + 12;
}
@ -158,7 +158,7 @@ static void window_music_credits_paint(rct_window* w, rct_drawpixelinfo* dpi)
*/
static void window_music_credits_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32_t scrollIndex)
{
int32_t lineHeight = font_get_line_height(FONT_SPRITE_BASE_MEDIUM);
int32_t lineHeight = font_get_line_height(FontSpriteBase::MEDIUM);
auto screenCoords = ScreenCoordsXY{ 245, 2 };

View File

@ -155,7 +155,7 @@ 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 = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
thread_local std::string buffer;
buffer.assign("{BLACK}");

View File

@ -2134,7 +2134,7 @@ static void window_options_advanced_paint(rct_window* w, rct_drawpixelinfo* dpi)
// Apply vertical alignment if appropriate.
int32_t widgetHeight = pathWidget.bottom - pathWidget.top;
int32_t lineHeight = font_get_line_height(FONT_SPRITE_BASE_MEDIUM);
int32_t lineHeight = font_get_line_height(FontSpriteBase::MEDIUM);
uint32_t padding = widgetHeight > lineHeight ? (widgetHeight - lineHeight) / 2 : 0;
ScreenCoordsXY screenCoords = { w->windowPos.x + pathWidget.left + 1,
w->windowPos.y + pathWidget.top + static_cast<int32_t>(padding) };

View File

@ -2971,7 +2971,7 @@ static void window_ride_vehicle_paint(rct_window* w, rct_drawpixelinfo* dpi)
factor = rideEntry->intensity_multiplier;
if (factor > 0)
{
int32_t lineHeight = font_get_line_height(FONT_SPRITE_BASE_MEDIUM);
int32_t lineHeight = font_get_line_height(FontSpriteBase::MEDIUM);
if (lineHeight != 10)
screenCoords.x += 150;
else

View File

@ -285,10 +285,10 @@ static int32_t get_scenario_list_item_size()
return 24;
// Scenario title
int32_t lineHeight = font_get_line_height(FONT_SPRITE_BASE_MEDIUM);
int32_t lineHeight = font_get_line_height(FontSpriteBase::MEDIUM);
// 'Completed by' line
lineHeight += font_get_line_height(FONT_SPRITE_BASE_SMALL);
lineHeight += font_get_line_height(FontSpriteBase::SMALL);
return lineHeight;
}
@ -479,7 +479,7 @@ static void window_scenarioselect_paint(rct_window* w, rct_drawpixelinfo* dpi)
{
utf8 path[MAX_PATH];
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
shorten_path(path, sizeof(path), scenario->path, w->width - 6);
const utf8* pathPtr = path;
@ -569,7 +569,7 @@ static void window_scenarioselect_scrollpaint(rct_window* w, rct_drawpixelinfo*
const int32_t scenarioItemHeight = get_scenario_list_item_size();
// Scenario title
int32_t scenarioTitleHeight = font_get_line_height(FONT_SPRITE_BASE_MEDIUM);
int32_t scenarioTitleHeight = font_get_line_height(FontSpriteBase::MEDIUM);
int32_t y = 0;
for (const auto& listItem : _listItems)
@ -613,7 +613,7 @@ static void window_scenarioselect_scrollpaint(rct_window* w, rct_drawpixelinfo*
colour = isDisabled ? w->colours[1] | COLOUR_FLAG_INSET : COLOUR_BLACK;
if (isDisabled)
{
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM_DARK;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM_DARK;
}
gfx_draw_string_centred(dpi, format, { wide ? 270 : 210, y + 1 }, colour, ft.Data());

View File

@ -199,7 +199,7 @@ public:
screenCoords.y = windowPos.y + 25;
int32_t no_lines = 0;
int32_t font_height = 0;
FontSpriteBase font_height = FontSpriteBase::SMALL;
if (_descriptionStringId == STR_NONE)
{
@ -215,7 +215,7 @@ public:
screenCoords.y += 25;
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
char wrapped_string[TEXT_INPUT_SIZE];
safe_strcpy(wrapped_string, _buffer.data(), TEXT_INPUT_SIZE);
@ -309,7 +309,7 @@ public:
// String length needs to add 12 either side of box +13 for cursor when max length.
int32_t numLines{};
int32_t fontHeight{};
FontSpriteBase fontHeight = FontSpriteBase::SMALL;
gfx_wrap_string(wrappedString.data(), WW - (24 + 13), &numLines, &fontHeight);
return numLines * 10 + WH;
}

View File

@ -911,7 +911,7 @@ 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 = FONT_SPRITE_BASE_MEDIUM_DARK;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM_DARK;
gfx_draw_string(dpi, static_cast<const char*>(CheckBoxMarkString), w->colours[1] & 0x7F, topLeft);
}
}

View File

@ -1713,7 +1713,7 @@ static void window_tile_inspector_paint(rct_window* w, rct_drawpixelinfo* dpi)
WindowDrawWidgets(w, dpi);
// Set medium font size
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
// Draw column headers
rct_widget* widget;
@ -2245,7 +2245,7 @@ static void window_tile_inspector_scrollpaint(rct_window* w, rct_drawpixelinfo*
const TileElement* tileElement = map_get_first_element_at(windowTileInspectorToolMap);
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
do
{
if (tileElement == nullptr)

View File

@ -56,14 +56,15 @@ static int32_t FormatTextForTooltip(const OpenRCT2String& message)
OpenRCT2String formattedMessage{ STR_STRING_TOOLTIP, Formatter() };
formattedMessage.args.Add<const char*>(tempBuffer);
format_string(_tooltipText, sizeof(_tooltipText), formattedMessage.str, formattedMessage.args.Data());
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
auto textWidth = gfx_get_string_width_new_lined(_tooltipText);
textWidth = std::min(textWidth, 196);
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
int32_t numLines, fontSpriteBase;
int32_t numLines;
FontSpriteBase fontSpriteBase;
textWidth = gfx_wrap_string(_tooltipText, textWidth + 1, &numLines, &fontSpriteBase);
_tooltipNumLines = numLines;
return textWidth;
@ -77,7 +78,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(FONT_SPRITE_BASE_MEDIUM)) + 4;
int32_t height = ((_tooltipNumLines + 1) * font_get_line_height(FontSpriteBase::MEDIUM)) + 4;
window_tooltip_widgets[WIDX_BACKGROUND].right = width;
window_tooltip_widgets[WIDX_BACKGROUND].bottom = height;

View File

@ -981,7 +981,7 @@ static void window_top_toolbar_paint(rct_window* w, rct_drawpixelinfo* dpi)
// Draw number of players.
auto ft = Formatter();
ft.Add<int32_t>(network_get_num_players());
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
DrawTextBasic(
dpi, screenPos + ScreenCoordsXY{ 23, 1 }, STR_COMMA16, ft, COLOUR_WHITE | COLOUR_FLAG_OUTLINE,
TextAlignment::RIGHT);

View File

@ -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* outFontHeight)
int32_t gfx_wrap_string(utf8* text, int32_t width, int32_t* outNumLines, FontSpriteBase* outFontHeight)
{
constexpr size_t NULL_INDEX = std::numeric_limits<size_t>::max();
thread_local std::string buffer;
@ -269,7 +269,7 @@ int32_t gfx_wrap_string(utf8* text, int32_t width, int32_t* outNumLines, int32_t
void gfx_draw_string_left_centred(
rct_drawpixelinfo* dpi, rct_string_id format, void* args, int32_t colour, const ScreenCoordsXY& coords)
{
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
char* buffer = gCommonStringFormatBuffer;
format_string(buffer, 256, format, args);
int32_t height = string_get_height_raw(buffer);
@ -334,7 +334,7 @@ static void colour_char_window(uint8_t colour, const uint16_t* current_font_flag
void draw_string_centred_raw(rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, int32_t numLines, char* text)
{
ScreenCoordsXY screenCoords(dpi->x, dpi->y);
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
gfx_draw_string(dpi, "", COLOUR_BLACK, screenCoords);
screenCoords = coords;
@ -358,12 +358,12 @@ void draw_string_centred_raw(rct_drawpixelinfo* dpi, const ScreenCoordsXY& coord
int32_t string_get_height_raw(std::string_view text)
{
uint16_t fontBase = gCurrentFontSpriteBase;
auto fontBase = gCurrentFontSpriteBase;
int32_t height = 0;
if (fontBase <= FONT_SPRITE_BASE_MEDIUM)
if (fontBase <= FontSpriteBase::MEDIUM)
height += 10;
else if (fontBase == FONT_SPRITE_BASE_TINY)
else if (fontBase == FontSpriteBase::TINY)
height += 6;
FmtString fmt(text);
@ -372,12 +372,12 @@ int32_t string_get_height_raw(std::string_view text)
switch (token.kind)
{
case FormatToken::Newline:
if (fontBase == FONT_SPRITE_BASE_SMALL || fontBase == FONT_SPRITE_BASE_MEDIUM)
if (fontBase == FontSpriteBase::SMALL || fontBase == FontSpriteBase::MEDIUM)
{
height += 10;
break;
}
else if (fontBase == FONT_SPRITE_BASE_TINY)
else if (fontBase == FontSpriteBase::TINY)
{
height += 6;
break;
@ -385,12 +385,12 @@ int32_t string_get_height_raw(std::string_view text)
height += 18;
break;
case FormatToken::NewlineSmall:
if (fontBase == FONT_SPRITE_BASE_SMALL || fontBase == FONT_SPRITE_BASE_MEDIUM)
if (fontBase == FontSpriteBase::SMALL || fontBase == FontSpriteBase::MEDIUM)
{
height += 5;
break;
}
else if (fontBase == FONT_SPRITE_BASE_TINY)
else if (fontBase == FontSpriteBase::TINY)
{
height += 3;
break;
@ -398,13 +398,13 @@ int32_t string_get_height_raw(std::string_view text)
height += 9;
break;
case FormatToken::FontTiny:
fontBase = FONT_SPRITE_BASE_TINY;
fontBase = FontSpriteBase::TINY;
break;
case FormatToken::FontMedium:
fontBase = FONT_SPRITE_BASE_MEDIUM;
fontBase = FontSpriteBase::MEDIUM;
break;
case FormatToken::FontSmall:
fontBase = FONT_SPRITE_BASE_SMALL;
fontBase = FontSpriteBase::SMALL;
break;
default:
break;
@ -430,15 +430,16 @@ void gfx_draw_string_centred_wrapped_partial(
rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, int32_t width, int32_t colour, rct_string_id format, void* args,
int32_t ticks)
{
int32_t numLines, fontSpriteBase, lineHeight, lineY;
int32_t numLines, lineHeight, lineY;
FontSpriteBase fontSpriteBase;
utf8* buffer = gCommonStringFormatBuffer;
ScreenCoordsXY screenCoords(dpi->x, dpi->y);
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
gfx_draw_string(dpi, "", colour, screenCoords);
format_string(buffer, 256, format, args);
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
gfx_wrap_string(buffer, width, &numLines, &fontSpriteBase);
lineHeight = font_get_line_height(fontSpriteBase);
@ -496,7 +497,7 @@ struct text_draw_info
int32_t maxY;
int32_t flags;
uint8_t palette[8];
uint16_t font_sprite_base;
FontSpriteBase font_sprite_base;
const int8_t* y_offset;
};
@ -695,13 +696,13 @@ static void ttf_process_format_code(rct_drawpixelinfo* dpi, const FmtString::tok
info->y += font_get_line_height_small(info->font_sprite_base);
break;
case FormatToken::FontTiny:
info->font_sprite_base = FONT_SPRITE_BASE_TINY;
info->font_sprite_base = FontSpriteBase::TINY;
break;
case FormatToken::FontSmall:
info->font_sprite_base = FONT_SPRITE_BASE_SMALL;
info->font_sprite_base = FontSpriteBase::SMALL;
break;
case FormatToken::FontMedium:
info->font_sprite_base = FONT_SPRITE_BASE_MEDIUM;
info->font_sprite_base = FontSpriteBase::MEDIUM;
break;
case FormatToken::OutlineEnable:
info->flags |= TEXT_DRAW_FLAG_OUTLINE;
@ -872,14 +873,15 @@ static void ttf_process_initial_colour(int32_t colour, text_draw_info* info)
if (colour != TEXT_COLOUR_254 && colour != TEXT_COLOUR_255)
{
info->flags &= ~(TEXT_DRAW_FLAG_INSET | TEXT_DRAW_FLAG_OUTLINE | TEXT_DRAW_FLAG_DARK | TEXT_DRAW_FLAG_EXTRA_DARK);
if (static_cast<int16_t>(info->font_sprite_base) < 0)
if (info->font_sprite_base == FontSpriteBase::MEDIUM_DARK
|| info->font_sprite_base == FontSpriteBase::MEDIUM_EXTRA_DARK)
{
info->flags |= TEXT_DRAW_FLAG_DARK;
if (static_cast<int16_t>(info->font_sprite_base) == FONT_SPRITE_BASE_MEDIUM_EXTRA_DARK)
if (info->font_sprite_base == FontSpriteBase::MEDIUM_EXTRA_DARK)
{
info->flags |= TEXT_DRAW_FLAG_EXTRA_DARK;
}
info->font_sprite_base = FONT_SPRITE_BASE_MEDIUM;
info->font_sprite_base = FontSpriteBase::MEDIUM;
}
if (colour & COLOUR_FLAG_OUTLINE)
{

View File

@ -85,7 +85,7 @@ 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 int16_t gCurrentFontSpriteBase;
thread_local FontSpriteBase gCurrentFontSpriteBase;
uint8_t gGamePalette[256 * 4];
uint32_t gPaletteEffectFrame;

View File

@ -14,6 +14,7 @@
#include "../interface/Colour.h"
#include "../interface/ZoomLevel.h"
#include "../world/Location.hpp"
#include "Font.h"
#include "Text.h"
#include <memory>
@ -652,7 +653,7 @@ void FASTCALL BlitPixels(const uint8_t* src, uint8_t* dst, const PaletteMap& pal
#define MAX_SCROLLING_TEXT_MODES 38
extern thread_local int16_t gCurrentFontSpriteBase;
extern thread_local FontSpriteBase gCurrentFontSpriteBase;
extern GamePalette gPalette;
extern uint8_t gGamePalette[256 * 4];
@ -760,7 +761,7 @@ 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);
int32_t gfx_wrap_string(char* buffer, int32_t width, int32_t* num_lines, int32_t* font_height);
int32_t gfx_wrap_string(char* buffer, int32_t width, int32_t* num_lines, FontSpriteBase* font_height);
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);

View File

@ -283,12 +283,11 @@ int32_t font_sprite_get_codepoint_offset(int32_t codepoint)
return codepoint - 32;
}
int32_t font_sprite_get_codepoint_width(uint16_t fontSpriteBase, int32_t codepoint)
int32_t font_sprite_get_codepoint_width(FontSpriteBase fontSpriteBase, int32_t codepoint)
{
if (fontSpriteBase == static_cast<uint16_t>(FONT_SPRITE_BASE_MEDIUM_DARK)
|| fontSpriteBase == static_cast<uint16_t>(FONT_SPRITE_BASE_MEDIUM_EXTRA_DARK))
if (fontSpriteBase == FontSpriteBase::MEDIUM_DARK || fontSpriteBase == FontSpriteBase::MEDIUM_EXTRA_DARK)
{
fontSpriteBase = static_cast<uint16_t>(FONT_SPRITE_BASE_MEDIUM);
fontSpriteBase = FontSpriteBase::MEDIUM;
}
int32_t glyphIndex = font_sprite_get_codepoint_offset(codepoint);
@ -312,46 +311,47 @@ int32_t font_sprite_get_codepoint_width(uint16_t fontSpriteBase, int32_t codepoi
return _spriteFontCharacterWidths[baseFontIndex][glyphIndex];
}
int32_t font_sprite_get_codepoint_sprite(int32_t fontSpriteBase, int32_t codepoint)
int32_t font_sprite_get_codepoint_sprite(FontSpriteBase fontSpriteBase, int32_t codepoint)
{
int32_t offset = static_cast<int32_t>(fontSpriteBase);
auto codePointOffset = font_sprite_get_codepoint_offset(codepoint);
if (codePointOffset > FONT_SPRITE_GLYPH_COUNT)
{
fontSpriteBase = font_get_font_index_from_sprite_base(fontSpriteBase) * SPR_G2_GLYPH_COUNT;
offset = font_get_font_index_from_sprite_base(fontSpriteBase) * SPR_G2_GLYPH_COUNT;
}
return SPR_CHAR_START + (IMAGE_TYPE_REMAP | (fontSpriteBase + codePointOffset));
return SPR_CHAR_START + (IMAGE_TYPE_REMAP | (offset + codePointOffset));
}
int32_t font_get_font_index_from_sprite_base(uint16_t spriteBase)
int32_t font_get_font_index_from_sprite_base(FontSpriteBase spriteBase)
{
switch (spriteBase)
{
case FONT_SPRITE_BASE_TINY:
case FontSpriteBase::TINY:
return FONT_SIZE_TINY;
case FONT_SPRITE_BASE_SMALL:
case FontSpriteBase::SMALL:
return FONT_SIZE_SMALL;
default:
case FONT_SPRITE_BASE_MEDIUM:
case FontSpriteBase::MEDIUM:
return FONT_SIZE_MEDIUM;
}
}
int32_t font_get_size_from_sprite_base(uint16_t spriteBase)
int32_t font_get_size_from_sprite_base(FontSpriteBase spriteBase)
{
switch (spriteBase)
{
case FONT_SPRITE_BASE_TINY:
case FontSpriteBase::TINY:
return 0;
case FONT_SPRITE_BASE_SMALL:
case FontSpriteBase::SMALL:
return 1;
default:
case FONT_SPRITE_BASE_MEDIUM:
case FontSpriteBase::MEDIUM:
return 2;
}
}
int32_t font_get_line_height(int32_t fontSpriteBase)
int32_t font_get_line_height(FontSpriteBase fontSpriteBase)
{
int32_t fontSize = font_get_size_from_sprite_base(fontSpriteBase);
#ifndef NO_TTF
@ -368,7 +368,7 @@ int32_t font_get_line_height(int32_t fontSpriteBase)
#endif // NO_TTF
}
int32_t font_get_line_height_small(int32_t fontSpriteBase)
int32_t font_get_line_height_small(FontSpriteBase fontSpriteBase)
{
return font_get_line_height(fontSpriteBase) / 2;
}

View File

@ -12,6 +12,8 @@
#include "../common.h"
constexpr const uint16_t FONT_SPRITE_GLYPH_COUNT = 224;
enum
{
FONT_SIZE_TINY = 2,
@ -20,15 +22,14 @@ enum
FONT_SIZE_COUNT = 3
};
enum
enum class FontSpriteBase : int16_t
{
FONT_SPRITE_GLYPH_COUNT = 224,
FONT_SPRITE_BASE_MEDIUM_EXTRA_DARK = -2,
FONT_SPRITE_BASE_MEDIUM_DARK = -1,
MEDIUM_EXTRA_DARK = -2,
MEDIUM_DARK = -1,
FONT_SPRITE_BASE_TINY = FONT_SIZE_TINY * FONT_SPRITE_GLYPH_COUNT,
FONT_SPRITE_BASE_SMALL = FONT_SIZE_SMALL * FONT_SPRITE_GLYPH_COUNT,
FONT_SPRITE_BASE_MEDIUM = FONT_SIZE_MEDIUM * FONT_SPRITE_GLYPH_COUNT,
TINY = FONT_SIZE_TINY * FONT_SPRITE_GLYPH_COUNT,
SMALL = FONT_SIZE_SMALL * FONT_SPRITE_GLYPH_COUNT,
MEDIUM = FONT_SIZE_MEDIUM * FONT_SPRITE_GLYPH_COUNT,
};
#ifndef NO_TTF
@ -58,12 +59,12 @@ extern TTFFontSetDescriptor* gCurrentTTFFontSet;
void font_sprite_initialise_characters();
int32_t font_sprite_get_codepoint_offset(int32_t codepoint);
int32_t font_sprite_get_codepoint_width(uint16_t fontSpriteBase, int32_t codepoint);
int32_t font_sprite_get_codepoint_sprite(int32_t fontSpriteBase, int32_t codepoint);
int32_t font_get_font_index_from_sprite_base(uint16_t spriteBase);
int32_t font_get_size_from_sprite_base(uint16_t spriteBase);
int32_t font_get_line_height(int32_t fontSpriteBase);
int32_t font_get_line_height_small(int32_t fontSpriteBase);
int32_t font_sprite_get_codepoint_width(FontSpriteBase fontSpriteBase, int32_t codepoint);
int32_t font_sprite_get_codepoint_sprite(FontSpriteBase fontSpriteBase, int32_t codepoint);
int32_t font_get_font_index_from_sprite_base(FontSpriteBase spriteBase);
int32_t font_get_size_from_sprite_base(FontSpriteBase spriteBase);
int32_t font_get_line_height(FontSpriteBase fontSpriteBase);
int32_t font_get_line_height_small(FontSpriteBase fontSpriteBase);
bool font_supports_string_sprite(const utf8* text);
bool font_supports_string_ttf(const utf8* text, int32_t fontSize);
bool font_supports_string(const utf8* text, int32_t fontSize);

View File

@ -57,7 +57,8 @@ void scrolling_text_initialise_bitmaps()
for (int32_t i = 0; i < FONT_SPRITE_GLYPH_COUNT; i++)
{
std::fill_n(drawingSurface, sizeof(drawingSurface), 0x00);
gfx_draw_sprite_software(&dpi, ImageId::FromUInt32(SPR_CHAR_START + FONT_SPRITE_BASE_TINY + i), { -1, 0 });
gfx_draw_sprite_software(
&dpi, ImageId::FromUInt32(SPR_CHAR_START + static_cast<uint32_t>(FontSpriteBase::TINY) + i), { -1, 0 });
for (int32_t x = 0; x < 8; x++)
{
@ -1510,7 +1511,7 @@ static void scrolling_text_set_bitmap_for_sprite(
CodepointView codepoints(token.text);
for (auto codepoint : codepoints)
{
auto characterWidth = font_sprite_get_codepoint_width(FONT_SPRITE_BASE_TINY, codepoint);
auto characterWidth = font_sprite_get_codepoint_width(FontSpriteBase::TINY, codepoint);
auto characterBitmap = font_sprite_get_codepoint_bitmap(codepoint);
for (; characterWidth != 0; characterWidth--, characterBitmap++)
{
@ -1558,7 +1559,7 @@ static void scrolling_text_set_bitmap_for_ttf(
std::string_view text, int32_t scroll, uint8_t* bitmap, const int16_t* scrollPositionOffsets, colour_t colour)
{
#ifndef NO_TTF
auto fontDesc = ttf_get_font_from_sprite_base(FONT_SPRITE_BASE_TINY);
auto fontDesc = ttf_get_font_from_sprite_base(FontSpriteBase::TINY);
if (fontDesc->font == nullptr)
{
scrolling_text_set_bitmap_for_sprite(text, scroll, bitmap, scrollPositionOffsets, colour);

View File

@ -346,7 +346,7 @@ uint32_t ttf_getwidth_cache_get_or_add(TTF_Font* font, std::string_view text)
return entry->width;
}
TTFFontDescriptor* ttf_get_font_from_sprite_base(uint16_t spriteBase)
TTFFontDescriptor* ttf_get_font_from_sprite_base(FontSpriteBase spriteBase)
{
FontLockHelper<std::mutex> lock(_mutex);
return &gCurrentTTFFontSet->size[font_get_size_from_sprite_base(spriteBase)];

View File

@ -26,7 +26,7 @@ struct TTFSurface
int32_t pitch;
};
TTFFontDescriptor* ttf_get_font_from_sprite_base(uint16_t spriteBase);
TTFFontDescriptor* ttf_get_font_from_sprite_base(FontSpriteBase spriteBase);
void ttf_toggle_hinting();
TTFSurface* ttf_surface_cache_get_or_add(TTF_Font* font, std::string_view text);
uint32_t ttf_getwidth_cache_get_or_add(TTF_Font* font, std::string_view text);

View File

@ -23,7 +23,7 @@ StaticLayout::StaticLayout(utf8string source, const TextPaint& paint, int32_t wi
Buffer = source;
Paint = paint;
int32_t fontSpriteBase;
FontSpriteBase fontSpriteBase;
gCurrentFontSpriteBase = paint.SpriteBase;
MaxWidth = gfx_wrap_string(Buffer, width, &LineCount, &fontSpriteBase);
@ -120,8 +120,8 @@ void DrawTextBasic(
rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, rct_string_id format, const void* args, colour_t colour,
TextAlignment alignment, bool underline)
{
TextPaint textPaint = { colour, FONT_SPRITE_BASE_MEDIUM, underline ? TextUnderline::On : TextUnderline::Off, alignment };
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
TextPaint textPaint = { colour, FontSpriteBase::MEDIUM, underline ? TextUnderline::On : TextUnderline::Off, alignment };
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
DrawText(dpi, coords, textPaint, format, args);
}
@ -136,8 +136,8 @@ 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 = { colour, FONT_SPRITE_BASE_MEDIUM, underline ? TextUnderline::On : TextUnderline::Off, alignment };
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
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());
@ -179,9 +179,9 @@ int32_t gfx_draw_string_left_wrapped(
utf8 buffer[512];
format_string(buffer, sizeof(buffer), format, args);
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
TextPaint textPaint = { colour, FONT_SPRITE_BASE_MEDIUM, TextUnderline::Off, TextAlignment::LEFT };
TextPaint textPaint = { colour, FontSpriteBase::MEDIUM, TextUnderline::Off, TextAlignment::LEFT };
StaticLayout layout(buffer, textPaint, width);
layout.Draw(dpi, coords);
@ -194,7 +194,7 @@ int32_t gfx_draw_string_centred_wrapped(
utf8 buffer[512];
format_string(buffer, sizeof(buffer), format, args);
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
TextPaint textPaint = { colour, gCurrentFontSpriteBase, TextUnderline::Off, TextAlignment::CENTRE };
StaticLayout layout(buffer, textPaint, width);

View File

@ -10,6 +10,7 @@
#pragma once
#include "../common.h"
#include "Font.h"
struct ScreenCoordsXY;
struct rct_drawpixelinfo;
@ -31,7 +32,7 @@ enum class TextUnderline
struct TextPaint
{
uint8_t Colour = 0;
int16_t SpriteBase = 0;
FontSpriteBase SpriteBase = FontSpriteBase::SMALL;
TextUnderline UnderlineText = TextUnderline::Off;
TextAlignment Alignment = TextAlignment::LEFT;
};

View File

@ -274,8 +274,9 @@ static int32_t chat_history_draw_string(
auto buffer = gCommonStringFormatBuffer;
FormatStringToBuffer(gCommonStringFormatBuffer, sizeof(gCommonStringFormatBuffer), "{OUTLINE}{WHITE}{STRING}", text);
int32_t fontSpriteBase, numLines;
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
int32_t numLines;
FontSpriteBase fontSpriteBase;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
gfx_wrap_string(buffer, width, &numLines, &fontSpriteBase);
auto lineHeight = font_get_line_height(fontSpriteBase);
@ -299,14 +300,15 @@ 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 fontSpriteBase, lineHeight, lineY, numLines;
int32_t lineHeight, lineY, numLines;
FontSpriteBase fontSpriteBase;
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
char* buffer = gCommonStringFormatBuffer;
format_string(buffer, 256, STR_STRING, args);
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
gfx_wrap_string(buffer, width, &numLines, &fontSpriteBase);
lineHeight = font_get_line_height(fontSpriteBase);

View File

@ -952,7 +952,7 @@ void PaintDrawMoneyStructs(rct_drawpixelinfo* dpi, paint_string_struct* ps)
{
char buffer[256]{};
format_string(buffer, sizeof(buffer), ps->string_id, &ps->args);
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
// Use sprite font unless the currency contains characters unsupported by the sprite font
auto forceSpriteFont = false;

View File

@ -113,7 +113,7 @@ 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 = FONT_SPRITE_BASE_TINY;
gCurrentFontSpriteBase = FontSpriteBase::TINY;
uint16_t string_width = gfx_get_string_width(gCommonStringFormatBuffer);
uint16_t scroll = (gCurrentTicks / 2) % string_width;

View File

@ -183,7 +183,7 @@ 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 = FONT_SPRITE_BASE_TINY;
gCurrentFontSpriteBase = FontSpriteBase::TINY;
uint16_t stringWidth = gfx_get_string_width(entrance_string);
uint16_t scroll = stringWidth > 0 ? (gCurrentTicks / 2) % stringWidth : 0;
@ -291,7 +291,7 @@ 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 = FONT_SPRITE_BASE_TINY;
gCurrentFontSpriteBase = FontSpriteBase::TINY;
uint16_t stringWidth = gfx_get_string_width(park_name);
uint16_t scroll = stringWidth > 0 ? (gCurrentTicks / 2) % stringWidth : 0;

View File

@ -440,7 +440,7 @@ 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 = FONT_SPRITE_BASE_TINY;
gCurrentFontSpriteBase = FontSpriteBase::TINY;
uint16_t stringWidth = gfx_get_string_width(signString);
uint16_t scroll = stringWidth > 0 ? (gCurrentTicks / 2) % stringWidth : 0;

View File

@ -470,7 +470,7 @@ static void sub_6A4101(
format_string(gCommonStringFormatBuffer, sizeof(gCommonStringFormatBuffer), STR_BANNER_TEXT_FORMAT, ft.Data());
}
gCurrentFontSpriteBase = FONT_SPRITE_BASE_TINY;
gCurrentFontSpriteBase = FontSpriteBase::TINY;
uint16_t stringWidth = gfx_get_string_width(gCommonStringFormatBuffer);
uint16_t scroll = stringWidth > 0 ? (gCurrentTicks / 2) % stringWidth : 0;

View File

@ -446,7 +446,7 @@ 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 = FONT_SPRITE_BASE_TINY;
gCurrentFontSpriteBase = FontSpriteBase::TINY;
uint16_t stringWidth = gfx_get_string_width(signString);
uint16_t scroll = stringWidth > 0 ? (gCurrentTicks / 2) % stringWidth : 0;

View File

@ -54,7 +54,7 @@ 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 = FONT_SPRITE_BASE_MEDIUM;
gCurrentFontSpriteBase = FontSpriteBase::MEDIUM;
offsetX = -(gfx_get_string_width(buffer) / 2);
}
moneyEffect->OffsetX = offsetX;