Core: Eliminate FreeLookConfig by putting the "active config" within FreeLookCamera.

This commit is contained in:
Jordan Woyak
2025-11-12 18:01:53 -06:00
parent c08fda96ca
commit be95035cc4
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