aboutsummaryrefslogtreecommitdiff
path: root/src/menu
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2022-07-10 00:21:09 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2022-07-10 00:26:48 +0200
commitf69dc6f359015e992d181c60cd815cefd6c62aad (patch)
tree67e47e8862884f6e66b5bb745ff0b964c93a9124 /src/menu
parentf318a66f8ccc847bd9940d125936aa87df74fb0f (diff)
downloadjancity-f69dc6f359015e992d181c60cd815cefd6c62aad.tar.gz
Allow children of gui_container be resized anytime
So far, their position inside the container was determined when initializing the interface. However, if a child were resized afterwards, the container would not adjust its elements accordingly. Moreover, the implementation for gui_container relied on hacking the children's X/Y coordinates, which could only be done once. Now, two additional members have been added to gui_common so that specific X/Y offset can be determined by the parent, additionally to the traditional rules followed by gui_coords. Despite the extra memory footprint, it now allows containers to set specific X/Y offsets for their children on every game cycle.
Diffstat (limited to 'src/menu')
-rw-r--r--src/menu/src/gamecfg_menu.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/menu/src/gamecfg_menu.c b/src/menu/src/gamecfg_menu.c
index 31d105e..9fc3873 100644
--- a/src/menu/src/gamecfg_menu.c
+++ b/src/menu/src/gamecfg_menu.c
@@ -20,8 +20,11 @@ static int update(struct menu_common *const c, void *const arg)
struct gamecfg_menu *const m = arg;
m->bcnt.common.y = screen_h - 40;
+ m->r.w = screen_w / 2;
+ m->r.h = screen_h / 2;
- if (gui_update(&m->bcnt.common, &c->p, &c->cam))
+ if (gui_update(&m->cnt.common, &c->p, &c->cam)
+ || gui_update(&m->bcnt.common, &c->p, &c->cam))
return -1;
return 0;
@@ -48,8 +51,6 @@ int menu_gamecfg(struct menu_common *const c)
m.cnt.common.vcentered = true;
gui_rounded_rect_init(&m.r);
- m.r.w = screen_w / 2;
- m.r.h = screen_h / 2;
gui_add_child(&m.cnt.common, &m.r.common);
gui_container_init(&m.bcnt);