mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-19 04:53:12 +01:00
Pass the formatter directly to scrolling_text_setup
This commit is contained in:
@@ -694,8 +694,12 @@ void ttf_draw_string(rct_drawpixelinfo* dpi, const_utf8string text, int32_t colo
|
||||
// scrolling text
|
||||
void scrolling_text_initialise_bitmaps();
|
||||
void scrolling_text_invalidate();
|
||||
|
||||
class Formatter;
|
||||
|
||||
int32_t scrolling_text_setup(
|
||||
struct paint_session* session, rct_string_id stringId, uint16_t scroll, uint16_t scrollingMode, colour_t colour);
|
||||
struct paint_session* session, rct_string_id stringId, Formatter& ft, uint16_t scroll, uint16_t scrollingMode,
|
||||
colour_t colour);
|
||||
|
||||
rct_size16 FASTCALL gfx_get_sprite_size(uint32_t image_id);
|
||||
size_t g1_calculate_data_size(const rct_g1_element* g1);
|
||||
|
||||
@@ -128,7 +128,7 @@ static uint8_t* font_sprite_get_codepoint_bitmap(int32_t codepoint)
|
||||
}
|
||||
|
||||
static int32_t scrolling_text_get_matching_or_oldest(
|
||||
rct_string_id stringId, uint16_t scroll, uint16_t scrollingMode, colour_t colour)
|
||||
rct_string_id stringId, Formatter& ft, uint16_t scroll, uint16_t scrollingMode, colour_t colour)
|
||||
{
|
||||
uint32_t oldestId = 0xFFFFFFFF;
|
||||
int32_t scrollIndex = -1;
|
||||
@@ -143,7 +143,7 @@ static int32_t scrolling_text_get_matching_or_oldest(
|
||||
|
||||
// If exact match return the matching index
|
||||
if (scrollText->string_id == stringId
|
||||
&& std::memcmp(scrollText->string_args, gCommonFormatArgs, sizeof(scrollText->string_args)) == 0
|
||||
&& std::memcmp(scrollText->string_args, ft.Buf(), sizeof(scrollText->string_args)) == 0
|
||||
&& scrollText->colour == colour && scrollText->position == scroll && scrollText->mode == scrollingMode)
|
||||
{
|
||||
scrollText->id = _drawSCrollNextIndex;
|
||||
@@ -1442,7 +1442,7 @@ void scrolling_text_invalidate()
|
||||
}
|
||||
|
||||
int32_t scrolling_text_setup(
|
||||
paint_session* session, rct_string_id stringId, uint16_t scroll, uint16_t scrollingMode, colour_t colour)
|
||||
paint_session* session, rct_string_id stringId, Formatter& ft, uint16_t scroll, uint16_t scrollingMode, colour_t colour)
|
||||
{
|
||||
std::scoped_lock<std::mutex> lock(_scrollingTextMutex);
|
||||
|
||||
@@ -1454,15 +1454,15 @@ int32_t scrolling_text_setup(
|
||||
return SPR_SCROLLING_TEXT_DEFAULT;
|
||||
|
||||
_drawSCrollNextIndex++;
|
||||
|
||||
int32_t scrollIndex = scrolling_text_get_matching_or_oldest(stringId, scroll, scrollingMode, colour);
|
||||
ft.Rewind();
|
||||
int32_t scrollIndex = scrolling_text_get_matching_or_oldest(stringId, ft, scroll, scrollingMode, colour);
|
||||
if (scrollIndex >= SPR_SCROLLING_TEXT_START)
|
||||
return scrollIndex;
|
||||
|
||||
// Setup scrolling text
|
||||
auto scrollText = &_drawScrollTextList[scrollIndex];
|
||||
scrollText->string_id = stringId;
|
||||
std::memcpy(scrollText->string_args, gCommonFormatArgs, sizeof(scrollText->string_args));
|
||||
std::memcpy(scrollText->string_args, ft.Buf(), sizeof(scrollText->string_args));
|
||||
scrollText->colour = colour;
|
||||
scrollText->position = scroll;
|
||||
scrollText->mode = scrollingMode;
|
||||
|
||||
@@ -118,6 +118,6 @@ void banner_paint(paint_session* session, uint8_t direction, int32_t height, con
|
||||
|
||||
uint16_t string_width = gfx_get_string_width(gCommonStringFormatBuffer);
|
||||
uint16_t scroll = (gCurrentTicks / 2) % string_width;
|
||||
auto scrollIndex = scrolling_text_setup(session, STR_BANNER_TEXT_FORMAT, scroll, scrollingMode, COLOUR_BLACK);
|
||||
auto scrollIndex = scrolling_text_setup(session, STR_BANNER_TEXT_FORMAT, ft, scroll, scrollingMode, COLOUR_BLACK);
|
||||
sub_98199C(session, scrollIndex, 0, 0, 1, 1, 0x15, height + 22, boundBoxOffset.x, boundBoxOffset.y, boundBoxOffset.z);
|
||||
}
|
||||
|
||||
@@ -196,8 +196,8 @@ static void ride_entrance_exit_paint(paint_session* session, uint8_t direction,
|
||||
uint16_t scroll = stringWidth > 0 ? (gCurrentTicks / 2) % stringWidth : 0;
|
||||
|
||||
sub_98199C(
|
||||
session, scrolling_text_setup(session, STR_BANNER_TEXT_FORMAT, scroll, stationObj->ScrollingMode, COLOUR_BLACK), 0,
|
||||
0, 0x1C, 0x1C, 0x33, height + stationObj->Height, 2, 2, height + stationObj->Height);
|
||||
session, scrolling_text_setup(session, STR_BANNER_TEXT_FORMAT, ft, scroll, stationObj->ScrollingMode, COLOUR_BLACK),
|
||||
0, 0, 0x1C, 0x1C, 0x33, height + stationObj->Height, 2, 2, height + stationObj->Height);
|
||||
}
|
||||
|
||||
image_id = entranceImageId;
|
||||
@@ -308,7 +308,7 @@ static void park_entrance_paint(paint_session* session, uint8_t direction, int32
|
||||
break;
|
||||
|
||||
int32_t stsetup = scrolling_text_setup(
|
||||
session, STR_BANNER_TEXT_FORMAT, scroll, entrance->scrolling_mode + direction / 2, COLOUR_BLACK);
|
||||
session, STR_BANNER_TEXT_FORMAT, ft, scroll, entrance->scrolling_mode + direction / 2, COLOUR_BLACK);
|
||||
int32_t text_height = height + entrance->text_height;
|
||||
sub_98199C(session, stsetup, 0, 0, 0x1C, 0x1C, 0x2F, text_height, 2, 2, text_height);
|
||||
}
|
||||
|
||||
@@ -446,7 +446,7 @@ void large_scenery_paint(paint_session* session, uint8_t direction, uint16_t hei
|
||||
uint16_t stringWidth = gfx_get_string_width(signString);
|
||||
uint16_t scroll = stringWidth > 0 ? (gCurrentTicks / 2) % stringWidth : 0;
|
||||
sub_98199C(
|
||||
session, scrolling_text_setup(session, STR_SCROLLING_SIGN_TEXT, scroll, scrollMode, textColour), 0, 0, 1, 1, 21,
|
||||
session, scrolling_text_setup(session, STR_SCROLLING_SIGN_TEXT, ft, scroll, scrollMode, textColour), 0, 0, 1, 1, 21,
|
||||
height + 25, boxoffset.x, boxoffset.y, boxoffset.z);
|
||||
}
|
||||
|
||||
|
||||
@@ -479,8 +479,8 @@ static void sub_6A4101(
|
||||
uint16_t scroll = stringWidth > 0 ? (gCurrentTicks / 2) % stringWidth : 0;
|
||||
|
||||
sub_98199C(
|
||||
session, scrolling_text_setup(session, STR_BANNER_TEXT_FORMAT, scroll, scrollingMode, COLOUR_BLACK), 0, 0, 1, 1,
|
||||
21, height + 7, boundBoxOffsets.x, boundBoxOffsets.y, boundBoxOffsets.z);
|
||||
session, scrolling_text_setup(session, STR_BANNER_TEXT_FORMAT, ft, scroll, scrollingMode, COLOUR_BLACK), 0, 0,
|
||||
1, 1, 21, height + 7, boundBoxOffsets.x, boundBoxOffsets.y, boundBoxOffsets.z);
|
||||
}
|
||||
|
||||
session->InteractionType = VIEWPORT_INTERACTION_ITEM_FOOTPATH;
|
||||
|
||||
@@ -452,7 +452,7 @@ void fence_paint(paint_session* session, uint8_t direction, int32_t height, cons
|
||||
uint16_t scroll = stringWidth > 0 ? (gCurrentTicks / 2) % stringWidth : 0;
|
||||
|
||||
sub_98199C(
|
||||
session, scrolling_text_setup(session, STR_SCROLLING_SIGN_TEXT, scroll, scrollingMode, secondaryColour), 0, 0, 1, 1,
|
||||
13, height + 8, boundsOffset.x, boundsOffset.y, boundsOffset.z);
|
||||
session, scrolling_text_setup(session, STR_SCROLLING_SIGN_TEXT, ft, scroll, scrollingMode, secondaryColour), 0, 0,
|
||||
1, 1, 13, height + 8, boundsOffset.x, boundsOffset.y, boundsOffset.z);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user