diff --git a/CMake/lus-cvars.cmake b/CMake/lus-cvars.cmake new file mode 100644 index 00000000000..e7376cfe28d --- /dev/null +++ b/CMake/lus-cvars.cmake @@ -0,0 +1,24 @@ +set(CVAR_VSYNC_ENABLED "${CVAR_PREFIX_SETTING}.VsyncEnabled" CACHE STRING "") +set(CVAR_Z_FIGHTING_MODE "${CVAR_PREFIX_SETTING}.ZFightingMode" CACHE STRING "") +set(CVAR_NEW_FILE_DROPPED "${CVAR_PREFIX_GENERAL}.NewFileDropped" CACHE STRING "") +set(CVAR_DROPPED_FILE "${CVAR_PREFIX_GENERAL}.DroppedFile" CACHE STRING "") +set(CVAR_INTERNAL_RESOLUTION "${CVAR_PREFIX_SETTING}.InternalResolution" CACHE STRING "") +set(CVAR_MSAA_VALUE "${CVAR_PREFIX_SETTING}.MSAAValue" CACHE STRING "") +set(CVAR_SDL_WINDOWED_FULLSCREEN "${CVAR_PREFIX_SETTING}.SdlWindowedFullscreen" CACHE STRING "") +set(CVAR_TEXTURE_FILTER "${CVAR_PREFIX_SETTING}.TextureFilter" CACHE STRING "") +set(CVAR_IMGUI_CONTROLLER_NAV "${CVAR_PREFIX_SETTING}.ControlNav" CACHE STRING "") +set(CVAR_CONSOLE_WINDOW_OPEN "${CVAR_PREFIX_WINDOW}.Console" CACHE STRING "") +set(CVAR_CONTROLLER_CONFIGURATION_WINDOW_OPEN "${CVAR_PREFIX_WINDOW}.ControllerConfiguration" CACHE STRING "") +set(CVAR_CONTROLLER_DISCONNECTED_WINDOW_OPEN "${CVAR_PREFIX_WINDOW}.ControllerDisconnected" CACHE STRING "") +set(CVAR_CONTROLLER_REORDERING_WINDOW_OPEN "${CVAR_PREFIX_WINDOW}.ControllerReordering" CACHE STRING "") +set(CVAR_GFX_DEBUGGER_WINDOW_OPEN "${CVAR_PREFIX_WINDOW}.GfxDebugger" CACHE STRING "") +set(CVAR_STATS_WINDOW_OPEN "${CVAR_PREFIX_WINDOW}.Stats" CACHE STRING "") +set(CVAR_ENABLE_MULTI_VIEWPORTS "${CVAR_PREFIX_SETTING}.EnableMultiViewports" CACHE STRING "") +set(CVAR_LOW_RES_MODE "${CVAR_PREFIX_SETTING}.LowResMode" CACHE STRING "") +set(CVAR_SIMULATED_INPUT_LAG "${CVAR_PREFIX_SETTING}.SimulatedInputLag" CACHE STRING "") +set(CVAR_ALT_ASSETS "${CVAR_PREFIX_ENHANCEMENT}.AltAssets" CACHE STRING "") +set(CVAR_GAME_OVERLAY_FONT "${CVAR_PREFIX_SETTING}.OverlayFont" CACHE STRING "") +set(CVAR_MENU_BAR_OPEN "${CVAR_PREFIX_SETTING}.OpenMenuBar" CACHE STRING "") +set(CVAR_PREFIX_CONTROLLERS "${CVAR_PREFIX_SETTING}.Controllers" CACHE STRING "") +set(CVAR_PREFIX_ADVANCED_RESOLUTION "${CVAR_PREFIX_SETTING}.AdvancedResolution" CACHE STRING "") +include("libultraship/cmake/cvars.cmake") \ No newline at end of file diff --git a/CMake/soh-cvars.cmake b/CMake/soh-cvars.cmake new file mode 100644 index 00000000000..e5ff8a38418 --- /dev/null +++ b/CMake/soh-cvars.cmake @@ -0,0 +1,26 @@ +set(CVAR_PREFIX_RANDOMIZER_ENHANCEMENT "gRandoEnhancements") +set(CVAR_PREFIX_RANDOMIZER_SETTING "gRandoSettings") +set(CVAR_PREFIX_COSMETIC "gCosmetics") +set(CVAR_PREFIX_AUDIO "gAudioEditor") +set(CVAR_PREFIX_CHEAT "gCheats") +set(CVAR_PREFIX_ENHANCEMENT "gEnhancements") +set(CVAR_PREFIX_SETTING "gSettings") +set(CVAR_PREFIX_WINDOW "gOpenWindows") +set(CVAR_PREFIX_TRACKER "gTrackers") +set(CVAR_PREFIX_DEVELOPER_TOOLS "gDeveloperTools") +set(CVAR_PREFIX_GENERAL "gGeneral") +set(CVAR_PREFIX_REMOTE "gRemote") +add_compile_definitions( + CVAR_PREFIX_RANDOMIZER_ENHANCEMENT="${CVAR_PREFIX_RANDOMIZER_ENHANCEMENT}" + CVAR_PREFIX_RANDOMIZER_SETTING="${CVAR_PREFIX_RANDOMIZER_SETTING}" + CVAR_PREFIX_COSMETIC="${CVAR_PREFIX_COSMETIC}" + CVAR_PREFIX_AUDIO="${CVAR_PREFIX_AUDIO}" + CVAR_PREFIX_CHEAT="${CVAR_PREFIX_CHEAT}" + CVAR_PREFIX_ENHANCEMENT="${CVAR_PREFIX_ENHANCEMENT}" + CVAR_PREFIX_SETTING="${CVAR_PREFIX_SETTING}" + CVAR_PREFIX_WINDOW="${CVAR_PREFIX_WINDOW}" + CVAR_PREFIX_TRACKER="${CVAR_PREFIX_TRACKER}" + CVAR_PREFIX_DEVELOPER_TOOLS="${CVAR_PREFIX_DEVELOPER_TOOLS}" + CVAR_PREFIX_GENERAL="${CVAR_PREFIX_GENERAL}" + CVAR_PREFIX_REMOTE="${CVAR_PREFIX_REMOTE}" +) \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c1f3dbed57..891d6ad26cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,8 @@ set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use") set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version") project(Ship VERSION 8.0.5 LANGUAGES C CXX) +include(CMake/soh-cvars.cmake) +include(CMake/lus-cvars.cmake) set(PROJECT_BUILD_NAME "MacReady Foxtrot" CACHE STRING "") set(PROJECT_TEAM "github.com/harbourmasters" CACHE STRING "") diff --git a/soh/soh/Enhancements/bootcommands.c b/soh/soh/Enhancements/bootcommands.c index 385a544a608..be3a766dc28 100644 --- a/soh/soh/Enhancements/bootcommands.c +++ b/soh/soh/Enhancements/bootcommands.c @@ -29,7 +29,7 @@ void BootCommands_Init() CVarClear("gCheatEasyPauseBufferLastInputs"); CVarClear("gCheatEasyPauseBufferTimer"); #if defined(__SWITCH__) || defined(__WIIU__) - CVarRegisterInteger("gControlNav", 1); // always enable controller nav on switch/wii u + CVarRegisterInteger(CVAR_IMGUI_CONTROLLER_NAV, 1); // always enable controller nav on switch/wii u #endif } diff --git a/soh/soh/Enhancements/mods.cpp b/soh/soh/Enhancements/mods.cpp index 8f9819f0857..8ddd59cef98 100644 --- a/soh/soh/Enhancements/mods.cpp +++ b/soh/soh/Enhancements/mods.cpp @@ -660,10 +660,10 @@ void UpdateDirtPathFixState(int32_t sceneNum) { case SCENE_HYRULE_FIELD: case SCENE_KOKIRI_FOREST: case SCENE_HYRULE_CASTLE: - CVarSetInteger("gZFightingMode", CVarGetInteger(CVAR_ENHANCEMENT("SceneSpecificDirtPathFix"), ZFIGHT_FIX_DISABLED)); + CVarSetInteger(CVAR_Z_FIGHTING_MODE, CVarGetInteger(CVAR_ENHANCEMENT("SceneSpecificDirtPathFix"), ZFIGHT_FIX_DISABLED)); return; default: - CVarClear("gZFightingMode"); + CVarClear(CVAR_Z_FIGHTING_MODE); } } diff --git a/soh/soh/Enhancements/presets.h b/soh/soh/Enhancements/presets.h index 8064fc66ca7..1392691df06 100644 --- a/soh/soh/Enhancements/presets.h +++ b/soh/soh/Enhancements/presets.h @@ -223,12 +223,12 @@ const std::vector enhancementsCvars = { CVAR_ENHANCEMENT("DisableLOD"), CVAR_ENHANCEMENT("DisableDrawDistance"), CVAR_ENHANCEMENT("DisableKokiriDrawDistance"), - "gLowResMode", + CVAR_LOW_RES_MODE, CVAR_ENHANCEMENT("DrawLineupTick"), CVAR_ENHANCEMENT("QuickBongoKill"), CVAR_ENHANCEMENT("FirstPersonGauntlets"), CVAR_ENHANCEMENT("SceneSpecificDirtPathFix"), - "gZFightingMode", + CVAR_Z_FIGHTING_MODE, CVAR_ENHANCEMENT("AuthenticLogo"), CVAR_ENHANCEMENT("PauseLiveLinkRotationSpeed"), CVAR_ENHANCEMENT("BowReticle"), @@ -282,7 +282,7 @@ const std::vector enhancementsCvars = { }; const std::vector cheatCvars = { - "gConsoleEnabled", + CVAR_CONSOLE_WINDOW_OPEN, CVAR_WINDOW("ActorViewer"), CVAR_WINDOW("CollisionViewer"), CVAR_WINDOW("DLViewer"), @@ -336,7 +336,7 @@ const std::vector cheatCvars = { CVAR_CHEAT("NoFishDespawn"), CVAR_CHEAT("NoBugsDespawn"), "gWalkModifierDoesntChangeJump", - "gStatsEnabled", + CVAR_STATS_WINDOW_OPEN, CVAR_CHEAT("SaveStatesEnabled"), CVAR_CHEAT("SaveStatePromise"), CVAR_DEVELOPER_TOOLS("RegEditEnabled"), diff --git a/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp b/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp index e20f469396a..b522879cb12 100644 --- a/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp +++ b/soh/soh/Enhancements/resolution-editor/ResolutionEditor.cpp @@ -114,19 +114,19 @@ void AdvancedResolutionSettingsWindow::DrawElement() { // The original resolution slider (for convenience) const bool disabled_resolutionSlider = (CVarGetInteger("gAdvancedResolution.VerticalResolutionToggle", 0) && CVarGetInteger("gAdvancedResolution.Enabled", 0)) || - CVarGetInteger("gLowResMode", 0); - if (UIWidgets::EnhancementSliderFloat("Internal Resolution: %.1f%%", "##IMul", "gInternalResolution", 0.5f, + CVarGetInteger(CVAR_LOW_RES_MODE, 0); + if (UIWidgets::EnhancementSliderFloat("Internal Resolution: %.1f%%", "##IMul", CVAR_INTERNAL_RESOLUTION, 0.5f, 2.0f, "", 1.0f, true, true, disabled_resolutionSlider)) { Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier( - CVarGetFloat("gInternalResolution", 1)); + CVarGetFloat(CVAR_INTERNAL_RESOLUTION, 1)); } UIWidgets::Tooltip("Multiplies your output resolution by the value entered."); // The original MSAA slider (also for convenience) #ifndef __WIIU__ - if (UIWidgets::PaddedEnhancementSliderInt("MSAA: %d", "##IMSAA", "gMSAAValue", 1, 8, "", 1, true, true, + if (UIWidgets::PaddedEnhancementSliderInt("MSAA: %d", "##IMSAA", CVAR_MSAA_VALUE, 1, 8, "", 1, true, true, false)) { - Ship::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger("gMSAAValue", 1)); + Ship::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger(CVAR_MSAA_VALUE, 1)); }; UIWidgets::Tooltip( "Activates multi-sample anti-aliasing when above 1x, up to 8x for 8 samples for every pixel.\n\n" @@ -135,7 +135,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { #endif // N64 Mode toggle (again for convenience) - // UIWidgets::PaddedEnhancementCheckbox("(Enhancements>Graphics) N64 Mode", "gLowResMode", false, false, false, "", UIWidgets::CheckboxGraphics::Cross, false); + // UIWidgets::PaddedEnhancementCheckbox("(Enhancements>Graphics) N64 Mode", CVAR_LOW_RES_MODE, false, false, false, "", UIWidgets::CheckboxGraphics::Cross, false); } UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); @@ -143,7 +143,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { UIWidgets::PaddedEnhancementCheckbox("Enable advanced settings.", "gAdvancedResolution.Enabled", false, false, false, "", UIWidgets::CheckboxGraphics::Cross, false); // Error/Warning display - if (!CVarGetInteger("gLowResMode", 0)) { + if (!CVarGetInteger(CVAR_LOW_RES_MODE, 0)) { if (IsDroppingFrames()) { // Significant frame drop warning ImGui::TextColored(messageColor[MESSAGE_WARNING], ICON_FA_EXCLAMATION_TRIANGLE " Significant frame rate (FPS) drops may be occuring."); @@ -156,7 +156,7 @@ void AdvancedResolutionSettingsWindow::DrawElement() { ICON_FA_QUESTION_CIRCLE " \"N64 Mode\" is overriding these settings."); ImGui::SameLine(); if (ImGui::Button("Click to disable")) { - CVarSetInteger("gLowResMode", 0); + CVarSetInteger(CVAR_LOW_RES_MODE, 0); CVarSave(); } } diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index a6ea015dad3..744db9561e7 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -318,13 +318,13 @@ OTRGlobals::OTRGlobals() { context->InitCrashHandler(); context->InitConsole(); - auto sohInputEditorWindow = std::make_shared("gControllerConfigurationEnabled", "Input Editor"); + auto sohInputEditorWindow = std::make_shared(CVAR_CONTROLLER_CONFIGURATION_WINDOW_OPEN, "Input Editor"); context->InitWindow({ sohInputEditorWindow }); auto overlay = context->GetInstance()->GetWindow()->GetGui()->GetGameOverlay(); overlay->LoadFont("Press Start 2P", "fonts/PressStart2P-Regular.ttf", 12.0f); overlay->LoadFont("Fipps", "fonts/Fipps-Regular.otf", 32.0f); - overlay->SetCurrentFont(CVarGetString("gOverlayFont", "Press Start 2P")); + overlay->SetCurrentFont(CVarGetString(CVAR_GAME_OVERLAY_FONT, "Press Start 2P")); context->InitAudio(); @@ -1330,13 +1330,13 @@ extern "C" void Graph_StartFrame() { } #endif - if (CVarGetInteger("gNewFileDropped", 0)) { - std::string filePath = SohUtils::Sanitize(CVarGetString("gDroppedFile", "")); + if (CVarGetInteger(CVAR_NEW_FILE_DROPPED, 0)) { + std::string filePath = SohUtils::Sanitize(CVarGetString(CVAR_DROPPED_FILE, "")); if (!filePath.empty()) { GameInteractor::Instance->ExecuteHooks(filePath); } - CVarClear("gNewFileDropped"); - CVarClear("gDroppedFile"); + CVarClear(CVAR_NEW_FILE_DROPPED); + CVarClear(CVAR_DROPPED_FILE); } OTRGlobals::Instance->context->GetWindow()->StartFrame(); @@ -1408,7 +1408,7 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { ToggleAltAssetsAtEndOfFrame = false; // Actually update the CVar now before runing the alt asset update listeners - CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0)); + CVarSetInteger(CVAR_ALT_ASSETS, !CVarGetInteger(CVAR_ALT_ASSETS, 0)); gfx_texture_cache_clear(); SOH::SkeletonPatcher::UpdateSkeletons(); GameInteractor::Instance->ExecuteHooks(); @@ -1587,7 +1587,7 @@ extern "C" uint8_t ResourceMgr_FileAltExists(const char* filePath) { // Unloads a resource if an alternate version exists when alt assets are enabled // The resource is only removed from the internal cache to prevent it from used in the next resource lookup extern "C" void ResourceMgr_UnloadOriginalWhenAltExists(const char* resName) { - if (CVarGetInteger("gAltAssets", 0) && ResourceMgr_FileAltExists((char*) resName)) { + if (CVarGetInteger(CVAR_ALT_ASSETS, 0) && ResourceMgr_FileAltExists((char*) resName)) { ResourceMgr_UnloadResource((char*) resName); } } @@ -1938,7 +1938,7 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, Skel pathStr = pathStr.substr(sOtr.length()); } - bool isAlt = CVarGetInteger("gAltAssets", 0); + bool isAlt = CVarGetInteger(CVAR_ALT_ASSETS, 0); if (isAlt) { pathStr = Ship::IResource::gAltAssetPrefix + pathStr; diff --git a/soh/soh/OTRGlobals.h b/soh/soh/OTRGlobals.h index 3a1b3e1f60c..73cb58d9764 100644 --- a/soh/soh/OTRGlobals.h +++ b/soh/soh/OTRGlobals.h @@ -65,21 +65,21 @@ class OTRGlobals uint32_t IsGameMasterQuest(); #endif -#define CVAR_RANDOMIZER_ENHANCEMENT(var) "gRandoEnhancements." var -#define CVAR_RANDOMIZER_SETTING(var) "gRandoSettings." var -#define CVAR_COSMETIC(var) "gCosmetics." var -#define CVAR_AUDIO(var) "gAudioEditor." var -#define CVAR_CHEAT(var) "gCheats." var -#define CVAR_ENHANCEMENT(var) "gEnhancements." var -#define CVAR_SETTING(var) "gSettings." var -#define CVAR_WINDOW(var) "gOpenWindows." var -#define CVAR_TRACKER(var) "gTrackers." var -#define CVAR_TRACKER_ITEM(var) CVAR_TRACKER("ItemTracker." var) -#define CVAR_TRACKER_CHECK(var) CVAR_TRACKER("CheckTracker." var) -#define CVAR_TRACKER_ENTRANCE(var) CVAR_TRACKER("EntranceTracker." var) -#define CVAR_DEVELOPER_TOOLS(var) "gDeveloperTools." var -#define CVAR_GENERAL(var) "gGeneral." var -#define CVAR_REMOTE(var) "gRemote." var +#define CVAR_RANDOMIZER_ENHANCEMENT(var) CVAR_PREFIX_RANDOMIZER_ENHANCEMENT "." var +#define CVAR_RANDOMIZER_SETTING(var) CVAR_PREFIX_RANDOMIZER_SETTING "." var +#define CVAR_COSMETIC(var) CVAR_PREFIX_COSMETIC "." var +#define CVAR_AUDIO(var) CVAR_PREFIX_AUDIO "." var +#define CVAR_CHEAT(var) CVAR_PREFIX_CHEAT "." var +#define CVAR_ENHANCEMENT(var) CVAR_PREFIX_ENHANCEMENT "." var +#define CVAR_SETTING(var) CVAR_PREFIX_SETTING "." var +#define CVAR_WINDOW(var) CVAR_PREFIX_WINDOW "." var +#define CVAR_TRACKER(var) CVAR_PREFIX_TRACKER "." var +#define CVAR_TRACKER_ITEM(var) CVAR_TRACKER(".ItemTracker." var) +#define CVAR_TRACKER_CHECK(var) CVAR_TRACKER(".CheckTracker." var) +#define CVAR_TRACKER_ENTRANCE(var) CVAR_TRACKER(".EntranceTracker." var) +#define CVAR_DEVELOPER_TOOLS(var) CVAR_PREFIX_DEVELOPER_TOOLS "." var +#define CVAR_GENERAL(var) CVAR_PREFIX_GENERAL "." var +#define CVAR_REMOTE(var) CVAR_PREFIX_REMOTE "." var #ifndef __cplusplus void InitOTR(void); diff --git a/soh/soh/SohGui.cpp b/soh/soh/SohGui.cpp index 0ac185706c0..e7eb998dd63 100644 --- a/soh/soh/SohGui.cpp +++ b/soh/soh/SohGui.cpp @@ -139,7 +139,7 @@ namespace SohGui { void SetupGuiElements() { auto gui = Ship::Context::GetInstance()->GetWindow()->GetGui(); - mSohMenuBar = std::make_shared("gOpenMenuBar", CVarGetInteger("gOpenMenuBar", 0)); + mSohMenuBar = std::make_shared(CVAR_MENU_BAR_OPEN, CVarGetInteger(CVAR_MENU_BAR_OPEN, 0)); gui->SetMenuBar(std::reinterpret_pointer_cast(mSohMenuBar)); if (gui->GetMenuBar() && !gui->GetMenuBar()->IsVisible()) { diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index 6639f7a8a2e..fbcf2496a4f 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -231,7 +231,7 @@ void DrawSettingsMenu() { ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.22f, 0.38f, 0.56f, 1.0f)); if (mInputEditorWindow) { - if (ImGui::Button(GetWindowButtonText("Controller Mapping", CVarGetInteger("gControllerConfigurationEnabled", 0)).c_str(), ImVec2 (-1.0f, 0.0f))) { + if (ImGui::Button(GetWindowButtonText("Controller Mapping", CVarGetInteger(CVAR_CONTROLLER_CONFIGURATION_WINDOW_OPEN, 0)).c_str(), ImVec2 (-1.0f, 0.0f))) { mInputEditorWindow->ToggleVisibility(); } } @@ -239,7 +239,7 @@ void DrawSettingsMenu() { ImGui::PopStyleColor(1); ImGui::PopStyleVar(3); #ifndef __SWITCH__ - UIWidgets::EnhancementCheckbox("Menubar Controller Navigation", "gControlNav"); + UIWidgets::EnhancementCheckbox("Menubar Controller Navigation", CVAR_IMGUI_CONTROLLER_NAV); UIWidgets::Tooltip("Allows controller navigation of the SOH menu bar (Settings, Enhancements,...)\nCAUTION: This will disable game inputs while the menubar is visible.\n\nD-pad to move between items, A to select, and X to grab focus on the menu bar"); UIWidgets::PaddedSeparator(); #endif @@ -260,7 +260,7 @@ void DrawSettingsMenu() { ImGui::PopStyleColor(1); ImGui::PopStyleVar(3); - UIWidgets::PaddedEnhancementSliderInt("Simulated Input Lag: %d frames", "##SimulatedInputLag", "gSimulatedInputLag", 0, 6, "", 0, true, true, false); + UIWidgets::PaddedEnhancementSliderInt("Simulated Input Lag: %d frames", "##SimulatedInputLag", CVAR_SIMULATED_INPUT_LAG, 0, 6, "", 0, true, true, false); UIWidgets::Tooltip("Buffers your inputs to be executed a specified amount of frames later"); ImGui::EndMenu(); @@ -272,9 +272,9 @@ void DrawSettingsMenu() { #ifndef __APPLE__ const bool disabled_resolutionSlider = CVarGetInteger("gAdvancedResolution.VerticalResolutionToggle", 0) && CVarGetInteger("gAdvancedResolution.Enabled", 0); - if (UIWidgets::EnhancementSliderFloat("Internal Resolution: %.1f %%", "##IMul", "gInternalResolution", 0.5f, + if (UIWidgets::EnhancementSliderFloat("Internal Resolution: %.1f %%", "##IMul", CVAR_INTERNAL_RESOLUTION, 0.5f, 2.0f, "", 1.0f, true, true, disabled_resolutionSlider)) { - Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat("gInternalResolution", 1)); + Ship::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat(CVAR_INTERNAL_RESOLUTION, 1)); } UIWidgets::Tooltip("Resolution scale. Multiplies output resolution by this value, on each axis relative to window size.\n" "Lower values may improve performance.\n" @@ -305,9 +305,9 @@ void DrawSettingsMenu() { #ifndef __WIIU__ if (UIWidgets::PaddedEnhancementSliderInt( - (CVarGetInteger("gMSAAValue", 1) == 1) ? "Anti-aliasing (MSAA): Off" : "Anti-aliasing (MSAA): %d", - "##IMSAA", "gMSAAValue", 1, 8, "", 1, true, true, false)) { - Ship::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger("gMSAAValue", 1)); + (CVarGetInteger(CVAR_MSAA_VALUE, 1) == 1) ? "Anti-aliasing (MSAA): Off" : "Anti-aliasing (MSAA): %d", + "##IMSAA", CVAR_MSAA_VALUE, 1, 8, "", 1, true, true, false)) { + Ship::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger(CVAR_MSAA_VALUE, 1)); } UIWidgets::Tooltip("Activates MSAA (multi-sample anti-aliasing) from 2x up to 8x, to smooth the edges of rendered geometry.\n" "Higher sample count will result in smoother edges on models, but may reduce performance.\n\n" @@ -479,22 +479,22 @@ void DrawSettingsMenu() { } if (Ship::Context::GetInstance()->GetWindow()->CanDisableVerticalSync()) { - UIWidgets::PaddedEnhancementCheckbox("Enable Vsync", "gVsyncEnabled", true, false); + UIWidgets::PaddedEnhancementCheckbox("Enable Vsync", CVAR_VSYNC_ENABLED, true, false); UIWidgets::Tooltip("Activate vertical sync, to prevent screen tearing."); } if (Ship::Context::GetInstance()->GetWindow()->SupportsWindowedFullscreen()) { - UIWidgets::PaddedEnhancementCheckbox("Windowed fullscreen", "gSdlWindowedFullscreen", true, false); + UIWidgets::PaddedEnhancementCheckbox("Windowed fullscreen", CVAR_SDL_WINDOWED_FULLSCREEN, true, false); } if (Ship::Context::GetInstance()->GetWindow()->GetGui()->SupportsViewports()) { - UIWidgets::PaddedEnhancementCheckbox("Allow multi-windows (Needs reload)", "gEnableMultiViewports", true, false, false, "", UIWidgets::CheckboxGraphics::Cross, true); + UIWidgets::PaddedEnhancementCheckbox("Allow multi-windows (Needs reload)", CVAR_ENABLE_MULTI_VIEWPORTS, true, false, false, "", UIWidgets::CheckboxGraphics::Cross, true); UIWidgets::Tooltip("Allows windows to be able to be dragged off of the main game window. Requires a reload to take effect."); } // If more filters are added to LUS, make sure to add them to the filters list here ImGui::Text("Texture Filtering (Needs reload)"); - UIWidgets::EnhancementCombobox("gTextureFilter", filters, FILTER_THREE_POINT); + UIWidgets::EnhancementCombobox(CVAR_TEXTURE_FILTER, filters, FILTER_THREE_POINT); UIWidgets::Tooltip("Texture filtering, aka texture smoothing. Requires a reload to take effect.\n\n" "Three-Point: Replicates real N64 texture filtering.\n" "Bilinear: If Three-Point causes poor performance, try this.\n" @@ -1059,10 +1059,10 @@ void DrawEnhancementsMenu() { if (ImGui::BeginMenu("Graphics")) { if (ImGui::BeginMenu("Mods")) { - if (UIWidgets::PaddedEnhancementCheckbox("Use Alternate Assets", "gAltAssets", false, false)) { + if (UIWidgets::PaddedEnhancementCheckbox("Use Alternate Assets", CVAR_ALT_ASSETS, false, false)) { // The checkbox will flip the alt asset CVar, but we instead want it to change at the end of the game frame // We toggle it back while setting the flag to update the CVar later - CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0)); + CVarSetInteger(CVAR_ALT_ASSETS, !CVarGetInteger(CVAR_ALT_ASSETS, 0)); ToggleAltAssetsAtEndOfFrame = true; } UIWidgets::Tooltip("Toggle between standard assets and alternate assets. Usually mods will indicate if this setting has to be used or not."); @@ -1147,7 +1147,7 @@ void DrawEnhancementsMenu() { UIWidgets::PaddedEnhancementCheckbox("Scale Adult Equipment as Child", CVAR_ENHANCEMENT("ScaleAdultEquimentAsChild"), true, false); UIWidgets::Tooltip("Scales all of the Adult Equipment, as well and moving some a bit, to fit on Child Link Better. May not work properly with some mods."); } - UIWidgets::PaddedEnhancementCheckbox("N64 Mode", "gLowResMode", true, false); + UIWidgets::PaddedEnhancementCheckbox("N64 Mode", CVAR_LOW_RES_MODE, true, false); UIWidgets::Tooltip("Sets aspect ratio to 4:3 and lowers resolution to 240p, the N64's native resolution"); UIWidgets::PaddedEnhancementCheckbox("Glitch line-up tick", CVAR_ENHANCEMENT("DrawLineupTick"), true, false); UIWidgets::Tooltip("Displays a tick in the top center of the screen to help with glitch line-ups in SoH, as traditional UI based line-ups do not work outside of 4:3"); @@ -1680,14 +1680,14 @@ void DrawDeveloperToolsMenu() { ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.22f, 0.38f, 0.56f, 1.0f)); if (mStatsWindow) { - if (ImGui::Button(GetWindowButtonText("Stats", CVarGetInteger("gStatsEnabled", 0)).c_str(), ImVec2(-1.0f, 0.0f))) { + if (ImGui::Button(GetWindowButtonText("Stats", CVarGetInteger(CVAR_STATS_WINDOW_OPEN, 0)).c_str(), ImVec2(-1.0f, 0.0f))) { mStatsWindow->ToggleVisibility(); } UIWidgets::Tooltip("Shows the stats window, with your FPS and frametimes, and the OS you're playing on"); } UIWidgets::Spacer(0); if (mConsoleWindow) { - if (ImGui::Button(GetWindowButtonText("Console", CVarGetInteger("gConsoleEnabled", 0)).c_str(), ImVec2(-1.0f, 0.0f))) { + if (ImGui::Button(GetWindowButtonText("Console", CVarGetInteger(CVAR_CONSOLE_WINDOW_OPEN, 0)).c_str(), ImVec2(-1.0f, 0.0f))) { mConsoleWindow->ToggleVisibility(); } UIWidgets::Tooltip("Enables the console window, allowing you to input commands, type help for some examples"); diff --git a/soh/soh/config/ConfigUpdaters.cpp b/soh/soh/config/ConfigUpdaters.cpp index 994505dd676..b3d137c1f9e 100644 --- a/soh/soh/config/ConfigUpdaters.cpp +++ b/soh/soh/config/ConfigUpdaters.cpp @@ -52,7 +52,7 @@ namespace SOH { conf->Erase("Game.Patches Archive"); } if (CVarGetInteger("gDirtPathFix", 0) != 0) { - CVarSetInteger("gZFightingMode", CVarGetInteger("gDirtPathFix", 0)); + CVarSetInteger(CVAR_Z_FIGHTING_MODE, CVarGetInteger("gDirtPathFix", 0)); CVarClear("gDirtPathFix"); } if (CVarGetInteger("gRandomizedEnemies", 0) != 0) { diff --git a/soh/soh/resource/type/Skeleton.cpp b/soh/soh/resource/type/Skeleton.cpp index 8abce78db80..8ac676c5557 100644 --- a/soh/soh/resource/type/Skeleton.cpp +++ b/soh/soh/resource/type/Skeleton.cpp @@ -65,7 +65,7 @@ void SkeletonPatcher::ClearSkeletons() } void SkeletonPatcher::UpdateSkeletons() { - bool isHD = CVarGetInteger("gAltAssets", 0); + bool isHD = CVarGetInteger(CVAR_ALT_ASSETS, 0); for (auto skel : skeletons) { Skeleton* newSkel = (Skeleton*)Ship::Context::GetInstance()->GetResourceManager() diff --git a/soh/src/code/game.c b/soh/src/code/game.c index 5fca89dbdc8..8d97177fd2a 100644 --- a/soh/src/code/game.c +++ b/soh/src/code/game.c @@ -467,7 +467,7 @@ void GameState_Destroy(GameState* gameState) { // Performing clear skeletons before unload resources fixes an actor heap corruption crash due to the skeleton patching system. ResourceMgr_ClearSkeletons(); - if (CVarGetInteger("gAltAssets", 0)) { + if (CVarGetInteger(CVAR_ALT_ASSETS, 0)) { ResourceUnloadDirectory("alt/*"); gfx_texture_cache_clear(); } diff --git a/soh/src/code/gfxprint.c b/soh/src/code/gfxprint.c index 8a0dbead434..9caad46a8f2 100644 --- a/soh/src/code/gfxprint.c +++ b/soh/src/code/gfxprint.c @@ -141,7 +141,7 @@ static const ALIGN_ASSET(2) char rGfxPrintFontDataAlt[] = drGfxPrintFontDataAlt; // https://github.com/HarbourMasters/Shipwright/issues/2762 typedef enum {hardcoded, otrDefault, otrAlt} font_texture_t; font_texture_t GfxPrint_TextureToUse() { - if (CVarGetInteger("gAltAssets", 0) && ResourceMgr_FileExists(rGfxPrintFontDataAlt)) { + if (CVarGetInteger(CVAR_ALT_ASSETS, 0) && ResourceMgr_FileExists(rGfxPrintFontDataAlt)) { // If we have alt assets enabled, and we have alt prefixed font texture, use that return otrAlt; } else if (ResourceMgr_FileExists(rGfxPrintFontData)) {