diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2024-01-27 17:09:39 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2024-01-27 17:38:12 +0100 |
| commit | cd2b58b5619bf33deb99b0765f2d69969c61ed74 (patch) | |
| tree | 19a594c4b2be73d9e34d3d017f0c62d4611564a6 /src/player | |
| parent | 27553f8ed1d062c4d8175e7376f5b16cf2c8f9ef (diff) | |
| download | jancity-cd2b58b5619bf33deb99b0765f2d69969c61ed74.tar.gz | |
Add btn_small
Diffstat (limited to 'src/player')
| -rw-r--r-- | src/player/src/human_player.c | 1 | ||||
| -rw-r--r-- | src/player/src/human_player_gui.c | 24 |
2 files changed, 20 insertions, 5 deletions
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 <unit.h> #include <gui.h> #include <gui/bar.h> +#include <gui/button.h> #include <gui/container.h> #include <gui/label.h> #include <gui/progress_bar.h> @@ -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; |
