summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2021-03-18 19:00:02 (EDT)
committer P. J. McDermott <pj@pehjota.net>2021-03-18 19:00:02 (EDT)
commit29fb8700572cfa1687d84e0a9376e2cd991c3a7a (patch)
tree12e78d5070e955907860d3a1c44c1977fbda1a2e /src
parent0e92178007ccfa8997c87a5b89e859a396224277 (diff)
downloaddodge-balls-29fb8700572cfa1687d84e0a9376e2cd991c3a7a.zip
dodge-balls-29fb8700572cfa1687d84e0a9376e2cd991c3a7a.tar.gz
dodge-balls-29fb8700572cfa1687d84e0a9376e2cd991c3a7a.tar.bz2
main-menu: Link buttons (for tab key nav)
Diffstat (limited to 'src')
-rw-r--r--src/main-menu.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main-menu.c b/src/main-menu.c
index 9583668..f1a3830 100644
--- a/src/main-menu.c
+++ b/src/main-menu.c
@@ -34,6 +34,8 @@ struct _db_main_menu_button {
struct _db_main_menu_button *d;
struct _db_main_menu_button *l;
struct _db_main_menu_button *r;
+ struct _db_main_menu_button *p;
+ struct _db_main_menu_button *n;
};
static SDL_Texture *
@@ -175,6 +177,7 @@ db_main_menu(void)
&buttons[1]->rect);
/* Render game buttons */
+ buttons[1]->n = buttons[0]; /* Quit button link (may change below) */
for (i = 0; i < n; ++i) {
buttons[i + 2] = malloc(sizeof(**buttons));
if (buttons[i + 2] == NULL) {
@@ -214,6 +217,11 @@ db_main_menu(void)
}
buttons[i + 2]->l = NULL;
buttons[i + 2]->r = buttons[0];
+ buttons[i + 2]->p = buttons[i + 1];
+ buttons[i + 1]->n = buttons[i + 2];
+ }
+ if (n > 0) {
+ buttons[i + 1]->n = buttons[0];
}
/* Help button links */
@@ -225,6 +233,8 @@ db_main_menu(void)
buttons[0]->l = NULL;
}
buttons[0]->r = NULL;
+ buttons[0]->p = buttons[1 + n];
+ buttons[0]->n = buttons[1];
/* Quit button links */
buttons[1]->u = buttons[0];
@@ -235,6 +245,7 @@ db_main_menu(void)
buttons[1]->l = NULL;
}
buttons[1]->r = NULL;
+ buttons[1]->p = buttons[0];
SDL_RenderPresent(renderer);
SDL_Delay(1000);