config: Organize config files into directories
Keeps the config folder a little neater. Moves config files from the old location to the new one if able. A nice-to-have, especially when per-game input configs take their own file later.
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <array>
|
||||
#include <QKeySequence>
|
||||
#include <QSettings>
|
||||
#include "common/common_paths.h"
|
||||
#include "common/file_util.h"
|
||||
#include "configure_input_simple.h"
|
||||
#include "core/hle/service/acc/profile_manager.h"
|
||||
@@ -13,10 +14,28 @@
|
||||
#include "input_common/udp/client.h"
|
||||
#include "yuzu/configuration/config.h"
|
||||
|
||||
Config::Config(const std::string& config_file, bool is_global) {
|
||||
Config::Config() {
|
||||
// TODO: Don't hardcode the path; let the frontend decide where to put the config files.
|
||||
qt_config_loc = FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + config_file;
|
||||
qt_config_loc = FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + "qt-config.ini";
|
||||
FileUtil::CreateFullPath(qt_config_loc);
|
||||
qt_config =
|
||||
std::make_unique<QSettings>(QString::fromStdString(qt_config_loc), QSettings::IniFormat);
|
||||
Reload();
|
||||
}
|
||||
|
||||
Config::Config(u64 title_id, bool is_global) {
|
||||
// TODO: Ditto
|
||||
std::string old_filename = fmt::format(
|
||||
"{}{:016X}.ini", FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir), title_id);
|
||||
qt_config_loc = fmt::format("{}custom" DIR_SEP "{:016X}" DIR_SEP "qt-config.ini",
|
||||
FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir), title_id);
|
||||
FileUtil::CreateFullPath(qt_config_loc);
|
||||
if (FileUtil::Exists(old_filename)) {
|
||||
FileUtil::Copy(old_filename, qt_config_loc);
|
||||
if (FileUtil::Exists(qt_config_loc)) {
|
||||
FileUtil::Delete(old_filename);
|
||||
}
|
||||
}
|
||||
qt_config =
|
||||
std::make_unique<QSettings>(QString::fromStdString(qt_config_loc), QSettings::IniFormat);
|
||||
global = is_global;
|
||||
|
||||
@@ -16,7 +16,8 @@ class QSettings;
|
||||
|
||||
class Config {
|
||||
public:
|
||||
explicit Config(const std::string& config_loc = "qt-config.ini", bool is_global = true);
|
||||
explicit Config();
|
||||
explicit Config(u64 title_id, bool is_global);
|
||||
~Config();
|
||||
|
||||
void Reload();
|
||||
@@ -109,7 +110,7 @@ private:
|
||||
std::unique_ptr<QSettings> qt_config;
|
||||
std::string qt_config_loc;
|
||||
|
||||
bool global;
|
||||
bool global{true};
|
||||
};
|
||||
|
||||
// These metatype declarations cannot be in core/settings.h because core is devoid of QT
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id)
|
||||
: QDialog(parent), ui(std::make_unique<Ui::ConfigurePerGame>()), title_id(title_id) {
|
||||
game_config = std::make_unique<Config>(fmt::format("{:016X}.ini", title_id), false);
|
||||
game_config = std::make_unique<Config>(title_id, false);
|
||||
|
||||
Settings::configuring_global = false;
|
||||
|
||||
|
||||
@@ -1063,7 +1063,7 @@ void GMainWindow::BootGame(const QString& filename) {
|
||||
const auto loader = Loader::GetLoader(v_file);
|
||||
if (!(loader == nullptr || loader->ReadProgramId(title_id) != Loader::ResultStatus::Success)) {
|
||||
// Load per game settings
|
||||
Config per_game_config(fmt::format("{:016X}.ini", title_id), false);
|
||||
Config per_game_config(title_id, false);
|
||||
}
|
||||
|
||||
Settings::LogSettings();
|
||||
|
||||
Reference in New Issue
Block a user