From 12c6e44b2b99add9039c23a2999e60ba5759205f Mon Sep 17 00:00:00 2001 From: Viktor Holta Date: Fri, 20 May 2022 00:06:05 +0200 Subject: [PATCH] Add rainbow option for tunics --- libultraship/libultraship/SohImGuiImpl.cpp | 7 +++++ soh/src/code/z_player_lib.c | 35 +++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/libultraship/libultraship/SohImGuiImpl.cpp b/libultraship/libultraship/SohImGuiImpl.cpp index d17d6ccee..c35a99f5b 100644 --- a/libultraship/libultraship/SohImGuiImpl.cpp +++ b/libultraship/libultraship/SohImGuiImpl.cpp @@ -724,8 +724,15 @@ namespace SohImGui { ImGui::Separator(); EnhancementColor3("Kokiri Tunic", "gTunic_Kokiri", kokiri_col); + ImGui::SameLine(); + EnhancementCheckbox("Rainbow##Kokiri", "gTunic_KokiriRainbow"); EnhancementColor3("Goron Tunic", "gTunic_Goron", goron_col); + ImGui::SameLine(); + EnhancementCheckbox("Rainbow##Goron", "gTunic_GoronRainbow"); EnhancementColor3("Zora Tunic", "gTunic_Zora", zora_col); + ImGui::SameLine(); + EnhancementCheckbox("Rainbow##Zora", "gTunic_ZoraRainbow"); + EnhancementSliderInt("Rainbow Speed: %dx", "##RainbowTunicSpeed", "gTunic_RainbowSpeed", 1, 6, ""); ImGui::Text("Navi"); ImGui::Separator(); diff --git a/soh/src/code/z_player_lib.c b/soh/src/code/z_player_lib.c index 4e4e1ff70..816120fee 100644 --- a/soh/src/code/z_player_lib.c +++ b/soh/src/code/z_player_lib.c @@ -746,7 +746,40 @@ void func_8008F470(GlobalContext* globalCtx, void** skeleton, Vec3s* jointTable, #endif Color_RGB8 sTemp; color = &sTemp; - if (tunic == PLAYER_TUNIC_KOKIRI) { + if (tunic == PLAYER_TUNIC_KOKIRI && CVar_GetS32("gTunic_KokiriRainbow", 0) != 0 || + tunic == PLAYER_TUNIC_GORON && CVar_GetS32("gTunic_GoronRainbow", 0) != 0 || + tunic == PLAYER_TUNIC_ZORA && CVar_GetS32("gTunic_ZoraRainbow", 0) != 0) { + u16 hue = CVar_GetS32("gTunic_RainbowHue", 0); + u16 hueDelta = CVar_GetS32("gTunic_RainbowSpeed", 1) * 36.0f / 20.0f; + CVar_SetS32("gTunic_RainbowHue", (hue + hueDelta) % 360); + + if (hue < 60) { + color->r = 255; + color->g = (hue / 60.0f) * 255; + color->b = 0; + } else if (hue < 120) { + color->r = (-hue / 60.0f + 2.0f) * 255; + color->g = 255; + color->b = 0; + } else if (hue < 180) { + color->r = 0; + color->g = 255; + color->b = (hue / 60.0f - 2.0f) * 255; + } else if (hue < 240) { + color->r = 0; + color->g = (-hue / 60.0f + 4.0f) * 255; + color->b = 255; + } else if (hue < 300) { + color->r = (hue / 60.0f - 4.0f) * 255; + color->g = 0; + color->b = 255; + } else { + color->r = 255; + color->g = 0; + color->b = (-hue / 60.0f + 6.0f) * 255; + } + } + else if (tunic == PLAYER_TUNIC_KOKIRI) { color->r = CVar_GetS32("gTunic_Kokiri_Red", sTunicColors[PLAYER_TUNIC_KOKIRI].r); color->g = CVar_GetS32("gTunic_Kokiri_Green", sTunicColors[PLAYER_TUNIC_KOKIRI].g); color->b = CVar_GetS32("gTunic_Kokiri_Blue", sTunicColors[PLAYER_TUNIC_KOKIRI].b);