From 443badee874daa08e1fd1ada37bd49555ffbc6c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= Date: Tue, 6 Jan 2026 01:22:10 +0000 Subject: [PATCH] combobox: use ordered maps to avoid dropdown having non-determinisitic ordering (#6101) --- soh/soh/Enhancements/ExtraTraps.cpp | 1 - soh/soh/Enhancements/Presets/Presets.cpp | 3 +- soh/soh/Enhancements/audio/AudioEditor.cpp | 3 +- soh/soh/Enhancements/controls/InputViewer.cpp | 19 +++++----- .../cosmetics/CosmeticsEditor.cpp | 2 +- soh/soh/Enhancements/debugger/colViewer.cpp | 2 +- .../Enhancements/debugger/debugSaveEditor.cpp | 29 ++++++--------- soh/soh/Enhancements/debugger/valueViewer.cpp | 6 +-- soh/soh/Enhancements/mod_menu.cpp | 3 +- .../Enhancements/randomizer/Plandomizer.cpp | 2 +- soh/soh/Enhancements/randomizer/option.h | 2 +- .../randomizer/randomizer_check_tracker.cpp | 8 ++-- .../randomizer/randomizer_item_tracker.cpp | 21 +++++------ soh/soh/OTRGlobals.cpp | 4 +- soh/soh/SohGui/Menu.cpp | 9 ++--- soh/soh/SohGui/Menu.h | 2 +- soh/soh/SohGui/MenuTypes.h | 4 +- soh/soh/SohGui/ResolutionEditor.cpp | 14 +++---- soh/soh/SohGui/SohMenu.cpp | 8 ++-- soh/soh/SohGui/SohMenu.h | 11 +----- soh/soh/SohGui/SohMenuDevTools.cpp | 10 +++-- soh/soh/SohGui/SohMenuEnhancements.cpp | 37 +++++++++++-------- soh/soh/SohGui/SohMenuRandomizer.cpp | 11 ++++-- soh/soh/SohGui/SohMenuSettings.cpp | 14 +++---- soh/soh/SohGui/UIWidgets.hpp | 15 ++++---- 25 files changed, 117 insertions(+), 123 deletions(-) diff --git a/soh/soh/Enhancements/ExtraTraps.cpp b/soh/soh/Enhancements/ExtraTraps.cpp index 155b1af71..c54f593b7 100644 --- a/soh/soh/Enhancements/ExtraTraps.cpp +++ b/soh/soh/Enhancements/ExtraTraps.cpp @@ -1,4 +1,3 @@ -#include "libultraship/bridge.h" #include "soh/Enhancements/game-interactor/GameInteractor_Hooks.h" #include "soh/ShipInit.hpp" #include "soh/Enhancements/randomizer/3drando/random.hpp" diff --git a/soh/soh/Enhancements/Presets/Presets.cpp b/soh/soh/Enhancements/Presets/Presets.cpp index b0d9fa033..e611a028a 100644 --- a/soh/soh/Enhancements/Presets/Presets.cpp +++ b/soh/soh/Enhancements/Presets/Presets.cpp @@ -1,5 +1,4 @@ #include "Presets.h" -#include #include #include #include @@ -295,7 +294,7 @@ void DrawNewPresetPopup() { auto config = Ship::Context::GetInstance()->GetConfig()->GetNestedJson(); for (int i = PRESET_SECTION_SETTINGS; i < PRESET_SECTION_MAX; i++) { if (saveSection[i]) { - for (int j = 0; j < blockInfo[i].sections.size(); j++) { + for (size_t j = 0; j < blockInfo[i].sections.size(); j++) { presets[newPresetName].presetValues["blocks"][blockInfo[i].names[1]][blockInfo[i].sections[j]] = config["CVars"][blockInfo[i].sections[j]]; } diff --git a/soh/soh/Enhancements/audio/AudioEditor.cpp b/soh/soh/Enhancements/audio/AudioEditor.cpp index 19fa0ee8a..51bc7f32c 100644 --- a/soh/soh/Enhancements/audio/AudioEditor.cpp +++ b/soh/soh/Enhancements/audio/AudioEditor.cpp @@ -13,6 +13,7 @@ #include "soh/SohGui/SohMenu.h" #include "soh/SohGui/SohGui.hpp" #include "AudioCollection.h" +#include "soh/Enhancements/enhancementTypes.h" #include "soh/Enhancements/game-interactor/GameInteractor.h" extern "C" { @@ -78,7 +79,7 @@ size_t AuthenticCountBySequenceType(SeqType type) { } } -static const std::unordered_map audioRandomizerModes = { +static const std::map audioRandomizerModes = { { RANDOMIZE_OFF, "Manual" }, { RANDOMIZE_ON_NEW_SCENE, "On New Scene" }, { RANDOMIZE_ON_RANDO_GEN_ONLY, "On Rando Gen Only" }, diff --git a/soh/soh/Enhancements/controls/InputViewer.cpp b/soh/soh/Enhancements/controls/InputViewer.cpp index 2f73fb057..f2a6ebe72 100644 --- a/soh/soh/Enhancements/controls/InputViewer.cpp +++ b/soh/soh/Enhancements/controls/InputViewer.cpp @@ -21,22 +21,21 @@ static Color_RGBA8 textColorDefault = { 255, 255, 255, 255 }; static Color_RGBA8 range1ColorDefault = { 255, 178, 0, 255 }; static Color_RGBA8 range2ColorDefault = { 0, 255, 0, 255 }; -static std::unordered_map buttonOutlineOptions = { - { BUTTON_OUTLINE_ALWAYS_SHOWN, "Always Shown" }, - { BUTTON_OUTLINE_NOT_PRESSED, "Shown Only While Not Pressed" }, - { BUTTON_OUTLINE_PRESSED, "Shown Only While Pressed" }, - { BUTTON_OUTLINE_ALWAYS_HIDDEN, "Always Hidden" } -}; -static std::unordered_map buttonOutlineOptionsVerbose = { +static std::map buttonOutlineOptions = { { BUTTON_OUTLINE_ALWAYS_SHOWN, "Always Shown" }, + { BUTTON_OUTLINE_NOT_PRESSED, + "Shown Only While Not Pressed" }, + { BUTTON_OUTLINE_PRESSED, "Shown Only While Pressed" }, + { BUTTON_OUTLINE_ALWAYS_HIDDEN, "Always Hidden" } }; +static std::map buttonOutlineOptionsVerbose = { { BUTTON_OUTLINE_ALWAYS_SHOWN, "Outline Always Shown" }, { BUTTON_OUTLINE_NOT_PRESSED, "Outline Shown Only While Not Pressed" }, { BUTTON_OUTLINE_PRESSED, "Outline Shown Only While Pressed" }, { BUTTON_OUTLINE_ALWAYS_HIDDEN, "Outline Always Hidden" } }; -static std::unordered_map stickModeOptions = { { STICK_MODE_ALWAYS_SHOWN, "Always" }, - { STICK_MODE_HIDDEN_IN_DEADZONE, "While In Use" }, - { STICK_MODE_ALWAYS_HIDDEN, "Never" } }; +static std::map stickModeOptions = { { STICK_MODE_ALWAYS_SHOWN, "Always" }, + { STICK_MODE_HIDDEN_IN_DEADZONE, "While In Use" }, + { STICK_MODE_ALWAYS_HIDDEN, "Never" } }; InputViewer::~InputViewer() { SPDLOG_TRACE("destruct input viewer"); diff --git a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp index 3a475516b..b8cb0c35d 100644 --- a/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp +++ b/soh/soh/Enhancements/cosmetics/CosmeticsEditor.cpp @@ -99,7 +99,7 @@ std::map groupLabels = { { COSMETICS_GROUP_MESSAGE, "Message" }, }; -static const std::unordered_map cosmeticsRandomizerModes = { +static const std::map cosmeticsRandomizerModes = { { RANDOMIZE_OFF, "Manual" }, { RANDOMIZE_ON_NEW_SCENE, "On New Scene" }, { RANDOMIZE_ON_RANDO_GEN_ONLY, "On Rando Gen Only" }, diff --git a/soh/soh/Enhancements/debugger/colViewer.cpp b/soh/soh/Enhancements/debugger/colViewer.cpp index e180e93ef..e68fbbf63 100644 --- a/soh/soh/Enhancements/debugger/colViewer.cpp +++ b/soh/soh/Enhancements/debugger/colViewer.cpp @@ -20,7 +20,7 @@ extern PlayState* gPlayState; enum ColRenderSetting { ColRenderDisabled, ColRenderSolid, ColRenderTransparent }; -static std::unordered_map ColRenderSettingNames = { +static std::map ColRenderSettingNames = { { ColRenderDisabled, "Disabled" }, { ColRenderSolid, "Solid" }, { ColRenderTransparent, "Transparent" }, diff --git a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp index 180b045aa..4cd3b4f45 100644 --- a/soh/soh/Enhancements/debugger/debugSaveEditor.cpp +++ b/soh/soh/Enhancements/debugger/debugSaveEditor.cpp @@ -13,7 +13,6 @@ #include #include #include -#include "soh_assets.h" extern "C" { #include @@ -22,10 +21,6 @@ extern "C" { #include "macros.h" #include "soh/cvar_prefixes.h" extern PlayState* gPlayState; - -#include "textures/icon_item_static/icon_item_static.h" -#include "textures/icon_item_24_static/icon_item_24_static.h" -#include "textures/parameter_static/parameter_static.h" } #include "message_data_static.h" @@ -156,7 +151,7 @@ std::string decodeNTSCPlayerNameChar(int code) { enum MagicLevel { MAGIC_LEVEL_NONE, MAGIC_LEVEL_SINGLE, MAGIC_LEVEL_DOUBLE }; -std::unordered_map magicLevelMap = { +std::map magicLevelMap = { { MAGIC_LEVEL_NONE, "None" }, { MAGIC_LEVEL_SINGLE, "Single" }, { MAGIC_LEVEL_DOUBLE, "Double" }, @@ -169,7 +164,7 @@ enum AudioOutput { AUDIO_SURROUND, }; -std::unordered_map audioMap = { +std::map audioMap = { { AUDIO_STEREO, "Stereo" }, { AUDIO_MONO, "Mono" }, { AUDIO_HEADSET, "Headset" }, @@ -181,24 +176,24 @@ enum ZTarget { Z_TARGET_HOLD, }; -std::unordered_map zTargetMap = { +std::map zTargetMap = { { Z_TARGET_SWITCH, "Switch" }, { Z_TARGET_HOLD, "Hold" }, }; -std::unordered_map fileNumMap = { +std::map fileNumMap = { { 0, "File 1" }, { 1, "File 2" }, { 2, "File 3" }, }; -std::unordered_map filenameLanguageMap = { +std::map filenameLanguageMap = { { NAME_LANGUAGE_PAL, "PAL" }, { NAME_LANGUAGE_NTSC_JPN, "NTSC JPN" }, { NAME_LANGUAGE_NTSC_ENG, "NTSC ENG" }, }; -std::unordered_map filenameLanguageMapNTSCOnly = { +std::map filenameLanguageMapNTSCOnly = { { NAME_LANGUAGE_NTSC_JPN, "NTSC JPN" }, { NAME_LANGUAGE_NTSC_ENG, "NTSC ENG" }, }; @@ -592,7 +587,7 @@ void DrawInventoryTab() { } } - for (int32_t pickerIndex = 0; pickerIndex < possibleItems.size(); pickerIndex++) { + for (size_t pickerIndex = 0; pickerIndex < possibleItems.size(); pickerIndex++) { if (((pickerIndex + 1) % 8) != 0) { ImGui::SameLine(); } @@ -1034,14 +1029,14 @@ void DrawFlagsTab() { }, "Gold Skulltulas"); - for (int i = 0; i < flagTables.size(); i++) { + for (size_t i = 0; i < flagTables.size(); i++) { const FlagTable& flagTable = flagTables[i]; if (flagTable.flagTableType == RANDOMIZER_INF && !IS_RANDO && !IS_BOSS_RUSH) { continue; } if (ImGui::TreeNode(flagTable.name)) { - for (int j = 0; j < flagTable.size + 1; j++) { + for (size_t j = 0; j < flagTable.size + 1; j++) { DrawGroupWithBorder( [&]() { if (j == 0) { @@ -1116,7 +1111,7 @@ void DrawUpgrade(const std::string& categoryName, int32_t categoryId, const std: PushStyleCombobox(THEME_COLOR); ImGui::AlignTextToFramePadding(); if (ImGui::BeginCombo("##upgrade", names[CUR_UPG_VALUE(categoryId)].c_str())) { - for (int32_t i = 0; i < names.size(); i++) { + for (size_t i = 0; i < names.size(); i++) { if (ImGui::Selectable(names[i].c_str())) { Inventory_ChangeUpgrade(categoryId, i); } @@ -1153,7 +1148,7 @@ void DrawUpgradeIcon(const std::string& categoryName, int32_t categoryId, const Tooltip(categoryName.c_str()); if (ImGui::BeginPopup(upgradePopupPicker)) { - for (int32_t pickerIndex = 0; pickerIndex < items.size(); pickerIndex++) { + for (size_t pickerIndex = 0; pickerIndex < items.size(); pickerIndex++) { if ((pickerIndex % 8) != 0) { ImGui::SameLine(); } @@ -1192,7 +1187,7 @@ void DrawEquipmentTab() { ITEM_TUNIC_KOKIRI, ITEM_TUNIC_GORON, ITEM_TUNIC_ZORA, ITEM_NONE, ITEM_BOOTS_KOKIRI, ITEM_BOOTS_IRON, ITEM_BOOTS_HOVER, ITEM_NONE, }; - for (int32_t i = 0; i < equipmentValues.size(); i++) { + for (size_t i = 0; i < equipmentValues.size(); i++) { // Skip over unused 4th slots for shields, boots, and tunics if (equipmentValues[i] == ITEM_NONE) { continue; diff --git a/soh/soh/Enhancements/debugger/valueViewer.cpp b/soh/soh/Enhancements/debugger/valueViewer.cpp index a4ab75e72..f906f4a96 100644 --- a/soh/soh/Enhancements/debugger/valueViewer.cpp +++ b/soh/soh/Enhancements/debugger/valueViewer.cpp @@ -75,7 +75,7 @@ std::vector valueTable = { // clang-format on extern "C" void ValueViewer_Draw(GfxPrint* printer) { - for (int i = 0; i < valueTable.size(); i++) { + for (size_t i = 0; i < valueTable.size(); i++) { ValueTableElement& element = valueTable[i]; if (!element.isActive || !element.isPrinted || (gPlayState == NULL && element.requiresPlayState)) continue; @@ -164,7 +164,7 @@ void ValueViewerWindow::DrawElement() { std::string(valueTable[selectedElement].path) + ")"); UIWidgets::PushStyleCombobox(THEME_COLOR); if (ImGui::BeginCombo("##valueViewerElement", selectedElementText.c_str())) { - for (int i = 0; i < valueTable.size(); i++) { + for (size_t i = 0; i < valueTable.size(); i++) { if (valueTable[i].isActive) continue; bool isSelected = (selectedElement == i); @@ -188,7 +188,7 @@ void ValueViewerWindow::DrawElement() { UIWidgets::PopStyleButton(); ImGui::EndGroup(); - for (int i = 0; i < valueTable.size(); i++) { + for (size_t i = 0; i < valueTable.size(); i++) { ValueTableElement& element = valueTable[i]; if (!element.isActive || (gPlayState == NULL && element.requiresPlayState)) continue; diff --git a/soh/soh/Enhancements/mod_menu.cpp b/soh/soh/Enhancements/mod_menu.cpp index e60eee7e9..23f525e85 100644 --- a/soh/soh/Enhancements/mod_menu.cpp +++ b/soh/soh/Enhancements/mod_menu.cpp @@ -1,5 +1,4 @@ #include -#include #include #include @@ -214,7 +213,7 @@ void DrawMods(bool enabled) { int switchToIndex = -1; uint32_t index = 0; - for (int i = static_cast(selectedModFiles.size()) - 1; i >= 0; i--) { + for (size_t i = selectedModFiles.size() - 1; i >= 0; i--) { std::string file = selectedModFiles[i]; if (enabled) { ImGui::BeginGroup(); diff --git a/soh/soh/Enhancements/randomizer/Plandomizer.cpp b/soh/soh/Enhancements/randomizer/Plandomizer.cpp index 3cea3949f..6b47cabeb 100644 --- a/soh/soh/Enhancements/randomizer/Plandomizer.cpp +++ b/soh/soh/Enhancements/randomizer/Plandomizer.cpp @@ -894,7 +894,7 @@ void PlandomizerDrawIceTrapSetup(uint32_t index) { ImGui::PopID(); } -static std::unordered_map rcAreaNameMap = { +static std::map rcAreaNameMap = { { RCAREA_KOKIRI_FOREST, "Kokiri Forest" }, { RCAREA_LOST_WOODS, "Lost Woods" }, { RCAREA_SACRED_FOREST_MEADOW, "Sacred Forest Meadow" }, diff --git a/soh/soh/Enhancements/randomizer/option.h b/soh/soh/Enhancements/randomizer/option.h index f4e814088..9d847f471 100644 --- a/soh/soh/Enhancements/randomizer/option.h +++ b/soh/soh/Enhancements/randomizer/option.h @@ -336,7 +336,7 @@ class Option { std::shared_ptr widgetOptions; struct WidgetInfo widgetInfo; WidgetFunc callback; - std::unordered_map optionsMap = {}; + std::map optionsMap = {}; }; class LocationOption : public Option { diff --git a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp index 0326867d5..9902ae32d 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_check_tracker.cpp @@ -2112,10 +2112,10 @@ void CheckTrackerWindow::Draw() { SyncVisibilityConsoleVariable(); } -static std::unordered_map windowType = { { TRACKER_WINDOW_FLOATING, "Floating" }, - { TRACKER_WINDOW_WINDOW, "Window" } }; -static std::unordered_map displayType = { { 0, "Always" }, { 1, "Combo Button Hold" } }; -static std::unordered_map buttonStrings = { +static std::map windowType = { { TRACKER_WINDOW_FLOATING, "Floating" }, + { TRACKER_WINDOW_WINDOW, "Window" } }; +static std::map displayType = { { 0, "Always" }, { 1, "Combo Button Hold" } }; +static std::map buttonStrings = { { TRACKER_COMBO_BUTTON_A, "A Button" }, { TRACKER_COMBO_BUTTON_B, "B Button" }, { TRACKER_COMBO_BUTTON_C_UP, "C-Up" }, { TRACKER_COMBO_BUTTON_C_DOWN, "C-Down" }, { TRACKER_COMBO_BUTTON_C_LEFT, "C-Left" }, { TRACKER_COMBO_BUTTON_C_RIGHT, "C-Right" }, diff --git a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp index 2faf1a0cb..02b1860cf 100644 --- a/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp +++ b/soh/soh/Enhancements/randomizer/randomizer_item_tracker.cpp @@ -1837,31 +1837,31 @@ void ItemTrackerWindow::DrawElement() { } } -static std::unordered_map itemTrackerCapacityTrackOptions = { +static std::map itemTrackerCapacityTrackOptions = { { ITEM_TRACKER_NUMBER_NONE, "No Numbers" }, { ITEM_TRACKER_NUMBER_CURRENT_CAPACITY_ONLY, "Current Capacity" }, { ITEM_TRACKER_NUMBER_CURRENT_AMMO_ONLY, "Current Ammo" }, { ITEM_TRACKER_NUMBER_CAPACITY, "Current Capacity / Max Capacity" }, { ITEM_TRACKER_NUMBER_AMMO, "Current Ammo / Current Capacity" }, }; -static std::unordered_map itemTrackerKeyTrackOptions = { +static std::map itemTrackerKeyTrackOptions = { { KEYS_COLLECTED_MAX, "Collected / Max" }, { KEYS_CURRENT_COLLECTED_MAX, "Current / Collected / Max" }, { KEYS_CURRENT_MAX, "Current / Max" }, }; -static std::unordered_map itemTrackerTriforcePieceTrackOptions = { +static std::map itemTrackerTriforcePieceTrackOptions = { { TRIFORCE_PIECE_COLLECTED_REQUIRED, "Collected / Required" }, { TRIFORCE_PIECE_COLLECTED_REQUIRED_MAX, "Collected / Required / Max" }, }; -static std::unordered_map windowTypes = { +static std::map windowTypes = { { TRACKER_WINDOW_FLOATING, "Floating" }, { TRACKER_WINDOW_WINDOW, "Window" }, }; -static std::unordered_map displayModes = { +static std::map displayModes = { { TRACKER_DISPLAY_ALWAYS, "Always" }, { TRACKER_DISPLAY_COMBO_BUTTON, "Combo Button Hold" }, }; -static std::unordered_map buttons = { +static std::map buttons = { { TRACKER_COMBO_BUTTON_A, "A" }, { TRACKER_COMBO_BUTTON_B, "B" }, { TRACKER_COMBO_BUTTON_C_UP, "C-Up" }, { TRACKER_COMBO_BUTTON_C_DOWN, "C-Down" }, { TRACKER_COMBO_BUTTON_C_LEFT, "C-Left" }, { TRACKER_COMBO_BUTTON_C_RIGHT, "C-Right" }, @@ -1870,20 +1870,19 @@ static std::unordered_map buttons = { { TRACKER_COMBO_BUTTON_D_UP, "D-Up" }, { TRACKER_COMBO_BUTTON_D_DOWN, "D-Down" }, { TRACKER_COMBO_BUTTON_D_LEFT, "D-Left" }, { TRACKER_COMBO_BUTTON_D_RIGHT, "D-Right" }, }; -static std::unordered_map displayTypes = { +static std::map displayTypes = { { SECTION_DISPLAY_HIDDEN, "Hidden" }, { SECTION_DISPLAY_MAIN_WINDOW, "Main Window" }, { SECTION_DISPLAY_SEPARATE, "Separate" }, }; -static std::unordered_map extendedDisplayTypes = { +static std::map extendedDisplayTypes = { { SECTION_DISPLAY_EXTENDED_HIDDEN, "Hidden" }, { SECTION_DISPLAY_EXTENDED_MAIN_WINDOW, "Main Window" }, { SECTION_DISPLAY_EXTENDED_MISC_WINDOW, "Misc Window" }, { SECTION_DISPLAY_EXTENDED_SEPARATE, "Separate" }, }; -static std::unordered_map minimalDisplayTypes = { - { SECTION_DISPLAY_MINIMAL_HIDDEN, "Hidden" }, { SECTION_DISPLAY_MINIMAL_SEPARATE, "Separate" } -}; +static std::map minimalDisplayTypes = { { SECTION_DISPLAY_MINIMAL_HIDDEN, "Hidden" }, + { SECTION_DISPLAY_MINIMAL_SEPARATE, "Separate" } }; void ItemTrackerSettingsWindow::DrawElement() { ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, { 8.0f, 8.0f }); diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index d05569e4f..114435e9c 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -23,7 +23,6 @@ #include #include "Enhancements/speechsynthesizer/SpeechSynthesizer.h" #include "Enhancements/controls/SohInputEditorWindow.h" -#include "Enhancements/cosmetics/CosmeticsEditor.h" #include "Enhancements/audio/AudioCollection.h" #include "Enhancements/enhancementTypes.h" #include "Enhancements/debugconsole.h" @@ -35,7 +34,6 @@ #include "Enhancements/randomizer/randomizer_check_tracker.h" #include "Enhancements/randomizer/3drando/random.hpp" #include "Enhancements/randomizer/static_data.h" -#include "Enhancements/randomizer/dungeon.h" #include "Enhancements/gameplaystats.h" #include "ObjectExtension/ObjectExtension.h" #include "frame_interpolation.h" @@ -2127,7 +2125,7 @@ extern "C" size_t GetEquipNowMessage(char* buffer, char* src, const size_t maxBu std::string postfix = customMessage.GetForCurrentLanguage(); std::string str; std::string FixedBaseStr(src); - int RemoveControlChar = FixedBaseStr.find_first_of("\x02"); + size_t RemoveControlChar = FixedBaseStr.find_first_of("\x02"); if (RemoveControlChar != std::string::npos) { FixedBaseStr = FixedBaseStr.substr(0, RemoveControlChar); diff --git a/soh/soh/SohGui/Menu.cpp b/soh/soh/SohGui/Menu.cpp index 592c0c5e6..1cb28f620 100644 --- a/soh/soh/SohGui/Menu.cpp +++ b/soh/soh/SohGui/Menu.cpp @@ -1,18 +1,15 @@ #include "Menu.h" #include "UIWidgets.hpp" #include "soh/OTRGlobals.h" -#include "soh/Enhancements/controls/SohInputEditorWindow.h" #include #include #include "SohModals.h" #include #include -#include "variables.h" #include extern "C" { #include "z64.h" -#include "functions.h" extern PlayState* gPlayState; } std::vector windowTypeSizes = { {} }; @@ -204,7 +201,7 @@ uint32_t Menu::DrawSearchResults(std::string& menuSearchText) { auto& menuEntry = menuEntries.at(menuLabel); for (auto& sidebarLabel : menuEntry.sidebarOrder) { auto& sidebar = menuEntry.sidebars[sidebarLabel]; - for (int i = 0; i < sidebar.columnWidgets.size(); i++) { + for (size_t i = 0; i < sidebar.columnWidgets.size(); i++) { auto& column = sidebar.columnWidgets.at(i); for (auto& info : column) { if (info.type == WIDGET_SEARCH || info.type == WIDGET_SEPARATOR || @@ -862,7 +859,7 @@ void Menu::DrawElement() { ImGui::SetNextWindowPos(pos + style.ItemSpacing); float sectionWidth = menuSize.x - sidebarWidth - 4 - style.ItemSpacing.x * 4; std::string sectionMenuId = sectionIndex + " Settings"; - int columns = sidebar->at(sectionIndex).columnCount; + size_t columns = sidebar->at(sectionIndex).columnCount; size_t columnFuncs = sidebar->at(sectionIndex).columnWidgets.size(); if (windowWidth < 800) { columns = 1; @@ -905,7 +902,7 @@ void Menu::DrawElement() { } } } - for (int i = 0; i < columnFuncs; i++) { + for (size_t i = 0; i < columnFuncs; i++) { std::string sectionId = fmt::format("{} Column {}", sectionMenuId, i); if (useColumns) { ImGui::SetNextWindowSizeConstraints({ columnWidth, 0 }, { columnWidth, columnHeight }); diff --git a/soh/soh/SohGui/Menu.h b/soh/soh/SohGui/Menu.h index a39d48510..915403e72 100644 --- a/soh/soh/SohGui/Menu.h +++ b/soh/soh/SohGui/Menu.h @@ -40,7 +40,7 @@ class Menu : public GuiWindow { uint8_t searchSidebarIndex; UIWidgets::Colors defaultThemeIndex; std::shared_ptr> availableWindowBackends; - std::unordered_map availableWindowBackendsMap; + std::map availableWindowBackendsMap; Ship::WindowBackend configWindowBackend; std::unordered_map disabledMap; diff --git a/soh/soh/SohGui/MenuTypes.h b/soh/soh/SohGui/MenuTypes.h index 6dd9aca2c..d1803c675 100644 --- a/soh/soh/SohGui/MenuTypes.h +++ b/soh/soh/SohGui/MenuTypes.h @@ -260,13 +260,13 @@ struct MainMenuEntry { std::vector sidebarOrder = {}; }; -static const std::unordered_map audioBackendsMap = { +static const std::map audioBackendsMap = { { Ship::AudioBackend::WASAPI, "Windows Audio Session API" }, { Ship::AudioBackend::SDL, "SDL" }, { Ship::AudioBackend::NUL, "Null" }, }; -static const std::unordered_map windowBackendsMap = { +static const std::map windowBackendsMap = { { Ship::WindowBackend::FAST3D_DXGI_DX11, "DirectX" }, { Ship::WindowBackend::FAST3D_SDL_OPENGL, "OpenGL" }, { Ship::WindowBackend::FAST3D_SDL_METAL, "Metal" }, diff --git a/soh/soh/SohGui/ResolutionEditor.cpp b/soh/soh/SohGui/ResolutionEditor.cpp index 8e84e5ab7..db61e814c 100644 --- a/soh/soh/SohGui/ResolutionEditor.cpp +++ b/soh/soh/SohGui/ResolutionEditor.cpp @@ -31,13 +31,13 @@ namespace SohGui { extern std::shared_ptr mSohMenu; enum setting { UPDATE_aspectRatioX, UPDATE_aspectRatioY, UPDATE_verticalPixelCount }; -std::unordered_map aspectRatioPresetLabels = { { 0, "Off" }, - { 1, "Custom" }, - { 2, "Original (4:3)" }, - { 3, "Widescreen (16:9)" }, - { 4, "Nintendo 3DS (5:3)" }, - { 5, "16:10 (8:5)" }, - { 6, "Ultrawide (21:9)" } }; +std::map aspectRatioPresetLabels = { { 0, "Off" }, + { 1, "Custom" }, + { 2, "Original (4:3)" }, + { 3, "Widescreen (16:9)" }, + { 4, "Nintendo 3DS (5:3)" }, + { 5, "16:10 (8:5)" }, + { 6, "Ultrawide (21:9)" } }; const float aspectRatioPresetsX[] = { 0.0f, 16.0f, 4.0f, 16.0f, 5.0f, 16.0f, 21.0f }; const float aspectRatioPresetsY[] = { 0.0f, 9.0f, 3.0f, 9.0f, 3.0f, 10.0f, 9.0f }; const int default_aspectRatio = 1; // Default combo list option diff --git a/soh/soh/SohGui/SohMenu.cpp b/soh/soh/SohGui/SohMenu.cpp index c5153074e..0a78563db 100644 --- a/soh/soh/SohGui/SohMenu.cpp +++ b/soh/soh/SohGui/SohMenu.cpp @@ -1,12 +1,12 @@ #include "SohMenu.h" -#include "soh/OTRGlobals.h" -#include "soh/Enhancements/controls/SohInputEditorWindow.h" #include #include -#include #include #include -#include + +extern "C" { +extern PlayState* gPlayState; +} extern std::unordered_map warpPointSceneList; diff --git a/soh/soh/SohGui/SohMenu.h b/soh/soh/SohGui/SohMenu.h index d6833f28b..5d24dbcce 100644 --- a/soh/soh/SohGui/SohMenu.h +++ b/soh/soh/SohGui/SohMenu.h @@ -2,19 +2,12 @@ #define SOHMENU_H #include -#include "UIWidgets.hpp" #include "Menu.h" #include #include "soh/cvar_prefixes.h" -#include "soh/Enhancements/enhancementTypes.h" -#include "soh/Enhancements/Presets/Presets.h" extern "C" { #include "z64.h" -#include "functions.h" -#include "variables.h" -#include "macros.h" -extern PlayState* gPlayState; } #ifdef __cplusplus @@ -27,7 +20,7 @@ void disableBetaQuest(); #endif namespace SohGui { -static std::unordered_map languages = { +static std::map languages = { { LANGUAGE_ENG, "English" }, { LANGUAGE_GER, "German" }, { LANGUAGE_FRA, "French" }, @@ -50,7 +43,7 @@ class SohMenu : public Ship::Menu { void AddMenuDevTools(); void AddMenuRandomizer(); void AddMenuNetwork(); - static void UpdateLanguageMap(std::unordered_map& languageMap); + static void UpdateLanguageMap(std::map& languageMap); private: char mGitCommitHashTruncated[8]; diff --git a/soh/soh/SohGui/SohMenuDevTools.cpp b/soh/soh/SohGui/SohMenuDevTools.cpp index f3a88f0c3..f7688c42c 100644 --- a/soh/soh/SohGui/SohMenuDevTools.cpp +++ b/soh/soh/SohGui/SohMenuDevTools.cpp @@ -1,6 +1,10 @@ #include "SohMenu.h" #include "SohGui.hpp" +extern "C" { +extern PlayState* gPlayState; +} + void WarpPointsWidget(WidgetInfo& info); namespace SohGui { @@ -8,12 +12,12 @@ namespace SohGui { extern std::shared_ptr mSohMenu; using namespace UIWidgets; -static const std::unordered_map logLevels = { +static const std::map logLevels = { { DEBUG_LOG_TRACE, "Trace" }, { DEBUG_LOG_DEBUG, "Debug" }, { DEBUG_LOG_INFO, "Info" }, { DEBUG_LOG_WARN, "Warn" }, { DEBUG_LOG_ERROR, "Error" }, { DEBUG_LOG_CRITICAL, "Critical" }, { DEBUG_LOG_OFF, "Off" }, }; -static std::unordered_map bootToOptions = { +static std::map bootToOptions = { { 0, "Disabled" }, { 1, "Debug Warp Screen" }, { 2, "Warp Point" }, @@ -25,7 +29,7 @@ DebugLogOption defaultLogLevel = DEBUG_LOG_TRACE; DebugLogOption defaultLogLevel = DEBUG_LOG_INFO; #endif -static const std::unordered_map debugSaveFileModes = { +static const std::map debugSaveFileModes = { { 0, "Off" }, { 1, "Vanilla" }, { 2, "Maxed" }, diff --git a/soh/soh/SohGui/SohMenuEnhancements.cpp b/soh/soh/SohGui/SohMenuEnhancements.cpp index b775c9963..30cf7d549 100644 --- a/soh/soh/SohGui/SohMenuEnhancements.cpp +++ b/soh/soh/SohGui/SohMenuEnhancements.cpp @@ -1,4 +1,5 @@ #include "SohMenu.h" +#include #include #include #include @@ -6,6 +7,12 @@ #include #include +extern "C" { +#include "functions.h" +#include "variables.h" +extern PlayState* gPlayState; +} + #define CVAR_INT_SHIP_INIT(cvar, val) \ CVarSetInteger(cvar, val); \ ShipInit::Init(cvar); @@ -27,26 +34,26 @@ namespace SohGui { extern std::shared_ptr mSohMenu; using namespace UIWidgets; -static std::unordered_map bunnyHoodEffectMap = { +static std::map bunnyHoodEffectMap = { { BUNNY_HOOD_VANILLA, "Vanilla" }, { BUNNY_HOOD_FAST, "Faster Run" }, { BUNNY_HOOD_FAST_AND_JUMP, "Faster + Longer Jump" }, }; -static const std::unordered_map dekuStickCheat = { +static const std::map dekuStickCheat = { { DEKU_STICK_NORMAL, "Normal" }, { DEKU_STICK_UNBREAKABLE, "Unbreakable" }, { DEKU_STICK_UNBREAKABLE_AND_ALWAYS_ON_FIRE, "Unbreakable + Always on Fire" }, }; -static const std::unordered_map skipForcedDialogOptions = { +static const std::map skipForcedDialogOptions = { { FORCED_DIALOG_SKIP_NONE, "None" }, { FORCED_DIALOG_SKIP_NAVI, "Navi" }, { FORCED_DIALOG_SKIP_NPC, "NPCs" }, { FORCED_DIALOG_SKIP_ALL, "All" }, }; -static const std::unordered_map timeTravelOptions = { +static const std::map timeTravelOptions = { { TIME_TRAVEL_DISABLED, "Disabled" }, { TIME_TRAVEL_OOT, "Ocarina of Time" }, { TIME_TRAVEL_OOT_MS, "Ocarina of Time + Master Sword" }, @@ -54,13 +61,13 @@ static const std::unordered_map timeTravelOptions = { { TIME_TRAVEL_ANY_MS, "Any Ocarina + Master Sword" }, }; -static const std::unordered_map sleepingWaterfallOptions = { +static const std::map sleepingWaterfallOptions = { { WATERFALL_ALWAYS, "Always" }, { WATERFALL_ONCE, "Once" }, { WATERFALL_NEVER, "Never" }, }; -static const std::unordered_map allPowers = { +static const std::map allPowers = { { DAMAGE_VANILLA, "Vanilla (1x)" }, { DAMAGE_DOUBLE, "Double (2x)" }, { DAMAGE_QUADRUPLE, "Quadruple (4x)" }, { DAMAGE_OCTUPLE, "Octuple (8x)" }, { DAMAGE_FOOLISH, "Foolish (16x)" }, { DAMAGE_RIDICULOUS, "Ridiculous (32x)" }, @@ -68,28 +75,28 @@ static const std::unordered_map allPowers = { { DAMAGE_OHKO, "OHKO (256x)" }, }; -static const std::unordered_map subPowers = { +static const std::map subPowers = { { DAMAGE_VANILLA, "Vanilla (1x)" }, { DAMAGE_DOUBLE, "Double (2x)" }, { DAMAGE_QUADRUPLE, "Quadruple (4x)" }, { DAMAGE_OCTUPLE, "Octuple (8x)" }, { DAMAGE_FOOLISH, "Foolish (16x)" }, { DAMAGE_RIDICULOUS, "Ridiculous (32x)" }, { DAMAGE_MERCILESS, "Merciless (64x)" }, { DAMAGE_TORTURE, "Pure Torture (128x)" }, }; -static const std::unordered_map subSubPowers = { +static const std::map subSubPowers = { { DAMAGE_VANILLA, "Vanilla (1x)" }, { DAMAGE_DOUBLE, "Double (2x)" }, { DAMAGE_QUADRUPLE, "Quadruple (4x)" }, { DAMAGE_OCTUPLE, "Octuple (8x)" }, { DAMAGE_FOOLISH, "Foolish (16x)" }, { DAMAGE_RIDICULOUS, "Ridiculous (32x)" }, { DAMAGE_MERCILESS, "Merciless (64x)" }, }; -static const std::unordered_map bonkDamageValues = { +static const std::map bonkDamageValues = { { BONK_DAMAGE_NONE, "No Damage" }, { BONK_DAMAGE_QUARTER_HEART, "0.25 Hearts" }, { BONK_DAMAGE_HALF_HEART, "0.5 Hearts" }, { BONK_DAMAGE_1_HEART, "1 Heart" }, { BONK_DAMAGE_2_HEARTS, "2 Hearts" }, { BONK_DAMAGE_4_HEARTS, "4 Hearts" }, { BONK_DAMAGE_8_HEARTS, "8 Hearts" }, { BONK_DAMAGE_OHKO, "OHKO" }, }; -static const std::unordered_map dampeDropRates = { +static const std::map dampeDropRates = { { DAMPE_NONE, "None" }, { DAMPE_NORMAL, "Vanilla" }, { DAMPE_JALAPENO, "Jalapeño" }, @@ -99,25 +106,25 @@ static const std::unordered_map dampeDropRates = { { DAMPE_INFERNO, "Dampe's Inferno" }, }; -static const std::unordered_map cursorAnywhereValues = { +static const std::map cursorAnywhereValues = { { PAUSE_ANY_CURSOR_RANDO_ONLY, "Only in Rando" }, { PAUSE_ANY_CURSOR_ALWAYS_ON, "Always" }, { PAUSE_ANY_CURSOR_ALWAYS_OFF, "Never" }, }; -static const std::unordered_map zFightingOptions = { +static const std::map zFightingOptions = { { ZFIGHT_FIX_DISABLED, "Disabled" }, { ZFIGHT_FIX_CONSISTENT_VANISH, "Consistent Vanish" }, { ZFIGHT_FIX_NO_VANISH, "No Vanish" }, }; -static const std::unordered_map swordToggleModes = { +static const std::map swordToggleModes = { { SWORD_TOGGLE_NONE, "None" }, { SWORD_TOGGLE_CHILD, "Child Toggle" }, { SWORD_TOGGLE_BOTH_AGES, "Both Ages" }, }; -static const std::unordered_map mirroredWorldModes = { +static const std::map mirroredWorldModes = { { MIRRORED_WORLD_OFF, "Disabled" }, { MIRRORED_WORLD_ALWAYS, "Always" }, { MIRRORED_WORLD_RANDOM, "Random" }, @@ -129,7 +136,7 @@ static const std::unordered_map mirroredWorldModes = { { MIRRORED_WORLD_DUNGEONS_RANDOM_SEEDED, "Dungeons Random (Seeded)" }, }; -static const std::unordered_map enemyRandomizerModes = { +static const std::map enemyRandomizerModes = { { ENEMY_RANDOMIZER_OFF, "Disabled" }, { ENEMY_RANDOMIZER_RANDOM, "Random" }, { ENEMY_RANDOMIZER_RANDOM_SEEDED, "Random (Seeded)" }, diff --git a/soh/soh/SohGui/SohMenuRandomizer.cpp b/soh/soh/SohGui/SohMenuRandomizer.cpp index 59cd096c6..18912459e 100644 --- a/soh/soh/SohGui/SohMenuRandomizer.cpp +++ b/soh/soh/SohGui/SohMenuRandomizer.cpp @@ -1,15 +1,20 @@ #include "SohMenu.h" +#include "soh/Enhancements/enhancementTypes.h" #include "soh/Enhancements/randomizer/randomizer.h" #include "soh/Enhancements/randomizer/randomizerTypes.h" #include "soh/OTRGlobals.h" #include "soh/SohGui/SohGui.hpp" +extern "C" { +#include "variables.h" +} + namespace SohGui { extern std::shared_ptr mSohMenu; using namespace UIWidgets; -static const std::unordered_map skipGetItemAnimationOptions = { +static const std::map skipGetItemAnimationOptions = { { SGIA_DISABLED, "Disabled" }, { SGIA_JUNK, "Junk Items" }, { SGIA_ALL, "All Items" }, @@ -185,7 +190,7 @@ void DrawTricksMenu(WidgetInfo& info) { ImGui::BeginDisabled(CVarGetInteger(CVAR_SETTING("DisableChanges"), 0) || disableEditingRandoSettings); // Tricks - static std::unordered_map areaTreeDisabled{ + static std::map areaTreeDisabled{ { RA_NONE, true }, { RA_KOKIRI_FOREST, true }, { RA_THE_LOST_WOODS, true }, @@ -220,7 +225,7 @@ void DrawTricksMenu(WidgetInfo& info) { { RA_GERUDO_TRAINING_GROUND, true }, { RA_GANONS_CASTLE, true }, }; - static std::unordered_map areaTreeEnabled{ + static std::map areaTreeEnabled{ { RA_NONE, true }, { RA_KOKIRI_FOREST, true }, { RA_THE_LOST_WOODS, true }, diff --git a/soh/soh/SohGui/SohMenuSettings.cpp b/soh/soh/SohGui/SohMenuSettings.cpp index 3ea0d8d34..f165aad11 100644 --- a/soh/soh/SohGui/SohMenuSettings.cpp +++ b/soh/soh/SohGui/SohMenuSettings.cpp @@ -1,6 +1,6 @@ #include "SohMenu.h" #include "soh/Notification/Notification.h" -#include "soh/Enhancements/controls/SohInputEditorWindow.h" +#include "soh/Enhancements/enhancementTypes.h" #include "SohModals.h" #include "soh/OTRGlobals.h" #include @@ -19,14 +19,14 @@ extern std::shared_ptr mSohMenu; extern std::shared_ptr mModalWindow; using namespace UIWidgets; -static std::unordered_map imguiScaleOptions = { +static std::map imguiScaleOptions = { { 0, "Small" }, { 1, "Normal" }, { 2, "Large" }, { 3, "X-Large" }, }; -static const std::unordered_map menuThemeOptions = { +static const std::map menuThemeOptions = { { UIWidgets::Colors::Red, "Red" }, { UIWidgets::Colors::DarkRed, "Dark Red" }, { UIWidgets::Colors::Orange, "Orange" }, @@ -43,17 +43,17 @@ static const std::unordered_map menuThemeOptions = { { UIWidgets::Colors::DarkGray, "Dark Gray" }, }; -static const std::unordered_map textureFilteringMap = { +static const std::map textureFilteringMap = { { Fast::FILTER_THREE_POINT, "Three-Point" }, { Fast::FILTER_LINEAR, "Linear" }, { Fast::FILTER_NONE, "None" }, }; -static const std::unordered_map notificationPosition = { +static const std::map notificationPosition = { { 0, "Top Left" }, { 1, "Top Right" }, { 2, "Bottom Left" }, { 3, "Bottom Right" }, { 4, "Hidden" }, }; -static const std::unordered_map bootSequenceLabels = { +static const std::map bootSequenceLabels = { { BOOTSEQUENCE_DEFAULT, "Default" }, { BOOTSEQUENCE_AUTHENTIC, "Authentic" }, { BOOTSEQUENCE_FILESELECT, "File Select" }, @@ -110,7 +110,7 @@ static const std::array messageTables = { &sNesMessageEntryTablePtr, &sGerMessageEntryTablePtr, &sFraMessageEntryTablePtr, &sJpnMessageEntryTablePtr }; -void SohMenu::UpdateLanguageMap(std::unordered_map& languageMap) { +void SohMenu::UpdateLanguageMap(std::map& languageMap) { for (int32_t i = LANGUAGE_ENG; i < LANGUAGE_MAX; i++) { if (*messageTables.at(i) != NULL) { if (!languageMap.contains(i)) { diff --git a/soh/soh/SohGui/UIWidgets.hpp b/soh/soh/SohGui/UIWidgets.hpp index a1f16a059..8ff022870 100644 --- a/soh/soh/SohGui/UIWidgets.hpp +++ b/soh/soh/SohGui/UIWidgets.hpp @@ -1,14 +1,13 @@ #ifndef UIWidgets2_hpp #define UIWidgets2_hpp +#include #include #include -#include #include #define IMGUI_DEFINE_MATH_OPERATORS #include #include -#include #include "soh/ShipUtils.h" #include "soh/ShipInit.hpp" @@ -306,14 +305,14 @@ struct CheckboxOptions : WidgetOptions { }; struct ComboboxOptions : WidgetOptions { - std::unordered_map comboMap = {}; + std::map comboMap = {}; uint32_t defaultIndex = 0; // Only applicable to CVarCombobox ComponentAlignments alignment = ComponentAlignments::Left; LabelPositions labelPosition = LabelPositions::Above; ImGuiComboFlags flags = 0; Colors color = Colors::LightBlue; - ComboboxOptions& ComboMap(std::unordered_map comboMap_) { + ComboboxOptions& ComboMap(std::map comboMap_) { comboMap = comboMap_; return *this; } @@ -504,11 +503,11 @@ struct FloatSliderOptions : WidgetOptions { }; struct RadioButtonsOptions : WidgetOptions { - std::unordered_map buttonMap; + std::map buttonMap; int32_t defaultIndex = 0; Colors color = Colors::LightBlue; - RadioButtonsOptions& ButtonMap(std::unordered_map buttonMap_) { + RadioButtonsOptions& ButtonMap(std::map buttonMap_) { buttonMap = buttonMap_; return *this; } @@ -650,7 +649,7 @@ void Separator(bool padTop = true, bool padBottom = true, float extraVerticalTop float CalcComboWidth(const char* preview_value, ImGuiComboFlags flags); template -bool Combobox(const char* label, T* value, const std::unordered_map& comboMap, +bool Combobox(const char* label, T* value, const std::map& comboMap, const ComboboxOptions& options = {}) { bool dirty = false; float startX = ImGui::GetCursorPosX(); @@ -986,7 +985,7 @@ bool Combobox(const char* label, T* value, const char* (&comboArray)[N], const C } template -bool CVarCombobox(const char* label, const char* cvarName, const std::unordered_map& comboMap, +bool CVarCombobox(const char* label, const char* cvarName, const std::map& comboMap, const ComboboxOptions& options = {}) { bool dirty = false; int32_t value = CVarGetInteger(cvarName, options.defaultIndex);