human_player_gui.c: use gui_container for top gui_bar

This commit is contained in:
Xavier Del Campo Romero 2022-07-02 04:47:50 +02:00
parent 7325906351
commit 7bc58ab0e6
1 changed files with 16 additions and 9 deletions

View File

@ -5,6 +5,7 @@
#include <unit.h>
#include <gui.h>
#include <gui/bar.h>
#include <gui/container.h>
#include <gui/label.h>
#include <gui/progress_bar.h>
#include <gui/rounded_rect.h>
@ -265,9 +266,18 @@ static int render_sel(const struct human_player *const h)
static int render_top(const struct human_player *const h)
{
const struct player *const pl = &h->pl;
struct gui_container c;
struct gui_bar b;
gui_bar_init(&b);
b.w = screen_w;
gui_container_init(&c);
c.mode = GUI_CONTAINER_MODE_H;
c.spacing = 16;
c.common.hcentered = true;
c.common.vcentered = true;
gui_add_child(&b.common, &c.common);
char wood_str[sizeof "Wood=429496729"];
{
@ -281,10 +291,9 @@ static int render_top(const struct human_player *const h)
struct gui_label wl;
gui_label_init(&wl);
wl.common.x = 16;
wl.common.y = 6;
wl.common.vcentered = true;
wl.text = wood_str;
gui_add_child(&b.common, &wl.common);
gui_add_child(&c.common, &wl.common);
char gold_str[sizeof "Gold=429496729"];
@ -299,10 +308,9 @@ static int render_top(const struct human_player *const h)
struct gui_label gl;
gui_label_init(&gl);
gl.common.x = 108;
gl.common.y = 6;
wl.common.vcentered = true;
gl.text = gold_str;
gui_add_child(&b.common, &gl.common);
gui_add_child(&c.common, &gl.common);
char pop_str[sizeof "Pop.=255/255"];
@ -317,10 +325,9 @@ static int render_top(const struct human_player *const h)
struct gui_label popl;
gui_label_init(&popl);
popl.common.x = 212;
popl.common.y = 6;
wl.common.vcentered = true;
popl.text = pop_str;
gui_add_child(&b.common, &popl.common);
gui_add_child(&c.common, &popl.common);
if (gui_render(&b.common))
return -1;