implement utf8, part 4

This commit is contained in:
IntelOrca 2015-07-26 18:47:26 +01:00
parent 2bb0c6c53f
commit 1682eae048
6 changed files with 24 additions and 20 deletions

View File

@ -1311,6 +1311,9 @@ static void ttf_draw_string(rct_drawpixelinfo *dpi, char *text, int colour, int
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;
}

View File

@ -725,6 +725,8 @@ static void widget_closebox_draw(rct_drawpixelinfo *dpi, rct_window *w, int widg
gfx_draw_string_centred_clipped(dpi, widget->image, (void*)0x013CE952, colour, l, t, widget->right - widget->left - 2);
}
static const utf8 CheckBoxMarkString[] = { 0xE2, 0x9C, 0x93, 0x00 };
/**
*
* rct2: 0x006EBAD9
@ -754,7 +756,7 @@ static void widget_checkbox_draw(rct_drawpixelinfo *dpi, rct_window *w, int widg
// fill it when checkbox is pressed
if (widget_is_pressed(w, widgetIndex)) {
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 224;
gfx_draw_string(dpi, (char*)0x009DED72, colour & 0x7F, l, yMid - 5);
gfx_draw_string(dpi, (char*)CheckBoxMarkString, colour & 0x7F, l, yMid - 5);
}
}
@ -848,10 +850,10 @@ static void widget_scroll_draw(rct_drawpixelinfo *dpi, rct_window *w, int widget
window_event_scroll_paint_call(w, &scroll_dpi, scrollIndex);
}
static utf8 BlackUpArrowString[] = { 0xC2, 0x8E, 0xE2, 0x96, 0xB2, 0x00 };
static utf8 BlackDownArrowString[] = { 0xC2, 0x8E, 0xE2, 0x96, 0xBC, 0x00 };
static utf8 BlackLeftArrowString[] = { 0xC2, 0x8E, 0xE2, 0x96, 0x80, 0x00 };
static utf8 BlackRightArrowString[] = { 0xC2, 0x8E, 0xE2, 0x96, 0xB6, 0x00 };
static const utf8 BlackUpArrowString[] = { 0xC2, 0x8E, 0xE2, 0x96, 0xB2, 0x00 };
static const utf8 BlackDownArrowString[] = { 0xC2, 0x8E, 0xE2, 0x96, 0xBC, 0x00 };
static const utf8 BlackLeftArrowString[] = { 0xC2, 0x8E, 0xE2, 0x96, 0x80, 0x00 };
static const utf8 BlackRightArrowString[] = { 0xC2, 0x8E, 0xE2, 0x96, 0xB6, 0x00 };
static void widget_hscrollbar_draw(rct_drawpixelinfo *dpi, rct_scroll *scroll, int l, int t, int r, int b, int colour)
{
@ -866,7 +868,7 @@ static void widget_hscrollbar_draw(rct_drawpixelinfo *dpi, rct_scroll *scroll, i
// Left button
gfx_fill_rect_inset(dpi, l, t, l + 9, b, colour, (scroll->flags & HSCROLLBAR_LEFT_PRESSED ? 0x20 : 0));
gfx_draw_string(dpi, BlackLeftArrowString, 0, l + 1, t);
gfx_draw_string(dpi, (char*)BlackLeftArrowString, 0, l + 1, t);
// Thumb
gfx_fill_rect_inset(dpi,
@ -876,7 +878,7 @@ static void widget_hscrollbar_draw(rct_drawpixelinfo *dpi, rct_scroll *scroll, i
// Right button
gfx_fill_rect_inset(dpi, r - 9, t, r, b, colour, (scroll->flags & HSCROLLBAR_RIGHT_PRESSED ? 0x20 : 0));
gfx_draw_string(dpi, BlackRightArrowString, 0, r - 6, t);
gfx_draw_string(dpi, (char*)BlackRightArrowString, 0, r - 6, t);
}
static void widget_vscrollbar_draw(rct_drawpixelinfo *dpi, rct_scroll *scroll, int l, int t, int r, int b, int colour)
@ -892,7 +894,7 @@ static void widget_vscrollbar_draw(rct_drawpixelinfo *dpi, rct_scroll *scroll, i
// Up button
gfx_fill_rect_inset(dpi, l, t, r, t + 9, colour, (scroll->flags & VSCROLLBAR_UP_PRESSED ? 0x20 : 0));
gfx_draw_string(dpi, BlackUpArrowString, 0, l + 1, t - 1);
gfx_draw_string(dpi, (char*)BlackUpArrowString, 0, l + 1, t - 1);
// Thumb
gfx_fill_rect_inset(dpi,
@ -902,7 +904,7 @@ static void widget_vscrollbar_draw(rct_drawpixelinfo *dpi, rct_scroll *scroll, i
// Down button
gfx_fill_rect_inset(dpi, l, b - 9, r, b, colour, (scroll->flags & VSCROLLBAR_DOWN_PRESSED ? 0x20 : 0));
gfx_draw_string(dpi, BlackDownArrowString, 0, l + 1, b - 9);
gfx_draw_string(dpi, (char*)BlackDownArrowString, 0, l + 1, b - 9);
}
/**

View File

@ -328,8 +328,7 @@ void news_item_add_to_queue_raw(uint8 type, const char *text, uint32 assoc)
newsItem->ticks = 0;
newsItem->month_year = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_YEAR, uint16);
newsItem->day = ((days_in_month[(newsItem->month_year & 7)] * RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_MONTH_TICKS, uint16)) >> 16) + 1;
newsItem->colour = text[0];
strncpy(newsItem->text, text + 1, 254);
strncpy(newsItem->text, text, 255);
newsItem->text[254] = 0;
// blatant disregard for what happens on the last element.

View File

@ -48,8 +48,7 @@ typedef struct {
uint16 month_year; // 0x08
uint8 day; // 0x0A
uint8 pad_0B; // 0x0B
uint8 colour; // 0x0C
char text[255]; // 0x0D
utf8 text[256]; // 0x0C
} rct_news_item;
void news_item_init_queue();

View File

@ -524,8 +524,8 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo *dpi, rc
// Text
stringId = 1926;
// memcpy((char*)language_get_string(1926) + 1, &newsItem->colour, 256);
memcpy((void*)0x009B5F2C, &newsItem->colour, 256);
utf8 *buffer = (utf8*)0x009B5F2C;
memcpy(buffer, &newsItem->text, 256);
x = w->x + (middleOutsetWidget->left + middleOutsetWidget->right) / 2;
y = w->y + middleOutsetWidget->top + 11;
width = middleOutsetWidget->right - middleOutsetWidget->left - 62;

View File

@ -295,11 +295,12 @@ static void window_news_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int s
gfx_draw_string_left(dpi, 2235, (void*)0x013CE952, 2, 4, y);
// Item text
char sz[400];// = (char*)0x09B5F2C;
char* args[1];
args[0] = (char*)&sz;
sprintf(sz, "%c%c%s", newsItem->colour, FORMAT_SMALLFONT, newsItem->text);
gfx_draw_string_left_wrapped(dpi, args, 2, y + 10, 325, 1170, 14);
utf8 buffer[400];
utf8 *ch = buffer;
ch = utf8_write_codepoint(ch, FORMAT_SMALLFONT);
memcpy(ch, newsItem->text, 256);
ch = buffer;
gfx_draw_string_left_wrapped(dpi, &ch, 2, y + 10, 325, 1170, 14);
// Subject button
if ((RCT2_ADDRESS(0x0097BE7C, uint8)[newsItem->type] & 2) && !(newsItem->flags & 1)) {