From cf13976db38b034e1f1ed7eae925a46ac8151474 Mon Sep 17 00:00:00 2001 From: Jonaeru Date: Sat, 31 Aug 2024 00:46:04 +0900 Subject: [PATCH] Add copy simulant mp menu --- src/game/mplayer/mplayer.c | 15 +++++++++++++++ src/game/mplayer/setup.c | 28 ++++++++++++++++++++++++++++ src/include/game/mplayer/mplayer.h | 3 +++ src/include/game/mplayer/setup.h | 3 +++ 4 files changed, 49 insertions(+) diff --git a/src/game/mplayer/mplayer.c b/src/game/mplayer/mplayer.c index 80b9a4c1f..142d94028 100644 --- a/src/game/mplayer/mplayer.c +++ b/src/game/mplayer/mplayer.c @@ -3146,6 +3146,21 @@ void mpRemoveSimulant(s32 index) mpGenerateBotNames(); } +#ifndef PLATFORM_N64 +void mpCopySimulant(s32 index) +{ + s32 dest = mpGetSlotForNewBot(); + + g_MpSetup.chrslots |= 1 << (dest + 4); + g_BotConfigsArray[dest].base.name[0] = g_BotConfigsArray[index].base.name[0]; + g_BotConfigsArray[dest].base.mpheadnum = g_BotConfigsArray[index].base.mpheadnum; + g_BotConfigsArray[dest].base.mpbodynum = g_BotConfigsArray[index].base.mpbodynum; + g_BotConfigsArray[dest].type = g_BotConfigsArray[index].type; + g_BotConfigsArray[dest].difficulty = g_BotConfigsArray[index].difficulty; + mpGenerateBotNames(); +} +#endif + bool mpHasSimulants(void) { if ((g_MpSetup.chrslots & 0xfff0) != 0) { diff --git a/src/game/mplayer/setup.c b/src/game/mplayer/setup.c index 44834bbfb..c9935c620 100644 --- a/src/game/mplayer/setup.c +++ b/src/game/mplayer/setup.c @@ -2933,6 +2933,24 @@ MenuItemHandlerResult menuhandlerMpDeleteSimulant(s32 operation, struct menuitem return 0; } +#ifndef PLATFORM_N64 +MenuItemHandlerResult menuhandlerMpCopySimulant(s32 operation, struct menuitem *item, union handlerdata *data) +{ + switch (operation) { + case MENUOP_SET: + mpCopySimulant(g_Menus[g_MpPlayerNum].mpsetup.slotindex); + menuPopDialog(); + break; + case MENUOP_CHECKDISABLED: + if (mpHasUnusedBotSlots() == 0) { + return true; + } + } + + return 0; +} +#endif + char *mpMenuTitleEditSimulant(struct menudialogdef *dialogdef) { sprintf(g_StringPointer, "%s", &g_BotConfigsArray[g_Menus[g_MpPlayerNum].mpsetup.slotindex].base.name); @@ -3151,6 +3169,16 @@ struct menuitem g_MpEditSimulantMenuItems[] = { 0, NULL, }, +#ifndef PLATFORM_N64 + { + MENUITEMTYPE_SELECTABLE, + 0, + MENUITEMFLAG_LOCKABLEMINOR | MENUITEMFLAG_LITERAL_TEXT, + (uintptr_t)"Copy Simulant\n", + 0, + menuhandlerMpCopySimulant, + }, +#endif { MENUITEMTYPE_SELECTABLE, 0, diff --git a/src/include/game/mplayer/mplayer.h b/src/include/game/mplayer/mplayer.h index bb4b17e56..b2ab42f95 100644 --- a/src/include/game/mplayer/mplayer.h +++ b/src/include/game/mplayer/mplayer.h @@ -90,6 +90,9 @@ void mpCreateBotFromProfile(s32 botnum, u8 difficulty); void mpSetBotDifficulty(s32 botnum, s32 difficulty); s32 mpGetSlotForNewBot(void); void mpRemoveSimulant(s32 index); +#ifndef PLATFORM_N64 +void mpCopySimulant(s32 index); +#endif bool mpHasSimulants(void); bool mpHasUnusedBotSlots(void); bool mpIsSimSlotEnabled(s32 slot); diff --git a/src/include/game/mplayer/setup.h b/src/include/game/mplayer/setup.h index ebb915747..b92f76c6e 100644 --- a/src/include/game/mplayer/setup.h +++ b/src/include/game/mplayer/setup.h @@ -144,6 +144,9 @@ MenuDialogHandlerResult menudialogMpSimulant(s32 operation, struct menudialogdef MenuItemHandlerResult menuhandlerMpSimulantHead(s32 operation, struct menuitem *item, union handlerdata *data); MenuItemHandlerResult menuhandlerMpSimulantBody(s32 operation, struct menuitem *item, union handlerdata *data); MenuItemHandlerResult menuhandlerMpDeleteSimulant(s32 operation, struct menuitem *item, union handlerdata *data); +#ifndef PLATFORM_N64 +MenuItemHandlerResult menuhandlerMpCopySimulant(s32 operation, struct menuitem *item, union handlerdata *data); +#endif MenuItemHandlerResult menuhandlerMpChangeSimulantType(s32 operation, struct menuitem *item, union handlerdata *data); MenuItemHandlerResult menuhandlerMpClearAllSimulants(s32 operation, struct menuitem *item, union handlerdata *data); MenuItemHandlerResult menuhandlerMpAddSimulant(s32 operation, struct menuitem *item, union handlerdata *data);