Redone fast file select (#1854)

* Redone fast file select

* Update soh/src/overlays/gamestates/ovl_title/z_title.c

* Prevent loading incompatible saves

* Dont change cvar on incompatible file
This commit is contained in:
Garrett Cox 2022-10-29 12:53:39 -05:00 committed by GitHub
parent cc7f831ec1
commit 4a686cf800
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 103 deletions

View File

@ -1465,13 +1465,11 @@ namespace GameMenuBar {
"File N.1", "File N.1",
"File N.2", "File N.2",
"File N.3", "File N.3",
"Zelda Map Select (require OoT Debug Mode)",
"File select", "File select",
"Zelda Map Select (require OoT Debug Mode)"
}; };
ImGui::Text("Loading :"); ImGui::Text("Loading :");
UIWidgets::EnhancementCombobox("gSaveFileID", FastFileSelect, 5, 0); UIWidgets::EnhancementCombobox("gSaveFileID", FastFileSelect, 5, 0);
UIWidgets::PaddedEnhancementCheckbox("Create a new save if none", "gCreateNewSave", true, false);
UIWidgets::Tooltip("Enable the creation of a new save file if none exist in the File number selected\nNo file name will be assigned please do in Save editor once you see the first text else your save file name will be named \"00000000\"\nIf disabled you will fall back in File select menu");
}; };
UIWidgets::PaddedEnhancementCheckbox("Better Debug Warp Screen", "gBetterDebugWarpScreen", true, false); UIWidgets::PaddedEnhancementCheckbox("Better Debug Warp Screen", "gBetterDebugWarpScreen", true, false);
UIWidgets::Tooltip("Optimized debug warp screen, with the added ability to chose entrances and time of day"); UIWidgets::Tooltip("Optimized debug warp screen, with the added ability to chose entrances and time of day");

View File

@ -685,14 +685,13 @@ void SaveManager::LoadFile(int fileNum) {
} }
bool SaveManager::SaveFile_Exist(int fileNum) { bool SaveManager::SaveFile_Exist(int fileNum) {
try { try {
std::filesystem::exists(GetFileName(fileNum)); bool exists = std::filesystem::exists(GetFileName(fileNum));
printf("File[%d] - exist \n",fileNum); SPDLOG_INFO("File[{}] - {}", fileNum, exists ? "exists" : "does not exist" );
return true; return exists;
} }
catch(std::filesystem::filesystem_error const& ex) { catch(std::filesystem::filesystem_error const& ex) {
printf("File[%d] - do not exist \n",fileNum); SPDLOG_ERROR("Filesystem error");
return false; return false;
} }
} }

View File

@ -12,6 +12,7 @@ static s16 sUnused = 106;
static s16 sScreenFillAlpha = 255; static s16 sScreenFillAlpha = 255;
static u8 isFastFileIdIncompatible = 0;
static Gfx sScreenFillSetupDL[] = { static Gfx sScreenFillSetupDL[] = {
gsDPPipeSync(), gsDPPipeSync(),
@ -1608,10 +1609,14 @@ void FileChoose_LoadGame(GameState* thisx) {
u16 swordEquipMask; u16 swordEquipMask;
s32 pad; s32 pad;
if (this->buttonIndex == FS_BTN_SELECT_FILE_1 && CVar_GetS32("gDebugEnabled", 0)) { if ((this->buttonIndex == FS_BTN_SELECT_FILE_1 && CVar_GetS32("gDebugEnabled", 0)) || this->buttonIndex == 0xFF) {
Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8); Audio_PlaySoundGeneral(NA_SE_SY_FSEL_DECIDE_L, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
gSaveContext.fileNum = this->buttonIndex; gSaveContext.fileNum = this->buttonIndex;
if (this->buttonIndex == 0xFF) {
Sram_InitDebugSave();
} else {
Sram_OpenSave(); Sram_OpenSave();
}
gSaveContext.gameMode = 0; gSaveContext.gameMode = 0;
SET_NEXT_GAMESTATE(&this->state, Select_Init, SelectContext); SET_NEXT_GAMESTATE(&this->state, Select_Init, SelectContext);
this->state.running = false; this->state.running = false;
@ -1627,7 +1632,9 @@ void FileChoose_LoadGame(GameState* thisx) {
Randomizer_LoadSettings(""); Randomizer_LoadSettings("");
Randomizer_LoadHintLocations(""); Randomizer_LoadHintLocations("");
Randomizer_LoadItemLocations("", true); Randomizer_LoadItemLocations("", true);
Randomizer_LoadRequiredTrials("");
Randomizer_LoadMerchantMessages(""); Randomizer_LoadMerchantMessages("");
Randomizer_LoadMasterQuestDungeons("");
gSaveContext.respawn[0].entranceIndex = -1; gSaveContext.respawn[0].entranceIndex = -1;
gSaveContext.respawnFlag = 0; gSaveContext.respawnFlag = 0;
@ -1785,6 +1792,20 @@ void FileChoose_Main(GameState* thisx) {
gSaveContext.skyboxTime += 0x10; gSaveContext.skyboxTime += 0x10;
} }
if (CVar_GetS32("gSkipLogoTitle", 0) && CVar_GetS32("gSaveFileID", 0) < 3 && !isFastFileIdIncompatible) {
if (Save_Exist(CVar_GetS32("gSaveFileID", 0)) && FileChoose_IsSaveCompatible(Save_GetSaveMetaInfo(CVar_GetS32("gSaveFileID", 0)))) {
this->buttonIndex = CVar_GetS32("gSaveFileID", 0);
this->menuMode = FS_MENU_MODE_SELECT;
this->selectMode = SM_LOAD_GAME;
} else {
isFastFileIdIncompatible = 1;
}
} else if (CVar_GetS32("gSkipLogoTitle", 0) && CVar_GetS32("gSaveFileID", 0) == 3) {
this->buttonIndex = 0xFF;
this->menuMode = FS_MENU_MODE_SELECT;
this->selectMode = SM_LOAD_GAME;
}
OPEN_DISPS(this->state.gfxCtx); OPEN_DISPS(this->state.gfxCtx);
gSPSegment(POLY_OPA_DISP++, 0x00, NULL); gSPSegment(POLY_OPA_DISP++, 0x00, NULL);
@ -2099,6 +2120,7 @@ void FileChoose_Init(GameState* thisx) {
size_t size = (u32)_title_staticSegmentRomEnd - (u32)_title_staticSegmentRomStart; size_t size = (u32)_title_staticSegmentRomEnd - (u32)_title_staticSegmentRomStart;
s32 pad; s32 pad;
fileSelectSpoilerFileLoaded = false; fileSelectSpoilerFileLoaded = false;
isFastFileIdIncompatible = 0;
CVar_SetS32("gOnFileSelectNameEntry", 0); CVar_SetS32("gOnFileSelectNameEntry", 0);
SREG(30) = 1; SREG(30) = 1;

View File

@ -243,13 +243,13 @@ void Title_Main(GameState* thisx) {
POLY_OPA_DISP = gfx; POLY_OPA_DISP = gfx;
} }
if (this->exit) { if (this->exit || CVar_GetS32("gSkipLogoTitle", 0)) {
gSaveContext.seqId = (u8)NA_BGM_DISABLED; gSaveContext.seqId = (u8)NA_BGM_DISABLED;
gSaveContext.natureAmbienceId = 0xFF; gSaveContext.natureAmbienceId = 0xFF;
gSaveContext.gameMode = 1; gSaveContext.gameMode = 1;
this->state.running = false; this->state.running = false;
if (gLoadFileSelect) if (gLoadFileSelect || CVar_GetS32("gSkipLogoTitle", 0))
SET_NEXT_GAMESTATE(&this->state, FileChoose_Init, FileChooseContext); SET_NEXT_GAMESTATE(&this->state, FileChoose_Init, FileChooseContext);
else else
SET_NEXT_GAMESTATE(&this->state, Opening_Init, OpeningContext); SET_NEXT_GAMESTATE(&this->state, Opening_Init, OpeningContext);
@ -267,77 +267,7 @@ void Title_Destroy(GameState* thisx) {
void Title_Init(GameState* thisx) { void Title_Init(GameState* thisx) {
//u32 size = 0; //u32 size = 0;
TitleContext* this = (TitleContext*)thisx; TitleContext* this = (TitleContext*)thisx;
FileChooseContext* FileChooseCtx = (FileChooseContext*)thisx;
if (CVar_GetS32("gSkipLogoTitle",0)) {
bool saveloading = false;
Sram_InitSram(&this->state.init);
gSaveContext.language = CVar_GetS32("gLanguages", 0);
s32 selectedfile = CVar_GetS32("gSaveFileID", 0);
if (selectedfile == 4) {
if (CVar_GetS32("gDebugEnabled",0)) {
selectedfile = 0xFF;
} else {
selectedfile = 3;
}
}
if (selectedfile < 0) {
selectedfile = 3; //If somehow the save file number under 0 revert back to 3 to prevent boot error
}
if(selectedfile == 3){
saveloading = true;
gSaveContext.seqId = (u8)NA_BGM_DISABLED;
gSaveContext.natureAmbienceId = 0xFF;
gSaveContext.gameMode = 1;
SET_NEXT_GAMESTATE(&this->state, FileChoose_Init, FileChooseContext);
this->state.running = false;
return;
} else if (selectedfile == 0xFF || selectedfile > 3) {
saveloading = true;
Sram_InitDebugSave();
gSaveContext.fileNum = selectedfile;
SET_NEXT_GAMESTATE(&this->state, Select_Init, SelectContext);
this->state.running = false;
return;
} else if (selectedfile >= 0 && selectedfile <= 2) {
if (Save_Exist(selectedfile) == true) { //The file exist load it
saveloading = true;
gSaveContext.fileNum = selectedfile;
Sram_OpenSave();
Randomizer_LoadSettings("");
Randomizer_LoadHintLocations("");
Randomizer_LoadItemLocations("", true);
Randomizer_LoadMerchantMessages("");
gSaveContext.gameMode = 0;
gSaveContext.magic = gSaveContext.magic;
SET_NEXT_GAMESTATE(&this->state, Gameplay_Init, GlobalContext);
this->state.running = false;
return;
} else {
if (CVar_GetS32("gCreateNewSave",0)) {
//File do not exist create a new save file
saveloading = true;
Sram_InitSram(&FileChooseCtx->state.init);
gSaveContext.fileNum = selectedfile;
Sram_InitSave(FileChooseCtx);
Sram_OpenSave();
gSaveContext.gameMode = 0;
SET_NEXT_GAMESTATE(&this->state, Gameplay_Init, GlobalContext);
this->state.running = false;
return;
} else {
//File do not exist but user do not wish to auto create a save file with blank name
saveloading = true;
gSaveContext.seqId = (u8)NA_BGM_DISABLED;
gSaveContext.natureAmbienceId = 0xFF;
gSaveContext.gameMode = 1;
SET_NEXT_GAMESTATE(&this->state, FileChoose_Init, FileChooseContext);
this->state.running = false;
return;
}
}
}
} else {
quote = SetQuote(); quote = SetQuote();
this->staticSegment = NULL; this->staticSegment = NULL;
@ -362,4 +292,3 @@ void Title_Init(GameState* thisx) {
this->addAlpha = -3; this->addAlpha = -3;
this->visibleDuration = 0x3C; this->visibleDuration = 0x3C;
} }
}