Skip to content

Commit

Permalink
Add copy simulant mp menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonaeru committed Aug 30, 2024
1 parent bdbf0ab commit cf13976
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/game/mplayer/mplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
28 changes: 28 additions & 0 deletions src/game/mplayer/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions src/include/game/mplayer/mplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/include/game/mplayer/setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cf13976

Please sign in to comment.