mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-03 19:42:45 +01:00
22aa88109f
This lets us reduce the number of USE_RETRO_ACHIEVEMENTS ifdefs in the code base, reducing visual clutter. In particular, needing an ifdef for each call to IsHardcodeModeActive was annoying to me. This also reduces the risk that someone writes code that accidentally fails to compile with USE_RETRO_ACHIEVEMENTS disabled. We could cut down on ifdefs even further by making HardcodeWarningWidget always exist, but that would result in non-trivial code ending up in the binary even with USE_RETRO_ACHIEVEMENTS disabled, so I'm leaving it out of this PR. It's not a lot of code though, so I might end up revisiting it at some point.
53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
// Copyright 2020 Dolphin Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include "Core/FreeLookConfig.h"
|
|
|
|
#include "Core/AchievementManager.h"
|
|
#include "Core/CPUThreadConfigCallback.h"
|
|
#include "Core/Config/AchievementSettings.h"
|
|
#include "Core/Config/FreeLookSettings.h"
|
|
#include "Core/ConfigManager.h"
|
|
#include "Core/Core.h"
|
|
|
|
namespace FreeLook
|
|
{
|
|
static Config s_config;
|
|
static Config s_active_config;
|
|
static bool s_has_registered_callback = false;
|
|
|
|
Config& GetConfig()
|
|
{
|
|
return s_config;
|
|
}
|
|
|
|
const Config& GetActiveConfig()
|
|
{
|
|
return s_active_config;
|
|
}
|
|
|
|
void UpdateActiveConfig()
|
|
{
|
|
s_active_config = s_config;
|
|
}
|
|
|
|
Config::Config()
|
|
{
|
|
camera_config.control_type = ControlType::SixAxis;
|
|
enabled = false;
|
|
}
|
|
|
|
void Config::Refresh()
|
|
{
|
|
if (!s_has_registered_callback)
|
|
{
|
|
CPUThreadConfigCallback::AddConfigChangedCallback([] { s_config.Refresh(); });
|
|
s_has_registered_callback = true;
|
|
}
|
|
|
|
camera_config.control_type = ::Config::Get(::Config::FL1_CONTROL_TYPE);
|
|
enabled = ::Config::Get(::Config::FREE_LOOK_ENABLED) &&
|
|
!AchievementManager::GetInstance().IsHardcoreModeActive();
|
|
}
|
|
} // namespace FreeLook
|