mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-29 21:02:18 -05:00
develop-rando: File Select Fixes (#3734)
* Fixes pressing B on name entry after randomizer quest. * Reverts to auto parsing previous spoiler file. Also includes an option to press L to automatically gen a fresh seed. It still does regenerate the old spoiler to regen the hints in the user's current language, but it will now automatically do this instead of requiring dragging and dropping the spoiler every time. * Fixes bug causing rando settings to come from CVars instead of a spoiler file when a spoiler is dropped/imported on boot. * Pressing Generate Randomizer in ImGui doesn't use loaded spoilerfile. * Adds tooltip to Generate Randomizer ImGui Button.
This commit is contained in:
parent
7f961abd8d
commit
f74ba3c1da
@ -21,6 +21,5 @@ void RandoMain::GenerateRando(std::set<RandomizerCheck> excludedLocations, std::
|
||||
|
||||
CVarSave();
|
||||
CVarLoad();
|
||||
Rando::Context::GetInstance()->SetSpoilerLoaded(false);
|
||||
Rando::Context::GetInstance()->SetPlandoLoaded(false);
|
||||
}
|
@ -864,6 +864,8 @@ const char* SpoilerLog_Write() {
|
||||
jsonFile << std::setw(4) << jsonString << std::endl;
|
||||
jsonFile.close();
|
||||
|
||||
CVarSetString("gSpoilerLog", (std::string("./Randomizer/") + fileName + std::string(".json")).c_str());
|
||||
|
||||
// Note: probably shouldn't return this without making sure this string is stored somewhere, but
|
||||
// this return value is currently only used in playthrough.cpp as a true/false. Even if the pointer
|
||||
// is no longer valid it would still not be nullptr if the spoilerfile was written, so it works but
|
||||
|
@ -370,7 +370,7 @@ void Context::ParseSpoiler(const char* spoilerFileName, const bool plandoMode) {
|
||||
mSpoilerLoaded = true;
|
||||
mSeedGenerated = false;
|
||||
} catch (...) {
|
||||
throw;
|
||||
LUSLOG_ERROR("Failed to load Spoiler File: %s", spoilerFileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1659,7 +1659,10 @@ void GenerateRandomizerImgui(std::string seed = "") {
|
||||
CVarSetInteger("gRandoGenerating", 1);
|
||||
CVarSave();
|
||||
auto ctx = Rando::Context::GetInstance();
|
||||
ctx->GetSettings()->SetAllFromCVar();
|
||||
if (!ctx->IsSpoilerLoaded()) {
|
||||
// We use the settings from the spoiler rather than CVars.
|
||||
ctx->GetSettings()->SetAllFromCVar();
|
||||
}
|
||||
// todo: this efficently when we build out cvar array support
|
||||
std::set<RandomizerCheck> excludedLocations;
|
||||
std::stringstream excludedLocationStringStream(CVarGetString("gRandomizeExcludedLocations", ""));
|
||||
@ -1755,8 +1758,10 @@ void RandomizerSettingsWindow::DrawElement() {
|
||||
UIWidgets::Spacer(0);
|
||||
ImGui::BeginDisabled(CVarGetInteger("gRandomizerDontGenerateSpoiler", 0) && gSaveContext.gameMode != GAMEMODE_FILE_SELECT);
|
||||
if (ImGui::Button("Generate Randomizer")) {
|
||||
ctx->SetSpoilerLoaded(false);
|
||||
GenerateRandomizer(CVarGetInteger("gRandoManualSeedEntry", 0) ? seedString : "");
|
||||
}
|
||||
UIWidgets::Tooltip("You can also press L on the Quest Select screen to generate a new seed");
|
||||
ImGui::EndDisabled();
|
||||
|
||||
UIWidgets::Spacer(0);
|
||||
|
@ -974,9 +974,9 @@ void DrawSeedHashSprites(FileChooseContext* this) {
|
||||
// Draw Seed Icons for spoiler log:
|
||||
// 1. On Name Entry if a rando seed has been generated
|
||||
// 2. On Quest Menu if a spoiler has been dropped and the Randomizer quest option is currently hovered.
|
||||
if ((Randomizer_IsSeedGenerated() ||
|
||||
(strnlen(CVarGetString("gSpoilerLog", ""), 1) != 0 && Randomizer_IsSpoilerLoaded())) &&
|
||||
if ((Randomizer_IsSeedGenerated() || Randomizer_IsSpoilerLoaded()) &&
|
||||
((this->configMode == CM_NAME_ENTRY && gSaveContext.questId == QUEST_RANDOMIZER) ||
|
||||
(this->configMode == CM_GENERATE_SEED && Randomizer_IsSpoilerLoaded()) ||
|
||||
(this->configMode == CM_QUEST_MENU && this->questType[this->buttonIndex] == QUEST_RANDOMIZER))) {
|
||||
// Fade top seed icons based on main menu fade and if save supports rando
|
||||
u8 alpha =
|
||||
@ -999,6 +999,7 @@ void DrawSeedHashSprites(FileChooseContext* this) {
|
||||
}
|
||||
|
||||
u8 generating;
|
||||
bool fileSelectSpoilerFileLoaded = false;
|
||||
|
||||
void FileChoose_UpdateRandomizer() {
|
||||
if (CVarGetInteger("gRandoGenerating", 0) != 0 && generating == 0) {
|
||||
@ -1006,7 +1007,7 @@ void FileChoose_UpdateRandomizer() {
|
||||
func_800F5E18(SEQ_PLAYER_BGM_MAIN, NA_BGM_HORSE, 0, 7, 1);
|
||||
return;
|
||||
} else if (CVarGetInteger("gRandoGenerating", 0) == 0 && generating) {
|
||||
if (SpoilerFileExists(CVarGetString("gSpoilerLog", "")) || Randomizer_IsSeedGenerated()) {
|
||||
if (Randomizer_IsSeedGenerated()) {
|
||||
Audio_PlayFanfare(NA_BGM_HORSE_GOAL);
|
||||
} else {
|
||||
func_80078884(NA_SE_SY_OCARINA_ERROR);
|
||||
@ -1022,13 +1023,16 @@ void FileChoose_UpdateRandomizer() {
|
||||
CVarSetString("gSpoilerLog", "");
|
||||
}
|
||||
|
||||
if ((CVarGetInteger("gNewFileDropped", 0) != 0)) {
|
||||
CVarSetString("gSpoilerLog", CVarGetString("gDroppedFile", ""));
|
||||
CVarSetInteger("gNewSeedGenerated", 0);
|
||||
if (CVarGetInteger("gNewFileDropped", 0) != 0 || !(Randomizer_IsSeedGenerated() || Randomizer_IsSpoilerLoaded()) &&
|
||||
SpoilerFileExists(CVarGetString("gSpoilerLog", "")) && !fileSelectSpoilerFileLoaded) {
|
||||
const char* fileLoc = CVarGetString("gSpoilerLog", "");
|
||||
if (CVarGetInteger("gNewFileDropped", 0) != 0) {
|
||||
CVarSetString("gSpoilerLog", CVarGetString("gDroppedFile", ""));
|
||||
}
|
||||
CVarSetInteger("gNewFileDropped", 0);
|
||||
CVarSetString("gDroppedFile", "");
|
||||
const char* fileLoc = CVarGetString("gSpoilerLog", "");
|
||||
Randomizer_ParseSpoiler(fileLoc);
|
||||
fileSelectSpoilerFileLoaded = true;
|
||||
|
||||
if (SpoilerFileExists(CVarGetString("gSpoilerLog", "")) && CVarGetInteger("gRandomizerDontGenerateSpoiler", 0)) {
|
||||
remove(fileLoc);
|
||||
@ -1274,6 +1278,14 @@ void FileChoose_UpdateQuestMenu(GameState* thisx) {
|
||||
GameInteractor_ExecuteOnUpdateFileQuestSelection(this->questType[this->buttonIndex]);
|
||||
}
|
||||
|
||||
if (CHECK_BTN_ALL(input->press.button, BTN_L)) {
|
||||
if (this->questType[this->buttonIndex] == QUEST_RANDOMIZER) {
|
||||
Randomizer_SetSpoilerLoaded(false);
|
||||
this->prevConfigMode = this->configMode;
|
||||
this->configMode = CM_GENERATE_SEED;
|
||||
}
|
||||
}
|
||||
|
||||
if (CHECK_BTN_ALL(input->press.button, BTN_A)) {
|
||||
gSaveContext.questId = this->questType[this->buttonIndex];
|
||||
|
||||
@ -1318,6 +1330,10 @@ void FileChoose_GenerateRandoSeed(GameState* thisx) {
|
||||
FileChooseContext* this = (FileChooseContext*)thisx;
|
||||
FileChoose_UpdateRandomizer();
|
||||
if (Randomizer_IsSeedGenerated() || Randomizer_IsPlandoLoaded()) {
|
||||
Audio_PlayFanfare(NA_BGM_HORSE_GOAL);
|
||||
func_800F5E18(SEQ_PLAYER_BGM_MAIN, NA_BGM_FILE_SELECT, 0, 7, 1);
|
||||
generating = 0;
|
||||
Randomizer_SetSpoilerLoaded(true);
|
||||
static u8 emptyName[] = { 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E };
|
||||
static u8 linkName[] = { 0x15, 0x2C, 0x31, 0x2E, 0x3E, 0x3E, 0x3E, 0x3E };
|
||||
this->prevConfigMode = this->configMode;
|
||||
@ -3190,25 +3206,25 @@ void FileChoose_DrawRandoSaveVersionWarning(GameState* thisx) {
|
||||
|
||||
static const char* noRandoGeneratedText[] = {
|
||||
// English
|
||||
"Open Randomizer Settings to change your settings,\nthen press A to generate a new seed"
|
||||
"No Randomizer seed currently available.\nGenerate one in the Randomizer Settings"
|
||||
#if defined(__WIIU__) || defined(__SWITCH__)
|
||||
".",
|
||||
#else
|
||||
",\nor drop a spoiler log on the game window.",
|
||||
#endif
|
||||
// German
|
||||
"Open Randomizer Settings to change your settings,\nthen press A to generate a new seed"
|
||||
"No Randomizer seed currently available.\nGenerate one in the Randomizer Settings"
|
||||
#if defined(__WIIU__) || defined(__SWITCH__)
|
||||
".",
|
||||
#else
|
||||
",\nor drop a spoiler log on the game window.",
|
||||
#endif
|
||||
// French
|
||||
"Ouvrez le menu \"Randomizer Settings\" pour modifier\nvos paramètres, appuyez sur A pour générer\nune nouvelle seed"
|
||||
"Aucune Seed de Randomizer actuellement disponible.\nGénérez-en une dans les \"Randomizer Settings\""
|
||||
#if (defined(__WIIU__) || defined(__SWITCH__))
|
||||
"."
|
||||
#else
|
||||
" ou glissez un spoilerlog sur la\nfenêtre du jeu."
|
||||
"\nou glissez un spoilerlog sur la fenêtre du jeu."
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -3231,18 +3247,12 @@ void FileChoose_DrawNoRandoGeneratedWarning(GameState* thisx) {
|
||||
uint16_t textboxWidth = 256 * textboxScale;
|
||||
uint16_t textboxHeight = 64 * textboxScale;
|
||||
uint8_t leftOffset = 72;
|
||||
uint8_t bottomOffset = 132;
|
||||
uint8_t bottomOffset = 84;
|
||||
uint8_t textVerticalOffset;
|
||||
#if defined(__WIIU__) || defined(__SWITCH__)
|
||||
textVerticalOffset = 80; // 2 lines
|
||||
if (gSaveContext.language == LANGUAGE_FRA) {
|
||||
textVerticalOffset = 75; // 3 lines
|
||||
}
|
||||
textVerticalOffset = 127; // 2 lines
|
||||
#else
|
||||
textVerticalOffset = 75; // 3 lines
|
||||
if (gSaveContext.language == LANGUAGE_FRA) {
|
||||
textVerticalOffset = 70; // 4 lines
|
||||
}
|
||||
textVerticalOffset = 122; // 3 lines
|
||||
#endif
|
||||
|
||||
Gfx_SetupDL_39Opa(this->state.gfxCtx);
|
||||
|
@ -373,7 +373,7 @@ void FileChoose_DrawNameEntry(GameState* thisx) {
|
||||
|
||||
if (this->newFileNameCharCount < 0) {
|
||||
this->newFileNameCharCount = 0;
|
||||
if (this->prevConfigMode == CM_QUEST_MENU) {
|
||||
if (this->prevConfigMode == CM_QUEST_MENU || this->prevConfigMode == CM_GENERATE_SEED) {
|
||||
this->configMode = CM_NAME_ENTRY_TO_QUEST_MENU;
|
||||
Randomizer_SetSeedGenerated(false);
|
||||
} else {
|
||||
@ -459,8 +459,6 @@ void FileChoose_DrawNameEntry(GameState* thisx) {
|
||||
CVarSetInteger("gOnFileSelectNameEntry", 0);
|
||||
CVarSetInteger("gNewFileDropped", 0);
|
||||
Randomizer_SetSeedGenerated(false);
|
||||
Randomizer_SetSpoilerLoaded(false);
|
||||
Randomizer_SetPlandoLoaded(false);
|
||||
this->nameBoxAlpha[this->buttonIndex] = this->nameAlpha[this->buttonIndex] = 200;
|
||||
this->connectorAlpha[this->buttonIndex] = 255;
|
||||
func_800AA000(300.0f, 0xB4, 0x14, 0x64);
|
||||
|
Loading…
Reference in New Issue
Block a user