core: Print current game settings on game boot
This commit is contained in:
@@ -141,6 +141,9 @@ struct System::Impl {
|
||||
if (app_loader->ReadProgramId(title_id) == Loader::ResultStatus::Success)
|
||||
Settings::values.SetCurrentTitleID(title_id);
|
||||
|
||||
// Write config to log
|
||||
Settings::values->LogSettings();
|
||||
|
||||
auto main_process = Kernel::Process::Create(kernel, "main");
|
||||
kernel.MakeCurrentProcess(main_process.get());
|
||||
|
||||
|
||||
@@ -12,13 +12,47 @@ namespace Settings {
|
||||
|
||||
Values values = {};
|
||||
|
||||
void PerGameValues::LogSettings() {
|
||||
LOG_INFO(Config, "Buttons:");
|
||||
for (std::size_t i = 0; i < NativeButton::NumButtons; ++i)
|
||||
LOG_INFO(Config, " Button[{}]: ", buttons[i]);
|
||||
|
||||
LOG_INFO(Config, "Analogs:");
|
||||
for (std::size_t i = 0; i < NativeAnalog::NumAnalogs; ++i)
|
||||
LOG_INFO(Config, " Analog[{}]: ", analogs[i]);
|
||||
|
||||
LOG_INFO(Config, "Motion Device: {}", motion_device);
|
||||
LOG_INFO(Config, "Touch Device: {}", touch_device);
|
||||
|
||||
LOG_INFO(Config, "Docked Mode: {}", use_docked_mode);
|
||||
|
||||
LOG_INFO(Config, "Resolution Factor: {}", resolution_factor);
|
||||
LOG_INFO(Config, "Frame Limit Enabled: {}", use_frame_limit);
|
||||
LOG_INFO(Config, "Frame Limit: {}", frame_limit);
|
||||
|
||||
LOG_INFO(Config, "Background Red: {}", bg_red);
|
||||
LOG_INFO(Config, "Background Green: {}", bg_green);
|
||||
LOG_INFO(Config, "Background Blue: {}", bg_blue);
|
||||
|
||||
LOG_INFO(Config, "Audio Sink ID: {}", sink_id);
|
||||
LOG_INFO(Config, "Audio Stretching: {}", enable_audio_stretching);
|
||||
LOG_INFO(Config, "Audio Device ID: {}", audio_device_id);
|
||||
LOG_INFO(Config, "Volume: {}", volume);
|
||||
|
||||
LOG_INFO(Config, "Program Arguments: {}", program_args);
|
||||
|
||||
LOG_INFO(Config, "Disabled Patches:");
|
||||
for (const auto& patch : disabled_patches)
|
||||
LOG_INFO(Config, " - {}", patch);
|
||||
}
|
||||
|
||||
Values::Values() : current_game(default_game) {}
|
||||
|
||||
void Values::SetUpdateCurrentGameFunction(std::function<bool(u64, PerGameValues&)> new_function) {
|
||||
update_current_game = std::move(new_function);
|
||||
}
|
||||
|
||||
u64 Values::CurrentTitleID() {
|
||||
u64 Values::CurrentTitleID() const {
|
||||
return current_title_id;
|
||||
}
|
||||
|
||||
|
||||
@@ -116,6 +116,8 @@ static const std::array<const char*, NumAnalogs> mapping = {{
|
||||
} // namespace NativeAnalog
|
||||
|
||||
struct PerGameValues {
|
||||
void LogSettings();
|
||||
|
||||
// Controls
|
||||
std::array<std::string, NativeButton::NumButtons> buttons;
|
||||
std::array<std::string, NativeAnalog::NumAnalogs> analogs;
|
||||
@@ -154,7 +156,7 @@ struct Values {
|
||||
PerGameValues default_game;
|
||||
|
||||
void SetUpdateCurrentGameFunction(std::function<bool(u64, PerGameValues&)> new_function);
|
||||
u64 CurrentTitleID();
|
||||
u64 CurrentTitleID() const;
|
||||
void SetCurrentTitleID(u64 title_id);
|
||||
|
||||
PerGameValues& operator[](u64 title_id);
|
||||
|
||||
@@ -257,16 +257,17 @@ bool Config::UpdateCurrentGame(u64 title_id, Settings::PerGameValues& values) {
|
||||
|
||||
const auto size = qt_config->beginReadArray("Per Game Settings");
|
||||
|
||||
for (std::size_t i = 0; i < size; ++i) {
|
||||
for (int i = 0; i < size; ++i) {
|
||||
qt_config->setArrayIndex(i);
|
||||
const auto read_title_id = qt_config->value("title_id", 0).toULongLong();
|
||||
if (read_title_id == title_id) {
|
||||
PerGameValuesChange changes{};
|
||||
ReadPerGameSettings(values);
|
||||
ReadPerGameSettingsDelta(changes);
|
||||
if (read_title_id != title_id)
|
||||
continue;
|
||||
|
||||
values = ApplyValuesDelta(Settings::values.default_game, values, changes);
|
||||
}
|
||||
PerGameValuesChange changes{};
|
||||
ReadPerGameSettings(values);
|
||||
ReadPerGameSettingsDelta(changes);
|
||||
|
||||
values = ApplyValuesDelta(Settings::values.default_game, values, changes);
|
||||
}
|
||||
|
||||
qt_config->endArray();
|
||||
@@ -499,7 +500,7 @@ void Config::SaveValues() {
|
||||
|
||||
const auto size = qt_config->beginReadArray("Per Game Settings");
|
||||
|
||||
for (std::size_t i = 0; i < size; ++i) {
|
||||
for (int i = 0; i < size; ++i) {
|
||||
qt_config->setArrayIndex(i);
|
||||
const auto read_title_id = qt_config->value("title_id", 0).toULongLong();
|
||||
if (update_values.find(read_title_id) == update_values.end()) {
|
||||
@@ -517,7 +518,7 @@ void Config::SaveValues() {
|
||||
|
||||
qt_config->beginWriteArray("Per Game Settings", update_values.size());
|
||||
|
||||
std::size_t i = 0;
|
||||
int i = 0;
|
||||
for (const auto& kv : update_values) {
|
||||
qt_config->setArrayIndex(i++);
|
||||
qt_config->setValue("title_id", kv.first);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "core/core.h"
|
||||
#include "core/settings.h"
|
||||
#include "ui_configure_audio.h"
|
||||
#include "yuzu/configuration/config.h"
|
||||
#include "yuzu/configuration/configure_audio.h"
|
||||
|
||||
ConfigureAudio::ConfigureAudio(QWidget* parent)
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
#include <memory>
|
||||
#include <QWidget>
|
||||
#include "yuzu/configuration/config.h"
|
||||
|
||||
struct PerGameValuesChange;
|
||||
|
||||
namespace Ui {
|
||||
class ConfigureAudio;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "core/core.h"
|
||||
#include "core/settings.h"
|
||||
#include "ui_configure_debug.h"
|
||||
#include "yuzu/configuration/config.h"
|
||||
#include "yuzu/configuration/configure_debug.h"
|
||||
#include "yuzu/debugger/console.h"
|
||||
#include "yuzu/ui_settings.h"
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
#include <memory>
|
||||
#include <QWidget>
|
||||
#include "configuration/config.h"
|
||||
|
||||
struct PerGameValuesChange;
|
||||
|
||||
namespace Ui {
|
||||
class ConfigureDebug;
|
||||
|
||||
@@ -268,9 +268,9 @@ void ConfigureInput::applyConfiguration() {
|
||||
}
|
||||
|
||||
void ConfigureInput::setPerGame(bool show) {
|
||||
for (const auto button : buttons_delta)
|
||||
for (auto* button : buttons_delta)
|
||||
button->setHidden(!show);
|
||||
for (const auto analog : analogs_delta)
|
||||
for (auto* analog : analogs_delta)
|
||||
analog->setHidden(!show);
|
||||
ui->override_label->setHidden(!show);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
#include "core/settings.h"
|
||||
#include "input_common/main.h"
|
||||
#include "ui_configure_input.h"
|
||||
#include "yuzu/configuration/config.h"
|
||||
|
||||
class QPushButton;
|
||||
class QString;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "core/file_sys/vfs.h"
|
||||
#include "core/settings.h"
|
||||
#include "ui_configure_per_game.h"
|
||||
#include "yuzu/configuration/config.h"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <QDialog>
|
||||
#include "core/file_sys/vfs.h"
|
||||
#include "core/file_sys/vfs_types.h"
|
||||
|
||||
namespace Ui {
|
||||
class ConfigurePerGameDialog;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// Copyright 2016 Citra Emulator Project
|
||||
// Copyright 2018 yuzu Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <QHeaderView>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QStandardItemModel>
|
||||
@@ -23,7 +24,6 @@
|
||||
|
||||
ConfigurePerGameGeneral::ConfigurePerGameGeneral(QWidget* parent)
|
||||
: QWidget(parent), ui(std::make_unique<Ui::ConfigurePerGameGeneral>()) {
|
||||
|
||||
ui->setupUi(this);
|
||||
setFocusPolicy(Qt::ClickFocus);
|
||||
|
||||
@@ -42,8 +42,8 @@ ConfigurePerGameGeneral::ConfigurePerGameGeneral(QWidget* parent)
|
||||
tree_view->setContextMenuPolicy(Qt::NoContextMenu);
|
||||
|
||||
item_model->insertColumns(0, 2);
|
||||
item_model->setHeaderData(0, Qt::Horizontal, "Patch Name");
|
||||
item_model->setHeaderData(1, Qt::Horizontal, "Version");
|
||||
item_model->setHeaderData(0, Qt::Horizontal, tr("Patch Name"));
|
||||
item_model->setHeaderData(1, Qt::Horizontal, tr("Version"));
|
||||
|
||||
// We must register all custom types with the Qt Automoc system so that we are able to use it
|
||||
// with signals/slots. In this case, QList falls under the umbrells of custom types.
|
||||
@@ -61,6 +61,8 @@ ConfigurePerGameGeneral::ConfigurePerGameGeneral(QWidget* parent)
|
||||
this->loadConfiguration();
|
||||
}
|
||||
|
||||
ConfigurePerGameGeneral::~ConfigurePerGameGeneral() = default;
|
||||
|
||||
void ConfigurePerGameGeneral::applyConfiguration() {
|
||||
std::vector<std::string> disabled_add_ons;
|
||||
|
||||
@@ -96,7 +98,7 @@ void ConfigurePerGameGeneral::loadConfiguration() {
|
||||
|
||||
u64 program_id{};
|
||||
if (loader->ReadProgramId(program_id) == Loader::ResultStatus::Success) {
|
||||
ui->display_title_id->setText(fmt::format("{:016X}", program_id).c_str());
|
||||
ui->display_title_id->setText(QStringLiteral("%1").arg(program_id, 16, 16, QChar{'0'}));
|
||||
|
||||
FileSys::PatchManager pm{program_id};
|
||||
const auto control = pm.GetControlMetadata();
|
||||
|
||||
@@ -4,26 +4,18 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <QKeyEvent>
|
||||
#include <QList>
|
||||
#include <QWidget>
|
||||
#include <boost/optional.hpp>
|
||||
#include "common/param_package.h"
|
||||
#include "core/file_sys/vfs.h"
|
||||
#include "core/settings.h"
|
||||
#include "input_common/main.h"
|
||||
#include "ui_configure_per_general.h"
|
||||
#include "yuzu/configuration/config.h"
|
||||
|
||||
class QTreeView;
|
||||
class QGraphicsScene;
|
||||
class QStandardItem;
|
||||
class QStandardItemModel;
|
||||
class QTreeView;
|
||||
|
||||
namespace Ui {
|
||||
class ConfigurePerGameGeneral;
|
||||
@@ -34,6 +26,7 @@ class ConfigurePerGameGeneral : public QWidget {
|
||||
|
||||
public:
|
||||
explicit ConfigurePerGameGeneral(QWidget* parent = nullptr);
|
||||
~ConfigurePerGameGeneral() override;
|
||||
|
||||
/// Save all button configurations to settings file
|
||||
void applyConfiguration();
|
||||
@@ -44,6 +37,8 @@ public:
|
||||
void mergeValuesChange(PerGameValuesChange& change);
|
||||
|
||||
private:
|
||||
void loadConfiguration();
|
||||
|
||||
std::unique_ptr<Ui::ConfigurePerGameGeneral> ui;
|
||||
FileSys::VirtualFile file;
|
||||
|
||||
@@ -53,6 +48,4 @@ private:
|
||||
QGraphicsScene* scene;
|
||||
|
||||
std::vector<QList<QStandardItem*>> list_items;
|
||||
|
||||
void loadConfiguration();
|
||||
};
|
||||
|
||||
@@ -32,50 +32,46 @@
|
||||
|
||||
class HTMLDelegate : public QStyledItemDelegate {
|
||||
public:
|
||||
void paint(QPainter* painter, const QStyleOptionViewItem& option,
|
||||
const QModelIndex& index) const override;
|
||||
QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
||||
};
|
||||
void paint(QPainter* painter, const QStyleOptionViewItem& _option,
|
||||
const QModelIndex& index) const override {
|
||||
auto option = _option;
|
||||
initStyleOption(&option, index);
|
||||
|
||||
void HTMLDelegate::paint(QPainter* painter, const QStyleOptionViewItem& _option,
|
||||
const QModelIndex& index) const {
|
||||
auto option = _option;
|
||||
initStyleOption(&option, index);
|
||||
QStyle* style = option.widget ? option.widget->style() : QApplication::style();
|
||||
|
||||
QStyle* style = option.widget ? option.widget->style() : QApplication::style();
|
||||
QTextDocument document;
|
||||
document.setHtml(option.text);
|
||||
|
||||
QTextDocument document;
|
||||
document.setHtml(option.text);
|
||||
/// Painting item without text
|
||||
option.text = QString();
|
||||
style->drawControl(QStyle::CE_ItemViewItem, &option, painter);
|
||||
|
||||
/// Painting item without text
|
||||
option.text = QString();
|
||||
style->drawControl(QStyle::CE_ItemViewItem, &option, painter);
|
||||
QAbstractTextDocumentLayout::PaintContext ctx;
|
||||
|
||||
QAbstractTextDocumentLayout::PaintContext ctx;
|
||||
// Highlighting text if item is selected
|
||||
if (option.state & QStyle::State_Selected) {
|
||||
ctx.palette.setColor(QPalette::Text,
|
||||
option.palette.color(QPalette::Active, QPalette::HighlightedText));
|
||||
}
|
||||
|
||||
// Highlighting text if item is selected
|
||||
if (option.state & QStyle::State_Selected) {
|
||||
ctx.palette.setColor(QPalette::Text,
|
||||
option.palette.color(QPalette::Active, QPalette::HighlightedText));
|
||||
QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &option);
|
||||
painter->save();
|
||||
painter->translate(textRect.topLeft());
|
||||
painter->setClipRect(textRect.translated(-textRect.topLeft()));
|
||||
document.documentLayout()->draw(painter, ctx);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &option);
|
||||
painter->save();
|
||||
painter->translate(textRect.topLeft());
|
||||
painter->setClipRect(textRect.translated(-textRect.topLeft()));
|
||||
document.documentLayout()->draw(painter, ctx);
|
||||
painter->restore();
|
||||
}
|
||||
QSize sizeHint(const QStyleOptionViewItem& _option, const QModelIndex& index) const override {
|
||||
auto option = _option;
|
||||
initStyleOption(&option, index);
|
||||
|
||||
QSize HTMLDelegate::sizeHint(const QStyleOptionViewItem& _option, const QModelIndex& index) const {
|
||||
auto option = _option;
|
||||
initStyleOption(&option, index);
|
||||
|
||||
QTextDocument document;
|
||||
document.setHtml(option.text);
|
||||
document.setTextWidth(option.rect.width());
|
||||
return QSize(document.idealWidth(), UISettings::values.icon_size);
|
||||
}
|
||||
QTextDocument document;
|
||||
document.setHtml(option.text);
|
||||
document.setTextWidth(option.rect.width());
|
||||
return QSize(document.idealWidth(), UISettings::values.icon_size);
|
||||
}
|
||||
};
|
||||
|
||||
GameListSearchField::KeyReleaseEater::KeyReleaseEater(GameList* gamelist) : gamelist{gamelist} {}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
@@ -979,11 +979,12 @@ void GMainWindow::OnGameListOpenProperties(FileSys::VirtualFile file) {
|
||||
Settings::values.SetCurrentTitleID(title_id);
|
||||
ConfigurePerGameDialog dialog{this, file, config->GetPerGameSettingsDelta(title_id)};
|
||||
auto result = dialog.exec();
|
||||
if (result == QDialog::Accepted) {
|
||||
config->SetPerGameSettingsDelta(title_id, dialog.applyConfiguration());
|
||||
config->Save();
|
||||
game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan);
|
||||
}
|
||||
if (result != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
config->SetPerGameSettingsDelta(title_id, dialog.applyConfiguration());
|
||||
config->Save();
|
||||
game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan);
|
||||
}
|
||||
|
||||
void GMainWindow::OnMenuLoadFile() {
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <boost/optional.hpp>
|
||||
#include "common/common_types.h"
|
||||
#include "core/core.h"
|
||||
#include "core/file_sys/vfs.h"
|
||||
#include "core/file_sys/vfs_types.h"
|
||||
#include "ui_main.h"
|
||||
#include "yuzu/compatibility_list.h"
|
||||
#include "yuzu/hotkeys.h"
|
||||
|
||||
@@ -149,7 +149,7 @@ void Config::ReadValues() {
|
||||
if (token.size() != 16)
|
||||
continue;
|
||||
|
||||
u64 val = std::stoull(token, nullptr, 16);
|
||||
const u64 val = std::stoull(token, nullptr, 16);
|
||||
titles.push_back(val);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user