Use OnGameFrameUpdate for rainbow tick instead of relying on ImGui hidden window (#2872)

This commit is contained in:
Garrett Cox 2023-05-11 01:48:01 +00:00 committed by GitHub
parent d1c930b5e5
commit 85385db099
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -385,7 +385,7 @@ void ResetPositionAll() {
int hue = 0; 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. // 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; int index = 0;
float rainbowSpeed = CVarGetFloat("gCosmetics.RainbowSpeed", 0.6f); float rainbowSpeed = CVarGetFloat("gCosmetics.RainbowSpeed", 0.6f);
for (auto& [id, cosmeticOption] : cosmeticOptions) { for (auto& [id, cosmeticOption] : cosmeticOptions) {
@ -1800,11 +1800,13 @@ void RegisterOnLoadGameHook() {
}); });
} }
void InitCosmeticsEditor() { void RegisterOnGameFrameUpdateHook() {
// There's probably a better way to do this, but leaving as is for historical reasons. Even though there is no GameInteractor::Instance->RegisterGameHook<GameInteractor::OnGameFrameUpdate>([]() {
// real window being rendered here, it calls this every frame allowing us to rotate through the rainbow hue for cosmetics CosmeticsUpdateTick();
LUS::AddWindow("Enhancements", "Cosmetics Update Tick", CosmeticsUpdateTick, true, true); });
}
void InitCosmeticsEditor() {
// Draw the bar in the menu. // Draw the bar in the menu.
LUS::AddWindow("Enhancements", "Cosmetics Editor", DrawCosmeticsEditor, CVarGetInteger("gCosmeticsEditorEnabled", 0)); LUS::AddWindow("Enhancements", "Cosmetics Editor", DrawCosmeticsEditor, CVarGetInteger("gCosmeticsEditorEnabled", 0));
// 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
@ -1822,6 +1824,7 @@ void InitCosmeticsEditor() {
ApplyAuthenticGfxPatches(); ApplyAuthenticGfxPatches();
RegisterOnLoadGameHook(); RegisterOnLoadGameHook();
RegisterOnGameFrameUpdateHook();
} }
void CosmeticsEditor_RandomizeAll() { void CosmeticsEditor_RandomizeAll() {