summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett Cox <garrettjcox@gmail.com>2023-05-11 01:48:01 +0000
committerGitHub <noreply@github.com>2023-05-10 21:48:01 -0400
commit85385db09928e9ea241f1c71d11e0cbf88182167 (patch)
treea0ca3105829f8820fa2fa96508c4a62aa349f5d0
parentd1c930b5e56b68a5ca21bd2e2e566974cc916930 (diff)
Use OnGameFrameUpdate for rainbow tick instead of relying on ImGui hidden window (#2872)
-rw-r--r--soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp
index 76d4b7394..0cda15d01 100644
--- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp
+++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp
@@ -385,7 +385,7 @@ void ResetPositionAll() {
int hue = 0;
// Runs every frame to update rainbow hue, a potential future optimization is to only run this a once or twice a second and increase the speed of the rainbow hue rotation.
-void CosmeticsUpdateTick(bool& open) {
+void CosmeticsUpdateTick() {
int index = 0;
float rainbowSpeed = CVarGetFloat("gCosmetics.RainbowSpeed", 0.6f);
for (auto& [id, cosmeticOption] : cosmeticOptions) {
@@ -1800,11 +1800,13 @@ void RegisterOnLoadGameHook() {
});
}
-void InitCosmeticsEditor() {
- // There's probably a better way to do this, but leaving as is for historical reasons. Even though there is no
- // real window being rendered here, it calls this every frame allowing us to rotate through the rainbow hue for cosmetics
- LUS::AddWindow("Enhancements", "Cosmetics Update Tick", CosmeticsUpdateTick, true, true);
+void RegisterOnGameFrameUpdateHook() {
+ GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
+ CosmeticsUpdateTick();
+ });
+}
+void InitCosmeticsEditor() {
// Draw the bar in the menu.
LUS::AddWindow("Enhancements", "Cosmetics Editor", DrawCosmeticsEditor, CVarGetInteger("gCosmeticsEditorEnabled", 0));
// Convert the `current color` into the format that the ImGui color picker expects
@@ -1822,6 +1824,7 @@ void InitCosmeticsEditor() {
ApplyAuthenticGfxPatches();
RegisterOnLoadGameHook();
+ RegisterOnGameFrameUpdateHook();
}
void CosmeticsEditor_RandomizeAll() {