This commit is contained in:
Glought 2025-08-14 06:12:27 -07:00 committed by GitHub
commit de0e9cbef6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 33 additions and 0 deletions

View file

@ -468,8 +468,17 @@ void AudioEditorRegisterOnSceneInitHook() {
}); });
} }
void AudioEditorRegisterOnGenerationCompletionHook() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGenerationCompletion>([]() {
if (CVarGetInteger(CVAR_AUDIO("RandomizeAllOnRandoGen"), 0)) {
AudioEditor_RandomizeAll();
}
});
}
void AudioEditor::InitElement() { void AudioEditor::InitElement() {
AudioEditorRegisterOnSceneInitHook(); AudioEditorRegisterOnSceneInitHook();
AudioEditorRegisterOnGenerationCompletionHook();
} }
void AudioEditor::DrawElement() { void AudioEditor::DrawElement() {
@ -573,6 +582,12 @@ void AudioEditor::DrawElement() {
.Color(THEME_COLOR) .Color(THEME_COLOR)
.Tooltip( .Tooltip(
"Enables randomizing all unlocked music and sound effects when you enter a new scene.")); "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( UIWidgets::CVarCheckbox(
"Lower Octaves of Unplayable High Notes", CVAR_AUDIO("ExperimentalOctaveDrop"), "Lower Octaves of Unplayable High Notes", CVAR_AUDIO("ExperimentalOctaveDrop"),
UIWidgets::CheckboxOptions() UIWidgets::CheckboxOptions()

View file

@ -2382,6 +2382,11 @@ void CosmeticsEditorWindow::DrawElement() {
.Color(THEME_COLOR) .Color(THEME_COLOR)
.Tooltip("Enables randomizing all unlocked cosmetics when you enter a new scene.")); .Tooltip("Enables randomizing all unlocked cosmetics when you enter a new scene."));
ImGui::EndDisabled(); 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( UIWidgets::CVarCheckbox(
"Advanced Mode", CVAR_COSMETIC("AdvancedMode"), "Advanced Mode", CVAR_COSMETIC("AdvancedMode"),
UIWidgets::CheckboxOptions() UIWidgets::CheckboxOptions()
@ -2589,6 +2594,14 @@ void Cosmetics_RegisterOnSceneInitHook() {
}); });
} }
void CosmeticsEditorRegisterOnGenerationCompletionHook() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGenerationCompletion>([]() {
if (CVarGetInteger(CVAR_COSMETIC("RandomizeAllOnRandoGen"), 0)) {
CosmeticsEditor_RandomizeAll();
}
});
}
void CosmeticsEditorWindow::InitElement() { void CosmeticsEditorWindow::InitElement() {
// Convert the `current color` into the format that the ImGui color picker expects // Convert the `current color` into the format that the ImGui color picker expects
for (auto& [id, cosmeticOption] : cosmeticOptions) { for (auto& [id, cosmeticOption] : cosmeticOptions) {
@ -2608,6 +2621,7 @@ void CosmeticsEditorWindow::InitElement() {
RegisterOnLoadGameHook(); RegisterOnLoadGameHook();
RegisterOnGameFrameUpdateHook(); RegisterOnGameFrameUpdateHook();
Cosmetics_RegisterOnSceneInitHook(); Cosmetics_RegisterOnSceneInitHook();
CosmeticsEditorRegisterOnGenerationCompletionHook();
} }
void CosmeticsEditor_RandomizeAll() { void CosmeticsEditor_RandomizeAll() {

View file

@ -68,6 +68,7 @@ DEFINE_HOOK(OnUpdateFileBossRushOptionSelection, (uint8_t optionIndex, uint8_t o
DEFINE_HOOK(OnUpdateFileRandomizerOptionSelection, (uint8_t optionIndex)); DEFINE_HOOK(OnUpdateFileRandomizerOptionSelection, (uint8_t optionIndex));
DEFINE_HOOK(OnUpdateFileNameSelection, (int16_t charCode)); DEFINE_HOOK(OnUpdateFileNameSelection, (int16_t charCode));
DEFINE_HOOK(OnFileChooseMain, (void* gameState)); DEFINE_HOOK(OnFileChooseMain, (void* gameState));
DEFINE_HOOK(OnGenerationCompletion, ());
DEFINE_HOOK(OnSetGameLanguage, ()); DEFINE_HOOK(OnSetGameLanguage, ());
DEFINE_HOOK(OnFileDropped, (std::string filePath)); DEFINE_HOOK(OnFileDropped, (std::string filePath));

View file

@ -3800,6 +3800,8 @@ void GenerateRandomizerImgui(std::string seed = "") {
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame(); Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
generated = 1; generated = 1;
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnGenerationCompletion>();
} }
bool GenerateRandomizer(std::string seed /*= ""*/) { bool GenerateRandomizer(std::string seed /*= ""*/) {
@ -3809,6 +3811,7 @@ bool GenerateRandomizer(std::string seed /*= ""*/) {
} }
if (CVarGetInteger(CVAR_GENERAL("RandoGenerating"), 0) == 0) { if (CVarGetInteger(CVAR_GENERAL("RandoGenerating"), 0) == 0) {
randoThread = std::thread(&GenerateRandomizerImgui, seed); randoThread = std::thread(&GenerateRandomizerImgui, seed);
return true; return true;
} }
return false; return false;