From 85385db09928e9ea241f1c71d11e0cbf88182167 Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Thu, 11 May 2023 01:48:01 +0000 Subject: [PATCH] Use OnGameFrameUpdate for rainbow tick instead of relying on ImGui hidden window (#2872) --- soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp | 13 ++++++++----- 1 file 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([]() { + 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() {