Merge pull request 'font: fix the popup messages with the new font handling' (#20) from amr/rogged:fontFix1 into main
Reviewed-on: #20 Reviewed-by: raf <raf@notashelf.dev>
This commit is contained in:
commit
5577147496
1 changed files with 14 additions and 12 deletions
26
src/render.c
26
src/render.c
|
|
@ -168,6 +168,7 @@ void render_ui(const Player *p, Font *font) {
|
||||||
int bar_height = 16;
|
int bar_height = 16;
|
||||||
|
|
||||||
// HP Label, above bar
|
// HP Label, above bar
|
||||||
|
// Vector2 hp_width = MeasureTextEx(*font, "HP", BIG_FONT, NAR_CHAR_SPACE);
|
||||||
DrawTextEx(*font, "HP", (Vector2){bar_x, bar_y - 17}, BIG_FONT, NAR_CHAR_SPACE, text_dim);
|
DrawTextEx(*font, "HP", (Vector2){bar_x, bar_y - 17}, BIG_FONT, NAR_CHAR_SPACE, text_dim);
|
||||||
|
|
||||||
// HP Bar background
|
// HP Bar background
|
||||||
|
|
@ -351,7 +352,8 @@ void render_action_log(const char log[5][128], int count, int head, Font *font)
|
||||||
} else {
|
} else {
|
||||||
text_color = (Color){120, 110, 100, 200}; // oldest: dim
|
text_color = (Color){120, 110, 100, 200}; // oldest: dim
|
||||||
}
|
}
|
||||||
DrawTextEx(*font, log[idx], (Vector2){text_x, text_start_y + i * line_height}, 10, NAR_CHAR_SPACE, text_color);
|
DrawTextEx(*font, log[idx], (Vector2){text_x, text_start_y + i * line_height}, NORM_FONT, SMALL_CHAR_SPACE,
|
||||||
|
text_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -367,7 +369,7 @@ void render_inventory_overlay(const Player *p, int selected, Font *font) {
|
||||||
|
|
||||||
// Title
|
// Title
|
||||||
const char *title = "INVENTORY";
|
const char *title = "INVENTORY";
|
||||||
int title_w = MeasureText(title, 24);
|
// int title_w = MeasureText(title, 24);
|
||||||
Vector2 t_w = MeasureTextEx(*font, title, 30, NORM_CHAR_SPACE);
|
Vector2 t_w = MeasureTextEx(*font, title, 30, NORM_CHAR_SPACE);
|
||||||
DrawTextEx(*font, title, (Vector2){overlay.x + (overlay.width - t_w.x) / 2, overlay.y + 10}, HUGE_FONT,
|
DrawTextEx(*font, title, (Vector2){overlay.x + (overlay.width - t_w.x) / 2, overlay.y + 10}, HUGE_FONT,
|
||||||
NORM_CHAR_SPACE, WHITE);
|
NORM_CHAR_SPACE, WHITE);
|
||||||
|
|
@ -401,17 +403,17 @@ void render_inventory_overlay(const Player *p, int selected, Font *font) {
|
||||||
Color name_color = (item->type == ITEM_POTION) ? (Color){255, 140, 140, 255}
|
Color name_color = (item->type == ITEM_POTION) ? (Color){255, 140, 140, 255}
|
||||||
: (item->type == ITEM_WEAPON) ? (Color){255, 255, 140, 255}
|
: (item->type == ITEM_WEAPON) ? (Color){255, 255, 140, 255}
|
||||||
: (Color){140, 140, 255, 255};
|
: (Color){140, 140, 255, 255};
|
||||||
DrawTextEx(*font, name, (Vector2){overlay.x + 45, y_pos + 4}, 14, NORM_CHAR_SPACE, name_color);
|
DrawTextEx(*font, name, (Vector2){overlay.x + 45, y_pos + 4}, NORM_FONT, SMALL_CHAR_SPACE, name_color);
|
||||||
}
|
}
|
||||||
// Power
|
// Power
|
||||||
snprintf(slot_text, sizeof(slot_text), "+%d", item->power);
|
snprintf(slot_text, sizeof(slot_text), "+%d", item->power);
|
||||||
DrawTextEx(*font, slot_text, (Vector2){overlay.x + 150, y_pos + 4}, 14, NORM_CHAR_SPACE, YELLOW);
|
DrawTextEx(*font, slot_text, (Vector2){overlay.x + 150, y_pos + 4}, NORM_FONT, SMALL_CHAR_SPACE, YELLOW);
|
||||||
|
|
||||||
// Action
|
// Action
|
||||||
if (item->type == ITEM_POTION) {
|
if (item->type == ITEM_POTION) {
|
||||||
DrawTextEx(*font, "[U]se", (Vector2){overlay.x + 200, y_pos + 4}, 14, NORM_CHAR_SPACE, GREEN);
|
DrawTextEx(*font, "[U]se", (Vector2){overlay.x + 200, y_pos + 4}, NORM_FONT, SMALL_CHAR_SPACE, GREEN);
|
||||||
} else {
|
} else {
|
||||||
DrawTextEx(*font, "[E]quip [D]rop", (Vector2){overlay.x + 200, y_pos + 4}, 14, NORM_CHAR_SPACE, GOLD);
|
DrawTextEx(*font, "[E]quip [D]rop", (Vector2){overlay.x + 200, y_pos + 4}, NORM_FONT, SMALL_CHAR_SPACE, GOLD);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Empty slot
|
// Empty slot
|
||||||
|
|
@ -423,9 +425,9 @@ void render_inventory_overlay(const Player *p, int selected, Font *font) {
|
||||||
|
|
||||||
// Instructions at bottom
|
// Instructions at bottom
|
||||||
const char *hint = "[1-0] Select [E] Equip [U] Use [D] Drop [I/ESC] Close";
|
const char *hint = "[1-0] Select [E] Equip [U] Use [D] Drop [I/ESC] Close";
|
||||||
Vector2 hint_w = MeasureTextEx(*font, hint, NORM_FONT, NAR_CHAR_SPACE);
|
Vector2 hint_w = MeasureTextEx(*font, hint, SMALL_FONT, NAR_CHAR_SPACE);
|
||||||
DrawTextEx(*font, hint, (Vector2){overlay.x + (overlay.width - hint_w.x) / 2, overlay.y + overlay.height - 22},
|
DrawTextEx(*font, hint, (Vector2){overlay.x + (overlay.width - hint_w.x) / 2.0f, overlay.y + overlay.height - 22},
|
||||||
NORM_FONT, NAR_CHAR_SPACE, (Color){80, 80, 80, 255});
|
SMALL_FONT, NAR_CHAR_SPACE, (Color){80, 80, 80, 255});
|
||||||
}
|
}
|
||||||
|
|
||||||
static Color label_color(FloatingText *ft, int alpha) {
|
static Color label_color(FloatingText *ft, int alpha) {
|
||||||
|
|
@ -652,8 +654,8 @@ void render_message(const char *message, Font *font) {
|
||||||
longest_line_width = current_line_width;
|
longest_line_width = current_line_width;
|
||||||
|
|
||||||
// Measure full message
|
// Measure full message
|
||||||
int total_msg_width = MeasureText(message, font_size);
|
Vector2 total_msg_width = MeasureTextEx(*font, message, font_size, NORM_CHAR_SPACE);
|
||||||
int box_width = total_msg_width + (padding_x * 2);
|
int box_width = total_msg_width.x + (padding_x * 2);
|
||||||
|
|
||||||
// If message is too long, use wrapped width
|
// If message is too long, use wrapped width
|
||||||
if (box_width > max_box_width) {
|
if (box_width > max_box_width) {
|
||||||
|
|
@ -677,7 +679,7 @@ void render_message(const char *message, Font *font) {
|
||||||
DrawRectangleLines((int)msg_bg.x, (int)msg_bg.y, (int)msg_bg.width, (int)msg_bg.height, (Color){180, 180, 180, 255});
|
DrawRectangleLines((int)msg_bg.x, (int)msg_bg.y, (int)msg_bg.width, (int)msg_bg.height, (Color){180, 180, 180, 255});
|
||||||
|
|
||||||
// Draw text centered
|
// Draw text centered
|
||||||
int text_x = (SCREEN_WIDTH - total_msg_width) / 2;
|
int text_x = (SCREEN_WIDTH - total_msg_width.x) / 2;
|
||||||
int text_y = (SCREEN_HEIGHT - font_size) / 2;
|
int text_y = (SCREEN_HEIGHT - font_size) / 2;
|
||||||
|
|
||||||
// For wrapped text, draw at box center with padding
|
// For wrapped text, draw at box center with padding
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue