From d87df5f670304b2d5e2a06ba187dd8b22d257ef3 Mon Sep 17 00:00:00 2001 From: PurpleHato Date: Mon, 6 Jun 2022 18:11:12 +0200 Subject: [PATCH] Fixed from @louist103 and @Emill review --- libultraship/libultraship/SohImGuiImpl.cpp | 15 +++++++-------- libultraship/libultraship/SohImGuiImpl.h | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/libultraship/libultraship/SohImGuiImpl.cpp b/libultraship/libultraship/SohImGuiImpl.cpp index 7f28a9a38..5a38f5478 100644 --- a/libultraship/libultraship/SohImGuiImpl.cpp +++ b/libultraship/libultraship/SohImGuiImpl.cpp @@ -99,7 +99,7 @@ namespace SohImGui { "gCCMinimapPrim","gCCRupeePrim","gCCKeysPrim" }; - std::vector filters = { + const char* filters[3] = { "Three-Point", "Linear", "None" @@ -438,18 +438,17 @@ namespace SohImGui { } - void EnhancementCombobox(const char* name, std::vector ComboArray, uint8_t FirstTimeValue = 0) { + void EnhancementCombobox(const char* name, const char* ComboArray[], size_t arraySize, uint8_t FirstTimeValue = 0) { if (FirstTimeValue <= 0) { FirstTimeValue = 0; } uint8_t selected = CVar_GetS32(name, FirstTimeValue); uint8_t DefaultValue = selected; std::string comboName = std::string("##") + std::string(name); - if (ImGui::BeginCombo(comboName.c_str(), ComboArray[DefaultValue].c_str())) { - uint8_t ComboxSize = ComboArray.size(); - for (uint8_t i = 0; i < ComboxSize; i++) { - if (strlen(ComboArray[i].c_str()) > 1) { - if (ImGui::Selectable(ComboArray[i].c_str(), i == selected)) { + if (ImGui::BeginCombo(comboName.c_str(), ComboArray[DefaultValue])) { + for (uint8_t i = 0; i < arraySize; i++) { + if (strlen(ComboArray[i]) > 1) { + if (ImGui::Selectable(ComboArray[i], i == selected)) { CVar_SetS32(name, i); selected = i; needs_save = true; @@ -831,7 +830,7 @@ namespace SohImGui { EXPERIMENTAL(); ImGui::Text("Texture Filter (Needs reload)"); - EnhancementCombobox("gTextureFilter", filters); + EnhancementCombobox("gTextureFilter", filters, 0, 3); GfxRenderingAPI* gapi = gfx_get_current_rendering_api(); gapi->set_texture_filter((FilteringMode)CVar_GetS32("gTextureFilter", 0)); overlay->DrawSettings(); diff --git a/libultraship/libultraship/SohImGuiImpl.h b/libultraship/libultraship/SohImGuiImpl.h index 10260d62e..50d5c95e4 100644 --- a/libultraship/libultraship/SohImGuiImpl.h +++ b/libultraship/libultraship/SohImGuiImpl.h @@ -70,7 +70,7 @@ namespace SohImGui { void EnhancementButton(const char* text, const char* cvarName); void EnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format); void EnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage); - void EnhancementCombobox(const char* name, std::vector ComboArray, uint8_t FirstTimeValue); + void EnhancementCombobox(const char* name, const char* ComboArray[], size_t arraySize, uint8_t FirstTimeValue); void EnhancementColor(const char* text, const char* cvarName, ImVec4 ColorRGBA, ImVec4 default_colors, bool allow_rainbow = true, bool has_alpha=false, bool TitleSameLine=false); void DrawMainMenuAndCalculateGameSize(void);