diff --git a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp index 66a9adae9..95cef14c1 100644 --- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp +++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp @@ -9,6 +9,14 @@ #include "../../UIWidgets.hpp" +extern "C" { +#include +#include "objects/object_link_boy/object_link_boy.h" +#include "objects/object_gi_shield_3/object_gi_shield_3.h" +void ResourceMgr_PatchGfxByName(const char* path, const char* patchName, int index, Gfx instruction); +void ResourceMgr_UnpatchGfxByName(const char* path, const char* patchName); +} + const char* RainbowColorCvarList[] = { //This is the list of possible CVars that has rainbow effect. "gTunic_Kokiri", "gTunic_Goron", "gTunic_Zora", @@ -182,6 +190,40 @@ void LoadRainbowColor(bool& open) { } } +void ApplyOrResetCustomGfxPatches() { + // Mirror Shield + Color_RGB8 mirrorDefaultColor = {MirrorShieldMirror.DefaultColor.w, MirrorShieldMirror.DefaultColor.x, MirrorShieldMirror.DefaultColor.y}; + Color_RGB8 mirror = CVar_GetRGB(MirrorShieldMirror.CvarName.c_str(), mirrorDefaultColor); + Color_RGB8 borderDefaultColor = {MirrorShieldBorder.DefaultColor.w, MirrorShieldBorder.DefaultColor.x, MirrorShieldBorder.DefaultColor.y}; + Color_RGB8 border = CVar_GetRGB(MirrorShieldBorder.CvarName.c_str(), borderDefaultColor); + Color_RGB8 emblemDefaultColor = {MirrorShieldEmblem.DefaultColor.w, MirrorShieldEmblem.DefaultColor.x, MirrorShieldEmblem.DefaultColor.y}; + Color_RGB8 emblem = CVar_GetRGB(MirrorShieldEmblem.CvarName.c_str(), emblemDefaultColor); + PATCH_GFX(gGiMirrorShieldDL, "CosmeticsEditor_Mirror", "gUseMirrorShieldColors", 94, gsDPSetPrimColor(0, 0, mirror.r, mirror.g, mirror.b, 255)); + PATCH_GFX(gGiMirrorShieldDL, "CosmeticsEditor_mirror2", "gUseMirrorShieldColors", 96, gsDPSetEnvColor(mirror.r / 3, mirror.g / 3, mirror.b / 3, 255)); + PATCH_GFX(gGiMirrorShieldDL, "CosmeticsEditor_Border", "gUseMirrorShieldColors", 10, gsDPSetPrimColor(0, 0, border.r, border.g, border.b, 255)); + PATCH_GFX(gGiMirrorShieldDL, "CosmeticsEditor_border2", "gUseMirrorShieldColors", 12, gsDPSetEnvColor(border.r / 3, border.g / 3, border.b / 3, 255)); + PATCH_GFX(gGiMirrorShieldSymbolDL, "CosmeticsEditor_Emblem", "gUseMirrorShieldColors", 10, gsDPSetPrimColor(0, 0, emblem.r, emblem.g, emblem.b, 140)); + PATCH_GFX(gGiMirrorShieldSymbolDL, "CosmeticsEditor_Emblem2", "gUseMirrorShieldColors", 12, gsDPSetEnvColor(emblem.r / 3, emblem.g / 3, emblem.b / 3, 255)); + PATCH_GFX(gLinkAdultMirrorShieldSwordAndSheathNearDL, "CosmeticsEditor_Mirror", "gUseMirrorShieldColors", 34, gsDPSetPrimColor(0, 0, mirror.r, mirror.g, mirror.b, 255)); + PATCH_GFX(gLinkAdultMirrorShieldSwordAndSheathNearDL, "CosmeticsEditor_Border", "gUseMirrorShieldColors", 56, gsDPSetPrimColor(0, 0, border.r, border.g, border.b, 255)); + PATCH_GFX(gLinkAdultMirrorShieldSwordAndSheathNearDL, "CosmeticsEditor_Emblem", "gUseMirrorShieldColors", 330, gsDPSetPrimColor(0, 0, emblem.r, emblem.g, emblem.b, 255)); + PATCH_GFX(gLinkAdultMirrorShieldSwordAndSheathFarDL, "CosmeticsEditor_Mirror", "gUseMirrorShieldColors", 66, gsDPSetPrimColor(0, 0, mirror.r, mirror.g, mirror.b, 255)); + PATCH_GFX(gLinkAdultMirrorShieldSwordAndSheathFarDL, "CosmeticsEditor_Border", "gUseMirrorShieldColors", 34, gsDPSetPrimColor(0, 0, border.r, border.g, border.b, 255)); + PATCH_GFX(gLinkAdultMirrorShieldSwordAndSheathFarDL, "CosmeticsEditor_Emblem", "gUseMirrorShieldColors", 270, gsDPSetPrimColor(0, 0, emblem.r, emblem.g, emblem.b, 255)); + PATCH_GFX(gLinkAdultMirrorShieldAndSheathNearDL, "CosmeticsEditor_Mirror", "gUseMirrorShieldColors", 34, gsDPSetPrimColor(0, 0, mirror.r, mirror.g, mirror.b, 255)); + PATCH_GFX(gLinkAdultMirrorShieldAndSheathNearDL, "CosmeticsEditor_Border", "gUseMirrorShieldColors", 56, gsDPSetPrimColor(0, 0, border.r, border.g, border.b, 255)); + PATCH_GFX(gLinkAdultMirrorShieldAndSheathNearDL, "CosmeticsEditor_Emblem", "gUseMirrorShieldColors", 258, gsDPSetPrimColor(0, 0, emblem.r, emblem.g, emblem.b, 255)); + PATCH_GFX(gLinkAdultMirrorShieldAndSheathFarDL, "CosmeticsEditor_Mirror", "gUseMirrorShieldColors", 66, gsDPSetPrimColor(0, 0, mirror.r, mirror.g, mirror.b, 255)); + PATCH_GFX(gLinkAdultMirrorShieldAndSheathFarDL, "CosmeticsEditor_Border", "gUseMirrorShieldColors", 34, gsDPSetPrimColor(0, 0, border.r, border.g, border.b, 255)); + PATCH_GFX(gLinkAdultMirrorShieldAndSheathFarDL, "CosmeticsEditor_Emblem", "gUseMirrorShieldColors", 206, gsDPSetPrimColor(0, 0, emblem.r, emblem.g, emblem.b, 255)); + PATCH_GFX(gLinkAdultRightHandHoldingMirrorShieldNearDL, "CosmeticsEditor_Mirror", "gUseMirrorShieldColors", 34, gsDPSetPrimColor(0, 0, mirror.r, mirror.g, mirror.b, 255)); + PATCH_GFX(gLinkAdultRightHandHoldingMirrorShieldNearDL, "CosmeticsEditor_Border", "gUseMirrorShieldColors", 56, gsDPSetPrimColor(0, 0, border.r, border.g, border.b, 255)); + PATCH_GFX(gLinkAdultRightHandHoldingMirrorShieldNearDL, "CosmeticsEditor_Emblem", "gUseMirrorShieldColors", 324, gsDPSetPrimColor(0, 0, emblem.r, emblem.g, emblem.b, 255)); + PATCH_GFX(gLinkAdultRightHandHoldingMirrorShieldFarDL, "CosmeticsEditor_Mirror", "gUseMirrorShieldColors", 222, gsDPSetPrimColor(0, 0, mirror.r, mirror.g, mirror.b, 255)); + PATCH_GFX(gLinkAdultRightHandHoldingMirrorShieldFarDL, "CosmeticsEditor_Border", "gUseMirrorShieldColors", 190, gsDPSetPrimColor(0, 0, border.r, border.g, border.b, 255)); + PATCH_GFX(gLinkAdultRightHandHoldingMirrorShieldFarDL, "CosmeticsEditor_Emblem", "gUseMirrorShieldColors", 266, gsDPSetPrimColor(0, 0, emblem.r, emblem.g, emblem.b, 255)); +} + void Table_InitHeader(bool has_header = true) { if (has_header) { ImGui::TableHeadersRow(); @@ -310,7 +352,8 @@ void DrawScaleSlider(const std::string CvarName,float DefaultValue){ //Disabled for now. feature not done and several fixes needed to be merged. //UIWidgets::EnhancementSliderFloat("Scale : %dx", InvisibleLabel.c_str(), CvarLabel.c_str(), 0.1f, 3.0f,"",DefaultValue,true,true); } -void DrawColorSection(CosmeticsColorSection* ColorSection, int SectionSize) { +bool DrawColorSection(CosmeticsColorSection* ColorSection, int SectionSize) { + bool changed = false; for (s16 i = 0; i < SectionSize; i++) { CosmeticsColorIndividual* ThisElement = ColorSection[i].Element; const std::string Tooltip = ThisElement->ToolTip; @@ -330,10 +373,14 @@ void DrawColorSection(CosmeticsColorSection* ColorSection, int SectionSize) { Table_NextLine(); } Draw_HelpIcon(Tooltip.c_str()); - UIWidgets::EnhancementColor(Name.c_str(), Cvar.c_str(), ModifiedColor, DefaultColor, canRainbow, hasAlpha, sameLine); + if (UIWidgets::EnhancementColor(Name.c_str(), Cvar.c_str(), ModifiedColor, DefaultColor, canRainbow, hasAlpha, sameLine)) { + changed = true; + } } + return changed; } -void DrawRandomizeResetButton(const std::string Identifier, CosmeticsColorSection* ColorSection, int SectionSize, bool isAllCosmetics = false){ +bool DrawRandomizeResetButton(const std::string Identifier, CosmeticsColorSection* ColorSection, int SectionSize, bool isAllCosmetics = false){ + bool changed = false; std::string TableName = Identifier+"_Table"; std::string Col1Name = Identifier+"_Col1"; std::string Col2Name = Identifier+"_Col2"; @@ -354,6 +401,7 @@ void DrawRandomizeResetButton(const std::string Identifier, CosmeticsColorSectio CVar_SetS32("gUseKeeseCol", 1); CVar_SetS32("gUseDogsCol", 1); CVar_SetS32("gUseTunicsCol", 1); + CVar_SetS32("gUseMirrorShieldColors", 1); CVar_SetS32("gUseGauntletsCol", 1); CVar_SetS32("gUseArrowsCol", 1); CVar_SetS32("gUseSpellsCol", 1); @@ -361,6 +409,7 @@ void DrawRandomizeResetButton(const std::string Identifier, CosmeticsColorSectio CVar_SetS32("gUseTrailsCol", 1); CVar_SetS32("gCCparated", 1); GetRandomColorRGB(ColorSection, SectionSize); + changed = true; } UIWidgets::Tooltip(Tooltip_RNG.c_str()); Table_NextCol(); @@ -370,10 +419,12 @@ void DrawRandomizeResetButton(const std::string Identifier, CosmeticsColorSectio if(ImGui::Button(Reset_BtnText.c_str(), ImVec2( ImGui::GetContentRegionAvail().x, 20.0f))){ #endif GetDefaultColorRGB(ColorSection, SectionSize); + changed = true; } UIWidgets::Tooltip("Enable/Disable custom Link's tunics colors\nIf disabled you will have original colors for Link's tunics."); UIWidgets::Tooltip(Tooltip_RNG.c_str()); ImGui::EndTable(); + return changed; } } @@ -411,7 +462,9 @@ void Draw_Npcs(){ } } void Draw_ItemsSkills(){ - DrawRandomizeResetButton("all skills and items", AllItemsSkills_section, SECTION_SIZE(AllItemsSkills_section)); + if (DrawRandomizeResetButton("all skills and items", AllItemsSkills_section, SECTION_SIZE(AllItemsSkills_section))) { + ApplyOrResetCustomGfxPatches(); + }; UIWidgets::EnhancementCheckbox("Custom tunics color", "gUseTunicsCol"); UIWidgets::Tooltip("Enable/Disable custom Link's tunics colors\nIf disabled you will have original colors for Link's tunics."); if (CVar_GetS32("gUseTunicsCol",0)) { @@ -440,6 +493,27 @@ void Draw_ItemsSkills(){ ImGui::EndTable(); } + if (UIWidgets::EnhancementCheckbox("Custom mirror shield colors", "gUseMirrorShieldColors")) { + ApplyOrResetCustomGfxPatches(); + } + UIWidgets::Tooltip( + "Enable/Disable custom Mirror shield colors\nIf disabled you will have original colors for the Mirror shield."); + if (CVar_GetS32("gUseMirrorShieldColors", 0)) { + if (DrawRandomizeResetButton("Mirror Shield", MirrorShield_Section, SECTION_SIZE(MirrorShield_Section))) { + ApplyOrResetCustomGfxPatches(); + } + }; + if (CVar_GetS32("gUseMirrorShieldColors", 0) && ImGui::BeginTable("tableMirrorShield", 3, FlagsTable)) { + ImGui::TableSetupColumn("Border/Back", FlagsCell, TablesCellsWidth / 3); + ImGui::TableSetupColumn("Mirror", FlagsCell, TablesCellsWidth / 3); + ImGui::TableSetupColumn("Emblem", FlagsCell, TablesCellsWidth / 3); + Table_InitHeader(); + if (DrawColorSection(MirrorShield_Section, SECTION_SIZE(MirrorShield_Section))) { + ApplyOrResetCustomGfxPatches(); + } + ImGui::EndTable(); + } + UIWidgets::EnhancementCheckbox("Custom arrows colors", "gUseArrowsCol"); if (CVar_GetS32("gUseArrowsCol",0)) { DrawRandomizeResetButton("elemental arrows", Arrows_section, SECTION_SIZE(Arrows_section)); @@ -875,7 +949,9 @@ void Draw_HUDButtons(){ } } void Draw_General(){ - DrawRandomizeResetButton("all cosmetics", Everything_Section, SECTION_SIZE(Everything_Section), true); + if (DrawRandomizeResetButton("all cosmetics", Everything_Section, SECTION_SIZE(Everything_Section), true)) { + ApplyOrResetCustomGfxPatches(); + } if (ImGui::BeginTable("tableScheme", 3, FlagsTable | ImGuiTableFlags_Hideable)) { ImGui::TableSetupColumn("N64 Scheme", FlagsCell, TablesCellsWidth); ImGui::TableSetupColumn("GameCube Scheme", FlagsCell, TablesCellsWidth); @@ -1025,4 +1101,5 @@ void InitCosmeticsEditor() { SohImGui::AddWindow("Enhancements", "Rainbowfunction", LoadRainbowColor, true, true); //Draw the bar in the menu. SohImGui::AddWindow("Enhancements", "Cosmetics Editor", DrawCosmeticsEditor); + ApplyOrResetCustomGfxPatches(); } diff --git a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.h b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.h index fc7e4c8f6..4bdcf4f7c 100644 --- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.h +++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.h @@ -8,6 +8,13 @@ #define CATEGORY_HUD 3 #define CATEGORY_MISC 4 +#define PATCH_GFX(path, name, cvar, index, instruction) \ + if (CVar_GetS32(cvar, 0)) { \ + ResourceMgr_PatchGfxByName(path, name, index, instruction); \ + } else { \ + ResourceMgr_UnpatchGfxByName(path, name); \ + } + typedef struct { const std::string Name; const std::string ToolTip; @@ -28,38 +35,39 @@ typedef struct { static float TablesCellsWidth = 300.0f; static ImGuiTableColumnFlags FlagsTable = ImGuiTableFlags_BordersH | ImGuiTableFlags_BordersV; static ImGuiTableColumnFlags FlagsCell = ImGuiTableColumnFlags_WidthStretch | ImGuiTableColumnFlags_IndentEnable | ImGuiTableColumnFlags_NoSort; -static ImVec4 hearts_colors; static ImVec4 hearts_dd_colors; static ImVec4 hearts_ddi_colors; -static ImVec4 a_btn_colors; static ImVec4 b_btn_colors; static ImVec4 c_btn_colors; static ImVec4 start_btn_colors; -static ImVec4 c_btn_u_colors; static ImVec4 c_btn_l_colors; static ImVec4 c_btn_d_colors; static ImVec4 c_btn_r_colors; -static ImVec4 magic_border_colors; static ImVec4 magic_remaining_colors; static ImVec4 magic_use_colors; -static ImVec4 minimap_colors; static ImVec4 dgn_minimap_colors; -static ImVec4 cp_minimap_colors; static ImVec4 le_minimap_colors; -static ImVec4 rupee_colors; static ImVec4 smolekey_colors; static ImVec4 magic_bordern_colors; -static ImVec4 fileselect_colors; static ImVec4 fileselect_text_colors; -static ImVec4 kokiri_col; static ImVec4 goron_col; static ImVec4 zora_col; -static ImVec4 silvergaunts_col; static ImVec4 goldengaunts_col; -static ImVec4 navi_idle_i_col; static ImVec4 navi_idle_o_col; -static ImVec4 navi_npc_i_col; static ImVec4 navi_npc_o_col; -static ImVec4 navi_enemy_i_col; static ImVec4 navi_enemy_o_col; -static ImVec4 navi_prop_i_col; static ImVec4 navi_prop_o_col; -static ImVec4 swordtrailtop_col; static ImVec4 swordtrailbottom_col; -static ImVec4 boomtrailstart_col; static ImVec4 boomtrailend_col; +static ImVec4 hearts_colors; static ImVec4 hearts_dd_colors; static ImVec4 hearts_ddi_colors; +static ImVec4 a_btn_colors; static ImVec4 b_btn_colors; static ImVec4 c_btn_colors; static ImVec4 start_btn_colors; +static ImVec4 c_btn_u_colors; static ImVec4 c_btn_l_colors; static ImVec4 c_btn_d_colors; static ImVec4 c_btn_r_colors; +static ImVec4 magic_border_colors; static ImVec4 magic_remaining_colors; static ImVec4 magic_use_colors; +static ImVec4 minimap_colors; static ImVec4 dgn_minimap_colors; +static ImVec4 cp_minimap_colors; static ImVec4 le_minimap_colors; +static ImVec4 rupee_colors; static ImVec4 smolekey_colors; static ImVec4 magic_bordern_colors; +static ImVec4 fileselect_colors; static ImVec4 fileselect_text_colors; +static ImVec4 kokiri_col; static ImVec4 goron_col; static ImVec4 zora_col; +static ImVec4 silvergaunts_col; static ImVec4 goldengaunts_col; +static ImVec4 mirrorshield_border_col;static ImVec4 mirrorshield_mirror_col; static ImVec4 mirrorshield_emblem_col; +static ImVec4 navi_idle_i_col; static ImVec4 navi_idle_o_col; +static ImVec4 navi_npc_i_col; static ImVec4 navi_npc_o_col; +static ImVec4 navi_enemy_i_col; static ImVec4 navi_enemy_o_col; +static ImVec4 navi_prop_i_col; static ImVec4 navi_prop_o_col; +static ImVec4 swordtrailtop_col; static ImVec4 swordtrailbottom_col; +static ImVec4 boomtrailstart_col; static ImVec4 boomtrailend_col; static ImVec4 bombtrail_col; static ImVec4 crtfilter; -static ImVec4 normalarrow_col; static ImVec4 firearrow_col; static ImVec4 icearrow_col; static ImVec4 lightarrow_col; -static ImVec4 normalarrow_colenv; static ImVec4 firearrow_colenv; static ImVec4 icearrow_colenv; static ImVec4 lightarrow_colenv; -static ImVec4 charged1_col; static ImVec4 charged2_col; -static ImVec4 charged1_colenv; static ImVec4 charged2_colenv; -static ImVec4 Keese1_primcol; static ImVec4 Keese2_primcol; -static ImVec4 Keese1_envcol; static ImVec4 Keese2_envcol; -static ImVec4 doggo1col; static ImVec4 doggo2col; -static ImVec4 df_col; static ImVec4 df_colenv; -static ImVec4 nl_diam_col; static ImVec4 nl_diam_colenv; -static ImVec4 nl_orb_col; static ImVec4 nl_orb_colenv; -static ImVec4 tc_ou_colors; static ImVec4 tc_bu_colors; +static ImVec4 normalarrow_col; static ImVec4 firearrow_col; static ImVec4 icearrow_col; static ImVec4 lightarrow_col; +static ImVec4 normalarrow_colenv; static ImVec4 firearrow_colenv; static ImVec4 icearrow_colenv; static ImVec4 lightarrow_colenv; +static ImVec4 charged1_col; static ImVec4 charged2_col; +static ImVec4 charged1_colenv; static ImVec4 charged2_colenv; +static ImVec4 Keese1_primcol; static ImVec4 Keese2_primcol; +static ImVec4 Keese1_envcol; static ImVec4 Keese2_envcol; +static ImVec4 doggo1col; static ImVec4 doggo2col; +static ImVec4 df_col; static ImVec4 df_colenv; +static ImVec4 nl_diam_col; static ImVec4 nl_diam_colenv; +static ImVec4 nl_orb_col; static ImVec4 nl_orb_colenv; +static ImVec4 tc_ou_colors; static ImVec4 tc_bu_colors; static ImVec4 dpad_colors; static ImVec4 visualagony_colors; -static ImVec4 tc_fire_colors; static ImVec4 tc_fire_colors_env; +static ImVec4 tc_fire_colors; static ImVec4 tc_fire_colors_env; /*ImVec4 menu_equips_colors; ImVec4 menu_items_colors; ImVec4 menu_map_colors; @@ -96,6 +104,11 @@ static CosmeticsColorIndividual ZoraTunic = { "Zora Tunic", "Affects Zora Tunic static CosmeticsColorIndividual SilverGauntlets = { "Silver Gauntlets", "Affects Silver Gauntlets color", "gGauntlets_Silver", silvergaunts_col, ImVec4(255, 255, 255, 255), true, false, true }; static CosmeticsColorIndividual GoldenGauntlets = { "Golden Gauntlets", "Affects Golden Gauntlets color", "gGauntlets_Golden", goldengaunts_col, ImVec4(254, 207, 15, 255), true, false, true }; +//Mirror Shield colors +static CosmeticsColorIndividual MirrorShieldBorder = { "Mirror Shield Border", "Affects Mirror Shield Border color", "gMirrorShield_Border", mirrorshield_border_col, ImVec4(215, 0, 0, 255), false, false, true }; +static CosmeticsColorIndividual MirrorShieldMirror = { "Mirror Shield Mirror", "Affects Mirror Shield Mirror color", "gMirrorShield_Mirror", mirrorshield_mirror_col, ImVec4(255, 255, 255, 255), false, false, true }; +static CosmeticsColorIndividual MirrorShieldEmblem = { "Mirror Shield Emblem", "Affects Mirror Shield Emblem color", "gMirrorShield_Emblem", mirrorshield_emblem_col, ImVec4(205, 225, 255, 255), false, false, true }; + //Arrows (Fire -> Ice -> Light) static CosmeticsColorIndividual Normal_Arrow_Prim = { "Normal Arrows (primary)", "Affects Primary color", "gNormalArrowCol", normalarrow_col, ImVec4(255, 255, 170, 255), true, false, false }; static CosmeticsColorIndividual Normal_Arrow_Env = { "Normal Arrows (Secondary)", "Affects Secondary color", "gNormalArrowColEnv", normalarrow_colenv, ImVec4(0, 150, 0, 0), true, false, false }; @@ -217,6 +230,11 @@ static CosmeticsColorSection Gauntlets_Section[] = { { &SilverGauntlets, false, false }, { &GoldenGauntlets, true, false }, }; +static CosmeticsColorSection MirrorShield_Section[] = { + { &MirrorShieldBorder, false, false }, + { &MirrorShieldMirror, true, false }, + { &MirrorShieldEmblem, true, false }, +}; static CosmeticsColorSection Arrows_section[] = { { &Normal_Arrow_Prim, false, false }, { &Normal_Arrow_Env, true, false }, @@ -354,6 +372,9 @@ static CosmeticsColorSection Everything_Section[] = { { &ZoraTunic, true, false }, { &SilverGauntlets, true, false }, { &GoldenGauntlets, true, false }, + { &MirrorShieldBorder, false, false }, + { &MirrorShieldMirror, true, false }, + { &MirrorShieldEmblem, true, false }, { &Normal_Arrow_Prim, false, false }, { &Normal_Arrow_Env, true, false }, { &Fire_Arrow_Prim, false, true }, @@ -466,6 +487,11 @@ static CosmeticsColorSection AllItemsSkills_section[]{ { &KokiriTunic, false, false }, { &GoronTunic, true, false }, { &ZoraTunic, true, false }, + { &SilverGauntlets, true, false }, + { &GoldenGauntlets, true, false }, + { &MirrorShieldBorder, false, false }, + { &MirrorShieldMirror, true, false }, + { &MirrorShieldEmblem, true, false }, { &Normal_Arrow_Prim, false, false }, { &Normal_Arrow_Env, true, false }, { &Fire_Arrow_Prim, false, true }, diff --git a/soh/soh/UIWidgets.cpp b/soh/soh/UIWidgets.cpp index 9592a3cac..de1bc175e 100644 --- a/soh/soh/UIWidgets.cpp +++ b/soh/soh/UIWidgets.cpp @@ -178,7 +178,8 @@ namespace UIWidgets { return pressed; } - void EnhancementCheckbox(const char* text, const char* cvarName, bool disabled, const char* disabledTooltipText, CheckboxGraphics disabledGraphic) { + bool EnhancementCheckbox(const char* text, const char* cvarName, bool disabled, const char* disabledTooltipText, CheckboxGraphics disabledGraphic) { + bool changed = false; if (disabled) { ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f); @@ -187,6 +188,7 @@ namespace UIWidgets { if (CustomCheckbox(text, &val, disabled, disabledGraphic)) { CVar_SetS32(cvarName, val); SohImGui::RequestCvarSaveOnNextTick(); + changed = true; } if (disabled) { @@ -196,14 +198,20 @@ namespace UIWidgets { } ImGui::PopItemFlag(); } + return changed; } - void PaddedEnhancementCheckbox(const char* text, const char* cvarName, bool padTop, bool padBottom, bool disabled, const char* disabledTooltipText, CheckboxGraphics disabledGraphic) { + bool PaddedEnhancementCheckbox(const char* text, const char* cvarName, bool padTop, bool padBottom, bool disabled, const char* disabledTooltipText, CheckboxGraphics disabledGraphic) { + bool changed = false; if (padTop) Spacer(0); - EnhancementCheckbox(text, cvarName, disabled, disabledTooltipText, disabledGraphic); + if (EnhancementCheckbox(text, cvarName, disabled, disabledTooltipText, disabledGraphic)) { + changed = true; + } if (padBottom) Spacer(0); + + return changed; } void EnhancementCombo(const std::string& name, const char* cvarName, const std::vector& items, int defaultValue) { @@ -407,7 +415,8 @@ namespace UIWidgets { ImGui::Text("%s", text); } - void ResetColor(const char* cvarName, ImVec4* colors, ImVec4 defaultcolors, bool has_alpha) { + bool DrawResetColorButton(const char* cvarName, ImVec4* colors, ImVec4 defaultcolors, bool has_alpha) { + bool changed = false; std::string Cvar_RBM = cvarName; Cvar_RBM += "RBM"; std::string MakeInvisible = "Reset"; @@ -429,11 +438,14 @@ namespace UIWidgets { CVar_SetRGBA(cvarName, colorsRGBA); CVar_SetS32(Cvar_RBM.c_str(), 0); //On click disable rainbow mode. SohImGui::RequestCvarSaveOnNextTick(); + changed = true; } Tooltip("Revert colors to the game's original colors (GameCube version)\nOverwrites previously chosen color"); + return changed; } - void RandomizeColor(const char* cvarName, ImVec4* colors) { + bool DrawRandomizeColorButton(const char* cvarName, ImVec4* colors) { + bool changed = false; Color_RGBA8 NewColors = {0,0,0,255}; std::string Cvar_RBM = cvarName; Cvar_RBM += "RBM"; @@ -456,8 +468,10 @@ namespace UIWidgets { CVar_SetRGBA(cvarName, NewColors); CVar_SetS32(Cvar_RBM.c_str(), 0); // On click disable rainbow mode. SohImGui::RequestCvarSaveOnNextTick(); + changed = true; } Tooltip("Chooses a random color\nOverwrites previously chosen color"); + return changed; } void RainbowColor(const char* cvarName, ImVec4* colors) { @@ -472,7 +486,8 @@ namespace UIWidgets { Tooltip("Cycles through colors on a timer\nOverwrites previously chosen color"); } - void EnhancementColor(const char* text, const char* cvarName, ImVec4 ColorRGBA, ImVec4 default_colors, bool allow_rainbow, bool has_alpha, bool TitleSameLine) { + bool EnhancementColor(const char* text, const char* cvarName, ImVec4 ColorRGBA, ImVec4 default_colors, bool allow_rainbow, bool has_alpha, bool TitleSameLine) { + bool changed = false; LoadPickersColors(ColorRGBA, cvarName, default_colors, has_alpha); ImGuiColorEditFlags flags = ImGuiColorEditFlags_None; @@ -495,6 +510,7 @@ namespace UIWidgets { CVar_SetRGBA(cvarName, colors); SohImGui::RequestCvarSaveOnNextTick(); + changed = true; } } else @@ -509,6 +525,7 @@ namespace UIWidgets { CVar_SetRGBA(cvarName, colors); SohImGui::RequestCvarSaveOnNextTick(); + changed = true; } } @@ -516,9 +533,13 @@ namespace UIWidgets { //ImGui::SameLine(); // Removing that one to gain some width spacing on the HUD editor ImGui::PushItemWidth(-FLT_MIN); - ResetColor(cvarName, &ColorRGBA, default_colors, has_alpha); + if (DrawResetColorButton(cvarName, &ColorRGBA, default_colors, has_alpha)) { + changed = true; + } ImGui::SameLine(); - RandomizeColor(cvarName, &ColorRGBA); + if (DrawRandomizeColorButton(cvarName, &ColorRGBA)) { + changed = true; + } if (allow_rainbow) { if (ImGui::GetContentRegionAvail().x > 185) { ImGui::SameLine(); @@ -527,5 +548,7 @@ namespace UIWidgets { } ImGui::NewLine(); ImGui::PopItemWidth(); + + return changed; } } diff --git a/soh/soh/UIWidgets.hpp b/soh/soh/UIWidgets.hpp index 6ea62a9fa..fa25c727e 100644 --- a/soh/soh/UIWidgets.hpp +++ b/soh/soh/UIWidgets.hpp @@ -33,8 +33,8 @@ namespace UIWidgets { void Spacer(float height); void PaddedSeparator(bool padTop = true, bool padBottom = true, float extraVerticalTopPadding = 0.0f, float extraVerticalBottomPadding = 0.0f); - void EnhancementCheckbox(const char* text, const char* cvarName, bool disabled = false, const char* disabledTooltipText = "", CheckboxGraphics disabledGraphic = CheckboxGraphics::Cross); - void PaddedEnhancementCheckbox(const char* text, const char* cvarName, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = "", CheckboxGraphics disabledGraphic = CheckboxGraphics::Cross); + bool EnhancementCheckbox(const char* text, const char* cvarName, bool disabled = false, const char* disabledTooltipText = "", CheckboxGraphics disabledGraphic = CheckboxGraphics::Cross); + bool PaddedEnhancementCheckbox(const char* text, const char* cvarName, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = "", CheckboxGraphics disabledGraphic = CheckboxGraphics::Cross); void EnhancementCombo(const std::string& name, const char* cvarName, const std::vector& items, int defaultValue = 0); void EnhancementCombobox(const char* name, const char* ComboArray[], size_t arraySize, uint8_t FirstTimeValue); void PaddedText(const char* text, bool padTop = true, bool padBottom = true); @@ -43,7 +43,7 @@ namespace UIWidgets { void EnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton = false); void EnhancementRadioButton(const char* text, const char* cvarName, int id); - void EnhancementColor(const char* text, const char* cvarName, ImVec4 ColorRGBA, ImVec4 default_colors, bool allow_rainbow = true, bool has_alpha=false, bool TitleSameLine=false); + bool EnhancementColor(const char* text, const char* cvarName, ImVec4 ColorRGBA, ImVec4 default_colors, bool allow_rainbow = true, bool has_alpha=false, bool TitleSameLine=false); } #endif /* UIWidgets_hpp */