From 29fb8700572cfa1687d84e0a9376e2cd991c3a7a Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Thu, 18 Mar 2021 19:00:02 -0400 Subject: main-menu: Link buttons (for tab key nav) --- (limited to 'src') 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); -- cgit v0.9.1