Merge pull request #14114 from jordan-woyak/freelook-config-cleanup

Core: Eliminate FreeLookConfig by putting the "active config" within FreeLookCamera.
This commit is contained in:
JMC47
2025-12-22 13:30:12 -05:00
committed by GitHub
10 changed files with 30 additions and 146 deletions
+14 -18
View File
@@ -4,18 +4,13 @@
#include "VideoCommon/FreeLookCamera.h"
#include <algorithm>
#include <math.h>
#include <fmt/format.h>
#include "Common/MathUtil.h"
#include "Common/ChunkFile.h"
#include "Core/ConfigManager.h"
#include "Common/Config/Config.h"
#include "Core/Core.h"
#include "VideoCommon/VideoCommon.h"
FreeLookCamera g_freelook_camera;
namespace
@@ -260,21 +255,18 @@ float CameraControllerInput::GetSpeed() const
FreeLookCamera::FreeLookCamera()
{
SetControlType(FreeLook::ControlType::SixAxis);
RefreshConfig();
}
void FreeLookCamera::SetControlType(FreeLook::ControlType type)
void FreeLookCamera::RefreshConfig()
{
if (m_current_type && *m_current_type == type)
{
return;
}
m_is_enabled = Config::Get(Config::FREE_LOOK_ENABLED);
const auto type = Config::Get(Config::FL1_CONTROL_TYPE);
if (type == FreeLook::ControlType::SixAxis)
{
m_camera_controller = std::make_unique<SixAxisController>();
}
else if (type == FreeLook::ControlType::Orbital)
if (m_current_type == type)
return;
if (type == FreeLook::ControlType::Orbital)
{
m_camera_controller = std::make_unique<OrbitalController>();
}
@@ -282,6 +274,10 @@ void FreeLookCamera::SetControlType(FreeLook::ControlType type)
{
m_camera_controller = std::make_unique<FPSController>();
}
else
{
m_camera_controller = std::make_unique<SixAxisController>();
}
m_current_type = type;
}
@@ -330,7 +326,7 @@ void FreeLookCamera::DoState(PointerWrap& p)
bool FreeLookCamera::IsActive() const
{
return FreeLook::GetActiveConfig().enabled;
return m_is_enabled;
}
CameraController* FreeLookCamera::GetController() const
+7 -3
View File
@@ -7,7 +7,7 @@
#include <optional>
#include "Common/Matrix.h"
#include "Core/FreeLookConfig.h"
#include "Core/Config/FreeLookSettings.h"
class PointerWrap;
@@ -79,7 +79,9 @@ class FreeLookCamera
{
public:
FreeLookCamera();
void SetControlType(FreeLook::ControlType type);
void RefreshConfig();
Common::Matrix44 GetView() const;
Common::Vec2 GetFieldOfViewMultiplier() const;
@@ -90,8 +92,10 @@ public:
CameraController* GetController() const;
private:
std::optional<FreeLook::ControlType> m_current_type;
std::unique_ptr<CameraController> m_camera_controller;
bool m_is_enabled{};
std::optional<FreeLook::ControlType> m_current_type;
};
extern FreeLookCamera g_freelook_camera;
+1 -2
View File
@@ -305,10 +305,9 @@ void CheckForConfigChanges()
const auto old_hdr = g_ActiveConfig.bHDR;
UpdateActiveConfig();
FreeLook::UpdateActiveConfig();
g_vertex_manager->OnConfigChange();
g_freelook_camera.SetControlType(FreeLook::GetActiveConfig().camera_config.control_type);
g_freelook_camera.RefreshConfig();
if (g_ActiveConfig.bGraphicMods && !old_graphics_mods_enabled)
{