mirror of https://github.com/OpenRCT2/OpenRCT2.git
Name font flags
This commit is contained in:
parent
516b4c645b
commit
ec6724b4d4
|
@ -30,6 +30,8 @@ enum {
|
|||
|
||||
enum {
|
||||
FONT_SPRITE_GLYPH_COUNT = 224,
|
||||
FONT_SPRITE_BASE_MEDIUM_EXTRA_DARK = -2,
|
||||
FONT_SPRITE_BASE_MEDIUM_DARK = -1,
|
||||
|
||||
FONT_SPRITE_BASE_TINY = 448,
|
||||
FONT_SPRITE_BASE_SMALL = 0,
|
||||
|
|
|
@ -24,6 +24,16 @@
|
|||
#include "../world/map.h"
|
||||
#include "drawing.h"
|
||||
|
||||
enum {
|
||||
TEXT_DRAW_FLAG_INSET = 1 << 0,
|
||||
TEXT_DRAW_FLAG_OUTLINE = 1 << 1,
|
||||
TEXT_DRAW_FLAG_DARK = 1 << 2,
|
||||
TEXT_DRAW_FLAG_EXTRA_DARK = 1 << 3,
|
||||
TEXT_DRAW_FLAG_Y_OFFSET_EFFECT = 1 << 29,
|
||||
TEXT_DRAW_FLAG_TTF = 1 << 30,
|
||||
TEXT_DRAW_FLAG_NO_DRAW = 1u << 31
|
||||
};
|
||||
|
||||
static int ttf_get_string_width(const utf8 *text);
|
||||
static void ttf_draw_string(rct_drawpixelinfo *dpi, char *buffer, int colour, int x, int y);
|
||||
|
||||
|
@ -365,7 +375,7 @@ int gfx_draw_string_centred_wrapped(rct_drawpixelinfo *dpi, void *args, int x, i
|
|||
|
||||
for (int line = 0; line <= num_lines; ++line) {
|
||||
int half_width = gfx_get_string_width(buffer) / 2;
|
||||
gfx_draw_string(dpi, buffer, 0xFE, x - half_width, line_y);
|
||||
gfx_draw_string(dpi, buffer, TEXT_COLOUR_254, x - half_width, line_y);
|
||||
|
||||
buffer = get_string_end(buffer) + 1;
|
||||
line_y += line_height;
|
||||
|
@ -403,7 +413,7 @@ int gfx_draw_string_left_wrapped(rct_drawpixelinfo *dpi, void *args, int x, int
|
|||
gCurrentFontFlags = 0;
|
||||
lineY = y;
|
||||
for (int line = 0; line <= numLines; ++line) {
|
||||
gfx_draw_string(dpi, buffer, 0xFE, x, lineY);
|
||||
gfx_draw_string(dpi, buffer, TEXT_COLOUR_254, x, lineY);
|
||||
buffer = get_string_end(buffer) + 1;
|
||||
lineY += lineHeight;
|
||||
}
|
||||
|
@ -471,7 +481,7 @@ static void colour_char_window(uint8 colour, uint16* current_font_flags,uint8* p
|
|||
|
||||
colour = NOT_TRANSLUCENT(colour);
|
||||
eax = ColourMapA[colour].colour_11;
|
||||
if (*current_font_flags & 2) {
|
||||
if (*current_font_flags & TEXT_DRAW_FLAG_OUTLINE) {
|
||||
eax |= 0x0A0A00;
|
||||
}
|
||||
//Adjust text palette. Store current colour?
|
||||
|
@ -558,7 +568,7 @@ void draw_string_centred_raw(rct_drawpixelinfo *dpi, int x, int y, int numLines,
|
|||
|
||||
for (int i = 0; i <= numLines; i++) {
|
||||
int width = gfx_get_string_width(text);
|
||||
gfx_draw_string(dpi, text, 254, x - (width / 2), y);
|
||||
gfx_draw_string(dpi, text, TEXT_COLOUR_254, x - (width / 2), y);
|
||||
|
||||
const utf8 *ch = text;
|
||||
const utf8 *nextCh = 0;
|
||||
|
@ -685,7 +695,7 @@ void gfx_draw_string_centred_wrapped_partial(rct_drawpixelinfo *dpi, int x, int
|
|||
ch = nextCh;
|
||||
}
|
||||
|
||||
gfx_draw_string(dpi, buffer, 0xFE, x - halfWidth, lineY);
|
||||
gfx_draw_string(dpi, buffer, TEXT_COLOUR_254, x - halfWidth, lineY);
|
||||
|
||||
if (numCharactersDrawn > numCharactersToDraw) {
|
||||
break;
|
||||
|
@ -887,14 +897,6 @@ TTFFontDescriptor *ttf_get_font_from_sprite_base(uint16 spriteBase)
|
|||
return &gCurrentTTFFontSet->size[font_get_size_from_sprite_base(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 = 1u << 31
|
||||
};
|
||||
|
||||
typedef struct text_draw_info {
|
||||
int startX;
|
||||
int startY;
|
||||
|
@ -1204,14 +1206,14 @@ static void ttf_process_string(rct_drawpixelinfo *dpi, const utf8 *text, text_dr
|
|||
|
||||
static void ttf_process_initial_colour(int colour, text_draw_info *info)
|
||||
{
|
||||
if (colour != 254 && colour != 255) {
|
||||
info->flags &= ~(TEXT_DRAW_FLAG_INSET | TEXT_DRAW_FLAG_OUTLINE | 4 | 8);
|
||||
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 ((sint16)info->font_sprite_base < 0) {
|
||||
info->flags |= 4;
|
||||
if ((sint16)info->font_sprite_base != -1) {
|
||||
info->flags |= 8;
|
||||
info->flags |= TEXT_DRAW_FLAG_DARK;
|
||||
if ((sint16)info->font_sprite_base == FONT_SPRITE_BASE_MEDIUM_EXTRA_DARK) {
|
||||
info->flags |= TEXT_DRAW_FLAG_EXTRA_DARK;
|
||||
}
|
||||
info->font_sprite_base = 224;
|
||||
info->font_sprite_base = FONT_SPRITE_BASE_MEDIUM;
|
||||
}
|
||||
if (colour & COLOUR_FLAG_OUTLINE) {
|
||||
info->flags |= TEXT_DRAW_FLAG_OUTLINE;
|
||||
|
@ -1227,8 +1229,8 @@ static void ttf_process_initial_colour(int colour, text_draw_info *info)
|
|||
colour &= ~COLOUR_FLAG_INSET;
|
||||
|
||||
uint32 eax;
|
||||
if (info->flags & 4) {
|
||||
if (info->flags & 8) {
|
||||
if (info->flags & TEXT_DRAW_FLAG_DARK) {
|
||||
if (info->flags & TEXT_DRAW_FLAG_EXTRA_DARK) {
|
||||
eax = ColourMapA[colour].mid_light;
|
||||
eax = eax << 16;
|
||||
eax = eax | ColourMapA[colour].dark;
|
||||
|
|
|
@ -153,7 +153,7 @@ void chat_draw(rct_drawpixelinfo * dpi)
|
|||
y = _chatBottom - inputLineHeight - 5;
|
||||
|
||||
lineCh = lineBuffer;
|
||||
int inputLineHeight = gfx_draw_string_left_wrapped(dpi, (void*)&lineCh, x, y + 3, _chatWidth - 10, STR_STRING, 255);
|
||||
int inputLineHeight = gfx_draw_string_left_wrapped(dpi, (void*)&lineCh, x, y + 3, _chatWidth - 10, STR_STRING, TEXT_COLOUR_255);
|
||||
gfx_set_dirty_blocks(x, y, x + _chatWidth, y + inputLineHeight + 15);
|
||||
|
||||
//TODO: Show caret if the input text have multiple lines
|
||||
|
@ -218,7 +218,7 @@ int chat_history_draw_string(rct_drawpixelinfo *dpi, void *args, int x, int y, i
|
|||
|
||||
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
|
||||
|
||||
gfx_draw_string(dpi, "", 255, dpi->x, dpi->y);
|
||||
gfx_draw_string(dpi, "", TEXT_COLOUR_255, dpi->x, dpi->y);
|
||||
char *buffer = gCommonStringFormatBuffer;
|
||||
format_string(buffer, 256, STR_STRING, args);
|
||||
|
||||
|
@ -235,7 +235,7 @@ int chat_history_draw_string(rct_drawpixelinfo *dpi, void *args, int x, int y, i
|
|||
|
||||
lineY = y;
|
||||
for (int line = 0; line <= numLines; ++line) {
|
||||
gfx_draw_string(dpi, buffer, 0xFE, x, lineY - (numLines * lineHeight));
|
||||
gfx_draw_string(dpi, buffer, TEXT_COLOUR_254, x, lineY - (numLines * lineHeight));
|
||||
buffer = get_string_end(buffer) + 1;
|
||||
lineY += lineHeight;
|
||||
}
|
||||
|
|
|
@ -67,6 +67,9 @@ enum {
|
|||
COLOUR_LIGHT_WATER = 10
|
||||
};
|
||||
|
||||
#define TEXT_COLOUR_254 (254)
|
||||
#define TEXT_COLOUR_255 (255)
|
||||
|
||||
#define COLOUR_FLAG_OUTLINE (1 << 5)
|
||||
#define COLOUR_FLAG_INSET (1 << 6) // 64, 0x40
|
||||
#define COLOUR_FLAG_TRANSLUCENT (1 << 7)
|
||||
|
|
|
@ -227,7 +227,7 @@ void console_draw(rct_drawpixelinfo *dpi)
|
|||
lineCh = lineBuffer;
|
||||
lineCh = utf8_write_codepoint(lineCh, FORMAT_WHITE);
|
||||
safe_strcpy(lineCh, _consoleCurrentLine, sizeof(lineBuffer) - (lineCh - lineBuffer));
|
||||
gfx_draw_string(dpi, lineBuffer, 255, x, y);
|
||||
gfx_draw_string(dpi, lineBuffer, TEXT_COLOUR_255, x, y);
|
||||
|
||||
// Draw caret
|
||||
if (_consoleCaretTicks < 15) {
|
||||
|
|
|
@ -898,9 +898,9 @@ static void window_editor_inventions_list_scrollpaint(rct_window *w, rct_drawpix
|
|||
format_string(ptr, 256, stringId, NULL);
|
||||
|
||||
if (disableItemMovement) {
|
||||
gCurrentFontSpriteBase = -1;
|
||||
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM_DARK;
|
||||
if (colour == COLOUR_BRIGHT_GREEN && _editorInventionsListDraggedItem == NULL) {
|
||||
gCurrentFontSpriteBase = -2;
|
||||
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM_EXTRA_DARK;
|
||||
}
|
||||
colour = COLOUR_FLAG_INSET | w->colours[1];
|
||||
} else {
|
||||
|
|
|
@ -1422,7 +1422,7 @@ static void window_editor_object_selection_scrollpaint(rct_window *w, rct_drawpi
|
|||
// Draw checkmark
|
||||
if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) && (*listItem->flags & OBJECT_SELECTION_FLAG_SELECTED)) {
|
||||
x = 2;
|
||||
gCurrentFontSpriteBase = colour == COLOUR_BRIGHT_GREEN ? -2 : -1;
|
||||
gCurrentFontSpriteBase = colour == COLOUR_BRIGHT_GREEN ? FONT_SPRITE_BASE_MEDIUM_EXTRA_DARK : FONT_SPRITE_BASE_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;
|
||||
|
@ -1436,7 +1436,7 @@ static void window_editor_object_selection_scrollpaint(rct_window *w, rct_drawpi
|
|||
char *buffer = utf8_write_codepoint(bufferWithColour, colour);
|
||||
if (*listItem->flags & OBJECT_SELECTION_FLAG_6) {
|
||||
colour = w->colours[1] & 0x7F;
|
||||
gCurrentFontSpriteBase = -1;
|
||||
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM_DARK;
|
||||
}
|
||||
else {
|
||||
colour = COLOUR_BLACK;
|
||||
|
|
|
@ -1218,7 +1218,7 @@ static void window_editor_objective_options_rides_scrollpaint(rct_window *w, rct
|
|||
// Checkbox mark
|
||||
ride = get_ride(w->list_item_positions[i]);
|
||||
if (ride->lifecycle_flags & RIDE_LIFECYCLE_INDESTRUCTIBLE) {
|
||||
gCurrentFontSpriteBase = stringId == STR_WINDOW_COLOUR_2_STRINGID ? -2 : -1;
|
||||
gCurrentFontSpriteBase = stringId == STR_WINDOW_COLOUR_2_STRINGID ? FONT_SPRITE_BASE_MEDIUM_EXTRA_DARK : FONT_SPRITE_BASE_MEDIUM_DARK;
|
||||
gfx_draw_string(dpi, (char*)CheckBoxMarkString, w->colours[1] & 0x7F, 2, y);
|
||||
}
|
||||
|
||||
|
|
|
@ -837,7 +837,7 @@ void window_themes_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int scroll
|
|||
|
||||
gfx_fill_rect_inset(dpi, _button_offset_x + 12 * j, y + _check_offset_y, _button_offset_x + 12 * j + 9, y + _check_offset_y + 10, w->colours[1], INSET_RECT_F_E0);
|
||||
if (colour & COLOUR_FLAG_TRANSLUCENT) {
|
||||
gCurrentFontSpriteBase = -1;
|
||||
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM_DARK;
|
||||
gfx_draw_string(dpi, (char*)CheckBoxMarkString, w->colours[1] & 0x7F, _button_offset_x + 12 * j, y + _check_offset_y);
|
||||
}
|
||||
|
||||
|
|
|
@ -493,7 +493,7 @@ static void window_scenarioselect_scrollpaint(rct_window *w, rct_drawpixelinfo *
|
|||
set_format_arg(2, char *, buffer);
|
||||
colour = isDisabled ? w->colours[1] | COLOUR_FLAG_INSET : COLOUR_BLACK;
|
||||
if (isDisabled) {
|
||||
gCurrentFontSpriteBase = -1;
|
||||
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM_DARK;
|
||||
}
|
||||
gfx_draw_string_centred(dpi, format, wide ? 270 : 210, y + 1, colour, gCommonFormatArgs);
|
||||
|
||||
|
|
Loading…
Reference in New Issue