From f9bf647d18424fd67f6d89e4778b2395aed336fe Mon Sep 17 00:00:00 2001 From: c6 <31777460+c6-dev@users.noreply.github.com> Date: Tue, 23 Jan 2024 16:01:29 +0400 Subject: [PATCH] Option to "always run" only while outside of interiors (#420) --- data/update/TBoGT/common/data/frontend_menus.xml | 9 ++++++++- data/update/TLAD/common/data/frontend_menus.xml | 7 ++++++- data/update/common/data/frontend_menus.xml | 11 +++++++++-- source/ikeeponwalking.ixx | 9 ++++++--- source/settings.ixx | 16 +++++++++++----- 5 files changed, 40 insertions(+), 12 deletions(-) diff --git a/data/update/TBoGT/common/data/frontend_menus.xml b/data/update/TBoGT/common/data/frontend_menus.xml index 7d8294c7..5dc3ac9c 100644 --- a/data/update/TBoGT/common/data/frontend_menus.xml +++ b/data/update/TBoGT/common/data/frontend_menus.xml @@ -424,6 +424,13 @@ + + + + + + + @@ -481,7 +488,7 @@ - + diff --git a/data/update/TLAD/common/data/frontend_menus.xml b/data/update/TLAD/common/data/frontend_menus.xml index 095ba539..a3570e7b 100644 --- a/data/update/TLAD/common/data/frontend_menus.xml +++ b/data/update/TLAD/common/data/frontend_menus.xml @@ -500,6 +500,11 @@ + + + + + @@ -557,7 +562,7 @@ - + diff --git a/data/update/common/data/frontend_menus.xml b/data/update/common/data/frontend_menus.xml index a8bc4e7f..81fedf32 100644 --- a/data/update/common/data/frontend_menus.xml +++ b/data/update/common/data/frontend_menus.xml @@ -359,6 +359,13 @@ + + + + + + + @@ -422,7 +429,7 @@ - + @@ -861,7 +868,7 @@ - + diff --git a/source/ikeeponwalking.ixx b/source/ikeeponwalking.ixx index 3a00cdef..e9f0edd5 100644 --- a/source/ikeeponwalking.ixx +++ b/source/ikeeponwalking.ixx @@ -6,6 +6,7 @@ export module ikeeponwalking; import common; import settings; +import natives; class IKeepOnWalking { @@ -35,11 +36,13 @@ public: *(uintptr_t*)(regs.esp - 4) = loc_A2A60F; } + auto alwaysrunPref = FusionFixSettings.GetRef("PREF_ALWAYSRUN"); + bool shouldRun = (alwaysrunPref->get() == FusionFixSettings.AlwaysRunText.eMO_ON + || (alwaysrunPref->get() == FusionFixSettings.AlwaysRunText.eOutside && !Natives::IsInteriorScene())); - static auto alwaysrun = FusionFixSettings.GetRef("PREF_ALWAYSRUN"); if (!FusionFixSettings.Get("PREF_SPRINT")) // toggle { - if (alwaysrun->get()) + if (shouldRun) { static auto bRunState = true; static auto oldWalkKeyState = GetAsyncKeyState(nWalkKey); @@ -52,7 +55,7 @@ public: *(float*)(regs.esp + (flag ? 0x18 : 0x1C)) = 1.0f; } } - else if (alwaysrun->get() && !GetAsyncKeyState(nWalkKey)) // hold + else if (shouldRun && !GetAsyncKeyState(nWalkKey)) // hold *(float*)(regs.esp + (flag ? 0x18 : 0x1C)) = 1.0f; } }; injector::MakeInline2(pattern.get_first(0)); diff --git a/source/settings.ixx b/source/settings.ixx index 7bfb2522..931b79e3 100644 --- a/source/settings.ixx +++ b/source/settings.ixx @@ -29,9 +29,9 @@ private: auto GetValue() { return value; } auto SetValue(auto v) { value = v; WriteToIni(); if (callback) callback(value); } auto ReadFromIni(auto& iniReader) { return iniReader.ReadInteger(iniSec, iniName, iniDefValInt); } - auto ReadFromIni() { CIniReader iniReader(cfgPath.wstring()); return ReadFromIni(iniReader); } + auto ReadFromIni() { CIniReader iniReader(cfgPath); return ReadFromIni(iniReader); } void WriteToIni(auto& iniWriter) { iniWriter.WriteInteger(iniSec, iniName, value, true); } - void WriteToIni() { CIniReader iniWriter(cfgPath.wstring()); iniWriter.WriteInteger(iniSec, iniName, value, true); } + void WriteToIni() { CIniReader iniWriter(cfgPath); iniWriter.WriteInteger(iniSec, iniName, value, true); } }; struct MenuPrefs @@ -134,7 +134,7 @@ public: pattern = find_pattern("89 1C 95 ? ? ? ? E8 ? ? ? ? A1 ? ? ? ? 83 C4 04 8D 04 40", "89 1C 8D ? ? ? ? E8 ? ? ? ? A1 ? ? ? ? 8D 0C 40 8B 14 CD"); mPrefs = *pattern.get_first(3); - CIniReader iniReader(cfgPath.wstring()); + CIniReader iniReader(cfgPath); static CSetting arr[] = { { 0, "PREF_SKIP_INTRO", "MAIN", "SkipIntro", "", 1, nullptr, 0, 1 }, @@ -154,7 +154,6 @@ public: { 0, "PREF_DEFINITION", "MAIN", "Definition", "MENU_DISPLAY_DEFINITION", 6, nullptr, DefinitionText.eClassic, std::distance(std::begin(DefinitionText.data), std::end(DefinitionText.data)) - 1 }, { 0, "PREF_BLOOM", "MAIN", "Bloom", "", 1, nullptr, 0, 1 }, { 0, "PREF_FPSCOUNTER", "FRAMELIMIT", "DisplayFpsCounter", "", 0, nullptr, 0, 1 }, - { 0, "PREF_ALWAYSRUN", "MISC", "AlwaysRun", "", 0, nullptr, 0, 1 }, { 0, "PREF_ALTDIALOGUE", "MISC", "AltDialogue", "", 0, nullptr, 0, 1 }, { 0, "PREF_COVERCENTERING", "MISC", "CameraCenteringInCover", "", 0, nullptr, 0, 1 }, { 0, "PREF_KBCAMCENTERDELAY", "MISC", "DelayBeforeCenteringCameraKB", "", 0, nullptr, 0, 9 }, @@ -164,7 +163,8 @@ public: { 0, "PREF_BUTTONS", "MISC", "Buttons", "MENU_DISPLAY_BUTTONS", 6, nullptr, ButtonsText.eXbox360, std::distance(std::begin(ButtonsText.data), std::end(ButtonsText.data)) - 1 }, { 0, "PREF_LETTERBOX", "MISC", "Letterbox", "", 1, nullptr, 0, 1 }, { 0, "PREF_PILLARBOX", "MISC", "Pillarbox", "", 1, nullptr, 0, 1 }, - { 0, "PREF_ANTIALIASING", "MISC", "Antialiasing", "MENU_DISPLAY_ANTIALIASING", 5, nullptr, AntialiasingText.eMO_OFF, std::distance(std::begin(AntialiasingText.data), std::end(AntialiasingText.data)) - 1 }, + { 0, "PREF_ANTIALIASING", "MISC", "Antialiasing", "MENU_DISPLAY_ANTIALIASING", 1, nullptr, AntialiasingText.eMO_OFF, std::distance(std::begin(AntialiasingText.data), std::end(AntialiasingText.data)) - 1 }, + { 0, "PREF_ALWAYSRUN", "MISC", "AlwaysRun", "MENU_DISPLAY_ALWAYSRUN", 3, nullptr, AlwaysRunText.eMO_OFF, std::distance(std::begin(AlwaysRunText.data), std::end(AlwaysRunText.data)) - 1 }, }; auto i = firstCustomID; @@ -382,6 +382,12 @@ public: std::vector data = { "Low", "Medium", "High", "Very High", "Highest", "MO_OFF", "FXAA", "SMAA" }; } AntialiasingText; + struct + { + enum eAlwaysRunText { eLow, eMedium, eHigh, eMO_OFF, eMO_ON, eOutside }; + std::vector data = { "Low", "Medium", "High", "MO_OFF", "MO_ON", "Outside" }; + } AlwaysRunText; + } FusionFixSettings; class Settings