diff --git a/soh/soh/Enhancements/audio/AudioEditor.cpp b/soh/soh/Enhancements/audio/AudioEditor.cpp index 6660bee7d..f031048f2 100644 --- a/soh/soh/Enhancements/audio/AudioEditor.cpp +++ b/soh/soh/Enhancements/audio/AudioEditor.cpp @@ -468,8 +468,17 @@ void AudioEditorRegisterOnSceneInitHook() { }); } +void AudioEditorRegisterOnGenerationCompletionHook() { + GameInteractor::Instance->RegisterGameHook([]() { + if (CVarGetInteger(CVAR_AUDIO("RandomizeAllOnRandoGen"), 0)) { + AudioEditor_RandomizeAll(); + } + }); +} + void AudioEditor::InitElement() { AudioEditorRegisterOnSceneInitHook(); + AudioEditorRegisterOnGenerationCompletionHook(); } void AudioEditor::DrawElement() { @@ -573,6 +582,12 @@ void AudioEditor::DrawElement() { .Color(THEME_COLOR) .Tooltip( "Enables randomizing all unlocked music and sound effects when you enter a new scene.")); + UIWidgets::CVarCheckbox("Randomize All Music and Sound Effects on Randomizer Generation", + CVAR_AUDIO("RandomizeAllOnRandoGen"), + UIWidgets::CheckboxOptions() + .Color(THEME_COLOR) + .Tooltip("Enables randomizing all unlocked music and sound effects when " + "you generate a new randomizer.")); UIWidgets::CVarCheckbox( "Lower Octaves of Unplayable High Notes", CVAR_AUDIO("ExperimentalOctaveDrop"), UIWidgets::CheckboxOptions() diff --git a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp index 8074fa707..314b92b40 100644 --- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp +++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp @@ -2382,6 +2382,11 @@ void CosmeticsEditorWindow::DrawElement() { .Color(THEME_COLOR) .Tooltip("Enables randomizing all unlocked cosmetics when you enter a new scene.")); ImGui::EndDisabled(); + UIWidgets::CVarCheckbox( + "Randomize All on Randomizer Generation", CVAR_COSMETIC("RandomizeAllOnRandoGen"), + UIWidgets::CheckboxOptions() + .Color(THEME_COLOR) + .Tooltip("Enables randomizing all unlocked cosmetics when you generate a new randomizer.")); UIWidgets::CVarCheckbox( "Advanced Mode", CVAR_COSMETIC("AdvancedMode"), UIWidgets::CheckboxOptions() @@ -2589,6 +2594,14 @@ void Cosmetics_RegisterOnSceneInitHook() { }); } +void CosmeticsEditorRegisterOnGenerationCompletionHook() { + GameInteractor::Instance->RegisterGameHook([]() { + if (CVarGetInteger(CVAR_COSMETIC("RandomizeAllOnRandoGen"), 0)) { + CosmeticsEditor_RandomizeAll(); + } + }); +} + void CosmeticsEditorWindow::InitElement() { // Convert the `current color` into the format that the ImGui color picker expects for (auto& [id, cosmeticOption] : cosmeticOptions) { @@ -2608,6 +2621,7 @@ void CosmeticsEditorWindow::InitElement() { RegisterOnLoadGameHook(); RegisterOnGameFrameUpdateHook(); Cosmetics_RegisterOnSceneInitHook(); + CosmeticsEditorRegisterOnGenerationCompletionHook(); } void CosmeticsEditor_RandomizeAll() { diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h b/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h index 51a6ab5a8..3ac408e78 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h @@ -68,6 +68,7 @@ DEFINE_HOOK(OnUpdateFileBossRushOptionSelection, (uint8_t optionIndex, uint8_t o DEFINE_HOOK(OnUpdateFileRandomizerOptionSelection, (uint8_t optionIndex)); DEFINE_HOOK(OnUpdateFileNameSelection, (int16_t charCode)); DEFINE_HOOK(OnFileChooseMain, (void* gameState)); +DEFINE_HOOK(OnGenerationCompletion, ()); DEFINE_HOOK(OnSetGameLanguage, ()); DEFINE_HOOK(OnFileDropped, (std::string filePath)); diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index b8a4820d8..bbab5ebb3 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -3800,6 +3800,8 @@ void GenerateRandomizerImgui(std::string seed = "") { Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); generated = 1; + + GameInteractor::Instance->ExecuteHooks(); } bool GenerateRandomizer(std::string seed /*= ""*/) { @@ -3809,6 +3811,7 @@ bool GenerateRandomizer(std::string seed /*= ""*/) { } if (CVarGetInteger(CVAR_GENERAL("RandoGenerating"), 0) == 0) { randoThread = std::thread(&GenerateRandomizerImgui, seed); + return true; } return false;