From f4530633d6364bb2953a94303bee8c09dfab5b8c Mon Sep 17 00:00:00 2001 From: GreaseMonkey Date: Sat, 10 Feb 2024 11:20:01 +1300 Subject: [PATCH] Replace "Counter-Operative" player selection with "Main Player" + extend to 4 entries --- src/game/mainmenu.c | 94 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 93 insertions(+), 1 deletion(-) diff --git a/src/game/mainmenu.c b/src/game/mainmenu.c index 0b65599b5..bef20db6d 100644 --- a/src/game/mainmenu.c +++ b/src/game/mainmenu.c @@ -748,6 +748,7 @@ MenuItemHandlerResult menuhandlerAcceptMission(s32 operation, struct menuitem *i setNumPlayers(1); } } else if (g_MissionConfig.isanti) { +#ifdef PLATFORM_N64 if (g_Vars.pendingantiplayernum == 1) { g_Vars.bondplayernum = 0; g_Vars.antiplayernum = 1; @@ -757,9 +758,13 @@ MenuItemHandlerResult menuhandlerAcceptMission(s32 operation, struct menuitem *i } g_Vars.coopplayernum = -1; -#ifdef PLATFORM_N64 + setNumPlayers(2); #else + g_Vars.bondplayernum = g_Vars.pendingantiplayernum ^ 1; + g_Vars.antiplayernum = (g_Vars.bondplayernum == 0 ? 1 : 0); + g_Vars.coopplayernum = -1; + if ((joyGetConnectedControllers() & 0xF) == 0xF) { setNumPlayers(4); g_MpSetup.chrslots = 0xF; @@ -1558,6 +1563,8 @@ MenuItemHandlerResult menuhandlerAntiRadar(s32 operation, struct menuitem *item, return 0; } +#ifdef PLATFORM_N64 + MenuItemHandlerResult menuhandlerAntiPlayer(s32 operation, struct menuitem *item, union handlerdata *data) { const u16 labels[] = {L_OPTIONS_271, L_OPTIONS_272}; @@ -1624,6 +1631,91 @@ struct menuitem g_AntiOptionsMenuItems[] = { { MENUITEMTYPE_END }, }; +#else + +MenuItemHandlerResult menuhandlerAntiMainPlayer(s32 operation, struct menuitem *item, union handlerdata *data) +{ + static const char *labels[] = { + "Player 1", + "Player 2", + "Player 3", + "Player 4", + }; + + // For consistency with the main save format, + // the main player is (pendingantiplayernum XOR 1) + + switch (operation) { + case MENUOP_GETOPTIONCOUNT: + if ((joyGetConnectedControllers() & 0xF) == 0xF) { + data->dropdown.value = 4; + } else if ((joyGetConnectedControllers() & 0x7) == 0x7) { + data->dropdown.value = 3; + } else { + data->dropdown.value = 2; + } + break; + case MENUOP_GETOPTIONTEXT: + return (s32) (labels[data->dropdown.value]); + case MENUOP_SET: + g_Vars.pendingantiplayernum = data->dropdown.value ^ 1; + g_Vars.modifiedfiles |= MODFILE_GAME; + break; + case MENUOP_GETSELECTEDINDEX: + data->dropdown.value = g_Vars.pendingantiplayernum ^ 1; + break; + } + + return 0; +} + +struct menuitem g_AntiOptionsMenuItems[] = { + { + MENUITEMTYPE_CHECKBOX, + 0, + 0, + L_OPTIONS_267, // "Radar On" + 0, + menuhandlerAntiRadar, + }, + { + MENUITEMTYPE_DROPDOWN, + 0, + MENUITEMFLAG_LITERAL_TEXT, + (uintptr_t)"Main Player", + 0, + menuhandlerAntiMainPlayer, + }, + { + MENUITEMTYPE_SEPARATOR, + 0, + 0, + 0, + 0, + NULL, + }, + { + MENUITEMTYPE_SELECTABLE, + 0, + 0, + L_OPTIONS_269, // "Continue" + 0, + menuhandlerBuddyOptionsContinue, + }, + { + MENUITEMTYPE_SELECTABLE, + 0, + MENUITEMFLAG_SELECTABLE_CLOSESDIALOG, + L_OPTIONS_270, // "Cancel" + 0, + NULL, + }, + { MENUITEMTYPE_END }, +}; + +#endif + + struct menudialogdef g_AntiOptionsMenuDialog = { MENUDIALOGTYPE_DEFAULT, L_OPTIONS_266, // "Counter-Operative Options"