Config: Port remaining General settings to new config system.
This commit is contained in:
parent
8dd803bf2b
commit
d590aa88a4
|
@ -10,6 +10,7 @@
|
|||
#include "AudioCommon/AudioCommon.h"
|
||||
#include "Common/CommonPaths.h"
|
||||
#include "Common/Config/Config.h"
|
||||
#include "Common/MathUtil.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Common/Version.h"
|
||||
#include "Core/Config/DefaultLocale.h"
|
||||
|
@ -163,6 +164,59 @@ const Info<std::string> MAIN_RESOURCEPACK_PATH{{System::Main, "General", "Resour
|
|||
const Info<std::string> MAIN_FS_PATH{{System::Main, "General", "NANDRootPath"}, ""};
|
||||
const Info<std::string> MAIN_SD_PATH{{System::Main, "General", "WiiSDCardPath"}, ""};
|
||||
const Info<std::string> MAIN_WFS_PATH{{System::Main, "General", "WFSPath"}, ""};
|
||||
const Info<bool> MAIN_SHOW_LAG{{System::Main, "General", "ShowLag"}, false};
|
||||
const Info<bool> MAIN_SHOW_FRAME_COUNT{{System::Main, "General", "ShowFrameCount"}, false};
|
||||
const Info<std::string> MAIN_WIRELESS_MAC{{System::Main, "General", "WirelessMac"}, ""};
|
||||
const Info<std::string> MAIN_GDB_SOCKET{{System::Main, "General", "GDBSocket"}, ""};
|
||||
const Info<int> MAIN_GDB_PORT{{System::Main, "General", "GDBPort"}, -1};
|
||||
const Info<int> MAIN_ISO_PATH_COUNT{{System::Main, "General", "ISOPaths"}, 0};
|
||||
|
||||
static Info<std::string> MakeISOPathConfigInfo(size_t idx)
|
||||
{
|
||||
return Config::Info<std::string>{{Config::System::Main, "General", fmt::format("ISOPath{}", idx)},
|
||||
""};
|
||||
}
|
||||
|
||||
std::vector<std::string> GetIsoPaths()
|
||||
{
|
||||
size_t count = MathUtil::SaturatingCast<size_t>(Config::Get(Config::MAIN_ISO_PATH_COUNT));
|
||||
std::vector<std::string> paths;
|
||||
paths.reserve(count);
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
{
|
||||
std::string iso_path = Config::Get(MakeISOPathConfigInfo(i));
|
||||
if (!iso_path.empty())
|
||||
paths.emplace_back(std::move(iso_path));
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
|
||||
void SetIsoPaths(const std::vector<std::string>& paths)
|
||||
{
|
||||
size_t old_size = MathUtil::SaturatingCast<size_t>(Config::Get(Config::MAIN_ISO_PATH_COUNT));
|
||||
size_t new_size = paths.size();
|
||||
|
||||
size_t current_path_idx = 0;
|
||||
for (const std::string& p : paths)
|
||||
{
|
||||
if (p.empty())
|
||||
{
|
||||
--new_size;
|
||||
continue;
|
||||
}
|
||||
|
||||
Config::SetBase(MakeISOPathConfigInfo(current_path_idx), p);
|
||||
++current_path_idx;
|
||||
}
|
||||
|
||||
for (size_t i = current_path_idx; i < old_size; ++i)
|
||||
{
|
||||
// TODO: This actually needs a Config::Erase().
|
||||
Config::SetBase(MakeISOPathConfigInfo(i), "");
|
||||
}
|
||||
|
||||
Config::SetBase(Config::MAIN_ISO_PATH_COUNT, MathUtil::SaturatingCast<int>(new_size));
|
||||
}
|
||||
|
||||
// Main.GBA
|
||||
|
||||
|
|
|
@ -141,6 +141,14 @@ extern const Info<std::string> MAIN_RESOURCEPACK_PATH;
|
|||
extern const Info<std::string> MAIN_FS_PATH;
|
||||
extern const Info<std::string> MAIN_SD_PATH;
|
||||
extern const Info<std::string> MAIN_WFS_PATH;
|
||||
extern const Info<bool> MAIN_SHOW_LAG;
|
||||
extern const Info<bool> MAIN_SHOW_FRAME_COUNT;
|
||||
extern const Info<std::string> MAIN_WIRELESS_MAC;
|
||||
extern const Info<std::string> MAIN_GDB_SOCKET;
|
||||
extern const Info<int> MAIN_GDB_PORT;
|
||||
extern const Info<int> MAIN_ISO_PATH_COUNT;
|
||||
std::vector<std::string> GetIsoPaths();
|
||||
void SetIsoPaths(const std::vector<std::string>& paths);
|
||||
|
||||
// Main.GBA
|
||||
|
||||
|
|
|
@ -88,7 +88,6 @@ void SConfig::SaveSettings()
|
|||
IniFile ini;
|
||||
ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)); // load first to not kill unknown stuff
|
||||
|
||||
SaveGeneralSettings(ini);
|
||||
SaveCoreSettings(ini);
|
||||
|
||||
ini.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
||||
|
@ -96,38 +95,6 @@ void SConfig::SaveSettings()
|
|||
Config::Save();
|
||||
}
|
||||
|
||||
void SConfig::SaveGeneralSettings(IniFile& ini)
|
||||
{
|
||||
IniFile::Section* general = ini.GetOrCreateSection("General");
|
||||
|
||||
// General
|
||||
general->Set("ShowLag", m_ShowLag);
|
||||
general->Set("ShowFrameCount", m_ShowFrameCount);
|
||||
|
||||
// ISO folders
|
||||
// Clear removed folders
|
||||
int oldPaths;
|
||||
int numPaths = (int)m_ISOFolder.size();
|
||||
general->Get("ISOPaths", &oldPaths, 0);
|
||||
for (int i = numPaths; i < oldPaths; i++)
|
||||
{
|
||||
ini.DeleteKey("General", fmt::format("ISOPath{}", i));
|
||||
}
|
||||
|
||||
general->Set("ISOPaths", numPaths);
|
||||
for (int i = 0; i < numPaths; i++)
|
||||
{
|
||||
general->Set(fmt::format("ISOPath{}", i), m_ISOFolder[i]);
|
||||
}
|
||||
|
||||
general->Set("WirelessMac", m_WirelessMac);
|
||||
|
||||
#ifndef _WIN32
|
||||
general->Set("GDBSocket", gdb_socket);
|
||||
#endif
|
||||
general->Set("GDBPort", iGDBPort);
|
||||
}
|
||||
|
||||
void SConfig::SaveCoreSettings(IniFile& ini)
|
||||
{
|
||||
IniFile::Section* core = ini.GetOrCreateSection("Core");
|
||||
|
@ -185,37 +152,9 @@ void SConfig::LoadSettings()
|
|||
IniFile ini;
|
||||
ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX));
|
||||
|
||||
LoadGeneralSettings(ini);
|
||||
LoadCoreSettings(ini);
|
||||
}
|
||||
|
||||
void SConfig::LoadGeneralSettings(IniFile& ini)
|
||||
{
|
||||
IniFile::Section* general = ini.GetOrCreateSection("General");
|
||||
|
||||
general->Get("ShowLag", &m_ShowLag, false);
|
||||
general->Get("ShowFrameCount", &m_ShowFrameCount, false);
|
||||
#ifndef _WIN32
|
||||
general->Get("GDBSocket", &gdb_socket, "");
|
||||
#endif
|
||||
general->Get("GDBPort", &(iGDBPort), -1);
|
||||
|
||||
m_ISOFolder.clear();
|
||||
int numISOPaths;
|
||||
|
||||
if (general->Get("ISOPaths", &numISOPaths, 0))
|
||||
{
|
||||
for (int i = 0; i < numISOPaths; i++)
|
||||
{
|
||||
std::string tmpPath;
|
||||
general->Get(fmt::format("ISOPath{}", i), &tmpPath, "");
|
||||
m_ISOFolder.push_back(std::move(tmpPath));
|
||||
}
|
||||
}
|
||||
|
||||
general->Get("WirelessMac", &m_WirelessMac);
|
||||
}
|
||||
|
||||
void SConfig::LoadCoreSettings(IniFile& ini)
|
||||
{
|
||||
IniFile::Section* core = ini.GetOrCreateSection("Core");
|
||||
|
@ -392,11 +331,6 @@ void SConfig::LoadDefaults()
|
|||
bAutomaticStart = false;
|
||||
bBootToPause = false;
|
||||
|
||||
iGDBPort = -1;
|
||||
#ifndef _WIN32
|
||||
gdb_socket = "";
|
||||
#endif
|
||||
|
||||
cpu_core = PowerPC::DefaultCPUCore();
|
||||
iTimingVariance = 40;
|
||||
bCPUThread = false;
|
||||
|
|
|
@ -65,14 +65,7 @@ struct SConfig
|
|||
bool m_WiimoteEnableSpeaker;
|
||||
bool connect_wiimotes_for_ciface;
|
||||
|
||||
// ISO folder
|
||||
std::vector<std::string> m_ISOFolder;
|
||||
|
||||
// Settings
|
||||
int iGDBPort;
|
||||
#ifndef _WIN32
|
||||
std::string gdb_socket;
|
||||
#endif
|
||||
bool bAutomaticStart = false;
|
||||
bool bBootToPause = false;
|
||||
|
||||
|
@ -180,10 +173,6 @@ struct SConfig
|
|||
|
||||
float m_EmulationSpeed;
|
||||
|
||||
std::string m_WirelessMac;
|
||||
bool m_ShowLag;
|
||||
bool m_ShowFrameCount;
|
||||
|
||||
// Input settings
|
||||
bool m_AdapterRumble[4];
|
||||
bool m_AdapterKonga[4];
|
||||
|
@ -208,10 +197,8 @@ private:
|
|||
SConfig();
|
||||
~SConfig();
|
||||
|
||||
void SaveGeneralSettings(IniFile& ini);
|
||||
void SaveCoreSettings(IniFile& ini);
|
||||
|
||||
void LoadGeneralSettings(IniFile& ini);
|
||||
void LoadCoreSettings(IniFile& ini);
|
||||
|
||||
void SetRunningGameMetadata(const std::string& game_id, const std::string& gametdb_id,
|
||||
|
|
|
@ -363,22 +363,28 @@ static void CpuThread(const std::optional<std::string>& savestate_path, bool del
|
|||
}
|
||||
|
||||
s_is_started = true;
|
||||
{
|
||||
#ifndef _WIN32
|
||||
if (!_CoreParameter.gdb_socket.empty())
|
||||
{
|
||||
GDBStub::InitLocal(_CoreParameter.gdb_socket.data());
|
||||
CPUSetInitialExecutionState(true);
|
||||
}
|
||||
else
|
||||
std::string gdb_socket = Config::Get(Config::MAIN_GDB_SOCKET);
|
||||
if (!gdb_socket.empty())
|
||||
{
|
||||
GDBStub::InitLocal(gdb_socket.data());
|
||||
CPUSetInitialExecutionState(true);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (_CoreParameter.iGDBPort > 0)
|
||||
{
|
||||
GDBStub::Init(_CoreParameter.iGDBPort);
|
||||
CPUSetInitialExecutionState(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
CPUSetInitialExecutionState();
|
||||
{
|
||||
int gdb_port = Config::Get(Config::MAIN_GDB_PORT);
|
||||
if (gdb_port > 0)
|
||||
{
|
||||
GDBStub::Init(gdb_port);
|
||||
CPUSetInitialExecutionState(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
CPUSetInitialExecutionState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Enter CPU run loop. When we leave it - we are done.
|
||||
|
|
|
@ -10,22 +10,22 @@
|
|||
#include "Common/Logging/Log.h"
|
||||
#include "Common/Network.h"
|
||||
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Config/MainSettings.h"
|
||||
#include "Core/Core.h"
|
||||
|
||||
namespace IOS::Net
|
||||
{
|
||||
static void SaveMACAddress(const Common::MACAddress& mac)
|
||||
{
|
||||
SConfig::GetInstance().m_WirelessMac = Common::MacAddressToString(mac);
|
||||
SConfig::GetInstance().SaveSettings();
|
||||
Config::SetBaseOrCurrent(Config::MAIN_WIRELESS_MAC, Common::MacAddressToString(mac));
|
||||
Config::Save();
|
||||
}
|
||||
|
||||
Common::MACAddress GetMACAddress()
|
||||
{
|
||||
// Parse MAC address from config, and generate a new one if it doesn't
|
||||
// exist or can't be parsed.
|
||||
std::string wireless_mac = SConfig::GetInstance().m_WirelessMac;
|
||||
std::string wireless_mac = Config::Get(Config::MAIN_WIRELESS_MAC);
|
||||
|
||||
if (Core::WantsDeterminism())
|
||||
wireless_mac = "12:34:56:78:9a:bc";
|
||||
|
|
|
@ -191,7 +191,7 @@ void PCAPSSLCaptureLogger::LogIPv4(LogType log_type, const u8* data, u16 length,
|
|||
};
|
||||
|
||||
Common::EthernetHeader ethernet_header(0x800);
|
||||
auto mac = Common::StringToMacAddress(SConfig::GetInstance().m_WirelessMac);
|
||||
auto mac = Common::StringToMacAddress(Config::Get(Config::MAIN_WIRELESS_MAC));
|
||||
if (mac)
|
||||
{
|
||||
auto& mac_address =
|
||||
|
|
|
@ -758,15 +758,15 @@ void MenuBar::AddMovieMenu()
|
|||
|
||||
auto* lag_counter = movie_menu->addAction(tr("Show Lag Counter"));
|
||||
lag_counter->setCheckable(true);
|
||||
lag_counter->setChecked(SConfig::GetInstance().m_ShowLag);
|
||||
lag_counter->setChecked(Config::Get(Config::MAIN_SHOW_LAG));
|
||||
connect(lag_counter, &QAction::toggled,
|
||||
[](bool value) { SConfig::GetInstance().m_ShowLag = value; });
|
||||
[](bool value) { Config::SetBaseOrCurrent(Config::MAIN_SHOW_LAG, value); });
|
||||
|
||||
auto* frame_counter = movie_menu->addAction(tr("Show Frame Counter"));
|
||||
frame_counter->setCheckable(true);
|
||||
frame_counter->setChecked(SConfig::GetInstance().m_ShowFrameCount);
|
||||
frame_counter->setChecked(Config::Get(Config::MAIN_SHOW_FRAME_COUNT));
|
||||
connect(frame_counter, &QAction::toggled,
|
||||
[](bool value) { SConfig::GetInstance().m_ShowFrameCount = value; });
|
||||
[](bool value) { Config::SetBaseOrCurrent(Config::MAIN_SHOW_FRAME_COUNT, value); });
|
||||
|
||||
auto* input_display = movie_menu->addAction(tr("Show Input Display"));
|
||||
input_display->setCheckable(true);
|
||||
|
|
|
@ -216,7 +216,7 @@ void Settings::GetToolTipStyle(QColor& window_color, QColor& text_color,
|
|||
QStringList Settings::GetPaths() const
|
||||
{
|
||||
QStringList list;
|
||||
for (const auto& path : SConfig::GetInstance().m_ISOFolder)
|
||||
for (const auto& path : Config::GetIsoPaths())
|
||||
list << QString::fromStdString(path);
|
||||
return list;
|
||||
}
|
||||
|
@ -224,25 +224,27 @@ QStringList Settings::GetPaths() const
|
|||
void Settings::AddPath(const QString& qpath)
|
||||
{
|
||||
std::string path = qpath.toStdString();
|
||||
std::vector<std::string> paths = Config::GetIsoPaths();
|
||||
|
||||
std::vector<std::string>& paths = SConfig::GetInstance().m_ISOFolder;
|
||||
if (std::find(paths.begin(), paths.end(), path) != paths.end())
|
||||
return;
|
||||
|
||||
paths.emplace_back(path);
|
||||
Config::SetIsoPaths(paths);
|
||||
emit PathAdded(qpath);
|
||||
}
|
||||
|
||||
void Settings::RemovePath(const QString& qpath)
|
||||
{
|
||||
std::string path = qpath.toStdString();
|
||||
std::vector<std::string>& paths = SConfig::GetInstance().m_ISOFolder;
|
||||
std::vector<std::string> paths = Config::GetIsoPaths();
|
||||
|
||||
auto new_end = std::remove(paths.begin(), paths.end(), path);
|
||||
if (new_end == paths.end())
|
||||
return;
|
||||
|
||||
paths.erase(new_end, paths.end());
|
||||
Config::SetIsoPaths(paths);
|
||||
emit PathRemoved(qpath);
|
||||
}
|
||||
|
||||
|
|
|
@ -555,8 +555,6 @@ void Renderer::CheckForConfigChanges()
|
|||
// Create On-Screen-Messages
|
||||
void Renderer::DrawDebugText()
|
||||
{
|
||||
const auto& config = SConfig::GetInstance();
|
||||
|
||||
if (g_ActiveConfig.bShowFPS)
|
||||
{
|
||||
// Position in the top-right corner of the screen.
|
||||
|
@ -576,10 +574,10 @@ void Renderer::DrawDebugText()
|
|||
ImGui::End();
|
||||
}
|
||||
|
||||
const bool show_movie_window = config.m_ShowFrameCount || config.m_ShowLag ||
|
||||
Config::Get(Config::MAIN_MOVIE_SHOW_INPUT_DISPLAY) ||
|
||||
Config::Get(Config::MAIN_MOVIE_SHOW_RTC) ||
|
||||
Config::Get(Config::MAIN_MOVIE_SHOW_RERECORD);
|
||||
const bool show_movie_window =
|
||||
Config::Get(Config::MAIN_SHOW_FRAME_COUNT) || Config::Get(Config::MAIN_SHOW_LAG) ||
|
||||
Config::Get(Config::MAIN_MOVIE_SHOW_INPUT_DISPLAY) ||
|
||||
Config::Get(Config::MAIN_MOVIE_SHOW_RTC) || Config::Get(Config::MAIN_MOVIE_SHOW_RERECORD);
|
||||
if (show_movie_window)
|
||||
{
|
||||
// Position under the FPS display.
|
||||
|
@ -598,12 +596,12 @@ void Renderer::DrawDebugText()
|
|||
ImGui::Text("Input: %" PRIu64 " / %" PRIu64, Movie::GetCurrentInputCount(),
|
||||
Movie::GetTotalInputCount());
|
||||
}
|
||||
else if (config.m_ShowFrameCount)
|
||||
else if (Config::Get(Config::MAIN_SHOW_FRAME_COUNT))
|
||||
{
|
||||
ImGui::Text("Frame: %" PRIu64, Movie::GetCurrentFrame());
|
||||
ImGui::Text("Input: %" PRIu64, Movie::GetCurrentInputCount());
|
||||
}
|
||||
if (SConfig::GetInstance().m_ShowLag)
|
||||
if (Config::Get(Config::MAIN_SHOW_LAG))
|
||||
ImGui::Text("Lag: %" PRIu64 "\n", Movie::GetCurrentLagCount());
|
||||
if (Config::Get(Config::MAIN_MOVIE_SHOW_INPUT_DISPLAY))
|
||||
ImGui::TextUnformatted(Movie::GetInputDisplay().c_str());
|
||||
|
|
Loading…
Reference in New Issue