mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-29 12:52:18 -05:00
Cosmetics hotfixes (#640)
* Initial branch creation * Revert Main Game so it do not conflict later * should fix window build, made namespace for Cosmetics * forgot to edit one title * Ability to add hidden window (usefull for Rainbow) Fix building issues * Line break, unused bool remove
This commit is contained in:
parent
c25089b98f
commit
37bf9b36ad
@ -66,31 +66,13 @@ namespace SohImGui {
|
|||||||
bool p_open = false;
|
bool p_open = false;
|
||||||
bool needs_save = false;
|
bool needs_save = false;
|
||||||
|
|
||||||
const char* RainbowColorCvarList[] = {
|
|
||||||
//This is the list of possible CVars that has rainbow effect.
|
|
||||||
"gTunic_Kokiri_", "gTunic_Goron_", "gTunic_Zora_",
|
|
||||||
"gFireArrowCol", "gIceArrowCol", "gTunic_Zora_",
|
|
||||||
"gFireArrowColEnv", "gIceArrowColEnv", "gLightArrowColEnv",
|
|
||||||
"gCCHeartsPrim", "gDDCCHeartsPrim", "gLightArrowCol",
|
|
||||||
"gCCABtnPrim", "gCCBBtnPrim", "gCCCBtnPrim", "gCCStartBtnPrim",
|
|
||||||
"gCCCUBtnPrim", "gCCCLBtnPrim", "gCCCRBtnPrim", "gCCCDBtnPrim", "gCCDpadPrim",
|
|
||||||
"gCCMagicBorderNormPrim", "gCCMagicBorderPrim", "gCCMagicPrim", "gCCMagicUsePrim",
|
|
||||||
"gCCMinimapPrim", "gCCMinimapDGNPrim", "gCCMinimapCPPrim", "gCCMinimapLEPrim",
|
|
||||||
"gCCRupeePrim", "gCCKeysPrim", "gDog1Col", "gDog2Col", "gCCVSOAPrim",
|
|
||||||
"gKeese1_Ef_Prim","gKeese2_Ef_Prim","gKeese1_Ef_Env","gKeese2_Ef_Env",
|
|
||||||
"gDF_Col", "gDF_Env",
|
|
||||||
"gNL_Diamond_Col", "gNL_Diamond_Env", "gNL_Orb_Col", "gNL_Orb_Env",
|
|
||||||
"gTrailCol", "gCharged1Col", "gCharged1ColEnv", "gCharged2Col", "gCharged2ColEnv",
|
|
||||||
"gCCFileChoosePrim", "gCCFileChooseTextPrim", "gCCEquipmentsPrim", "gCCItemsPrim",
|
|
||||||
"gCCMapsPrim", "gCCQuestsPrim", "gCCSavePrim", "gCCGameoverPrim",
|
|
||||||
};
|
|
||||||
|
|
||||||
const char* filters[3] = {
|
const char* filters[3] = {
|
||||||
"Three-Point",
|
"Three-Point",
|
||||||
"Linear",
|
"Linear",
|
||||||
"None"
|
"None"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
std::map<std::string, std::vector<std::string>> hiddenwindowCategories;
|
||||||
std::map<std::string, std::vector<std::string>> windowCategories;
|
std::map<std::string, std::vector<std::string>> windowCategories;
|
||||||
std::map<std::string, CustomWindow> customWindows;
|
std::map<std::string, CustomWindow> customWindows;
|
||||||
|
|
||||||
@ -248,50 +230,6 @@ namespace SohImGui {
|
|||||||
stbi_image_free(img_data);
|
stbi_image_free(img_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadRainbowColor() {
|
|
||||||
u8 arrayLength = sizeof(RainbowColorCvarList) / sizeof(*RainbowColorCvarList);
|
|
||||||
for (u8 s = 0; s < arrayLength; s++) {
|
|
||||||
std::string cvarName = RainbowColorCvarList[s];
|
|
||||||
std::string Cvar_Red = cvarName;
|
|
||||||
Cvar_Red += "R";
|
|
||||||
std::string Cvar_Green = cvarName;
|
|
||||||
Cvar_Green += "G";
|
|
||||||
std::string Cvar_Blue = cvarName;
|
|
||||||
Cvar_Blue += "B";
|
|
||||||
std::string Cvar_RBM = cvarName;
|
|
||||||
Cvar_RBM += "RBM";
|
|
||||||
std::string RBM_HUE = cvarName;
|
|
||||||
RBM_HUE += "Hue";
|
|
||||||
f32 Canon = 10.f * s;
|
|
||||||
ImVec4 NewColor;
|
|
||||||
const f32 deltaTime = 1.0f / ImGui::GetIO().Framerate;
|
|
||||||
f32 hue = CVar_GetFloat(RBM_HUE.c_str(), 0.0f);
|
|
||||||
f32 newHue = hue + CVar_GetS32("gColorRainbowSpeed", 1) * 36.0f * deltaTime;
|
|
||||||
if (newHue >= 360)
|
|
||||||
newHue = 0;
|
|
||||||
CVar_SetFloat(RBM_HUE.c_str(), newHue);
|
|
||||||
f32 current_hue = CVar_GetFloat(RBM_HUE.c_str(), 0);
|
|
||||||
u8 i = current_hue / 60 + 1;
|
|
||||||
u8 a = (-current_hue / 60.0f + i) * 255;
|
|
||||||
u8 b = (current_hue / 60.0f + (1 - i)) * 255;
|
|
||||||
|
|
||||||
switch (i) {
|
|
||||||
case 1: NewColor.x = 255; NewColor.y = b; NewColor.z = 0; break;
|
|
||||||
case 2: NewColor.x = a; NewColor.y = 255; NewColor.z = 0; break;
|
|
||||||
case 3: NewColor.x = 0; NewColor.y = 255; NewColor.z = b; break;
|
|
||||||
case 4: NewColor.x = 0; NewColor.y = a; NewColor.z = 255; break;
|
|
||||||
case 5: NewColor.x = b; NewColor.y = 0; NewColor.z = 255; break;
|
|
||||||
case 6: NewColor.x = 255; NewColor.y = 0; NewColor.z = a; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CVar_GetS32(Cvar_RBM.c_str(), 0) != 0) {
|
|
||||||
CVar_SetS32(Cvar_Red.c_str(), ClampFloatToInt(NewColor.x, 0, 255));
|
|
||||||
CVar_SetS32(Cvar_Green.c_str(), ClampFloatToInt(NewColor.y, 0, 255));
|
|
||||||
CVar_SetS32(Cvar_Blue.c_str(), ClampFloatToInt(NewColor.z, 0, 255));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoadPickersColors(ImVec4& ColorArray, const char* cvarname, const ImVec4& default_colors, bool has_alpha) {
|
void LoadPickersColors(ImVec4& ColorArray, const char* cvarname, const ImVec4& default_colors, bool has_alpha) {
|
||||||
std::string Cvar_Red = cvarname;
|
std::string Cvar_Red = cvarname;
|
||||||
Cvar_Red += "R";
|
Cvar_Red += "R";
|
||||||
@ -1276,7 +1214,6 @@ namespace SohImGui {
|
|||||||
}
|
}
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndMenuBar();
|
ImGui::EndMenuBar();
|
||||||
@ -1284,6 +1221,15 @@ namespace SohImGui {
|
|||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
|
||||||
|
for (const auto& category : hiddenwindowCategories) {
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, 0));
|
||||||
|
ImGui::SetNextWindowSize(ImVec2 (0,0));
|
||||||
|
ImGui::SetNextWindowPos(ImVec2 (-100,-100));
|
||||||
|
ImGui::Begin(category.first.c_str(), nullptr, ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoNavFocus);
|
||||||
|
ImGui::End();
|
||||||
|
ImGui::PopStyleColor();
|
||||||
|
}
|
||||||
|
|
||||||
if (CVar_GetS32("gStatsEnabled", 0)) {
|
if (CVar_GetS32("gStatsEnabled", 0)) {
|
||||||
const float framerate = ImGui::GetIO().Framerate;
|
const float framerate = ImGui::GetIO().Framerate;
|
||||||
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, 0));
|
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, 0));
|
||||||
@ -1422,8 +1368,6 @@ namespace SohImGui {
|
|||||||
ImGui::UpdatePlatformWindows();
|
ImGui::UpdatePlatformWindows();
|
||||||
ImGui::RenderPlatformWindowsDefault();
|
ImGui::RenderPlatformWindowsDefault();
|
||||||
}
|
}
|
||||||
//Placed here so it does the rainbow effects even if menu is not on.
|
|
||||||
LoadRainbowColor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CancelFrame() {
|
void CancelFrame() {
|
||||||
@ -1437,18 +1381,22 @@ namespace SohImGui {
|
|||||||
console->Commands[cmd] = std::move(entry);
|
console->Commands[cmd] = std::move(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddWindow(const std::string& category, const std::string& name, WindowDrawFunc drawFunc) {
|
void AddWindow(const std::string& category, const std::string& name, WindowDrawFunc drawFunc, bool isEnabled, bool isHidden) {
|
||||||
if (customWindows.contains(name)) {
|
if (customWindows.contains(name)) {
|
||||||
SPDLOG_ERROR("SohImGui::AddWindow: Attempting to add duplicate window name %s", name.c_str());
|
SPDLOG_ERROR("SohImGui::AddWindow: Attempting to add duplicate window name %s", name.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
customWindows[name] = {
|
customWindows[name] = {
|
||||||
.enabled = false,
|
.enabled = isEnabled,
|
||||||
.drawFunc = drawFunc
|
.drawFunc = drawFunc
|
||||||
};
|
};
|
||||||
|
|
||||||
windowCategories[category].emplace_back(name);
|
if (isHidden) {
|
||||||
|
hiddenwindowCategories[category].emplace_back(name);
|
||||||
|
} else {
|
||||||
|
windowCategories[category].emplace_back(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImTextureID GetTextureByName(const std::string& name) {
|
ImTextureID GetTextureByName(const std::string& name) {
|
||||||
|
@ -81,9 +81,10 @@ namespace SohImGui {
|
|||||||
void CancelFrame(void);
|
void CancelFrame(void);
|
||||||
void ShowCursor(bool hide, Dialogues w);
|
void ShowCursor(bool hide, Dialogues w);
|
||||||
void BindCmd(const std::string& cmd, CommandEntry entry);
|
void BindCmd(const std::string& cmd, CommandEntry entry);
|
||||||
void AddWindow(const std::string& category, const std::string& name, WindowDrawFunc drawFunc);
|
void AddWindow(const std::string& category, const std::string& name, WindowDrawFunc drawFunc, bool isEnabled=false, bool isHidden=false);
|
||||||
void LoadResource(const std::string& name, const std::string& path, const ImVec4& tint = ImVec4(1, 1, 1, 1));
|
void LoadResource(const std::string& name, const std::string& path, const ImVec4& tint = ImVec4(1, 1, 1, 1));
|
||||||
void LoadPickersColors(ImVec4& ColorArray, const char* cvarname, const ImVec4& default_colors, bool has_alpha=false);
|
void LoadPickersColors(ImVec4& ColorArray, const char* cvarname, const ImVec4& default_colors, bool has_alpha=false);
|
||||||
|
int ClampFloatToInt(float value, int min, int max);
|
||||||
void RandomizeColor(const char* cvarName, ImVec4* colors);
|
void RandomizeColor(const char* cvarName, ImVec4* colors);
|
||||||
void RainbowColor(const char* cvarName, ImVec4* colors);
|
void RainbowColor(const char* cvarName, ImVec4* colors);
|
||||||
void ResetColor(const char* cvarName, ImVec4* colors, ImVec4 defaultcolors, bool has_alpha);
|
void ResetColor(const char* cvarName, ImVec4* colors, ImVec4 defaultcolors, bool has_alpha);
|
||||||
|
@ -79,6 +79,67 @@ ImVec4 menu_map_colors;
|
|||||||
ImVec4 menu_quest_colors;
|
ImVec4 menu_quest_colors;
|
||||||
ImVec4 menu_save_colors;
|
ImVec4 menu_save_colors;
|
||||||
ImVec4 menu_gameover_colors;*/
|
ImVec4 menu_gameover_colors;*/
|
||||||
|
const char* RainbowColorCvarList[] = {
|
||||||
|
//This is the list of possible CVars that has rainbow effect.
|
||||||
|
"gTunic_Kokiri_", "gTunic_Goron_", "gTunic_Zora_",
|
||||||
|
"gFireArrowCol", "gIceArrowCol", "gTunic_Zora_",
|
||||||
|
"gFireArrowColEnv", "gIceArrowColEnv", "gLightArrowColEnv",
|
||||||
|
"gCCHeartsPrim", "gDDCCHeartsPrim", "gLightArrowCol", "gCCDDHeartsPrim",
|
||||||
|
"gCCABtnPrim", "gCCBBtnPrim", "gCCCBtnPrim", "gCCStartBtnPrim",
|
||||||
|
"gCCCUBtnPrim", "gCCCLBtnPrim", "gCCCRBtnPrim", "gCCCDBtnPrim", "gCCDpadPrim",
|
||||||
|
"gCCMagicBorderNormPrim", "gCCMagicBorderPrim", "gCCMagicPrim", "gCCMagicUsePrim",
|
||||||
|
"gCCMinimapPrim", "gCCMinimapDGNPrim", "gCCMinimapCPPrim", "gCCMinimapLEPrim",
|
||||||
|
"gCCRupeePrim", "gCCKeysPrim", "gDog1Col", "gDog2Col", "gCCVSOAPrim",
|
||||||
|
"gKeese1_Ef_Prim","gKeese2_Ef_Prim","gKeese1_Ef_Env","gKeese2_Ef_Env",
|
||||||
|
"gDF_Col", "gDF_Env",
|
||||||
|
"gNL_Diamond_Col", "gNL_Diamond_Env", "gNL_Orb_Col", "gNL_Orb_Env",
|
||||||
|
"gTrailCol", "gCharged1Col", "gCharged1ColEnv", "gCharged2Col", "gCharged2ColEnv",
|
||||||
|
"gCCFileChoosePrim", "gCCFileChooseTextPrim", "gCCEquipmentsPrim", "gCCItemsPrim",
|
||||||
|
"gCCMapsPrim", "gCCQuestsPrim", "gCCSavePrim", "gCCGameoverPrim",
|
||||||
|
};
|
||||||
|
void LoadRainbowColor(bool& open) {
|
||||||
|
u8 arrayLength = sizeof(RainbowColorCvarList) / sizeof(*RainbowColorCvarList);
|
||||||
|
for (u8 s = 0; s < arrayLength; s++) {
|
||||||
|
std::string cvarName = RainbowColorCvarList[s];
|
||||||
|
std::string Cvar_Red = cvarName;
|
||||||
|
Cvar_Red += "R";
|
||||||
|
std::string Cvar_Green = cvarName;
|
||||||
|
Cvar_Green += "G";
|
||||||
|
std::string Cvar_Blue = cvarName;
|
||||||
|
Cvar_Blue += "B";
|
||||||
|
std::string Cvar_RBM = cvarName;
|
||||||
|
Cvar_RBM += "RBM";
|
||||||
|
std::string RBM_HUE = cvarName;
|
||||||
|
RBM_HUE += "Hue";
|
||||||
|
f32 Canon = 10.f * s;
|
||||||
|
ImVec4 NewColor;
|
||||||
|
const f32 deltaTime = 1.0f / ImGui::GetIO().Framerate;
|
||||||
|
f32 hue = CVar_GetFloat(RBM_HUE.c_str(), 0.0f);
|
||||||
|
f32 newHue = hue + CVar_GetS32("gColorRainbowSpeed", 1) * 36.0f * deltaTime;
|
||||||
|
if (newHue >= 360)
|
||||||
|
newHue = 0;
|
||||||
|
CVar_SetFloat(RBM_HUE.c_str(), newHue);
|
||||||
|
f32 current_hue = CVar_GetFloat(RBM_HUE.c_str(), 0);
|
||||||
|
u8 i = current_hue / 60 + 1;
|
||||||
|
u8 a = (-current_hue / 60.0f + i) * 255;
|
||||||
|
u8 b = (current_hue / 60.0f + (1 - i)) * 255;
|
||||||
|
|
||||||
|
switch (i) {
|
||||||
|
case 1: NewColor.x = 255; NewColor.y = b; NewColor.z = 0; break;
|
||||||
|
case 2: NewColor.x = a; NewColor.y = 255; NewColor.z = 0; break;
|
||||||
|
case 3: NewColor.x = 0; NewColor.y = 255; NewColor.z = b; break;
|
||||||
|
case 4: NewColor.x = 0; NewColor.y = a; NewColor.z = 255; break;
|
||||||
|
case 5: NewColor.x = b; NewColor.y = 0; NewColor.z = 255; break;
|
||||||
|
case 6: NewColor.x = 255; NewColor.y = 0; NewColor.z = a; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CVar_GetS32(Cvar_RBM.c_str(), 0) != 0) {
|
||||||
|
CVar_SetS32(Cvar_Red.c_str(), SohImGui::ClampFloatToInt(NewColor.x, 0, 255));
|
||||||
|
CVar_SetS32(Cvar_Green.c_str(), SohImGui::ClampFloatToInt(NewColor.y, 0, 255));
|
||||||
|
CVar_SetS32(Cvar_Blue.c_str(), SohImGui::ClampFloatToInt(NewColor.z, 0, 255));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
void Table_InitHeader(bool has_header = true) {
|
void Table_InitHeader(bool has_header = true) {
|
||||||
if (has_header) {
|
if (has_header) {
|
||||||
ImGui::TableHeadersRow();
|
ImGui::TableHeadersRow();
|
||||||
@ -258,11 +319,11 @@ void Draw_ItemsSkills(){
|
|||||||
SohImGui::EnhancementColor("Level 2 color", "gCharged2ColEnv", charged2_colenv, ImVec4(255,100,0,255));
|
SohImGui::EnhancementColor("Level 2 color", "gCharged2ColEnv", charged2_colenv, ImVec4(255,100,0,255));
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
SohImGui::EnhancementCheckbox("Custom sword trails color", "gUseTrailsCol");
|
SohImGui::EnhancementCheckbox("Custom trails color", "gUseTrailsCol");
|
||||||
if (CVar_GetS32("gUseTrailsCol",0) && ImGui::BeginTable("tabletrails", 1, ImGuiTableFlags_BordersH | ImGuiTableFlags_BordersV)) {
|
if (CVar_GetS32("gUseTrailsCol",0) && ImGui::BeginTable("tabletrails", 1, ImGuiTableFlags_BordersH | ImGuiTableFlags_BordersV)) {
|
||||||
ImGui::TableSetupColumn("Custom Swords trails", ImGuiTableColumnFlags_WidthStretch | ImGuiTableColumnFlags_IndentEnable | ImGuiTableColumnFlags_NoSort, TablesCellsWidth);
|
ImGui::TableSetupColumn("Custom Trails", ImGuiTableColumnFlags_WidthStretch | ImGuiTableColumnFlags_IndentEnable | ImGuiTableColumnFlags_NoSort, TablesCellsWidth);
|
||||||
Table_InitHeader();
|
Table_InitHeader();
|
||||||
Draw_HelpIcon("Affects Slash trails color");
|
Draw_HelpIcon("Affects Swords slash, boomerang and Bombchu trails color");
|
||||||
SohImGui::EnhancementColor("Trails color", "gTrailCol", trailscol, ImVec4(255,255,255,255));
|
SohImGui::EnhancementColor("Trails color", "gTrailCol", trailscol, ImVec4(255,255,255,255));
|
||||||
SohImGui::EnhancementSliderInt("Trails duration: %dx", "##TrailsMul", "gTrailDurantion", 1, 5, "");
|
SohImGui::EnhancementSliderInt("Trails duration: %dx", "##TrailsMul", "gTrailDurantion", 1, 5, "");
|
||||||
SohImGui::Tooltip("The longer the trails the weirder it become");
|
SohImGui::Tooltip("The longer the trails the weirder it become");
|
||||||
@ -1044,6 +1105,10 @@ void DrawCosmeticsEditor(bool& open) {
|
|||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
void InitCosmeticsEditor() {
|
void InitCosmeticsEditor() {
|
||||||
|
//This allow to hide a window without disturbing the player nor adding things in menu
|
||||||
|
//LoadRainbowColor() will this way run in background once it's window is activated
|
||||||
|
//ImGui::SetNextItemWidth(0.0f);
|
||||||
|
SohImGui::AddWindow("Cosmetics", "Rainbowfunction", LoadRainbowColor, true, true);
|
||||||
//Draw the bar in the menu.
|
//Draw the bar in the menu.
|
||||||
SohImGui::AddWindow("Cosmetics", "Cosmetics Editor", DrawCosmeticsEditor);
|
SohImGui::AddWindow("Cosmetics", "Cosmetics Editor", DrawCosmeticsEditor);
|
||||||
}
|
}
|
@ -1,3 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
void InitCosmeticsEditor();//Init the menu itself
|
void InitCosmeticsEditor();//Init the menu itself
|
||||||
|
void LoadRainbowColor();
|
Loading…
Reference in New Issue
Block a user