Mercurial > molko
comparison libmlk-rpg/mlk/rpg/battle-bar-default.c @ 504:52a305833381
ui: rework styles
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 01 Mar 2023 14:07:10 +0100 |
parents | 2af25db99273 |
children | 6100c643dba0 |
comparison
equal
deleted
inserted
replaced
503:a55d0a29f466 | 504:52a305833381 |
---|---|
40 #include "character.h" | 40 #include "character.h" |
41 #include "inventory.h" | 41 #include "inventory.h" |
42 #include "item.h" | 42 #include "item.h" |
43 #include "spell.h" | 43 #include "spell.h" |
44 | 44 |
45 #define THEME(bar) ((bar)->theme ? (bar)->theme : mlk_theme_default()) | 45 #define THEME(bar) ((bar)->theme ? (bar)->theme : &mlk_theme) |
46 | 46 |
47 struct geo { | 47 struct geo { |
48 int x, y; | 48 int x, y; |
49 unsigned int w, h; | 49 unsigned int w, h; |
50 }; | 50 }; |
236 /* Compute spacing between elements. */ | 236 /* Compute spacing between elements. */ |
237 spacing = h - (mlk_font_height(theme->fonts[MLK_THEME_FONT_INTERFACE]) * 3); | 237 spacing = h - (mlk_font_height(theme->fonts[MLK_THEME_FONT_INTERFACE]) * 3); |
238 spacing /= 4; | 238 spacing /= 4; |
239 | 239 |
240 /* Reuse the same label. */ | 240 /* Reuse the same label. */ |
241 label.theme = theme; | |
242 label.text = line; | 241 label.text = line; |
243 label.flags = MLK_LABEL_FLAGS_SHADOW; | 242 label.flags = MLK_LABEL_FLAGS_SHADOW; |
244 | 243 |
245 /* Name. */ | 244 /* Name. */ |
246 snprintf(line, sizeof (line), "%s", ch->name); | 245 snprintf(line, sizeof (line), "%s", ch->name); |
370 .w = geo->w, | 369 .w = geo->w, |
371 .h = geo->h | 370 .h = geo->h |
372 }); | 371 }); |
373 | 372 |
374 for (size_t i = 0; i < MLK_UTIL_SIZE(buttons); ++i) { | 373 for (size_t i = 0; i < MLK_UTIL_SIZE(buttons); ++i) { |
375 buttons[i].label.theme = theme; | |
376 | |
377 mlk_label_query(&buttons[i].label, &buttons[i].w, &buttons[i].h); | 374 mlk_label_query(&buttons[i].label, &buttons[i].w, &buttons[i].h); |
378 | 375 |
379 /* Change theme if it's selected. */ | 376 /* Change theme if it's selected. */ |
377 #if 0 | |
380 if ((size_t)bar->menu == i) | 378 if ((size_t)bar->menu == i) |
381 buttons[i].label.flags |= MLK_LABEL_FLAGS_SELECTED; | 379 buttons[i].label.flags |= MLK_LABEL_FLAGS_SELECTED; |
382 else | 380 else |
383 buttons[i].label.flags &= ~MLK_LABEL_FLAGS_SELECTED; | 381 buttons[i].label.flags &= ~MLK_LABEL_FLAGS_SELECTED; |
382 #endif | |
384 | 383 |
385 mlk_align(buttons[i].align, | 384 mlk_align(buttons[i].align, |
386 &buttons[i].label.x, &buttons[i].label.y, buttons[i].w, buttons[i].h, | 385 &buttons[i].label.x, &buttons[i].label.y, buttons[i].w, buttons[i].h, |
387 bx, by, bw, bh); | 386 bx, by, bw, bh); |
388 mlk_label_draw(&buttons[i].label); | 387 mlk_label_draw(&buttons[i].label); |
558 | 557 |
559 if (!bar->items) | 558 if (!bar->items) |
560 bar->items = mlk_alloc_new0(CHARACTER_SPELL_MAX, sizeof (*bar->items)); | 559 bar->items = mlk_alloc_new0(CHARACTER_SPELL_MAX, sizeof (*bar->items)); |
561 else | 560 else |
562 bar->items = mlk_alloc_renew0(bar->items, CHARACTER_SPELL_MAX); | 561 bar->items = mlk_alloc_renew0(bar->items, CHARACTER_SPELL_MAX); |
563 | 562 |
564 bar->itemsz = CHARACTER_SPELL_MAX; | 563 bar->itemsz = CHARACTER_SPELL_MAX; |
565 bar->state = BATTLE_BAR_DEFAULT_STATE_GRID; | 564 bar->state = BATTLE_BAR_DEFAULT_STATE_GRID; |
566 | 565 |
567 for (size_t i = 0; i < CHARACTER_SPELL_MAX; ++i) | 566 for (size_t i = 0; i < CHARACTER_SPELL_MAX; ++i) |
568 if (ch->spells[i]) | 567 if (ch->spells[i]) |