combobox: use ordered maps to avoid dropdown having non-determinisitic ordering (#6101)

This commit is contained in:
Philip Dubé
2026-01-06 01:22:10 +00:00
committed by GitHub
parent b5a7dc7c2d
commit 443badee87
25 changed files with 117 additions and 123 deletions

View File

@@ -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"

View File

@@ -1,5 +1,4 @@
#include "Presets.h"
#include <variant>
#include <string>
#include <fstream>
#include <ship/config/Config.h>
@@ -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]];
}

View File

@@ -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<int32_t, const char*> audioRandomizerModes = {
static const std::map<int32_t, const char*> audioRandomizerModes = {
{ RANDOMIZE_OFF, "Manual" },
{ RANDOMIZE_ON_NEW_SCENE, "On New Scene" },
{ RANDOMIZE_ON_RANDO_GEN_ONLY, "On Rando Gen Only" },

View File

@@ -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<int32_t, const char*> 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<int32_t, const char*> buttonOutlineOptionsVerbose = {
static std::map<int32_t, const char*> 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<int32_t, const char*> 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<int32_t, const char*> stickModeOptions = { { STICK_MODE_ALWAYS_SHOWN, "Always" },
{ STICK_MODE_HIDDEN_IN_DEADZONE, "While In Use" },
{ STICK_MODE_ALWAYS_HIDDEN, "Never" } };
static std::map<int32_t, const char*> 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");

View File

@@ -99,7 +99,7 @@ std::map<CosmeticGroup, const char*> groupLabels = {
{ COSMETICS_GROUP_MESSAGE, "Message" },
};
static const std::unordered_map<int32_t, const char*> cosmeticsRandomizerModes = {
static const std::map<int32_t, const char*> cosmeticsRandomizerModes = {
{ RANDOMIZE_OFF, "Manual" },
{ RANDOMIZE_ON_NEW_SCENE, "On New Scene" },
{ RANDOMIZE_ON_RANDO_GEN_ONLY, "On Rando Gen Only" },

View File

@@ -20,7 +20,7 @@ extern PlayState* gPlayState;
enum ColRenderSetting { ColRenderDisabled, ColRenderSolid, ColRenderTransparent };
static std::unordered_map<int32_t, const char*> ColRenderSettingNames = {
static std::map<int32_t, const char*> ColRenderSettingNames = {
{ ColRenderDisabled, "Disabled" },
{ ColRenderSolid, "Solid" },
{ ColRenderTransparent, "Transparent" },

View File

@@ -13,7 +13,6 @@
#include <string>
#include <libultraship/bridge.h>
#include <libultraship/libultraship.h>
#include "soh_assets.h"
extern "C" {
#include <z64.h>
@@ -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<int8_t, const char*> magicLevelMap = {
std::map<int8_t, const char*> magicLevelMap = {
{ MAGIC_LEVEL_NONE, "None" },
{ MAGIC_LEVEL_SINGLE, "Single" },
{ MAGIC_LEVEL_DOUBLE, "Double" },
@@ -169,7 +164,7 @@ enum AudioOutput {
AUDIO_SURROUND,
};
std::unordered_map<uint8_t, const char*> audioMap = {
std::map<uint8_t, const char*> audioMap = {
{ AUDIO_STEREO, "Stereo" },
{ AUDIO_MONO, "Mono" },
{ AUDIO_HEADSET, "Headset" },
@@ -181,24 +176,24 @@ enum ZTarget {
Z_TARGET_HOLD,
};
std::unordered_map<uint8_t, const char*> zTargetMap = {
std::map<uint8_t, const char*> zTargetMap = {
{ Z_TARGET_SWITCH, "Switch" },
{ Z_TARGET_HOLD, "Hold" },
};
std::unordered_map<int32_t, const char*> fileNumMap = {
std::map<int32_t, const char*> fileNumMap = {
{ 0, "File 1" },
{ 1, "File 2" },
{ 2, "File 3" },
};
std::unordered_map<uint8_t, const char*> filenameLanguageMap = {
std::map<uint8_t, const char*> filenameLanguageMap = {
{ NAME_LANGUAGE_PAL, "PAL" },
{ NAME_LANGUAGE_NTSC_JPN, "NTSC JPN" },
{ NAME_LANGUAGE_NTSC_ENG, "NTSC ENG" },
};
std::unordered_map<uint8_t, const char*> filenameLanguageMapNTSCOnly = {
std::map<uint8_t, const char*> 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;

View File

@@ -75,7 +75,7 @@ std::vector<ValueTableElement> 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;

View File

@@ -1,5 +1,4 @@
#include <map>
#include <ranges>
#include <vector>
#include <libultraship/classes.h>
@@ -214,7 +213,7 @@ void DrawMods(bool enabled) {
int switchToIndex = -1;
uint32_t index = 0;
for (int i = static_cast<int>(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();

View File

@@ -894,7 +894,7 @@ void PlandomizerDrawIceTrapSetup(uint32_t index) {
ImGui::PopID();
}
static std::unordered_map<RandomizerCheckArea, const char*> rcAreaNameMap = {
static std::map<RandomizerCheckArea, const char*> rcAreaNameMap = {
{ RCAREA_KOKIRI_FOREST, "Kokiri Forest" },
{ RCAREA_LOST_WOODS, "Lost Woods" },
{ RCAREA_SACRED_FOREST_MEADOW, "Sacred Forest Meadow" },

View File

@@ -336,7 +336,7 @@ class Option {
std::shared_ptr<UIWidgets::WidgetOptions> widgetOptions;
struct WidgetInfo widgetInfo;
WidgetFunc callback;
std::unordered_map<int32_t, const char*> optionsMap = {};
std::map<int32_t, const char*> optionsMap = {};
};
class LocationOption : public Option {

View File

@@ -2112,10 +2112,10 @@ void CheckTrackerWindow::Draw() {
SyncVisibilityConsoleVariable();
}
static std::unordered_map<int32_t, const char*> windowType = { { TRACKER_WINDOW_FLOATING, "Floating" },
{ TRACKER_WINDOW_WINDOW, "Window" } };
static std::unordered_map<int32_t, const char*> displayType = { { 0, "Always" }, { 1, "Combo Button Hold" } };
static std::unordered_map<int32_t, const char*> buttonStrings = {
static std::map<int32_t, const char*> windowType = { { TRACKER_WINDOW_FLOATING, "Floating" },
{ TRACKER_WINDOW_WINDOW, "Window" } };
static std::map<int32_t, const char*> displayType = { { 0, "Always" }, { 1, "Combo Button Hold" } };
static std::map<int32_t, const char*> 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" },

View File

@@ -1837,31 +1837,31 @@ void ItemTrackerWindow::DrawElement() {
}
}
static std::unordered_map<int32_t, const char*> itemTrackerCapacityTrackOptions = {
static std::map<int32_t, const char*> 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<int32_t, const char*> itemTrackerKeyTrackOptions = {
static std::map<int32_t, const char*> itemTrackerKeyTrackOptions = {
{ KEYS_COLLECTED_MAX, "Collected / Max" },
{ KEYS_CURRENT_COLLECTED_MAX, "Current / Collected / Max" },
{ KEYS_CURRENT_MAX, "Current / Max" },
};
static std::unordered_map<int32_t, const char*> itemTrackerTriforcePieceTrackOptions = {
static std::map<int32_t, const char*> itemTrackerTriforcePieceTrackOptions = {
{ TRIFORCE_PIECE_COLLECTED_REQUIRED, "Collected / Required" },
{ TRIFORCE_PIECE_COLLECTED_REQUIRED_MAX, "Collected / Required / Max" },
};
static std::unordered_map<int32_t, const char*> windowTypes = {
static std::map<int32_t, const char*> windowTypes = {
{ TRACKER_WINDOW_FLOATING, "Floating" },
{ TRACKER_WINDOW_WINDOW, "Window" },
};
static std::unordered_map<int32_t, const char*> displayModes = {
static std::map<int32_t, const char*> displayModes = {
{ TRACKER_DISPLAY_ALWAYS, "Always" },
{ TRACKER_DISPLAY_COMBO_BUTTON, "Combo Button Hold" },
};
static std::unordered_map<int32_t, const char*> buttons = {
static std::map<int32_t, const char*> 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<int32_t, const char*> 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<int32_t, const char*> displayTypes = {
static std::map<int32_t, const char*> displayTypes = {
{ SECTION_DISPLAY_HIDDEN, "Hidden" },
{ SECTION_DISPLAY_MAIN_WINDOW, "Main Window" },
{ SECTION_DISPLAY_SEPARATE, "Separate" },
};
static std::unordered_map<int32_t, const char*> extendedDisplayTypes = {
static std::map<int32_t, const char*> 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<int32_t, const char*> minimalDisplayTypes = {
{ SECTION_DISPLAY_MINIMAL_HIDDEN, "Hidden" }, { SECTION_DISPLAY_MINIMAL_SEPARATE, "Separate" }
};
static std::map<int32_t, const char*> minimalDisplayTypes = { { SECTION_DISPLAY_MINIMAL_HIDDEN, "Hidden" },
{ SECTION_DISPLAY_MINIMAL_SEPARATE, "Separate" } };
void ItemTrackerSettingsWindow::DrawElement() {
ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, { 8.0f, 8.0f });

View File

@@ -23,7 +23,6 @@
#include <ship/audio/AudioPlayer.h>
#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);

View File

@@ -1,18 +1,15 @@
#include "Menu.h"
#include "UIWidgets.hpp"
#include "soh/OTRGlobals.h"
#include "soh/Enhancements/controls/SohInputEditorWindow.h"
#include <ship/window/gui/GuiMenuBar.h>
#include <ship/window/gui/GuiElement.h>
#include "SohModals.h"
#include <variant>
#include <spdlog/fmt/fmt.h>
#include "variables.h"
#include <tuple>
extern "C" {
#include "z64.h"
#include "functions.h"
extern PlayState* gPlayState;
}
std::vector<ImVec2> 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 });

View File

@@ -40,7 +40,7 @@ class Menu : public GuiWindow {
uint8_t searchSidebarIndex;
UIWidgets::Colors defaultThemeIndex;
std::shared_ptr<std::vector<Ship::WindowBackend>> availableWindowBackends;
std::unordered_map<Ship::WindowBackend, const char*> availableWindowBackendsMap;
std::map<Ship::WindowBackend, const char*> availableWindowBackendsMap;
Ship::WindowBackend configWindowBackend;
std::unordered_map<uint32_t, disabledInfo> disabledMap;

View File

@@ -260,13 +260,13 @@ struct MainMenuEntry {
std::vector<std::string> sidebarOrder = {};
};
static const std::unordered_map<Ship::AudioBackend, const char*> audioBackendsMap = {
static const std::map<Ship::AudioBackend, const char*> audioBackendsMap = {
{ Ship::AudioBackend::WASAPI, "Windows Audio Session API" },
{ Ship::AudioBackend::SDL, "SDL" },
{ Ship::AudioBackend::NUL, "Null" },
};
static const std::unordered_map<Ship::WindowBackend, const char*> windowBackendsMap = {
static const std::map<Ship::WindowBackend, const char*> windowBackendsMap = {
{ Ship::WindowBackend::FAST3D_DXGI_DX11, "DirectX" },
{ Ship::WindowBackend::FAST3D_SDL_OPENGL, "OpenGL" },
{ Ship::WindowBackend::FAST3D_SDL_METAL, "Metal" },

View File

@@ -31,13 +31,13 @@ namespace SohGui {
extern std::shared_ptr<SohMenu> mSohMenu;
enum setting { UPDATE_aspectRatioX, UPDATE_aspectRatioY, UPDATE_verticalPixelCount };
std::unordered_map<int32_t, const char*> 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<int32_t, const char*> 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

View File

@@ -1,12 +1,12 @@
#include "SohMenu.h"
#include "soh/OTRGlobals.h"
#include "soh/Enhancements/controls/SohInputEditorWindow.h"
#include <ship/window/gui/GuiMenuBar.h>
#include <ship/window/gui/GuiElement.h>
#include <variant>
#include <ship/utils/StringHelper.h>
#include <spdlog/fmt/fmt.h>
#include <tuple>
extern "C" {
extern PlayState* gPlayState;
}
extern std::unordered_map<s16, const char*> warpPointSceneList;

View File

@@ -2,19 +2,12 @@
#define SOHMENU_H
#include <libultraship/libultraship.h>
#include "UIWidgets.hpp"
#include "Menu.h"
#include <fast/backends/gfx_rendering_api.h>
#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<int32_t, const char*> languages = {
static std::map<int32_t, const char*> 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<int32_t, const char*>& languageMap);
static void UpdateLanguageMap(std::map<int32_t, const char*>& languageMap);
private:
char mGitCommitHashTruncated[8];

View File

@@ -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<SohMenu> mSohMenu;
using namespace UIWidgets;
static const std::unordered_map<int32_t, const char*> logLevels = {
static const std::map<int32_t, const char*> 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<int32_t, const char*> bootToOptions = {
static std::map<int32_t, const char*> 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<int32_t, const char*> debugSaveFileModes = {
static const std::map<int32_t, const char*> debugSaveFileModes = {
{ 0, "Off" },
{ 1, "Vanilla" },
{ 2, "Maxed" },

View File

@@ -1,4 +1,5 @@
#include "SohMenu.h"
#include <soh/Enhancements/enhancementTypes.h>
#include <soh/Enhancements/mods.h>
#include <soh/Enhancements/game-interactor/GameInteractor.h>
#include <soh/OTRGlobals.h>
@@ -6,6 +7,12 @@
#include <soh/Enhancements/enemyrandomizer.h>
#include <soh/Enhancements/TimeDisplay/TimeDisplay.h>
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<SohMenu> mSohMenu;
using namespace UIWidgets;
static std::unordered_map<int32_t, const char*> bunnyHoodEffectMap = {
static std::map<int32_t, const char*> bunnyHoodEffectMap = {
{ BUNNY_HOOD_VANILLA, "Vanilla" },
{ BUNNY_HOOD_FAST, "Faster Run" },
{ BUNNY_HOOD_FAST_AND_JUMP, "Faster + Longer Jump" },
};
static const std::unordered_map<int32_t, const char*> dekuStickCheat = {
static const std::map<int32_t, const char*> 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<int32_t, const char*> skipForcedDialogOptions = {
static const std::map<int32_t, const char*> 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<int32_t, const char*> timeTravelOptions = {
static const std::map<int32_t, const char*> 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<int32_t, const char*> timeTravelOptions = {
{ TIME_TRAVEL_ANY_MS, "Any Ocarina + Master Sword" },
};
static const std::unordered_map<int32_t, const char*> sleepingWaterfallOptions = {
static const std::map<int32_t, const char*> sleepingWaterfallOptions = {
{ WATERFALL_ALWAYS, "Always" },
{ WATERFALL_ONCE, "Once" },
{ WATERFALL_NEVER, "Never" },
};
static const std::unordered_map<int32_t, const char*> allPowers = {
static const std::map<int32_t, const char*> 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<int32_t, const char*> allPowers = {
{ DAMAGE_OHKO, "OHKO (256x)" },
};
static const std::unordered_map<int32_t, const char*> subPowers = {
static const std::map<int32_t, const char*> 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<int32_t, const char*> subSubPowers = {
static const std::map<int32_t, const char*> 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<int32_t, const char*> bonkDamageValues = {
static const std::map<int32_t, const char*> 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<int32_t, const char*> dampeDropRates = {
static const std::map<int32_t, const char*> dampeDropRates = {
{ DAMPE_NONE, "None" },
{ DAMPE_NORMAL, "Vanilla" },
{ DAMPE_JALAPENO, "Jalapeño" },
@@ -99,25 +106,25 @@ static const std::unordered_map<int32_t, const char*> dampeDropRates = {
{ DAMPE_INFERNO, "Dampe's Inferno" },
};
static const std::unordered_map<int32_t, const char*> cursorAnywhereValues = {
static const std::map<int32_t, const char*> 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<int32_t, const char*> zFightingOptions = {
static const std::map<int32_t, const char*> zFightingOptions = {
{ ZFIGHT_FIX_DISABLED, "Disabled" },
{ ZFIGHT_FIX_CONSISTENT_VANISH, "Consistent Vanish" },
{ ZFIGHT_FIX_NO_VANISH, "No Vanish" },
};
static const std::unordered_map<int32_t, const char*> swordToggleModes = {
static const std::map<int32_t, const char*> swordToggleModes = {
{ SWORD_TOGGLE_NONE, "None" },
{ SWORD_TOGGLE_CHILD, "Child Toggle" },
{ SWORD_TOGGLE_BOTH_AGES, "Both Ages" },
};
static const std::unordered_map<int32_t, const char*> mirroredWorldModes = {
static const std::map<int32_t, const char*> mirroredWorldModes = {
{ MIRRORED_WORLD_OFF, "Disabled" },
{ MIRRORED_WORLD_ALWAYS, "Always" },
{ MIRRORED_WORLD_RANDOM, "Random" },
@@ -129,7 +136,7 @@ static const std::unordered_map<int32_t, const char*> mirroredWorldModes = {
{ MIRRORED_WORLD_DUNGEONS_RANDOM_SEEDED, "Dungeons Random (Seeded)" },
};
static const std::unordered_map<int32_t, const char*> enemyRandomizerModes = {
static const std::map<int32_t, const char*> enemyRandomizerModes = {
{ ENEMY_RANDOMIZER_OFF, "Disabled" },
{ ENEMY_RANDOMIZER_RANDOM, "Random" },
{ ENEMY_RANDOMIZER_RANDOM_SEEDED, "Random (Seeded)" },

View File

@@ -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<SohMenu> mSohMenu;
using namespace UIWidgets;
static const std::unordered_map<int32_t, const char*> skipGetItemAnimationOptions = {
static const std::map<int32_t, const char*> 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<RandomizerArea, bool> areaTreeDisabled{
static std::map<RandomizerArea, bool> 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<RandomizerArea, bool> areaTreeEnabled{
static std::map<RandomizerArea, bool> areaTreeEnabled{
{ RA_NONE, true },
{ RA_KOKIRI_FOREST, true },
{ RA_THE_LOST_WOODS, true },

View File

@@ -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 <soh/GameVersions.h>
@@ -19,14 +19,14 @@ extern std::shared_ptr<SohMenu> mSohMenu;
extern std::shared_ptr<SohModalWindow> mModalWindow;
using namespace UIWidgets;
static std::unordered_map<int32_t, const char*> imguiScaleOptions = {
static std::map<int32_t, const char*> imguiScaleOptions = {
{ 0, "Small" },
{ 1, "Normal" },
{ 2, "Large" },
{ 3, "X-Large" },
};
static const std::unordered_map<int32_t, const char*> menuThemeOptions = {
static const std::map<int32_t, const char*> menuThemeOptions = {
{ UIWidgets::Colors::Red, "Red" },
{ UIWidgets::Colors::DarkRed, "Dark Red" },
{ UIWidgets::Colors::Orange, "Orange" },
@@ -43,17 +43,17 @@ static const std::unordered_map<int32_t, const char*> menuThemeOptions = {
{ UIWidgets::Colors::DarkGray, "Dark Gray" },
};
static const std::unordered_map<int32_t, const char*> textureFilteringMap = {
static const std::map<int32_t, const char*> textureFilteringMap = {
{ Fast::FILTER_THREE_POINT, "Three-Point" },
{ Fast::FILTER_LINEAR, "Linear" },
{ Fast::FILTER_NONE, "None" },
};
static const std::unordered_map<int32_t, const char*> notificationPosition = {
static const std::map<int32_t, const char*> notificationPosition = {
{ 0, "Top Left" }, { 1, "Top Right" }, { 2, "Bottom Left" }, { 3, "Bottom Right" }, { 4, "Hidden" },
};
static const std::unordered_map<int32_t, const char*> bootSequenceLabels = {
static const std::map<int32_t, const char*> bootSequenceLabels = {
{ BOOTSEQUENCE_DEFAULT, "Default" },
{ BOOTSEQUENCE_AUTHENTIC, "Authentic" },
{ BOOTSEQUENCE_FILESELECT, "File Select" },
@@ -110,7 +110,7 @@ static const std::array<MessageTableEntry**, LANGUAGE_MAX> messageTables = {
&sNesMessageEntryTablePtr, &sGerMessageEntryTablePtr, &sFraMessageEntryTablePtr, &sJpnMessageEntryTablePtr
};
void SohMenu::UpdateLanguageMap(std::unordered_map<int32_t, const char*>& languageMap) {
void SohMenu::UpdateLanguageMap(std::map<int32_t, const char*>& languageMap) {
for (int32_t i = LANGUAGE_ENG; i < LANGUAGE_MAX; i++) {
if (*messageTables.at(i) != NULL) {
if (!languageMap.contains(i)) {

View File

@@ -1,14 +1,13 @@
#ifndef UIWidgets2_hpp
#define UIWidgets2_hpp
#include <map>
#include <string>
#include <vector>
#include <span>
#include <stdint.h>
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui.h>
#include <libultraship/libultraship.h>
#include <unordered_map>
#include "soh/ShipUtils.h"
#include "soh/ShipInit.hpp"
@@ -306,14 +305,14 @@ struct CheckboxOptions : WidgetOptions {
};
struct ComboboxOptions : WidgetOptions {
std::unordered_map<int32_t, const char*> comboMap = {};
std::map<int32_t, const char*> 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<int32_t, const char*> comboMap_) {
ComboboxOptions& ComboMap(std::map<int32_t, const char*> comboMap_) {
comboMap = comboMap_;
return *this;
}
@@ -504,11 +503,11 @@ struct FloatSliderOptions : WidgetOptions {
};
struct RadioButtonsOptions : WidgetOptions {
std::unordered_map<int32_t, const char*> buttonMap;
std::map<int32_t, const char*> buttonMap;
int32_t defaultIndex = 0;
Colors color = Colors::LightBlue;
RadioButtonsOptions& ButtonMap(std::unordered_map<int32_t, const char*> buttonMap_) {
RadioButtonsOptions& ButtonMap(std::map<int32_t, const char*> 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 <typename T>
bool Combobox(const char* label, T* value, const std::unordered_map<T, const char*>& comboMap,
bool Combobox(const char* label, T* value, const std::map<T, const char*>& 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 <typename T = int32_t>
bool CVarCombobox(const char* label, const char* cvarName, const std::unordered_map<T, const char*>& comboMap,
bool CVarCombobox(const char* label, const char* cvarName, const std::map<T, const char*>& comboMap,
const ComboboxOptions& options = {}) {
bool dirty = false;
int32_t value = CVarGetInteger(cvarName, options.defaultIndex);