mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fix #14212: Multiline news messages are shown incorrectly
This commit is contained in:
parent
30edc834ee
commit
50da55eaf3
|
@ -565,8 +565,7 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo* dpi, rc
|
|||
const auto* newsItemText = newsItem->Text.c_str();
|
||||
auto screenCoords = w->windowPos + ScreenCoordsXY{ middleOutsetWidget->midX(), middleOutsetWidget->top + 11 };
|
||||
width = middleOutsetWidget->width() - 62;
|
||||
gfx_draw_string_centred_wrapped_partial(
|
||||
dpi, screenCoords, width, COLOUR_BRIGHT_GREEN, STR_BOTTOM_TOOLBAR_NEWS_TEXT, &newsItemText, newsItem->Ticks);
|
||||
DrawNewsTicker(dpi, screenCoords, width, COLOUR_BRIGHT_GREEN, STR_BOTTOM_TOOLBAR_NEWS_TEXT, &newsItemText, newsItem->Ticks);
|
||||
|
||||
screenCoords = w->windowPos
|
||||
+ ScreenCoordsXY{ window_game_bottom_toolbar_widgets[WIDX_NEWS_SUBJECT].left,
|
||||
|
|
|
@ -243,13 +243,13 @@ static void window_news_scrollpaint(rct_window* w, rct_drawpixelinfo* dpi, int32
|
|||
auto ft = Formatter();
|
||||
ft.Add<rct_string_id>(DateDayNames[newsItem.Day - 1]);
|
||||
ft.Add<rct_string_id>(DateGameMonthNames[date_get_month(newsItem.MonthYear)]);
|
||||
DrawTextBasic(dpi, { 2, y }, STR_NEWS_DATE_FORMAT, ft, { COLOUR_WHITE });
|
||||
DrawTextBasic(dpi, { 2, y }, STR_NEWS_DATE_FORMAT, ft, { COLOUR_WHITE, FontSpriteBase::SMALL });
|
||||
}
|
||||
// Item text
|
||||
{
|
||||
auto ft = Formatter();
|
||||
ft.Add<const char*>(newsItem.Text.c_str());
|
||||
DrawTextWrapped(dpi, { 2, y + lineHeight }, 325, STR_BOTTOM_TOOLBAR_NEWS_TEXT, ft);
|
||||
DrawTextWrapped(dpi, { 2, y + lineHeight }, 325, STR_BOTTOM_TOOLBAR_NEWS_TEXT, ft, { FontSpriteBase::SMALL });
|
||||
}
|
||||
// Subject button
|
||||
if ((newsItem.TypeHasSubject()) && !(newsItem.HasButton()))
|
||||
|
|
|
@ -422,7 +422,7 @@ int32_t string_get_height_raw(std::string_view text, FontSpriteBase fontBase)
|
|||
* width : bp
|
||||
* ticks : ebp >> 16
|
||||
*/
|
||||
void gfx_draw_string_centred_wrapped_partial(
|
||||
void DrawNewsTicker(
|
||||
rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, int32_t width, colour_t colour, rct_string_id format, void* args,
|
||||
int32_t ticks)
|
||||
{
|
||||
|
@ -433,8 +433,8 @@ void gfx_draw_string_centred_wrapped_partial(
|
|||
gfx_draw_string(dpi, screenCoords, "", { colour });
|
||||
format_string(buffer, 256, format, args);
|
||||
|
||||
gfx_wrap_string(buffer, width, FontSpriteBase::MEDIUM, &numLines);
|
||||
lineHeight = font_get_line_height(FontSpriteBase::MEDIUM);
|
||||
gfx_wrap_string(buffer, width, FontSpriteBase::SMALL, &numLines);
|
||||
lineHeight = font_get_line_height(FontSpriteBase::SMALL);
|
||||
|
||||
int32_t numCharactersDrawn = 0;
|
||||
int32_t numCharactersToDraw = ticks;
|
||||
|
@ -442,7 +442,7 @@ void gfx_draw_string_centred_wrapped_partial(
|
|||
lineY = coords.y - ((numLines * lineHeight) / 2);
|
||||
for (int32_t line = 0; line <= numLines; line++)
|
||||
{
|
||||
int32_t halfWidth = gfx_get_string_width(buffer, FontSpriteBase::MEDIUM) / 2;
|
||||
int32_t halfWidth = gfx_get_string_width(buffer, FontSpriteBase::SMALL) / 2;
|
||||
|
||||
FmtString fmt(buffer);
|
||||
for (const auto& token : fmt)
|
||||
|
@ -468,7 +468,7 @@ void gfx_draw_string_centred_wrapped_partial(
|
|||
}
|
||||
|
||||
screenCoords = { coords.x - halfWidth, lineY };
|
||||
gfx_draw_string(dpi, screenCoords, buffer, { TEXT_COLOUR_254 });
|
||||
gfx_draw_string(dpi, screenCoords, buffer, { TEXT_COLOUR_254, FontSpriteBase::SMALL });
|
||||
|
||||
if (numCharactersDrawn > numCharactersToDraw)
|
||||
{
|
||||
|
|
|
@ -741,7 +741,7 @@ 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, FontSpriteBase fontSpriteBase);
|
||||
void gfx_draw_string_centred_wrapped_partial(
|
||||
void DrawNewsTicker(
|
||||
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(
|
||||
|
|
Loading…
Reference in New Issue