forked from Ports/perfect_dark
mpsetupfile (not 100% functional yet): load/save setup file, save new setups/groups, increased mp options/scenario data width
This commit is contained in:
1 parent
2ff8819265
commit
f5d851f7c2
13 files changed
+484
-112
No files matched your search
@@ -816,12 +816,6 @@ bool filemgrAttemptOperation(s32 device, bool closeonsuccess)
|
||||
g_Menus[g_MpPlayerNum].fm.fileid,
|
||||
g_Menus[g_MpPlayerNum].fm.deviceserial);
|
||||
break;
|
||||
case FILEOP_SAVE_MPSETUP:
|
||||
errnum = mpsetupfileSave(device,
|
||||
g_Menus[g_MpPlayerNum].fm.fileid,
|
||||
g_Menus[g_MpPlayerNum].fm.deviceserial);
|
||||
showfilesaved = true;
|
||||
break;
|
||||
case FILEOP_WRITE_GAME:
|
||||
case FILEOP_WRITE_MPSETUP:
|
||||
case FILEOP_WRITE_MPPLAYER:
|
||||
@@ -845,11 +839,6 @@ bool filemgrAttemptOperation(s32 device, bool closeonsuccess)
|
||||
g_Menus[g_MpPlayerNum].fm.fileid,
|
||||
g_Menus[g_MpPlayerNum].fm.deviceserial);
|
||||
break;
|
||||
case FILEOP_LOAD_MPSETUP:
|
||||
errnum = mpsetupfileLoad(device,
|
||||
g_Menus[g_MpPlayerNum].fm.fileid,
|
||||
g_Menus[g_MpPlayerNum].fm.deviceserial);
|
||||
break;
|
||||
case FILEOP_READ_GAME:
|
||||
case FILEOP_READ_MPSETUP:
|
||||
case FILEOP_READ_MPPLAYER:
|
||||
|
||||
@@ -614,6 +614,15 @@ Gfx *menuitemListRender(Gfx *gdl, struct menurendercontext *context)
|
||||
height = 0;
|
||||
}
|
||||
|
||||
// reuse the label color flag here
|
||||
if (context->item->flags & MENUITEMFLAG_LABEL_CUSTOMCOLOUR) {
|
||||
u32 savedunk04 = sp15c.list.unk04;
|
||||
sp15c.list.unk04 = colour;
|
||||
context->item->handler(MENUOP_GETCOLOUR, context->item, &sp15c);
|
||||
colour = sp15c.list.unk04;
|
||||
sp15c.list.unk04 = savedunk04;
|
||||
}
|
||||
|
||||
gdl = textRenderProjected(gdl, &x, &y, text2, chars, font, colour, context->width - left + context->x, height, sp128, 0);
|
||||
|
||||
// Consider a checkbox
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
#include "lib/lib_317f0.h"
|
||||
#include "data.h"
|
||||
#include "types.h"
|
||||
#include "fs.h"
|
||||
#include "system.h"
|
||||
#include "mpsetups.h"
|
||||
|
||||
// bss
|
||||
struct chrdata *g_MpAllChrPtrs[MAX_MPCHRS];
|
||||
@@ -3924,7 +3927,7 @@ void mpsetupfileLoadWad(struct savebuffer *buffer)
|
||||
scenarioInit();
|
||||
scenarioReadSave(buffer);
|
||||
|
||||
g_MpSetup.options = savebufferReadBits(buffer, 21);
|
||||
g_MpSetup.options = savebufferReadBits(buffer, 32);
|
||||
g_MpSetup.chrslots &= 0x000f;
|
||||
|
||||
for (i = 0; i < MAX_BOTS; i++) {
|
||||
@@ -3984,7 +3987,7 @@ void mpsetupfileSaveWad(struct savebuffer *buffer)
|
||||
|
||||
scenarioWriteSave(buffer);
|
||||
|
||||
savebufferOr(buffer, g_MpSetup.options, 21);
|
||||
savebufferOr(buffer, g_MpSetup.options, 32);
|
||||
|
||||
for (i = 0; i < MAX_BOTS; i++) {
|
||||
savebufferOr(buffer, g_BotConfigsArray[i].type, 5);
|
||||
@@ -4039,60 +4042,6 @@ void mpsetupfileGetOverview(char *arg0, char *filename, u16 *numsims, u16 *stage
|
||||
*scenarionum = savebufferReadBits(&buffer, 3);
|
||||
}
|
||||
|
||||
s32 mpsetupfileSave(s32 device, s32 fileid, u16 deviceserial)
|
||||
{
|
||||
s32 ret;
|
||||
s32 newfileid;
|
||||
struct savebuffer buffer;
|
||||
|
||||
if (device >= 0) {
|
||||
savebufferClear(&buffer);
|
||||
mpsetupfileSaveWad(&buffer);
|
||||
func0f0d54c4(&buffer);
|
||||
|
||||
ret = pakSaveAtGuid(device, fileid, PAKFILETYPE_MPSETUP, buffer.bytes, &newfileid, 0);
|
||||
var80075bd0[1] = true;
|
||||
|
||||
if (ret == 0) {
|
||||
g_MpSetup.fileguid.fileid = newfileid;
|
||||
g_MpSetup.fileguid.deviceserial = deviceserial;
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_FilemgrLastPakError = ret;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
s32 mpsetupfileLoad(s32 device, s32 fileid, u16 deviceserial)
|
||||
{
|
||||
s32 ret;
|
||||
struct savebuffer buffer;
|
||||
|
||||
if (device >= 0) {
|
||||
savebufferClear(&buffer);
|
||||
ret = pakReadBodyAtGuid(device, fileid, buffer.bytes, 0);
|
||||
|
||||
if (ret == 0) {
|
||||
g_MpSetup.fileguid.fileid = fileid;
|
||||
g_MpSetup.fileguid.deviceserial = deviceserial;
|
||||
|
||||
mpsetupfileLoadWad(&buffer);
|
||||
func0f0d54c4(&buffer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_FilemgrLastPakError = ret;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void func0f18e558(void)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
@@ -438,7 +438,7 @@ void scenarioWriteSave(struct savebuffer *buffer)
|
||||
if (g_MpScenarios[g_MpSetup.scenario].writesavefunc) {
|
||||
g_MpScenarios[g_MpSetup.scenario].writesavefunc(buffer);
|
||||
} else {
|
||||
savebufferOr(buffer, 0, 8);
|
||||
savebufferOr(buffer, 0, 32);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -183,12 +183,12 @@ struct menudialogdef g_KohOptionsMenuDialog = {
|
||||
|
||||
void kohReadSave(struct savebuffer *buffer)
|
||||
{
|
||||
g_Vars.mphilltime = savebufferReadBits(buffer, 8);
|
||||
g_Vars.mphilltime = savebufferReadBits(buffer, 32);
|
||||
}
|
||||
|
||||
void kohWriteSave(struct savebuffer *buffer)
|
||||
{
|
||||
savebufferOr(buffer, g_Vars.mphilltime, 8);
|
||||
savebufferOr(buffer, g_Vars.mphilltime, 32);
|
||||
}
|
||||
|
||||
void kohInit(void)
|
||||
|
||||
+66
-41
@@ -23,6 +23,8 @@
|
||||
#include "data.h"
|
||||
#include "gbiex.h"
|
||||
#include "types.h"
|
||||
#include "system.h"
|
||||
#include "mpsetups.h"
|
||||
|
||||
struct menuitem g_MpCharacterMenuItems[];
|
||||
struct menudialogdef g_MpAddSimulantMenuDialog;
|
||||
@@ -31,6 +33,10 @@ struct menudialogdef g_MpChangeTeamNameMenuDialog;
|
||||
struct menudialogdef g_MpEditSimulantMenuDialog;
|
||||
struct menudialogdef g_MpSaveSetupNameMenuDialog;
|
||||
|
||||
extern struct menudialogdef g_MpSetupGroupsDialog;
|
||||
extern struct menudialogdef g_FilemgrFileSavedMenuDialog;
|
||||
extern struct menudialogdef g_FilemgrErrorMenuDialog;
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
extern s32 g_MpWeaponSetNum;
|
||||
#endif
|
||||
@@ -454,6 +460,7 @@ MenuItemHandlerResult menuhandlerMpConfirmSaveChr(s32 operation, struct menuitem
|
||||
MenuItemHandlerResult menuhandlerMpSetupName(s32 operation, struct menuitem *item, union handlerdata *data)
|
||||
{
|
||||
char *name = data->keyboard.string;
|
||||
s32 err;
|
||||
|
||||
switch (operation) {
|
||||
case MENUOP_GETTEXT:
|
||||
@@ -463,7 +470,14 @@ MenuItemHandlerResult menuhandlerMpSetupName(s32 operation, struct menuitem *ite
|
||||
strcpy(g_MpSetup.name, name);
|
||||
break;
|
||||
case MENUOP_SET:
|
||||
filemgrPushSelectLocationDialog(7, FILETYPE_MPSETUP);
|
||||
err = mpsetupSaveFile(name, false);
|
||||
if (!err) {
|
||||
menuPushDialog(&g_FilemgrFileSavedMenuDialog);
|
||||
}
|
||||
else {
|
||||
// menuPushDialog(&g_FilemgrErrorMenuDialog);
|
||||
// TODO
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -474,7 +488,7 @@ MenuItemHandlerResult menuhandlerMpSaveSetupOverwrite(s32 operation, struct menu
|
||||
{
|
||||
if (operation == MENUOP_SET) {
|
||||
menuPopDialog();
|
||||
filemgrSaveOrLoad(&g_MpSetup.fileguid, FILEOP_SAVE_MPSETUP, 0);
|
||||
mpsetupSaveFile(g_MpSetupFile.setups[g_MpCurrentSetup].bytes, true);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -484,7 +498,7 @@ MenuItemHandlerResult menuhandlerMpSaveSetupCopy(s32 operation, struct menuitem
|
||||
{
|
||||
if (operation == MENUOP_SET) {
|
||||
menuPopDialog();
|
||||
menuPushDialog(&g_MpSaveSetupNameMenuDialog);
|
||||
menuPushDialog(&g_MpSetupGroupsDialog);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1112,10 +1126,10 @@ struct menuitem g_MpSaveSetupExistsMenuItems[] = {
|
||||
NULL,
|
||||
},
|
||||
{
|
||||
MENUITEMTYPE_LABEL,
|
||||
MENUITEMTYPE_SEPARATOR,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
MENUITEMFLAG_LESSLEFTPADDING | MENUITEMFLAG_SELECTABLE_CENTRE | MENUITEMFLAG_SMALLFONT,
|
||||
(uintptr_t)&filemgrMenuTextDeviceName,
|
||||
0,
|
||||
NULL,
|
||||
},
|
||||
@@ -1123,8 +1137,16 @@ struct menuitem g_MpSaveSetupExistsMenuItems[] = {
|
||||
{
|
||||
MENUITEMTYPE_LABEL,
|
||||
0,
|
||||
MENUITEMFLAG_LESSLEFTPADDING,
|
||||
L_MPMENU_184, // "Do you want to save over your original game file?"
|
||||
MENUITEMFLAG_LESSLEFTPADDING | MENUITEMFLAG_LITERAL_TEXT,
|
||||
(uintptr_t)"Save over your\noriginal setup?\n",
|
||||
0,
|
||||
NULL,
|
||||
},
|
||||
{
|
||||
MENUITEMTYPE_SEPARATOR,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
NULL,
|
||||
},
|
||||
@@ -2232,17 +2254,15 @@ MenuItemHandlerResult mpLoadSettingsMenuHandler(s32 operation, struct menuitem *
|
||||
switch (operation) {
|
||||
case MENUOP_GETOPTIONCOUNT:
|
||||
data->list.value = mpGetNumUnlockedPresets();
|
||||
|
||||
if (g_FileLists[1] != NULL) {
|
||||
data->list.value += g_FileLists[1]->numfiles;
|
||||
}
|
||||
data->list.value += g_MpSetupFile.numsetups;
|
||||
break;
|
||||
case MENUOP_GETOPTIONTEXT:
|
||||
if (data->list.value < mpGetNumUnlockedPresets()) {
|
||||
return (uintptr_t)mpGetPresetNameBySlot(data->list.value);
|
||||
}
|
||||
if (g_FileLists[1] != NULL) {
|
||||
func0f0d564c(g_FileLists[1]->files[data->list.value - mpGetNumUnlockedPresets()].name, g_StringPointer, false);
|
||||
if (g_MpSetupFile.numsetups > 0) {
|
||||
struct setupblock *block = &g_MpSetupFile.setups[data->list.value - mpGetNumUnlockedPresets()];
|
||||
func0f0d564c(block->bytes, g_StringPointer, false);
|
||||
return (uintptr_t)g_StringPointer;
|
||||
}
|
||||
break;
|
||||
@@ -2251,14 +2271,10 @@ MenuItemHandlerResult mpLoadSettingsMenuHandler(s32 operation, struct menuitem *
|
||||
|
||||
if (data->list.value < mpGetNumUnlockedPresets()) {
|
||||
mp0f18dec4(data->list.value);
|
||||
} else if (g_FileLists[1] != NULL) {
|
||||
struct filelistfile *file = &g_FileLists[1]->files[data->list.value - mpGetNumUnlockedPresets()];
|
||||
struct fileguid guid;
|
||||
|
||||
guid.fileid = file->fileid;
|
||||
guid.deviceserial = file->deviceserial;
|
||||
|
||||
filemgrSaveOrLoad(&guid, FILEOP_LOAD_MPSETUP, 0);
|
||||
g_MpCurrentSetup = -1;
|
||||
}
|
||||
else {
|
||||
mpsetupLoadSetup(data->list.value - mpGetNumUnlockedPresets());
|
||||
}
|
||||
|
||||
if (item->param == 1) {
|
||||
@@ -2273,19 +2289,14 @@ MenuItemHandlerResult mpLoadSettingsMenuHandler(s32 operation, struct menuitem *
|
||||
data->list.value = 0xfffff;
|
||||
break;
|
||||
case MENUOP_GETOPTGROUPCOUNT:
|
||||
data->list.value = 1;
|
||||
|
||||
if (g_FileLists[1] != NULL) {
|
||||
data->list.value += g_FileLists[1]->numdevices;
|
||||
}
|
||||
data->list.value = g_MpSetupFile.numgroups + 1;
|
||||
break;
|
||||
case MENUOP_GETOPTGROUPTEXT:
|
||||
if (data->list.value == 0) {
|
||||
return (uintptr_t)langGet(L_MPMENU_141); // "Presets"
|
||||
}
|
||||
if (g_FileLists[1] != NULL) {
|
||||
return (uintptr_t)filemgrGetDeviceNameOrStartIndex(1, operation, data->list.value - 1);
|
||||
}
|
||||
|
||||
return (uintptr_t)&g_MpSetupFile.groups[data->list.value - 1].name;
|
||||
break;
|
||||
case MENUOP_GETGROUPSTARTINDEX:
|
||||
if (data->list.value == 0) {
|
||||
@@ -2293,16 +2304,14 @@ MenuItemHandlerResult mpLoadSettingsMenuHandler(s32 operation, struct menuitem *
|
||||
} else {
|
||||
data->list.groupstartindex = mpGetNumUnlockedPresets();
|
||||
|
||||
if (g_FileLists[1] != NULL) {
|
||||
data->list.groupstartindex += filemgrGetDeviceNameOrStartIndex(1, operation, data->list.value - 1);
|
||||
if (g_MpSetupFile.numgroups > 0) {
|
||||
data->list.groupstartindex += g_MpSetupFile.groups[data->list.value - 1].offset_index;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MENUOP_LISTITEMFOCUS:
|
||||
if (data->list.value < mpGetNumUnlockedPresets()) {
|
||||
g_Menus[g_MpPlayerNum].mpsetup.slotindex = 0xffff;
|
||||
} else {
|
||||
g_Menus[g_MpPlayerNum].mpsetup.slotindex = data->list.value - mpGetNumUnlockedPresets();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2630,6 +2639,22 @@ struct menuitem g_MpLoadSettingsMenuItems[] = {
|
||||
0,
|
||||
NULL,
|
||||
},
|
||||
{
|
||||
MENUITEMTYPE_SEPARATOR,
|
||||
0,
|
||||
MENUITEMFLAG_00000002,
|
||||
0,
|
||||
0,
|
||||
NULL,
|
||||
},
|
||||
{
|
||||
MENUITEMTYPE_LABEL,
|
||||
0,
|
||||
MENUITEMFLAG_00000002 | MENUITEMFLAG_SELECTABLE_CENTRE,
|
||||
L_MPMENU_414, // "Press the B Button to go back."
|
||||
0,
|
||||
NULL,
|
||||
},
|
||||
{ MENUITEMTYPE_END },
|
||||
};
|
||||
|
||||
@@ -5013,13 +5038,10 @@ MenuItemHandlerResult menuhandler0017ef30(s32 operation, struct menuitem *item,
|
||||
MenuItemHandlerResult menuhandlerMpSaveSettings(s32 operation, struct menuitem *item, union handlerdata *data)
|
||||
{
|
||||
if (operation == MENUOP_SET) {
|
||||
if (g_MpSetup.fileguid.fileid == 0) {
|
||||
menuPushDialog(&g_MpSaveSetupNameMenuDialog);
|
||||
} else {
|
||||
#if VERSION >= VERSION_NTSC_1_0
|
||||
filemgrSetDevice1BySerial(g_MpSetup.fileguid.deviceserial);
|
||||
#endif
|
||||
|
||||
if (g_MpCurrentSetup < 0) {
|
||||
menuPushDialog(&g_MpSetupGroupsDialog);
|
||||
}
|
||||
else {
|
||||
menuPushDialog(&g_MpSaveSetupExistsMenuDialog);
|
||||
}
|
||||
}
|
||||
@@ -5362,6 +5384,9 @@ MenuDialogHandlerResult menudialogCombatSimulator(s32 operation, struct menudial
|
||||
g_Vars.waitingtojoin[1] = false;
|
||||
g_Vars.waitingtojoin[2] = false;
|
||||
g_Vars.waitingtojoin[3] = false;
|
||||
|
||||
// load the setup file when entering the Combat Simulator
|
||||
mpsetupLoadFile();
|
||||
}
|
||||
|
||||
if (g_Menus[g_MpPlayerNum].curdialog
|
||||
|
||||
@@ -4754,6 +4754,11 @@ enum weaponnum {
|
||||
|
||||
#define EXTRA_SLEEP_TIME 1000LL // 100us
|
||||
|
||||
#define MPSETUP_MAXSETUPS 100
|
||||
#define MPSETUP_MAXGROUPS 100
|
||||
#define MPSETUP_MAXGROUPNAME 33
|
||||
#define MPSETUP_BLOCKSIZE 64
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -562,6 +562,10 @@ extern s32 g_FileAutoSelect;
|
||||
extern u8 g_MpWeaponSetRandomFilters[NUM_MPWEAPONS];
|
||||
extern s32 g_MpWeaponRandomFilterNum;
|
||||
|
||||
extern struct mpsetupfile g_MpSetupFile;
|
||||
extern s16 g_MpCurrentSetup;
|
||||
extern s16 g_MpCurrentGroup;
|
||||
|
||||
#define PLAYER_EXTCFG() g_PlayerExtCfg[g_Vars.currentplayerstats->mpindex & 3]
|
||||
#define PLAYER_DEFAULT_FOV (PLAYER_EXTCFG().fovy)
|
||||
|
||||
|
||||
@@ -122,7 +122,6 @@ void mpsetupfileLoadWad(struct savebuffer *buffer);
|
||||
void mpsetupfileSaveWad(struct savebuffer *buffer);
|
||||
void mpsetupfileGetOverview(char *arg0, char *filename, u16 *numsims, u16 *stagenum, u16 *scenarionum);
|
||||
s32 mpsetupfileSave(s32 device, s32 filenum, u16 deviceserial);
|
||||
s32 mpsetupfileLoad(s32 device, s32 filenum, u16 deviceserial);
|
||||
void func0f18e558(void);
|
||||
struct modeldef *func0f18e57c(s32 index, s32 *headnum);
|
||||
|
||||
|
||||
@@ -6156,6 +6156,24 @@ struct extplayerconfig {
|
||||
s32 usereloads;
|
||||
};
|
||||
|
||||
struct setupblock {
|
||||
u8 bytes[MPSETUP_BLOCKSIZE];
|
||||
};
|
||||
|
||||
struct setupgroup {
|
||||
char name[MPSETUP_MAXGROUPNAME];
|
||||
u8 offset_index;
|
||||
};
|
||||
|
||||
struct mpsetupfile {
|
||||
u8 version;
|
||||
u8 defaultsetup;
|
||||
u8 numsetups;
|
||||
u8 numgroups;
|
||||
struct setupblock setups[MPSETUP_MAXSETUPS];
|
||||
struct setupgroup groups[MPSETUP_MAXGROUPS];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user