forked from Ports/perfect_dark
mpsetups: introduced "menu alt" button/key to toggle presets
Currently the "menu alt" (L/R buttons, or Ctrl/Alt keys) is fixed, but we may make it bindable later
This commit is contained in:
1 parent
7a98095a0b
commit
f9cfa0fa43
5 files changed
+81
-11
No files matched your search
@@ -600,6 +600,10 @@ void mpInit(void)
|
||||
}
|
||||
|
||||
g_MpSetup.chrslots = 0;
|
||||
|
||||
for (i = 0; i < ARRAYCOUNT(g_Menus); i++) {
|
||||
g_Menus[i].mpsetup.showpresets = 1;
|
||||
}
|
||||
}
|
||||
|
||||
#if VERSION >= VERSION_PAL_BETA
|
||||
|
||||
+42
-11
@@ -20,10 +20,12 @@
|
||||
#include "lib/vi.h"
|
||||
#include "lib/rng.h"
|
||||
#include "lib/str.h"
|
||||
#include "lib/joy.h"
|
||||
#include "data.h"
|
||||
#include "gbiex.h"
|
||||
#include "types.h"
|
||||
#include "system.h"
|
||||
#include "input.h"
|
||||
#include "mpsetups.h"
|
||||
|
||||
struct menuitem g_MpCharacterMenuItems[];
|
||||
@@ -2252,16 +2254,19 @@ MenuItemHandlerResult mpPlayerNameMenuHandler(s32 operation, struct menuitem *it
|
||||
|
||||
MenuItemHandlerResult mpLoadSettingsMenuHandler(s32 operation, struct menuitem *item, union handlerdata *data)
|
||||
{
|
||||
u8 presets = g_Menus[g_MpPlayerNum].mpsetup.showpresets;
|
||||
s32 numpresets = mpGetNumUnlockedPresets()*presets;
|
||||
|
||||
switch (operation) {
|
||||
case MENUOP_GETOPTIONCOUNT:
|
||||
data->list.value = mpGetNumUnlockedPresets() + g_MpSetupFile.numsetups;
|
||||
data->list.value = numpresets + g_MpSetupFile.numsetups;
|
||||
break;
|
||||
case MENUOP_GETOPTIONTEXT:
|
||||
if (data->list.value < mpGetNumUnlockedPresets()) {
|
||||
if (presets && data->list.value < mpGetNumUnlockedPresets()) {
|
||||
return (uintptr_t)mpGetPresetNameBySlot(data->list.value);
|
||||
}
|
||||
if (g_MpSetupFile.numsetups > 0) {
|
||||
struct setupblock *block = &g_MpSetupFile.setups[data->list.value - mpGetNumUnlockedPresets()];
|
||||
struct setupblock *block = &g_MpSetupFile.setups[data->list.value - numpresets];
|
||||
func0f0d564c_ext(block->bytes, g_StringPointer, false, MPSETUP_MAXNAME+1);
|
||||
return (uintptr_t)g_StringPointer;
|
||||
}
|
||||
@@ -2269,12 +2274,12 @@ MenuItemHandlerResult mpLoadSettingsMenuHandler(s32 operation, struct menuitem *
|
||||
case MENUOP_SET:
|
||||
mpCloseDialogsForNewSetup();
|
||||
|
||||
if (data->list.value < mpGetNumUnlockedPresets()) {
|
||||
if (presets && data->list.value < mpGetNumUnlockedPresets()) {
|
||||
mp0f18dec4(data->list.value);
|
||||
g_MpCurrentSetup = -1;
|
||||
}
|
||||
else {
|
||||
mpsetupLoadSetup(data->list.value - mpGetNumUnlockedPresets());
|
||||
mpsetupLoadSetup(data->list.value - numpresets);
|
||||
}
|
||||
|
||||
if (item->param == 1) {
|
||||
@@ -2289,22 +2294,22 @@ MenuItemHandlerResult mpLoadSettingsMenuHandler(s32 operation, struct menuitem *
|
||||
data->list.value = 0xfffff;
|
||||
break;
|
||||
case MENUOP_GETOPTGROUPCOUNT:
|
||||
data->list.value = 2;
|
||||
data->list.value = presets ? 2 : 1;
|
||||
break;
|
||||
case MENUOP_GETOPTGROUPTEXT:
|
||||
if (data->list.value == 0) {
|
||||
if (presets && data->list.value == 0) {
|
||||
return (uintptr_t)langGet(L_MPMENU_141); // "Presets"
|
||||
}
|
||||
return (uintptr_t)"Custom";
|
||||
case MENUOP_GETGROUPSTARTINDEX:
|
||||
data->list.groupstartindex = data->list.value == 0 ? 0 : mpGetNumUnlockedPresets();
|
||||
data->list.groupstartindex = data->list.value == 0 ? 0 : numpresets;
|
||||
break;
|
||||
case MENUOP_LISTITEMFOCUS:
|
||||
if (data->list.value < mpGetNumUnlockedPresets()) {
|
||||
if (presets && data->list.value < mpGetNumUnlockedPresets()) {
|
||||
g_Menus[g_MpPlayerNum].mpsetup.slotindex = 0xffff;
|
||||
}
|
||||
else {
|
||||
g_Menus[g_MpPlayerNum].mpsetup.slotindex = data->list.value - mpGetNumUnlockedPresets();
|
||||
g_Menus[g_MpPlayerNum].mpsetup.slotindex = data->list.value - numpresets;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2632,14 +2637,40 @@ struct menuitem g_MpLoadSettingsMenuItems[] = {
|
||||
0,
|
||||
NULL,
|
||||
},
|
||||
{
|
||||
MENUITEMTYPE_SEPARATOR,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
NULL,
|
||||
},
|
||||
{
|
||||
MENUITEMTYPE_LABEL,
|
||||
0,
|
||||
MENUITEMFLAG_LITERAL_TEXT | MENUITEMFLAG_LESSLEFTPADDING | MENUITEMFLAG_SMALLFONT,
|
||||
(uintptr_t)"Menu Alt: Toggle Presets\n",
|
||||
0,
|
||||
NULL,
|
||||
},
|
||||
{ MENUITEMTYPE_END },
|
||||
};
|
||||
|
||||
MenuDialogHandlerResult loadSettingsDialogHandler(s32 operation, struct menudialogdef *dialogdef, union handlerdata *data)
|
||||
{
|
||||
if (operation == MENUOP_TICK) {
|
||||
if (inputMenuAltMenuPressed(g_MpPlayerNum)) {
|
||||
u8 presets = g_Menus[g_MpPlayerNum].mpsetup.showpresets;
|
||||
g_Menus[g_MpPlayerNum].mpsetup.showpresets = 1 - presets;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct menudialogdef g_MpLoadSettingsMenuDialog = {
|
||||
MENUDIALOGTYPE_DEFAULT,
|
||||
L_MPMENU_139, // "Load Game Settings"
|
||||
g_MpLoadSettingsMenuItems,
|
||||
NULL,
|
||||
loadSettingsDialogHandler,
|
||||
MENUDIALOGFLAG_CLOSEONSELECT,
|
||||
NULL,
|
||||
};
|
||||
|
||||
@@ -3774,6 +3774,7 @@ struct menudata_main {
|
||||
struct menudata_mpsetup {
|
||||
u32 slotindex;
|
||||
u32 slotcount;
|
||||
u8 showpresets;
|
||||
u32 unke24;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user