From cd2b58b5619bf33deb99b0765f2d69969c61ed74 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Sat, 27 Jan 2024 17:09:39 +0100 Subject: Add btn_small --- src/player/src/human_player.c | 1 + src/player/src/human_player_gui.c | 24 +++++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) (limited to 'src/player') diff --git a/src/player/src/human_player.c b/src/player/src/human_player.c index 7f67ec7..6083ef3 100644 --- a/src/player/src/human_player.c +++ b/src/player/src/human_player.c @@ -462,6 +462,7 @@ int human_player_render(const struct human_player *const h, if (render_target(h) || render_own_units(h) || render_own_buildings(h) + || human_player_gui_render(h) || input_render(&h->in, h->periph)) return -1; diff --git a/src/player/src/human_player_gui.c b/src/player/src/human_player_gui.c index 3f79848..e985d9c 100644 --- a/src/player/src/human_player_gui.c +++ b/src/player/src/human_player_gui.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -96,6 +97,19 @@ static int render_sel_multiple(const struct human_player *const h, return gui_render(r); } +static int render_top(const struct human_player *const h) +{ + struct gui_button b; + + gui_button_init(&b, GUI_BUTTON_TYPE_SPRITE); + b.on_pressed = NULL; + b.arg = NULL; + b.u.sprite.s = &gui_button_sprites[GUI_BUTTON_SMALL]; + b.common.x = screen_w - b.u.sprite.s->w; + + return gui_render(&b.common); +} + static int render_sel(const struct human_player *const h) { struct gui_rounded_rect r; @@ -106,15 +120,15 @@ static int render_sel(const struct human_player *const h) r.h = screen_h / 4; r.common.y = screen_h - r.h; - if (h->n_sel == 1) - return render_sel_single(h, &r.common); - - return render_sel_multiple(h, &r.common); + return h->n_sel == 1 ? render_sel_single(h, &r.common) + : render_sel_multiple(h, &r.common); } int human_player_gui_render(const struct human_player *const h) { - if (h->n_sel && render_sel(h)) + if (render_top(h)) + return -1; + else if (h->n_sel && render_sel(h)) return -1; return 0; -- cgit v1.2.3