mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-06 06:32:56 +01:00
implement utf8, part 26 (bug fixes)
This commit is contained in:
@@ -133,6 +133,7 @@ void gfx_draw_string_right(rct_drawpixelinfo *dpi, int format, void *args, int c
|
||||
void draw_string_right_underline(rct_drawpixelinfo *dpi, int format, void *args, int colour, int x, int y);
|
||||
int string_get_height_raw(char *buffer);
|
||||
void gfx_draw_string_centred_wrapped_partial(rct_drawpixelinfo *dpi, int x, int y, int width, int colour, rct_string_id format, void *args, int ticks);
|
||||
void gfx_draw_string_with_y_offsets(rct_drawpixelinfo *dpi, utf8 *text, int colour, int x, int y, const sint8 *yOffsets);
|
||||
|
||||
bool ttf_initialise();
|
||||
void ttf_dispose();
|
||||
|
||||
@@ -924,6 +924,7 @@ TTFFontDescriptor *ttf_get_font_from_sprite_base(uint16 spriteBase)
|
||||
enum {
|
||||
TEXT_DRAW_FLAG_INSET = 1 << 0,
|
||||
TEXT_DRAW_FLAG_OUTLINE = 1 << 1,
|
||||
TEXT_DRAW_FLAG_Y_OFFSET_EFFECT = 1 << 29,
|
||||
TEXT_DRAW_FLAG_TTF = 1 << 30,
|
||||
TEXT_DRAW_FLAG_NO_DRAW = 1 << 31
|
||||
};
|
||||
@@ -938,6 +939,7 @@ typedef struct {
|
||||
int flags;
|
||||
uint8 palette[8];
|
||||
uint16 font_sprite_base;
|
||||
const sint8 *y_offset;
|
||||
} text_draw_info;
|
||||
|
||||
static void ttf_draw_character_sprite(rct_drawpixelinfo *dpi, int codepoint, text_draw_info *info)
|
||||
@@ -948,7 +950,13 @@ static void ttf_draw_character_sprite(rct_drawpixelinfo *dpi, int codepoint, tex
|
||||
if (!(info->flags & TEXT_DRAW_FLAG_NO_DRAW)) {
|
||||
RCT2_GLOBAL(0x009ABDA4, uint8*) = (uint8*)&info->palette;
|
||||
RCT2_GLOBAL(0x00EDF81C, uint32) = (IMAGE_TYPE_USE_PALETTE << 28);
|
||||
gfx_draw_sprite_palette_set(dpi, sprite, info->x, info->y, info->palette, NULL);
|
||||
|
||||
int x = info->x;
|
||||
int y = info->y;
|
||||
if (info->flags & TEXT_DRAW_FLAG_Y_OFFSET_EFFECT) {
|
||||
y += *info->y_offset++;
|
||||
}
|
||||
gfx_draw_sprite_palette_set(dpi, sprite, x, y, info->palette, NULL);
|
||||
}
|
||||
|
||||
info->x += characterWidth;
|
||||
@@ -972,6 +980,7 @@ static void ttf_draw_string_raw_ttf(rct_drawpixelinfo *dpi, const utf8 *text, te
|
||||
TTFFontDescriptor *fontDesc = ttf_get_font_from_sprite_base(info->font_sprite_base);
|
||||
if (fontDesc->font == NULL) {
|
||||
ttf_draw_string_raw_sprite(dpi, text, info);
|
||||
return;
|
||||
}
|
||||
|
||||
if (info->flags & TEXT_DRAW_FLAG_NO_DRAW) {
|
||||
@@ -1301,3 +1310,34 @@ static int ttf_get_string_width(const utf8 *text)
|
||||
|
||||
return info.maxX;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00682F28
|
||||
*/
|
||||
void gfx_draw_string_with_y_offsets(rct_drawpixelinfo *dpi, utf8 *text, int colour, int x, int y, const sint8 *yOffsets)
|
||||
{
|
||||
text_draw_info info;
|
||||
info.font_sprite_base = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16);
|
||||
info.flags = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_FLAGS, uint16);
|
||||
info.startX = x;
|
||||
info.startY = x;
|
||||
info.x = x;
|
||||
info.y = y;
|
||||
info.y_offset = yOffsets;
|
||||
|
||||
info.flags |= TEXT_DRAW_FLAG_Y_OFFSET_EFFECT;
|
||||
|
||||
// if (gUseTrueTypeFont) info.flags |= TEXT_DRAW_FLAG_TTF;
|
||||
|
||||
memcpy(info.palette, text_palette, sizeof(info.palette));
|
||||
ttf_process_initial_colour(colour, &info);
|
||||
ttf_process_string(dpi, text, &info);
|
||||
memcpy(text_palette, info.palette, sizeof(info.palette));
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = info.font_sprite_base;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_FLAGS, uint16) = info.flags;
|
||||
|
||||
gLastDrawStringX = info.x;
|
||||
gLastDrawStringY = info.y;
|
||||
}
|
||||
|
||||
@@ -1990,6 +1990,48 @@ void sub_688217()
|
||||
sub_688217_helper(eax & 0xFFFF, 0);
|
||||
}
|
||||
|
||||
typedef struct paint_string_struct paint_string_struct;
|
||||
struct paint_string_struct {
|
||||
rct_string_id string_id; // 0x00
|
||||
paint_string_struct *next; // 0x02
|
||||
uint16 x; // 0x06
|
||||
uint16 y; // 0x08
|
||||
uint8 args[16]; // 0x0A
|
||||
uint8 *y_offsets; // 0x1A
|
||||
};
|
||||
|
||||
static void draw_pixel_info_crop_by_zoom(rct_drawpixelinfo *dpi)
|
||||
{
|
||||
int zoom = dpi->zoom_level;
|
||||
dpi->zoom_level = 0;
|
||||
dpi->x >>= zoom;
|
||||
dpi->y >>= zoom;
|
||||
dpi->width >>= zoom;
|
||||
dpi->height >>= zoom;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2:0x006860C3
|
||||
*/
|
||||
static void viewport_draw_money_effects()
|
||||
{
|
||||
utf8 buffer[256];
|
||||
|
||||
paint_string_struct *ps = RCT2_GLOBAL(0x00F1AD20, paint_string_struct*);
|
||||
if (ps == NULL)
|
||||
return;
|
||||
|
||||
rct_drawpixelinfo dpi = *(RCT2_GLOBAL(0x0140E9A8, rct_drawpixelinfo*));
|
||||
draw_pixel_info_crop_by_zoom(&dpi);
|
||||
|
||||
do {
|
||||
format_string(buffer, ps->string_id, &ps->args);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = FONT_SPRITE_BASE_MEDIUM;
|
||||
gfx_draw_string_with_y_offsets(&dpi, buffer, 0, ps->x, ps->y, ps->y_offsets);
|
||||
} while ((ps = ps->next) != NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2:0x00685CBF
|
||||
@@ -2087,7 +2129,7 @@ void viewport_paint(rct_viewport* viewport, rct_drawpixelinfo* dpi, int left, in
|
||||
if ((weather_colour != -1) && (!(RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_VIEWPORT_FLAGS, uint16) & 0x4000)) && (!(RCT2_GLOBAL(0x9DEA6F, uint8) & 1))){
|
||||
gfx_fill_rect(dpi2, dpi2->x, dpi2->y, dpi2->width + dpi2->x - 1, dpi2->height + dpi2->y - 1, weather_colour);
|
||||
}
|
||||
RCT2_CALLPROC_EBPSAFE(0x6860C3); //string related
|
||||
viewport_draw_money_effects();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user