aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2022-07-02 04:47:50 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2022-07-02 04:47:50 +0200
commit7bc58ab0e6e9349fe3e4d121f772bd74d5a814dc (patch)
treeae4941160d536340d2a2e602ca8abd402f2e6737
parent73259063518d9a53db03d19f803faa44aa6f092f (diff)
human_player_gui.c: use gui_container for top gui_bar
-rw-r--r--src/player/src/human_player_gui.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/player/src/human_player_gui.c b/src/player/src/human_player_gui.c
index ea39bca..fce749e 100644
--- a/src/player/src/human_player_gui.c
+++ b/src/player/src/human_player_gui.c
@@ -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;