Compare commits

...

5 Commits

Author SHA1 Message Date
lat9nq
6543187b3c main: Actively move all configs to new directory
Rather than move a config whenever the user opens the properties or starts a game, this just moves everything in one go.

Co-Authored-By: Morph <morph1984@users.noreply.github.com>
2020-07-23 03:23:41 -04:00
lat9nq
3046baf297 config: Drop passive migration code
Removed in favor of actively moving all config files at once.
2020-07-23 02:06:57 -04:00
lat9nq
519e1177ff config: Target custom/[title id].ini instead
Input profiles supersedes and far simplifies my original plans, so there's no need for a directory for each game.
2020-07-22 23:42:32 -04:00
lat9nq
bf7d064545 config: Improve comments
Also reorganizes the code a bit to make it more clear what needs removed.

Co-Authored-By: LC <lioncash@users.noreply.github.com>
2020-07-22 18:37:29 -04:00
lat9nq
6f0d192a2f 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.
2020-07-22 17:41:31 -04:00
5 changed files with 44 additions and 6 deletions

View File

@@ -5,6 +5,7 @@
#include <array> #include <array>
#include <QKeySequence> #include <QKeySequence>
#include <QSettings> #include <QSettings>
#include "common/common_paths.h"
#include "common/file_util.h" #include "common/file_util.h"
#include "configure_input_simple.h" #include "configure_input_simple.h"
#include "core/hle/service/acc/profile_manager.h" #include "core/hle/service/acc/profile_manager.h"
@@ -13,9 +14,19 @@
#include "input_common/udp/client.h" #include "input_common/udp/client.h"
#include "yuzu/configuration/config.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. // 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: Don't hardcode the path; let the frontend decide where to put the config files.
qt_config_loc = fmt::format("{}custom" DIR_SEP "{:016X}.ini",
FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir), title_id);
FileUtil::CreateFullPath(qt_config_loc); FileUtil::CreateFullPath(qt_config_loc);
qt_config = qt_config =
std::make_unique<QSettings>(QString::fromStdString(qt_config_loc), QSettings::IniFormat); std::make_unique<QSettings>(QString::fromStdString(qt_config_loc), QSettings::IniFormat);

View File

@@ -16,7 +16,8 @@ class QSettings;
class Config { class Config {
public: 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(); ~Config();
void Reload(); void Reload();
@@ -109,7 +110,7 @@ private:
std::unique_ptr<QSettings> qt_config; std::unique_ptr<QSettings> qt_config;
std::string qt_config_loc; 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 // These metatype declarations cannot be in core/settings.h because core is devoid of QT

View File

@@ -29,7 +29,7 @@
ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id) ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id)
: QDialog(parent), ui(std::make_unique<Ui::ConfigurePerGame>()), title_id(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; Settings::configuring_global = false;

View File

@@ -47,6 +47,7 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
#include <QDesktopServices> #include <QDesktopServices>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QDir>
#include <QFile> #include <QFile>
#include <QFileDialog> #include <QFileDialog>
#include <QInputDialog> #include <QInputDialog>
@@ -274,6 +275,8 @@ GMainWindow::GMainWindow()
if (args.length() >= 2) { if (args.length() >= 2) {
BootGame(args[1]); BootGame(args[1]);
} }
MigrateConfigFiles();
} }
GMainWindow::~GMainWindow() { GMainWindow::~GMainWindow() {
@@ -1063,7 +1066,7 @@ void GMainWindow::BootGame(const QString& filename) {
const auto loader = Loader::GetLoader(v_file); const auto loader = Loader::GetLoader(v_file);
if (!(loader == nullptr || loader->ReadProgramId(title_id) != Loader::ResultStatus::Success)) { if (!(loader == nullptr || loader->ReadProgramId(title_id) != Loader::ResultStatus::Success)) {
// Load per game settings // Load per game settings
Config per_game_config(fmt::format("{:016X}.ini", title_id), false); Config per_game_config(title_id, false);
} }
Settings::LogSettings(); Settings::LogSettings();
@@ -2167,6 +2170,28 @@ void GMainWindow::OnCaptureScreenshot() {
OnStartGame(); OnStartGame();
} }
// TODO: Written 2020-07-23: Remove per-game config migration code when it is irrelevant
void GMainWindow::MigrateConfigFiles() {
const std::string& config_dir_s = FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir);
const QDir config_dir = QDir(QString::fromStdString(config_dir_s));
const QStringList config_dir_list = config_dir.entryList(QStringList(QStringLiteral("*.ini")));
FileUtil::CreateFullPath(fmt::format("{}custom" DIR_SEP, config_dir_s));
for (QStringList::const_iterator it = config_dir_list.constBegin();
it != config_dir_list.constEnd(); it++) {
const auto filename = it->toStdString();
if (filename.find_first_not_of("0123456789abcdefACBDEF", 0) < 16) {
continue;
}
const auto origin = fmt::format("{}{}", config_dir_s, filename);
const auto destination = fmt::format("{}custom" DIR_SEP "{}", config_dir_s, filename);
LOG_INFO(Frontend, "Migrating config file from {} to {}", origin, destination);
if (FileUtil::Copy(origin, destination)) {
FileUtil::Delete(origin);
}
}
}
void GMainWindow::UpdateWindowTitle(const std::string& title_name, void GMainWindow::UpdateWindowTitle(const std::string& title_name,
const std::string& title_version) { const std::string& title_version) {
const auto full_name = std::string(Common::g_build_fullname); const auto full_name = std::string(Common::g_build_fullname);

View File

@@ -232,6 +232,7 @@ private:
std::optional<u64> SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id); std::optional<u64> SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id);
InstallResult InstallNSPXCI(const QString& filename); InstallResult InstallNSPXCI(const QString& filename);
InstallResult InstallNCA(const QString& filename); InstallResult InstallNCA(const QString& filename);
void MigrateConfigFiles();
void UpdateWindowTitle(const std::string& title_name = {}, void UpdateWindowTitle(const std::string& title_name = {},
const std::string& title_version = {}); const std::string& title_version = {});
void UpdateStatusBar(); void UpdateStatusBar();