mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-01-31 01:15:17 +01:00
Core/ConfigLoaders: Refactor GetGameIniFilenames
This commit is contained in:
@@ -3,13 +3,12 @@
|
|||||||
|
|
||||||
#include "Core/ConfigLoaders/GameConfigLoader.h"
|
#include "Core/ConfigLoaders/GameConfigLoader.h"
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <list>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -22,7 +21,6 @@
|
|||||||
#include "Common/IniFile.h"
|
#include "Common/IniFile.h"
|
||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
#include "Common/MsgHandler.h"
|
#include "Common/MsgHandler.h"
|
||||||
#include "Common/StringUtil.h"
|
|
||||||
|
|
||||||
#include "Core/Config/MainSettings.h"
|
#include "Core/Config/MainSettings.h"
|
||||||
#include "Core/Config/SYSCONFSettings.h"
|
#include "Core/Config/SYSCONFSettings.h"
|
||||||
@@ -32,7 +30,7 @@
|
|||||||
namespace ConfigLoaders
|
namespace ConfigLoaders
|
||||||
{
|
{
|
||||||
// Returns all possible filenames in ascending order of priority
|
// Returns all possible filenames in ascending order of priority
|
||||||
std::vector<std::string> GetGameIniFilenames(const std::string& id, std::optional<u16> revision)
|
std::vector<std::string> GetGameIniFilenames(std::string_view id, std::optional<u16> revision)
|
||||||
{
|
{
|
||||||
std::vector<std::string> filenames;
|
std::vector<std::string> filenames;
|
||||||
|
|
||||||
@@ -44,18 +42,18 @@ std::vector<std::string> GetGameIniFilenames(const std::string& id, std::optiona
|
|||||||
if (id.length() == 6)
|
if (id.length() == 6)
|
||||||
{
|
{
|
||||||
// INIs that match the system code (unique for each Virtual Console system)
|
// INIs that match the system code (unique for each Virtual Console system)
|
||||||
filenames.push_back(id.substr(0, 1) + ".ini");
|
filenames.push_back(fmt::format("{}.ini", id.substr(0, 1)));
|
||||||
|
|
||||||
// INIs that match all regions
|
// INIs that match all regions
|
||||||
filenames.push_back(id.substr(0, 3) + ".ini");
|
filenames.push_back(fmt::format("{}.ini", id.substr(0, 3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regular INIs
|
// Regular INIs
|
||||||
filenames.push_back(id + ".ini");
|
filenames.push_back(fmt::format("{}.ini", id));
|
||||||
|
|
||||||
// INIs with specific revisions
|
// INIs with specific revisions
|
||||||
if (revision)
|
if (revision)
|
||||||
filenames.push_back(id + fmt::format("r{}", *revision) + ".ini");
|
filenames.push_back(fmt::format("{}r{}.ini", id, *revision));
|
||||||
|
|
||||||
return filenames;
|
return filenames;
|
||||||
}
|
}
|
||||||
@@ -313,7 +311,7 @@ void INIGameConfigLayerLoader::Save(Config::Layer* layer)
|
|||||||
|
|
||||||
// Try to save to the revision specific INI first, if it exists.
|
// Try to save to the revision specific INI first, if it exists.
|
||||||
const std::string gameini_with_rev =
|
const std::string gameini_with_rev =
|
||||||
File::GetUserPath(D_GAMESETTINGS_IDX) + m_id + fmt::format("r{}", m_revision) + ".ini";
|
fmt::format("{}{}r{}.ini", File::GetUserPath(D_GAMESETTINGS_IDX), m_id, m_revision);
|
||||||
if (File::Exists(gameini_with_rev))
|
if (File::Exists(gameini_with_rev))
|
||||||
{
|
{
|
||||||
ini.Save(gameini_with_rev);
|
ini.Save(gameini_with_rev);
|
||||||
@@ -322,7 +320,7 @@ void INIGameConfigLayerLoader::Save(Config::Layer* layer)
|
|||||||
|
|
||||||
// Otherwise, save to the game INI. We don't try any INI broader than that because it will
|
// Otherwise, save to the game INI. We don't try any INI broader than that because it will
|
||||||
// likely cause issues with cheat codes and game patches.
|
// likely cause issues with cheat codes and game patches.
|
||||||
const std::string gameini = File::GetUserPath(D_GAMESETTINGS_IDX) + m_id + ".ini";
|
const std::string gameini = fmt::format("{}{}.ini", File::GetUserPath(D_GAMESETTINGS_IDX), m_id);
|
||||||
ini.Save(gameini);
|
ini.Save(gameini);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <string_view>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
@@ -18,7 +18,7 @@ class ConfigLayerLoader;
|
|||||||
|
|
||||||
namespace ConfigLoaders
|
namespace ConfigLoaders
|
||||||
{
|
{
|
||||||
std::vector<std::string> GetGameIniFilenames(const std::string& id, std::optional<u16> revision);
|
std::vector<std::string> GetGameIniFilenames(std::string_view id, std::optional<u16> revision);
|
||||||
|
|
||||||
std::unique_ptr<Config::ConfigLayerLoader> GenerateGlobalGameConfigLoader(const std::string& id,
|
std::unique_ptr<Config::ConfigLayerLoader> GenerateGlobalGameConfigLoader(const std::string& id,
|
||||||
u16 revision);
|
u16 revision);
|
||||||
|
|||||||
Reference in New Issue
Block a user