diff --git a/mods/src/config.cc b/mods/src/config.cc index be1a80525..97fc6fa76 100644 --- a/mods/src/config.cc +++ b/mods/src/config.cc @@ -1109,6 +1109,8 @@ void Config::Load() this->system_pan_momentum_falloff = get_config_or_default(config, parsed, "graphics", "system_pan_momentum_falloff", DCG::system_pan_momentum_falloff, write_log); + this->disable_target_camera_lock = get_config_or_default(config, parsed, "graphics", "disable_target_camera_lock", + DCG::disable_target_camera_lock, write_log); this->borderless_fullscreen = get_config_or_default(config, parsed, "graphics", "borderless_fullscreen", DCG::borderless_fullscreen, write_log); this->transition_time = diff --git a/mods/src/config.h b/mods/src/config.h index 2817d1616..33aeabb6a 100644 --- a/mods/src/config.h +++ b/mods/src/config.h @@ -188,6 +188,7 @@ class Config final bool use_out_of_dock_power; float system_pan_momentum; float system_pan_momentum_falloff; + bool disable_target_camera_lock; float keyboard_zoom_speed; int select_timer; diff --git a/mods/src/defaultconfig.h b/mods/src/defaultconfig.h index ac58ef8b0..86a0f71d5 100644 --- a/mods/src/defaultconfig.h +++ b/mods/src/defaultconfig.h @@ -49,6 +49,7 @@ namespace Graphics constexpr bool free_resize = true; constexpr auto keyboard_zoom_speed = 350; constexpr auto system_pan_momentum_falloff = 0.8; + constexpr bool disable_target_camera_lock = false; constexpr auto system_pan_momentum = 0.4; constexpr auto system_zoom_preset_1 = 50; constexpr auto system_zoom_preset_2 = 500; diff --git a/mods/src/patches/parts/fix_pan.cc b/mods/src/patches/parts/fix_pan.cc index 174e9da7d..2bef8c411 100644 --- a/mods/src/patches/parts/fix_pan.cc +++ b/mods/src/patches/parts/fix_pan.cc @@ -42,11 +42,15 @@ bool KeyboardPanAllowed() bool NavigationPan_LateUpdate_Hook(auto original, NavigationPan* _this) { auto d = _this->_lastDelta; + const auto& config = Config::Get(); + const bool disable_target_camera_lock = config.disable_target_camera_lock; + if (disable_target_camera_lock && _this->_trackingPOI) { + _this->_trackingPOI = nullptr; + } static auto GetMouseButton = il2cpp_resolve_icall_typed("UnityEngine.Input::GetMouseButton(System.Int32)"); static auto GetTouchCount = il2cpp_resolve_icall_typed("UnityEngine.Input::get_touchCount()"); - const auto& config = Config::Get(); if (!config.disable_move_keys && config.hotkeys_enabled && !Key::IsDirectionalInputClaimed()) { if (config.use_scopely_hotkeys || !config.installHotkeyHooks) { original(_this); @@ -64,7 +68,7 @@ bool NavigationPan_LateUpdate_Hook(auto original, NavigationPan* _this) } } - if (_this->BlockPan() || _this->_trackingPOI) { + if (_this->BlockPan() || (_this->_trackingPOI && !disable_target_camera_lock)) { d->x = 0.0f; d->y = 0.0f; } else if (GetMouseButton(0) || GetTouchCount() > 0) { diff --git a/mods/src/prime/NavigationPan.h b/mods/src/prime/NavigationPan.h index 0d239dcc0..262adeb50 100644 --- a/mods/src/prime/NavigationPan.h +++ b/mods/src/prime/NavigationPan.h @@ -15,7 +15,7 @@ struct NavigationPan { __declspec(property(get = __get__lastDelta)) Vector2* _lastDelta; __declspec(property(get = __get__deltaScaler)) float _deltaScaler; __declspec(property(get = __get__keyboardDeltaScaler)) float _keyboardDeltaScaler; - __declspec(property(get = __get__trackingPOI)) uintptr_t* _trackingPOI; + __declspec(property(get = __get__trackingPOI, put = __set__trackingPOI)) uintptr_t* _trackingPOI; __declspec(property(get = __get__farMagRadiusRatioSystemNormal, put = __set__farMagRadiusRatioSystemNormal)) float _farMagRadiusRatioSystemNormal; @@ -48,6 +48,12 @@ struct NavigationPan { return *(uintptr_t**)((ptrdiff_t)this + field.offset()); } + void __set__trackingPOI(uintptr_t* value) + { + static auto field = get_class_helper().GetField("_trackingPOI"); + *(uintptr_t**)((ptrdiff_t)this + field.offset()) = value; + } + Vector2* __get__lastDelta() { static auto field = get_class_helper().GetField("_lastDelta");