summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Dubé <serprex@users.noreply.github.com>2025-12-03 15:58:16 +0000
committerGitHub <noreply@github.com>2025-12-03 08:58:16 -0700
commitc24b2d74d5c5ae3cb0ba7e5670fade5349290bd7 (patch)
treea41c35d65be27f0ca11da9debb19bd6382b8dfec
parent8aa7b2fc716cf40251bc9cb97db598d1d055636c (diff)
hookify cosmetics (#5900)
also make goron neck searchable
-rw-r--r--soh/soh/Enhancements/audio/AudioEditor.cpp1
-rw-r--r--soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp71
2 files changed, 38 insertions, 34 deletions
diff --git a/soh/soh/Enhancements/audio/AudioEditor.cpp b/soh/soh/Enhancements/audio/AudioEditor.cpp
index be6acae73..fa0727218 100644
--- a/soh/soh/Enhancements/audio/AudioEditor.cpp
+++ b/soh/soh/Enhancements/audio/AudioEditor.cpp
@@ -4,7 +4,6 @@
#include <map>
#include <set>
#include <string>
-#include <sstream>
#include <libultraship/libultraship.h>
#include <functions.h>
#include "../randomizer/3drando/random.hpp"
diff --git a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp
index 314b92b40..202fef039 100644
--- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp
+++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp
@@ -5,12 +5,11 @@
#include <string>
#include <libultraship/bridge.h>
-#include <random>
#include <math.h>
-#include <algorithm>
#include <libultraship/libultraship.h>
#include "soh/SohGui/UIWidgets.hpp"
+#include "soh/SohGui/SohMenu.h"
#include "soh/SohGui/SohGui.hpp"
#include "soh/OTRGlobals.h"
#include "soh/ResourceManagerHelpers.h"
@@ -22,7 +21,6 @@ extern "C" {
#include "objects/object_link_boy/object_link_boy.h"
#include "objects/object_link_child/object_link_child.h"
#include "objects/object_gi_shield_3/object_gi_shield_3.h"
-#include "objects/object_gi_heart/object_gi_heart.h"
#include "objects/object_gi_bow/object_gi_bow.h"
#include "objects/object_gi_bracelet/object_gi_bracelet.h"
#include "objects/object_gi_rupy/object_gi_rupy.h"
@@ -57,6 +55,12 @@ void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName);
u8 Randomizer_GetSettingValue(RandomizerSettingKey randoSettingKey);
}
+static WidgetInfo goronNeck;
+
+namespace SohGui {
+extern std::shared_ptr<SohMenu> mSohMenu;
+}
+
#define PATCH_GFX(path, name, cvar, index, instruction) \
if (CVarGetInteger(cvar, 0)) { \
ResourceMgr_PatchGfxByName(path, name, index, instruction); \
@@ -1964,15 +1968,7 @@ void DrawSillyTab() {
UIWidgets::Separator(true, true, 2.0f, 2.0f);
- UIWidgets::CVarSliderFloat("Goron Neck Length", CVAR_COSMETIC("Goron.NeckLength"),
- UIWidgets::FloatSliderOptions()
- .Format("%.0f")
- .Min(0.0f)
- .Max(5000.0f)
- .DefaultValue(0.0f)
- .Step(10.0f)
- .Size(ImVec2(300.0f, 0.0f))
- .Color(THEME_COLOR));
+ SohGui::mSohMenu->MenuDrawItem(goronNeck, ImGui::GetContentRegionAvail().x, THEME_COLOR);
Reset_Option_Single("Reset##Goron_NeckLength", CVAR_COSMETIC("Goron.NeckLength"));
UIWidgets::Separator(true, true, 2.0f, 2.0f);
@@ -2586,22 +2582,6 @@ void RegisterOnGameFrameUpdateHook() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() { CosmeticsUpdateTick(); });
}
-void Cosmetics_RegisterOnSceneInitHook() {
- GameInteractor::Instance->RegisterGameHook<GameInteractor::OnSceneInit>([](int16_t sceneNum) {
- if (CVarGetInteger(CVAR_COSMETIC("RandomizeAllOnNewScene"), 0)) {
- CosmeticsEditor_RandomizeAll();
- }
- });
-}
-
-void CosmeticsEditorRegisterOnGenerationCompletionHook() {
- GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGenerationCompletion>([]() {
- 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) {
@@ -2617,11 +2597,6 @@ void CosmeticsEditorWindow::InitElement() {
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
ApplyOrResetCustomGfxPatches();
ApplyAuthenticGfxPatches();
-
- RegisterOnLoadGameHook();
- RegisterOnGameFrameUpdateHook();
- Cosmetics_RegisterOnSceneInitHook();
- CosmeticsEditorRegisterOnGenerationCompletionHook();
}
void CosmeticsEditor_RandomizeAll() {
@@ -2670,3 +2645,33 @@ void CosmeticsEditor_ResetGroup(CosmeticGroup group) {
Ship::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesNextFrame();
ApplyOrResetCustomGfxPatches();
}
+
+void RegisterCosmeticHooks() {
+ COND_HOOK(OnSceneInit, CVarGetInteger(CVAR_COSMETIC("RandomizeAllOnNewScene"), 0),
+ [](s16 sceneNum) { CosmeticsEditor_RandomizeAll(); });
+
+ COND_HOOK(OnGenerationCompletion, CVarGetInteger(CVAR_COSMETIC("RandomizeAllOnRandoGen"), 0),
+ []() { CosmeticsEditor_RandomizeAll(); });
+
+ COND_HOOK(OnGameFrameUpdate, true, CosmeticsUpdateTick);
+}
+
+void RegisterCosmeticWidgets() {
+ goronNeck = { .name = "Goron Neck Length", .type = WidgetType::WIDGET_CVAR_SLIDER_FLOAT };
+ goronNeck.CVar(CVAR_COSMETIC("Goron.NeckLength"))
+ .Options(UIWidgets::FloatSliderOptions()
+ .Format("%.0f")
+ .Min(0.0f)
+ .Max(5000.0f)
+ .DefaultValue(0.0f)
+ .Step(10.0f)
+ .Size(ImVec2(300.0f, 0.0f))
+ .Color(THEME_COLOR));
+ SohGui::mSohMenu->AddSearchWidget({ goronNeck, "Enhancements", "Cosmetics Editor", "Silly" });
+}
+
+static RegisterShipInitFunc initFunc(RegisterCosmeticHooks, {
+ CVAR_COSMETIC("RandomizeAllOnNewScene"),
+ CVAR_COSMETIC("RandomizeAllOnRandoGen"),
+ });
+static RegisterMenuInitFunc menuInitFunc(RegisterCosmeticWidgets);