From d8e90a701c36e80979c5316f72c017873c45cc4c Mon Sep 17 00:00:00 2001 From: Glought <663343+Glought@users.noreply.github.com> Date: Fri, 11 Apr 2025 07:43:25 -0700 Subject: [PATCH 1/5] Add "Randomize on Randomizer Generation" options to Audio and Cosmetics Editors * Added "Randomize All Music and Sound Effects on Randomizer Generation" to the Audio Editor. * Added "Randomize All on Randomizer Generation" to the Cosmetics Editor. When enabled, these options randomize audio and/or cosmetics during a new randomizer generation. --- soh/soh/Enhancements/audio/AudioEditor.cpp | 6 ++++++ soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp | 4 ++++ soh/soh/Enhancements/randomizer/randomizer.cpp | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/soh/soh/Enhancements/audio/AudioEditor.cpp b/soh/soh/Enhancements/audio/AudioEditor.cpp index 9865615bd..f7e8974de 100644 --- a/soh/soh/Enhancements/audio/AudioEditor.cpp +++ b/soh/soh/Enhancements/audio/AudioEditor.cpp @@ -564,6 +564,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("RandomizeAllOnNewRandoGen"), + 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 e0f530bc2..68dc844ef 100644 --- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp +++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp @@ -2380,6 +2380,10 @@ void CosmeticsEditorWindow::DrawElement() { UIWidgets::CheckboxOptions() .Color(THEME_COLOR) .Tooltip("Enables randomizing all unlocked cosmetics when you enter a new scene.")); + UIWidgets::CVarCheckbox("Randomize All on Randomizer Generation", CVAR_COSMETIC("RandomizeAllOnNewRandoGen"), + 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() diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index d567a3d8e..e7de4c1fb 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -3611,6 +3611,12 @@ bool GenerateRandomizer(std::string seed /*= ""*/) { } if (CVarGetInteger(CVAR_GENERAL("RandoGenerating"), 0) == 0) { randoThread = std::thread(&GenerateRandomizerImgui, seed); + if (CVarGetInteger(CVAR_AUDIO("RandomizeAllOnNewRandoGen"), 0) == 1) { + AudioEditor_RandomizeAll(); + } + if (CVarGetInteger(CVAR_COSMETIC("RandomizeAllOnNewRandoGen"), 0) == 1) { + CosmeticsEditor_RandomizeAll(); + } return true; } return false; From 1ec4ca43449321c5b57fefa69936403693161cc6 Mon Sep 17 00:00:00 2001 From: Glought <663343+Glought@users.noreply.github.com> Date: Sun, 13 Apr 2025 11:51:02 -0700 Subject: [PATCH 2/5] Added "OnRandomizerGeneration" Hook. * It is executed on Randomizer Generation. --- .../game-interactor/GameInteractor_HookTable.h | 1 + .../game-interactor/GameInteractor_Hooks.cpp | 4 ++++ .../Enhancements/game-interactor/GameInteractor_Hooks.h | 1 + soh/soh/Enhancements/randomizer/randomizer.cpp | 9 +++------ 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h b/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h index 44d0e643a..0f0d1c8be 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h @@ -62,6 +62,7 @@ DEFINE_HOOK(OnUpdateFileLanguageSelection, (uint8_t optionIndex)); DEFINE_HOOK(OnUpdateFileQuestSelection, (uint8_t questIndex)); DEFINE_HOOK(OnUpdateFileBossRushOptionSelection, (uint8_t optionIndex, uint8_t optionValue)); DEFINE_HOOK(OnUpdateFileNameSelection, (int16_t charCode)); +DEFINE_HOOK(OnRandomizerGeneration, ()); DEFINE_HOOK(OnSetGameLanguage, ()); DEFINE_HOOK(OnFileDropped, (std::string filePath)); diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp index 9231da843..b1446e58b 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp @@ -274,6 +274,10 @@ void GameInteractor_ExecuteOnUpdateFileNameSelection(int16_t charCode) { GameInteractor::Instance->ExecuteHooks(charCode); } +void GameInteractor_ExecuteOnRandomizerGeneration() { + GameInteractor::Instance->ExecuteHooks(); +} + // MARK: - Game void GameInteractor_ExecuteOnSetGameLanguage() { diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h index 33c8d2681..3d05f509f 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h @@ -69,6 +69,7 @@ void GameInteractor_ExecuteOnUpdateFileLanguageSelection(uint8_t optionIndex); void GameInteractor_ExecuteOnUpdateFileQuestSelection(uint8_t questIndex); void GameInteractor_ExecuteOnUpdateFileBossRushOptionSelection(uint8_t optionIndex, uint8_t optionValue); void GameInteractor_ExecuteOnUpdateFileNameSelection(int16_t charCode); +void GameInteractor_ExecuteOnRandomizerGeneration(); // MARK: - Game void GameInteractor_ExecuteOnSetGameLanguage(); diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index e7de4c1fb..3616aad4f 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -3611,12 +3611,9 @@ bool GenerateRandomizer(std::string seed /*= ""*/) { } if (CVarGetInteger(CVAR_GENERAL("RandoGenerating"), 0) == 0) { randoThread = std::thread(&GenerateRandomizerImgui, seed); - if (CVarGetInteger(CVAR_AUDIO("RandomizeAllOnNewRandoGen"), 0) == 1) { - AudioEditor_RandomizeAll(); - } - if (CVarGetInteger(CVAR_COSMETIC("RandomizeAllOnNewRandoGen"), 0) == 1) { - CosmeticsEditor_RandomizeAll(); - } + + GameInteractor_ExecuteOnRandomizerGeneration(); + return true; } return false; From d69a4a7ea10b1fec600661604fcccc4d20053087 Mon Sep 17 00:00:00 2001 From: Glought <663343+Glought@users.noreply.github.com> Date: Sun, 13 Apr 2025 12:03:53 -0700 Subject: [PATCH 3/5] Changed AudioEditor and CosmeticsEditor "Randomize all on Randomizer Generation" options to use the "OnRandomizerGeneration" Hook. --- soh/soh/Enhancements/audio/AudioEditor.cpp | 21 +++++++++++++------ .../cosmetics/CosmeticsEditor.cpp | 12 ++++++++++- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/soh/soh/Enhancements/audio/AudioEditor.cpp b/soh/soh/Enhancements/audio/AudioEditor.cpp index f7e8974de..ad549e60c 100644 --- a/soh/soh/Enhancements/audio/AudioEditor.cpp +++ b/soh/soh/Enhancements/audio/AudioEditor.cpp @@ -459,8 +459,17 @@ void AudioEditorRegisterOnSceneInitHook() { }); } +void AudioEditorRegisterOnRandomizerGenerationHook() { + GameInteractor::Instance->RegisterGameHook([]() { + if (CVarGetInteger(CVAR_AUDIO("RandomizeAllOnRandoGen"), 0)) { + AudioEditor_RandomizeAll(); + } + }); +} + void AudioEditor::InitElement() { AudioEditorRegisterOnSceneInitHook(); + AudioEditorRegisterOnRandomizerGenerationHook(); } void AudioEditor::DrawElement() { @@ -564,12 +573,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("RandomizeAllOnNewRandoGen"), - UIWidgets::CheckboxOptions() - .Color(THEME_COLOR) - .Tooltip( - "Enables randomizing all unlocked music and sound effects when you generate a new randomizer.")); + 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 68dc844ef..8894b3327 100644 --- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp +++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp @@ -2380,7 +2380,8 @@ void CosmeticsEditorWindow::DrawElement() { UIWidgets::CheckboxOptions() .Color(THEME_COLOR) .Tooltip("Enables randomizing all unlocked cosmetics when you enter a new scene.")); - UIWidgets::CVarCheckbox("Randomize All on Randomizer Generation", CVAR_COSMETIC("RandomizeAllOnNewRandoGen"), + 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.")); @@ -2584,6 +2585,14 @@ void Cosmetics_RegisterOnSceneInitHook() { }); } +void CosmeticsEditorRegisterOnRandomizerGenerationHook() { + 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) { @@ -2603,6 +2612,7 @@ void CosmeticsEditorWindow::InitElement() { RegisterOnLoadGameHook(); RegisterOnGameFrameUpdateHook(); Cosmetics_RegisterOnSceneInitHook(); + CosmeticsEditorRegisterOnRandomizerGenerationHook(); } void CosmeticsEditor_RandomizeAll() { From 6176e70adf89575001167ef0537dcb260a1c3c43 Mon Sep 17 00:00:00 2001 From: Glought <663343+Glought@users.noreply.github.com> Date: Sat, 14 Jun 2025 09:29:57 -0700 Subject: [PATCH 4/5] Renamed "OnRandomizerGeneration" to "OnGenerationCompletion. Renamed "GameInteractor_ExecuteOnRandomizerGeneration" to "GameInteractor_ExecuteOnGenerationCompletion" Moved "GameInteractor_ExecuteOnGenerationCompletion" from "GenerateRandomizer" to the end of "GenerateRandomizerImgui". --- soh/soh/Enhancements/audio/AudioEditor.cpp | 6 +++--- soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp | 6 +++--- .../Enhancements/game-interactor/GameInteractor_HookTable.h | 2 +- .../Enhancements/game-interactor/GameInteractor_Hooks.cpp | 4 ++-- soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h | 2 +- soh/soh/Enhancements/randomizer/randomizer.cpp | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/soh/soh/Enhancements/audio/AudioEditor.cpp b/soh/soh/Enhancements/audio/AudioEditor.cpp index ad549e60c..f7aaa7fc3 100644 --- a/soh/soh/Enhancements/audio/AudioEditor.cpp +++ b/soh/soh/Enhancements/audio/AudioEditor.cpp @@ -459,8 +459,8 @@ void AudioEditorRegisterOnSceneInitHook() { }); } -void AudioEditorRegisterOnRandomizerGenerationHook() { - GameInteractor::Instance->RegisterGameHook([]() { +void AudioEditorRegisterOnGenerationCompletionHook() { + GameInteractor::Instance->RegisterGameHook([]() { if (CVarGetInteger(CVAR_AUDIO("RandomizeAllOnRandoGen"), 0)) { AudioEditor_RandomizeAll(); } @@ -469,7 +469,7 @@ void AudioEditorRegisterOnRandomizerGenerationHook() { void AudioEditor::InitElement() { AudioEditorRegisterOnSceneInitHook(); - AudioEditorRegisterOnRandomizerGenerationHook(); + AudioEditorRegisterOnGenerationCompletionHook(); } void AudioEditor::DrawElement() { diff --git a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp index 8894b3327..8eb09d07b 100644 --- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp +++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp @@ -2585,8 +2585,8 @@ void Cosmetics_RegisterOnSceneInitHook() { }); } -void CosmeticsEditorRegisterOnRandomizerGenerationHook() { - GameInteractor::Instance->RegisterGameHook([]() { +void CosmeticsEditorRegisterOnGenerationCompletionHook() { + GameInteractor::Instance->RegisterGameHook([]() { if (CVarGetInteger(CVAR_COSMETIC("RandomizeAllOnRandoGen"), 0)) { CosmeticsEditor_RandomizeAll(); } @@ -2612,7 +2612,7 @@ void CosmeticsEditorWindow::InitElement() { RegisterOnLoadGameHook(); RegisterOnGameFrameUpdateHook(); Cosmetics_RegisterOnSceneInitHook(); - CosmeticsEditorRegisterOnRandomizerGenerationHook(); + 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 0f0d1c8be..9e1ffe3df 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_HookTable.h @@ -62,7 +62,7 @@ DEFINE_HOOK(OnUpdateFileLanguageSelection, (uint8_t optionIndex)); DEFINE_HOOK(OnUpdateFileQuestSelection, (uint8_t questIndex)); DEFINE_HOOK(OnUpdateFileBossRushOptionSelection, (uint8_t optionIndex, uint8_t optionValue)); DEFINE_HOOK(OnUpdateFileNameSelection, (int16_t charCode)); -DEFINE_HOOK(OnRandomizerGeneration, ()); +DEFINE_HOOK(OnGenerationCompletion, ()); DEFINE_HOOK(OnSetGameLanguage, ()); DEFINE_HOOK(OnFileDropped, (std::string filePath)); diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp index b1446e58b..5bf861785 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp @@ -274,8 +274,8 @@ void GameInteractor_ExecuteOnUpdateFileNameSelection(int16_t charCode) { GameInteractor::Instance->ExecuteHooks(charCode); } -void GameInteractor_ExecuteOnRandomizerGeneration() { - GameInteractor::Instance->ExecuteHooks(); +void GameInteractor_ExecuteOnGenerationCompletion() { + GameInteractor::Instance->ExecuteHooks(); } // MARK: - Game diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h index 3d05f509f..7f60f9415 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h @@ -69,7 +69,7 @@ void GameInteractor_ExecuteOnUpdateFileLanguageSelection(uint8_t optionIndex); void GameInteractor_ExecuteOnUpdateFileQuestSelection(uint8_t questIndex); void GameInteractor_ExecuteOnUpdateFileBossRushOptionSelection(uint8_t optionIndex, uint8_t optionValue); void GameInteractor_ExecuteOnUpdateFileNameSelection(int16_t charCode); -void GameInteractor_ExecuteOnRandomizerGeneration(); +void GameInteractor_ExecuteOnGenerationCompletion(); // MARK: - Game void GameInteractor_ExecuteOnSetGameLanguage(); diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 3616aad4f..c0f897669 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -3602,6 +3602,8 @@ void GenerateRandomizerImgui(std::string seed = "") { Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); generated = 1; + + GameInteractor_ExecuteOnGenerationCompletion(); } bool GenerateRandomizer(std::string seed /*= ""*/) { @@ -3612,8 +3614,6 @@ bool GenerateRandomizer(std::string seed /*= ""*/) { if (CVarGetInteger(CVAR_GENERAL("RandoGenerating"), 0) == 0) { randoThread = std::thread(&GenerateRandomizerImgui, seed); - GameInteractor_ExecuteOnRandomizerGeneration(); - return true; } return false; From a3e41841bf9f0cb9d86a078fd7a7d028bec9a053 Mon Sep 17 00:00:00 2001 From: Glought <663343+Glought@users.noreply.github.com> Date: Sun, 29 Jun 2025 08:30:50 -0700 Subject: [PATCH 5/5] Removed "GameInteractor_ExecuteOnGenerationCompletion()" from "GameInteractor_Hooks.h" and "GameInteractor_Hooks.cpp" The "OnGenerationCompletion" hook is now called directly at the end of "GenerateRandomizerImgui" in "randomizer.cpp" --- soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp | 4 ---- soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h | 1 - soh/soh/Enhancements/randomizer/randomizer.cpp | 2 +- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp index 52866e683..f69cc29af 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.cpp @@ -306,10 +306,6 @@ void GameInteractor_ExecuteOnFileChooseMain(void* gameState) { GameInteractor::Instance->ExecuteHooks(gameState); } -void GameInteractor_ExecuteOnGenerationCompletion() { - GameInteractor::Instance->ExecuteHooks(); -} - // MARK: - Game void GameInteractor_ExecuteOnSetGameLanguage() { diff --git a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h index ba0e56118..a6f1563f2 100644 --- a/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h +++ b/soh/soh/Enhancements/game-interactor/GameInteractor_Hooks.h @@ -75,7 +75,6 @@ void GameInteractor_ExecuteOnUpdateFileBossRushOptionSelection(uint8_t optionInd void GameInteractor_ExecuteOnUpdateFileRandomizerOptionSelection(uint8_t optionIndex); void GameInteractor_ExecuteOnUpdateFileNameSelection(int16_t charCode); void GameInteractor_ExecuteOnFileChooseMain(void* gameState); -void GameInteractor_ExecuteOnGenerationCompletion(); // MARK: - Game void GameInteractor_ExecuteOnSetGameLanguage(); diff --git a/soh/soh/Enhancements/randomizer/randomizer.cpp b/soh/soh/Enhancements/randomizer/randomizer.cpp index 915419d8c..095a0eb6b 100644 --- a/soh/soh/Enhancements/randomizer/randomizer.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer.cpp @@ -3753,7 +3753,7 @@ void GenerateRandomizerImgui(std::string seed = "") { generated = 1; - GameInteractor_ExecuteOnGenerationCompletion(); + GameInteractor::Instance->ExecuteHooks(); } bool GenerateRandomizer(std::string seed /*= ""*/) {