configuration_shared: address reviewer concerns except operator overrides
Dropping operator override usage in next commit. Co-Authored-By: LC <lioncash@users.noreply.github.com>
This commit is contained in:
@@ -387,43 +387,31 @@ extern bool configuring_global;
|
|||||||
template <typename Type>
|
template <typename Type>
|
||||||
class Setting final {
|
class Setting final {
|
||||||
public:
|
public:
|
||||||
Setting() {
|
Setting() = default;
|
||||||
use_global = true;
|
explicit Setting(Type val) : global{val} {}
|
||||||
}
|
|
||||||
Setting(Type val) {
|
|
||||||
use_global = true;
|
|
||||||
global = val;
|
|
||||||
}
|
|
||||||
~Setting() = default;
|
~Setting() = default;
|
||||||
void SetGlobal(bool to_global) {
|
void SetGlobal(bool to_global) {
|
||||||
use_global = to_global;
|
use_global = to_global;
|
||||||
};
|
}
|
||||||
bool UsingGlobal() const {
|
bool UsingGlobal() const {
|
||||||
return use_global;
|
return use_global;
|
||||||
};
|
}
|
||||||
Type GetValue(bool need_global = false) const {
|
Type GetValue(bool need_global = false) const {
|
||||||
if (use_global || need_global) {
|
if (use_global || need_global) {
|
||||||
return global;
|
return global;
|
||||||
}
|
}
|
||||||
return local;
|
return local;
|
||||||
};
|
}
|
||||||
void SetValue(const Type& value) {
|
void SetValue(const Type& value) {
|
||||||
if (use_global) {
|
if (use_global) {
|
||||||
global = value;
|
global = value;
|
||||||
} else {
|
} else {
|
||||||
local = value;
|
local = value;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
operator Type() const {
|
|
||||||
return GetValue();
|
|
||||||
};
|
|
||||||
Type operator=(const Type& b) {
|
|
||||||
SetValue(b);
|
|
||||||
return b;
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool use_global{};
|
bool use_global = true;
|
||||||
Type global{};
|
Type global{};
|
||||||
Type local{};
|
Type local{};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class QSettings;
|
|||||||
|
|
||||||
class Config {
|
class Config {
|
||||||
public:
|
public:
|
||||||
Config(const std::string& config_loc = "qt-config.ini", bool is_global = true);
|
explicit Config(const std::string& config_loc = "qt-config.ini", bool is_global = true);
|
||||||
~Config();
|
~Config();
|
||||||
|
|
||||||
void Reload();
|
void Reload();
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ void ConfigurationShared::SetPerGameSetting(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ConfigurationShared::InsertGlobalItem(QComboBox* combobox) {
|
void ConfigurationShared::InsertGlobalItem(QComboBox* combobox) {
|
||||||
|
const QString use_global_text = tr("Use global configuration");
|
||||||
combobox->insertItem(ConfigurationShared::USE_GLOBAL_INDEX,
|
combobox->insertItem(ConfigurationShared::USE_GLOBAL_INDEX,
|
||||||
ConfigurationShared::use_global_text);
|
ConfigurationShared::use_global_text);
|
||||||
combobox->insertSeparator(ConfigurationShared::USE_GLOBAL_SEPARATOR_INDEX);
|
combobox->insertSeparator(ConfigurationShared::USE_GLOBAL_SEPARATOR_INDEX);
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ namespace ConfigurationShared {
|
|||||||
constexpr int USE_GLOBAL_INDEX = 0;
|
constexpr int USE_GLOBAL_INDEX = 0;
|
||||||
constexpr int USE_GLOBAL_SEPARATOR_INDEX = 1;
|
constexpr int USE_GLOBAL_SEPARATOR_INDEX = 1;
|
||||||
constexpr int USE_GLOBAL_OFFSET = 2;
|
constexpr int USE_GLOBAL_OFFSET = 2;
|
||||||
static const QString use_global_text = QString::fromUtf8("Use global configuration");
|
|
||||||
|
|
||||||
// Global-aware apply and set functions
|
// Global-aware apply and set functions
|
||||||
|
|
||||||
|
|||||||
@@ -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}", title_id) + ".ini", false);
|
game_config = std::make_unique<Config>(fmt::format("{:016X}.ini", title_id), false);
|
||||||
|
|
||||||
Settings::configuring_global = false;
|
Settings::configuring_global = false;
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ void ConfigurePerGame::LoadConfiguration() {
|
|||||||
|
|
||||||
ui->addonsTab->LoadFromFile(file);
|
ui->addonsTab->LoadFromFile(file);
|
||||||
|
|
||||||
ui->display_title_id->setText(QString::fromStdString(fmt::format("{:016X}", title_id)));
|
ui->display_title_id->setText(QStringLiteral("%1").arg(title_id, 16, 16, 0).toUpper());
|
||||||
|
|
||||||
FileSys::PatchManager pm{title_id};
|
FileSys::PatchManager pm{title_id};
|
||||||
const auto control = pm.GetControlMetadata();
|
const auto control = pm.GetControlMetadata();
|
||||||
|
|||||||
@@ -1045,7 +1045,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}", title_id) + ".ini", false);
|
Config per_game_config(fmt::format("{:016X}.ini", title_id), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Settings::LogSettings();
|
Settings::LogSettings();
|
||||||
|
|||||||
Reference in New Issue
Block a user