From ffae4540f91aa2e8169b3f74f99fceba7789893c Mon Sep 17 00:00:00 2001 From: Catherine Reprobate Date: Fri, 14 Jul 2023 23:27:20 -0700 Subject: [PATCH] dedicated radial menu mapped to `D_JPAD` --- src/game/activemenutick.c | 12 ++++++++---- src/game/bondmove.c | 29 +++++++++++++++++++++++++++-- src/include/types.h | 1 + 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/game/activemenutick.c b/src/game/activemenutick.c index 779ae69af..53ed8fea3 100644 --- a/src/game/activemenutick.c +++ b/src/game/activemenutick.c @@ -64,7 +64,7 @@ void amTick(void) g_AmMenus[g_AmIndex].allbots = false; if (g_Vars.currentplayer->activemenumode == AMMODE_EDIT) { - buttonsstate = buttonsstate & A_BUTTON; + buttonsstate = buttonsstate & D_JPAD; cstickx = 0; csticky = 0; buttonspressed = 0; @@ -76,7 +76,7 @@ void amTick(void) stayopen = true; } - if (buttonsstate & A_BUTTON) { + if (buttonsstate & D_JPAD) { #if VERSION >= VERSION_JPN_FINAL if (g_Vars.currentplayer->numaibuddies > 0) { g_AmMenus[g_AmIndex].allbots = true; @@ -86,7 +86,7 @@ void amTick(void) #endif } } else { - if (buttonsstate & A_BUTTON) { + if (buttonsstate & D_JPAD) { stayopen = true; } @@ -145,12 +145,16 @@ void amTick(void) u16 buttonspressed2 = joyGetButtonsPressedOnSample(j, contpadnum2, 0xffff); if (g_Vars.currentplayer->activemenumode == AMMODE_EDIT) { - buttonsstate2 = buttonsstate2 & A_BUTTON; + buttonsstate2 = buttonsstate2 & D_JPAD; cstickx2 = 0; csticky2 = 0; buttonspressed2 = 0; } + if (buttonsstate2 & D_JPAD) { + stayopen = true; + } + if (buttonspressed2 & Z_TRIG) { toggle = true; } diff --git a/src/game/bondmove.c b/src/game/bondmove.c index 084b9492e..8e87ddab1 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -914,7 +914,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i if (g_Vars.currentplayer->invdowntime > -1 && joyGetButtonsOnSample(i, shootpad, shootallowedbuttons & Z_TRIG) == 0) { if (g_Vars.currentplayer->invdowntime > TICKS(15)) { - amOpen(); + /* amOpen(); */ g_Vars.currentplayer->invdowntime = -1; } else { g_Vars.currentplayer->invdowntime++; @@ -1285,7 +1285,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i if (g_Vars.currentplayer->invdowntime >= 0 && joyGetButtonsOnSample(i, contpad1, shootbuttons & c1allowedbuttons) == 0) { // Holding A and haven't pressed Z if (g_Vars.currentplayer->invdowntime > TICKS(15)) { - amOpen(); + /* amOpen(); */ g_Vars.currentplayer->invdowntime = -1; } else { g_Vars.currentplayer->invdowntime++; @@ -1393,6 +1393,31 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i } } + + // Handle radial menu (D-Down) + for (i = 0; i < numsamples; i++) { + if (joyGetButtonsOnSample(i, contpad1, c1allowedbuttons & D_JPAD)) { + if (g_Vars.currentplayer->amdowntime < -2) { + g_Vars.currentplayer->amdowntime += numsamples; + + if (g_Vars.currentplayer->amdowntime > -3) { + g_Vars.currentplayer->amdowntime = 0; + } + } else { + if (g_Vars.currentplayer->amdowntime >= 0) { + if (joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons & D_JPAD)) { + amOpen(); + g_Vars.currentplayer->amdowntime = -1; + } else { + g_Vars.currentplayer->amdowntime++; + } + } + } + } else { + g_Vars.currentplayer->amdowntime = 0; + } + } + // Handle manual zoom in and out (sniper, farsight and horizon scanner) if (canmanualzoom && g_Vars.currentplayer->insightaimmode) { increment = 1; diff --git a/src/include/types.h b/src/include/types.h index 2c3de5498..94525fb1d 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -2817,6 +2817,7 @@ struct player { /*0x1c68*/ u32 unk1c68; /*0x1c6c*/ u32 unk1c6c; s16 altdowntime; // for alt-modes, used like invdowntime and amdowntime + s16 amdowntime; // for alt-modes, used like invdowntime and amdowntime }; struct ailist {