diff --git a/CMake/soh-cvars.cmake b/CMake/soh-cvars.cmake index e5ff8a384..227cfb2bb 100644 --- a/CMake/soh-cvars.cmake +++ b/CMake/soh-cvars.cmake @@ -10,6 +10,8 @@ set(CVAR_PREFIX_TRACKER "gTrackers") set(CVAR_PREFIX_DEVELOPER_TOOLS "gDeveloperTools") set(CVAR_PREFIX_GENERAL "gGeneral") set(CVAR_PREFIX_REMOTE "gRemote") +set(CVAR_PREFIX_GAMEPLAY_STATS "gGameplayStats") +set(CVAR_PREFIX_TIME_DISPLAY "gTimeDisplay") add_compile_definitions( CVAR_PREFIX_RANDOMIZER_ENHANCEMENT="${CVAR_PREFIX_RANDOMIZER_ENHANCEMENT}" CVAR_PREFIX_RANDOMIZER_SETTING="${CVAR_PREFIX_RANDOMIZER_SETTING}" @@ -23,4 +25,6 @@ add_compile_definitions( CVAR_PREFIX_DEVELOPER_TOOLS="${CVAR_PREFIX_DEVELOPER_TOOLS}" CVAR_PREFIX_GENERAL="${CVAR_PREFIX_GENERAL}" CVAR_PREFIX_REMOTE="${CVAR_PREFIX_REMOTE}" + CVAR_PREFIX_GAMEPLAY_STATS="${CVAR_PREFIX_GAMEPLAY_STATS}" + CVAR_PREFIX_TIME_DISPLAY="${CVAR_PREFIX_TIME_DISPLAY}" ) \ No newline at end of file diff --git a/soh/soh/Enhancements/TimeDisplay/TimeDisplay.cpp b/soh/soh/Enhancements/TimeDisplay/TimeDisplay.cpp index 80d048d68..4b374ed8e 100644 --- a/soh/soh/Enhancements/TimeDisplay/TimeDisplay.cpp +++ b/soh/soh/Enhancements/TimeDisplay/TimeDisplay.cpp @@ -37,10 +37,10 @@ const static std::vector> digitList = { }; const std::vector timeDisplayList = { - { DISPLAY_IN_GAME_TIMER, "Display Gameplay Timer", CVAR_ENHANCEMENT("TimeDisplay.Timers.InGameTimer") }, - { DISPLAY_TIME_OF_DAY, "Display Time of Day", CVAR_ENHANCEMENT("TimeDisplay.Timers.TimeofDay") }, - { DISPLAY_CONDITIONAL_TIMER, "Display Conditional Timer", CVAR_ENHANCEMENT("TimeDisplay.Timers.HotWater") }, - { DISPLAY_NAVI_TIMER, "Display Navi Timer", CVAR_ENHANCEMENT("TimeDisplay.Timers.NaviTimer") } + { DISPLAY_IN_GAME_TIMER, "Display Gameplay Timer", CVAR_TIME_DISPLAY("Timers.InGameTimer") }, + { DISPLAY_TIME_OF_DAY, "Display Time of Day", CVAR_TIME_DISPLAY("Timers.TimeofDay") }, + { DISPLAY_CONDITIONAL_TIMER, "Display Conditional Timer", CVAR_TIME_DISPLAY("Timers.HotWater") }, + { DISPLAY_NAVI_TIMER, "Display Navi Timer", CVAR_TIME_DISPLAY("Timers.NaviTimer") } }; static std::vector activeTimers; @@ -227,11 +227,11 @@ void TimeDisplayWindow::Draw() { } void TimeDisplayInitSettings() { - fontScale = CVarGetFloat(CVAR_ENHANCEMENT("TimeDisplay.FontScale"), 1.0f); + fontScale = CVarGetFloat(CVAR_TIME_DISPLAY("FontScale"), 1.0f); if (fontScale < 1.0f) { fontScale = 1.0f; } - if (CVarGetInteger(CVAR_ENHANCEMENT("TimeDisplay.ShowWindowBG"), 0)) { + if (CVarGetInteger(CVAR_TIME_DISPLAY("ShowWindowBG"), 0)) { windowBG = ImVec4(0, 0, 0, 0); } else { windowBG = ImVec4(0, 0, 0, 0.5f); diff --git a/soh/soh/Enhancements/gameplaystats.cpp b/soh/soh/Enhancements/gameplaystats.cpp index e939fa18c..347bfe982 100644 --- a/soh/soh/Enhancements/gameplaystats.cpp +++ b/soh/soh/Enhancements/gameplaystats.cpp @@ -391,7 +391,7 @@ void GameplayStatsRow(const char* label, const std::string& value, ImVec4 color } bool compareTimestampInfoByTime(const TimestampInfo& a, const TimestampInfo& b) { - return CVarGetInteger(CVAR_ENHANCEMENT("GameplayStats.ReverseTimestamps"), 0) ? a.time > b.time : a.time < b.time; + return CVarGetInteger(CVAR_GAMEPLAY_STATS("ReverseTimestamps"), 0) ? a.time > b.time : a.time < b.time; } const char* ResolveSceneID(int sceneID, int roomID){ @@ -452,13 +452,13 @@ void DrawGameplayStatsHeader() { } else { GameplayStatsRow("Total Game Time:", formatTimestampGameplayStat(GAMEPLAYSTAT_TOTAL_TIME), gSaveContext.ship.stats.gameComplete ? COLOR_GREEN : COLOR_WHITE); } - if (CVarGetInteger(CVAR_ENHANCEMENT("GameplayStats.ShowAdditionalTimers"), 0)) { // !Only display total game time + if (CVarGetInteger(CVAR_GAMEPLAY_STATS("ShowAdditionalTimers"), 0)) { // !Only display total game time GameplayStatsRow("Gameplay Time:", formatTimestampGameplayStat(gSaveContext.ship.stats.playTimer / 2), COLOR_GREY); GameplayStatsRow("Pause Menu Time:", formatTimestampGameplayStat(gSaveContext.ship.stats.pauseTimer / 3), COLOR_GREY); GameplayStatsRow("Time in scene:", formatTimestampGameplayStat(gSaveContext.ship.stats.sceneTimer / 2), COLOR_LIGHT_BLUE); GameplayStatsRow("Time in room:", formatTimestampGameplayStat(gSaveContext.ship.stats.roomTimer / 2), COLOR_LIGHT_BLUE); } - if (gPlayState != NULL && CVarGetInteger(CVAR_ENHANCEMENT("GameplayStats.ShowDebugInfo"), 0)) { // && display debug info + if (gPlayState != NULL && CVarGetInteger(CVAR_GAMEPLAY_STATS("ShowDebugInfo"), 0)) { // && display debug info GameplayStatsRow("play->sceneNum:", formatHexGameplayStat(gPlayState->sceneNum), COLOR_YELLOW); GameplayStatsRow("gSaveContext.entranceIndex:", formatHexGameplayStat(gSaveContext.entranceIndex), COLOR_YELLOW); GameplayStatsRow("gSaveContext.cutsceneIndex:", formatHexOnlyGameplayStat(gSaveContext.cutsceneIndex), COLOR_YELLOW); @@ -576,13 +576,13 @@ void DrawGameplayStatsBreakdownTab() { for (int i = 0; i < gSaveContext.ship.stats.tsIdx; i++) { std::string sceneName = ResolveSceneID(gSaveContext.ship.stats.sceneTimestamps[i].scene, gSaveContext.ship.stats.sceneTimestamps[i].room); std::string name; - if (CVarGetInteger(CVAR_ENHANCEMENT("GameplayStats.RoomBreakdown"), 0) && gSaveContext.ship.stats.sceneTimestamps[i].scene != SCENE_GROTTOS) { + if (CVarGetInteger(CVAR_GAMEPLAY_STATS("RoomBreakdown"), 0) && gSaveContext.ship.stats.sceneTimestamps[i].scene != SCENE_GROTTOS) { name = fmt::format("{:s} Room {:d}", sceneName, gSaveContext.ship.stats.sceneTimestamps[i].room); } else { name = sceneName; } strcpy(sceneTimestampDisplay[i].name, name.c_str()); - sceneTimestampDisplay[i].time = CVarGetInteger(CVAR_ENHANCEMENT("GameplayStats.RoomBreakdown"), 0) ? + sceneTimestampDisplay[i].time = CVarGetInteger(CVAR_GAMEPLAY_STATS("RoomBreakdown"), 0) ? gSaveContext.ship.stats.sceneTimestamps[i].roomTime : gSaveContext.ship.stats.sceneTimestamps[i].sceneTime; sceneTimestampDisplay[i].color = COLOR_GREY; sceneTimestampDisplay[i].isRoom = gSaveContext.ship.stats.sceneTimestamps[i].isRoom; @@ -593,13 +593,13 @@ void DrawGameplayStatsBreakdownTab() { ImGui::TableSetupColumn("stat", ImGuiTableColumnFlags_WidthStretch); for (int i = 0; i < gSaveContext.ship.stats.tsIdx; i++) { TimestampInfo tsInfo = sceneTimestampDisplay[i]; - bool canShow = !tsInfo.isRoom || CVarGetInteger(CVAR_ENHANCEMENT("GameplayStats.RoomBreakdown"), 0); + bool canShow = !tsInfo.isRoom || CVarGetInteger(CVAR_GAMEPLAY_STATS("RoomBreakdown"), 0); if (tsInfo.time > 0 && strnlen(tsInfo.name, 40) > 1 && canShow) { GameplayStatsRow(tsInfo.name, formatTimestampGameplayStat(tsInfo.time), tsInfo.color); } } std::string toPass; - if (CVarGetInteger(CVAR_ENHANCEMENT("GameplayStats.RoomBreakdown"), 0) && gSaveContext.ship.stats.sceneNum != SCENE_GROTTOS) { + if (CVarGetInteger(CVAR_GAMEPLAY_STATS("RoomBreakdown"), 0) && gSaveContext.ship.stats.sceneNum != SCENE_GROTTOS) { toPass = fmt::format("{:s} Room {:d}", ResolveSceneID(gSaveContext.ship.stats.sceneNum, gSaveContext.ship.stats.roomNum), gSaveContext.ship.stats.roomNum); } else { toPass = ResolveSceneID(gSaveContext.ship.stats.sceneNum, gSaveContext.ship.stats.roomNum); @@ -610,27 +610,27 @@ void DrawGameplayStatsBreakdownTab() { } void DrawGameplayStatsOptionsTab() { - UIWidgets::CVarCheckbox("Show in-game total timer", CVAR_ENHANCEMENT("GameplayStats.ShowIngameTimer"), + UIWidgets::CVarCheckbox("Show in-game total timer", CVAR_GAMEPLAY_STATS("ShowIngameTimer"), UIWidgets::CheckboxOptions() .Tooltip("Keep track of the timer as an in-game HUD element. The position of the " "timer can be changed in the Cosmetics Editor.") .Color(THEME_COLOR)); - UIWidgets::CVarCheckbox("Show latest timestamps on top", CVAR_ENHANCEMENT("GameplayStats.ReverseTimestamps"), + UIWidgets::CVarCheckbox("Show latest timestamps on top", CVAR_GAMEPLAY_STATS("ReverseTimestamps"), UIWidgets::CheckboxOptions().Color(THEME_COLOR)); - UIWidgets::CVarCheckbox("Room Breakdown", CVAR_ENHANCEMENT("GameplayStats.RoomBreakdown"), + UIWidgets::CVarCheckbox("Room Breakdown", CVAR_GAMEPLAY_STATS("RoomBreakdown"), UIWidgets::CheckboxOptions() .Tooltip("Allows a more in-depth perspective of time spent in a certain map.") .Color(THEME_COLOR)); - UIWidgets::CVarCheckbox("RTA Timing on new files", CVAR_ENHANCEMENT("GameplayStats.RTATiming"), + UIWidgets::CVarCheckbox("RTA Timing on new files", CVAR_GAMEPLAY_STATS("RTATiming"), UIWidgets::CheckboxOptions() .Tooltip("Timestamps are relative to starting timestamp rather than in game time, " "usually necessary for races/speedruns.\n\n" "Starting timestamp is on first non-C-up input after intro cutscene.\n\n" "NOTE: THIS NEEDS TO BE SET BEFORE CREATING A FILE TO TAKE EFFECT") .Color(THEME_COLOR)); - UIWidgets::CVarCheckbox("Show additional detail timers", CVAR_ENHANCEMENT("GameplayStats.ShowAdditionalTimers"), + UIWidgets::CVarCheckbox("Show additional detail timers", CVAR_GAMEPLAY_STATS("ShowAdditionalTimers"), UIWidgets::CheckboxOptions().Color(THEME_COLOR)); - UIWidgets::CVarCheckbox("Show Debug Info", CVAR_ENHANCEMENT("GameplayStats.ShowDebugInfo"), + UIWidgets::CVarCheckbox("Show Debug Info", CVAR_GAMEPLAY_STATS("ShowDebugInfo"), UIWidgets::CheckboxOptions().Color(THEME_COLOR)); } @@ -671,7 +671,7 @@ void InitStats(bool isDebug) { for (int dungeon = 0; dungeon < ARRAY_COUNT(gSaveContext.ship.stats.dungeonKeys); dungeon++) { gSaveContext.ship.stats.dungeonKeys[dungeon] = isDebug ? 8 : 0; } - gSaveContext.ship.stats.rtaTiming = CVarGetInteger(CVAR_ENHANCEMENT("GameplayStats.RTATiming"), 0); + gSaveContext.ship.stats.rtaTiming = CVarGetInteger(CVAR_GAMEPLAY_STATS("RTATiming"), 0); gSaveContext.ship.stats.fileCreatedAt = 0; gSaveContext.ship.stats.playTimer = 0; gSaveContext.ship.stats.pauseTimer = 0; diff --git a/soh/soh/Enhancements/gameplaystats.h b/soh/soh/Enhancements/gameplaystats.h index 81190c01e..b4d140f1f 100644 --- a/soh/soh/Enhancements/gameplaystats.h +++ b/soh/soh/Enhancements/gameplaystats.h @@ -27,7 +27,7 @@ extern "C" { : gSaveContext.ship.stats.itemTimestamp[TIMESTAMP_TRIFORCE_COMPLETED])) \ :\ (gSaveContext.ship.stats.playTimer / 2 + gSaveContext.ship.stats.pauseTimer / 3)) -#define CURRENT_MODE_TIMER (CVarGetInteger(CVAR_ENHANCEMENT("GameplayStats.RoomBreakdown"), 0) ?\ +#define CURRENT_MODE_TIMER (CVarGetInteger(CVAR_GAMEPLAY_STATS("RoomBreakdown"), 0) ?\ gSaveContext.ship.stats.roomTimer :\ gSaveContext.ship.stats.sceneTimer) diff --git a/soh/soh/SohGui/SohMenuEnhancements.cpp b/soh/soh/SohGui/SohMenuEnhancements.cpp index cc104b87d..febaa0a4a 100644 --- a/soh/soh/SohGui/SohMenuEnhancements.cpp +++ b/soh/soh/SohGui/SohMenuEnhancements.cpp @@ -1775,7 +1775,7 @@ void SohMenu::AddMenuEnhancements() { .WindowName("Additional Timers") .Options(WindowButtonOptions().Tooltip("Enables the separate Additional Timers Window.")); AddWidget(path, "Font Scale: %.2fx", WIDGET_CVAR_SLIDER_FLOAT) - .CVar(CVAR_ENHANCEMENT("TimeDisplay.FontScale")) + .CVar(CVAR_TIME_DISPLAY("FontScale")) .Callback([](WidgetInfo& info) { TimeDisplayInitSettings(); }) @@ -1786,7 +1786,7 @@ void SohMenu::AddMenuEnhancements() { .Format("%.2fx") ); AddWidget(path, "Hide Background", WIDGET_CVAR_CHECKBOX) - .CVar(CVAR_ENHANCEMENT("TimeDisplay.ShowWindowBG")) + .CVar(CVAR_TIME_DISPLAY("ShowWindowBG")) .Callback([](WidgetInfo& info) { TimeDisplayInitSettings(); }); diff --git a/soh/soh/config/ConfigMigrators.h b/soh/soh/config/ConfigMigrators.h index f3c663f66..021cab88e 100644 --- a/soh/soh/config/ConfigMigrators.h +++ b/soh/soh/config/ConfigMigrators.h @@ -299,12 +299,8 @@ namespace SOH { { MigrationAction::Rename, "gUniformLR", "gEnhancements.FixMenuLR" }, { MigrationAction::Rename, "gVisualAgony", "gEnhancements.VisualAgony" }, { MigrationAction::Rename, "gVoidDamageMul", "gEnhancements.VoidDamageMult" }, - { MigrationAction::Rename, "gGameplayStats.ShowAdditionalTimers", "gEnhancements.GameplayStats.ShowAdditionalTimers" }, - { MigrationAction::Rename, "gGameplayStats.ShowDebugInfo", "gEnhancements.GameplayStats.ShowDebugInfo" }, - { MigrationAction::Rename, "gGameplayStats.RoomBreakdown", "gEnhancements.GameplayStats.RoomBreakdown" }, - { MigrationAction::Rename, "gGameplayStats.ShowIngameTimer", "gEnhancements.GameplayStats.ShowInGameTimer" }, - { MigrationAction::Rename, "gGameplayStats.TimestampsReverse", "gEnhancements.GameplayStats.ReverseTimestamps" }, - { MigrationAction::Rename, "gGameplayStats.RTATiming", "gEnhancements.GameplayStats.RTATiming" }, + { MigrationAction::Rename, "gGameplayStats.ShowIngameTimer", "gGameplayStats.ShowInGameTimer" }, + { MigrationAction::Rename, "gGameplayStats.TimestampsReverse", "gGameplayStats.ReverseTimestamps" }, { MigrationAction::Rename, "gMirroredWorld", "gEnhancements.MirroredWorld" }, { MigrationAction::Rename, "gBetaQuestWorld", "gCheats.BetaQuestWorld" }, { MigrationAction::Rename, "gBombTimerMultiplier", "gCheats.BombTimerMultiplier" }, diff --git a/soh/soh/cvar_prefixes.h b/soh/soh/cvar_prefixes.h index 4b8d9f93a..375833cb1 100644 --- a/soh/soh/cvar_prefixes.h +++ b/soh/soh/cvar_prefixes.h @@ -14,4 +14,6 @@ #define CVAR_GENERAL(var) CVAR_PREFIX_GENERAL "." var #define CVAR_REMOTE(var) CVAR_PREFIX_REMOTE "." var #define CVAR_REMOTE_CROWD_CONTROL(var) CVAR_REMOTE("CrowdControl." var) -#define CVAR_REMOTE_SAIL(var) CVAR_REMOTE("Sail." var) \ No newline at end of file +#define CVAR_REMOTE_SAIL(var) CVAR_REMOTE("Sail." var) +#define CVAR_GAMEPLAY_STATS(var) CVAR_PREFIX_GAMEPLAY_STATS "." var +#define CVAR_TIME_DISPLAY(var) CVAR_PREFIX_TIME_DISPLAY "." var \ No newline at end of file diff --git a/soh/src/code/z_parameter.c b/soh/src/code/z_parameter.c index a221e570f..5060a0ab9 100644 --- a/soh/src/code/z_parameter.c +++ b/soh/src/code/z_parameter.c @@ -6123,7 +6123,7 @@ void Interface_DrawTotalGameplayTimer(PlayState* play) { // Draw timer based on the Gameplay Stats total time. if ((IS_BOSS_RUSH && gSaveContext.ship.quest.data.bossRush.options[BR_OPTIONS_TIMER] == BR_CHOICE_TIMER_YES) || - (CVarGetInteger(CVAR_ENHANCEMENT("GameplayStats.ShowIngameTimer"), 0) && gSaveContext.fileNum >= 0 && gSaveContext.fileNum <= 2)) { + (CVarGetInteger(CVAR_GAMEPLAY_STATS("ShowIngameTimer"), 0) && gSaveContext.fileNum >= 0 && gSaveContext.fileNum <= 2)) { s32 X_Margins_Timer = 0; if (CVarGetInteger(CVAR_COSMETIC("HUD.IGT.UseMargins"), 0) != 0) {