From 4b8e1d52b502aaf7347dadc7d3397b539d28f63c Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sun, 27 Apr 2025 15:54:39 +0200 Subject: [PATCH] port: move menuAlt functions to menu.c and make them global --- src/game/menu.c | 27 +++++++++++++++++++++++++++ src/game/mplayer/setup.c | 29 +---------------------------- src/include/game/menu.h | 4 ++++ 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/src/game/menu.c b/src/game/menu.c index 1e9159cae..7fdb9e2f3 100644 --- a/src/game/menu.c +++ b/src/game/menu.c @@ -147,6 +147,33 @@ s32 g_MouseDimmedMode = false; s32 g_MouseEndDeferredSlider = false; #endif +s32 menuAlt1Pressed(s32 playerNum) +{ + const s32 rshoulderKey = VK_JOY1_RSHOULDER + playerNum * INPUT_MAX_CONTROLLER_BUTTONS; + + if (playerNum == 0) { + return inputKeyJustPressed(VK_LCTRL) || inputKeyJustPressed(rshoulderKey); + } + + return inputKeyJustPressed(rshoulderKey); +} + +s32 menuAlt2Pressed(s32 playerNum) +{ + const s32 lshoulderKey = VK_JOY1_LSHOULDER + playerNum * INPUT_MAX_CONTROLLER_BUTTONS; + + if (playerNum == 0) { + return inputKeyJustPressed(VK_LALT) || inputKeyJustPressed(lshoulderKey); + } + + return inputKeyJustPressed(lshoulderKey); +} + +s32 menuAltAnyPressed(s32 playerNum) +{ + return menuAlt1Pressed(playerNum) || menuAlt2Pressed(playerNum); +} + void menuPlaySound(s32 menusound) { s32 sound = -1; diff --git a/src/game/mplayer/setup.c b/src/game/mplayer/setup.c index d06fb8c9f..8e7eefe61 100644 --- a/src/game/mplayer/setup.c +++ b/src/game/mplayer/setup.c @@ -43,33 +43,6 @@ extern struct menudialogdef g_FilemgrErrorMenuDialog; extern s32 g_MpWeaponSetNum; #endif -static inline s32 menuAlt1Pressed(s32 playerNum) -{ - const s32 rshoulderKey = VK_JOY1_RSHOULDER + playerNum * INPUT_MAX_CONTROLLER_BUTTONS; - - if (playerNum == 0) { - return inputKeyJustPressed(VK_LCTRL) || inputKeyJustPressed(rshoulderKey); - } - - return inputKeyJustPressed(rshoulderKey); -} - -static inline s32 menuAlt2Pressed(s32 playerNum) -{ - const s32 lshoulderKey = VK_JOY1_LSHOULDER + playerNum * INPUT_MAX_CONTROLLER_BUTTONS; - - if (playerNum == 0) { - return inputKeyJustPressed(VK_LALT) || inputKeyJustPressed(lshoulderKey); - } - - return inputKeyJustPressed(lshoulderKey); -} - -static inline s32 menuAltPressed(s32 playerNum) -{ - return menuAlt1Pressed(playerNum) || menuAlt2Pressed(playerNum); -} - MenuItemHandlerResult menuhandlerMpDropOut(s32 operation, struct menuitem *item, union handlerdata *data) { if (operation == MENUOP_SET) { @@ -2594,7 +2567,7 @@ MenuDialogHandlerResult menudialogMpSimulant(s32 operation, struct menudialogdef MenuDialogHandlerResult mpLoadSettingsDialogHandler(s32 operation, struct menudialogdef *dialogdef, union handlerdata *data) { if (operation == MENUOP_TICK) { - if (menuAltPressed(g_MpPlayerNum)) { + if (menuAltAnyPressed(g_MpPlayerNum)) { u8 presets = g_Menus[g_MpPlayerNum].mpsetup.showpresets; g_Menus[g_MpPlayerNum].mpsetup.showpresets = 1 - presets; } diff --git a/src/include/game/menu.h b/src/include/game/menu.h index 419fb659e..37bdbc5e5 100644 --- a/src/include/game/menu.h +++ b/src/include/game/menu.h @@ -113,6 +113,10 @@ MenuItemHandlerResult menuhandlerRepairPak(s32 operation, struct menuitem *item, MenuItemHandlerResult menuhandlerRetrySavePak(s32 operation, struct menuitem *item, union handlerdata *data); MenuItemHandlerResult menuhandlerWarnRepairPak(s32 operation, struct menuitem *item, union handlerdata *data); +s32 menuAlt1Pressed(s32 playerNum); +s32 menuAlt2Pressed(s32 playerNum); +s32 menuAltAnyPressed(s32 playerNum); + extern const char var7f1b2658[]; extern const char var7f1b265c[]; extern const char var7f1b2660[];