mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-26 03:55:37 +00:00
even more variables parsing
This commit is contained in:
parent
5fdd3a5695
commit
08d1bc2a46
@ -90,11 +90,9 @@ std::vector<std::string> m_elf_viewer;
|
||||
std::vector<std::string> m_recent_files;
|
||||
std::string emulator_language = "en_US";
|
||||
static int backgroundImageOpacity = 50;
|
||||
static bool showBackgroundImage = true;
|
||||
static bool isFullscreen = false;
|
||||
static std::string fullscreenMode = "Windowed";
|
||||
static bool isHDRAllowed = false;
|
||||
static bool showLabelsUnderIcons = true;
|
||||
|
||||
// Language
|
||||
u32 m_language = 1; // english
|
||||
@ -164,14 +162,6 @@ bool getIsFullscreen() {
|
||||
return isFullscreen;
|
||||
}
|
||||
|
||||
bool getShowLabelsUnderIcons() {
|
||||
return showLabelsUnderIcons;
|
||||
}
|
||||
|
||||
bool setShowLabelsUnderIcons() {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string getFullscreenMode() {
|
||||
return fullscreenMode;
|
||||
}
|
||||
@ -419,9 +409,6 @@ void setVblankDiv(u32 value) {
|
||||
void setIsFullscreen(bool enable) {
|
||||
isFullscreen = enable;
|
||||
}
|
||||
static void setShowLabelsUnderIcons(bool enable) {
|
||||
showLabelsUnderIcons = enable;
|
||||
}
|
||||
|
||||
void setFullscreenMode(std::string mode) {
|
||||
fullscreenMode = mode;
|
||||
@ -632,14 +619,6 @@ void setBackgroundImageOpacity(int opacity) {
|
||||
backgroundImageOpacity = std::clamp(opacity, 0, 100);
|
||||
}
|
||||
|
||||
bool getShowBackgroundImage() {
|
||||
return showBackgroundImage;
|
||||
}
|
||||
|
||||
void setShowBackgroundImage(bool show) {
|
||||
showBackgroundImage = show;
|
||||
}
|
||||
|
||||
void load(const std::filesystem::path& path) {
|
||||
// If the configuration file does not exist, create it and return
|
||||
std::error_code error;
|
||||
@ -770,7 +749,6 @@ void load(const std::filesystem::path& path) {
|
||||
m_recent_files = toml::find_or<std::vector<std::string>>(gui, "recentFiles", {});
|
||||
emulator_language = toml::find_or<std::string>(gui, "emulatorLanguage", "en_US");
|
||||
backgroundImageOpacity = toml::find_or<int>(gui, "backgroundImageOpacity", 50);
|
||||
showBackgroundImage = toml::find_or<bool>(gui, "showBackgroundImage", true);
|
||||
}
|
||||
|
||||
if (data.contains("Settings")) {
|
||||
@ -935,7 +913,6 @@ void save(const std::filesystem::path& path) {
|
||||
std::string{fmt::UTF(settings_addon_install_dir.u8string()).data};
|
||||
data["GUI"]["emulatorLanguage"] = emulator_language;
|
||||
data["GUI"]["backgroundImageOpacity"] = backgroundImageOpacity;
|
||||
data["GUI"]["showBackgroundImage"] = showBackgroundImage;
|
||||
data["Settings"]["consoleLanguage"] = m_language;
|
||||
|
||||
// Sorting of TOML sections
|
||||
@ -1030,7 +1007,6 @@ void setDefaultValues() {
|
||||
compatibilityData = false;
|
||||
checkCompatibilityOnStartup = false;
|
||||
backgroundImageOpacity = 50;
|
||||
showBackgroundImage = true;
|
||||
}
|
||||
|
||||
constexpr std::string_view GetDefaultKeyboardConfig() {
|
||||
|
@ -26,8 +26,6 @@ bool GetLoadGameSizeEnabled();
|
||||
std::filesystem::path GetSaveDataPath();
|
||||
void setLoadGameSizeEnabled(bool enable);
|
||||
bool getIsFullscreen();
|
||||
bool getShowLabelsUnderIcons();
|
||||
bool setShowLabelsUnderIcons();
|
||||
std::string getFullscreenMode();
|
||||
bool isNeoModeConsole();
|
||||
bool isDevKitConsole();
|
||||
@ -38,7 +36,6 @@ bool getEnableDiscordRPC();
|
||||
bool getCompatibilityEnabled();
|
||||
bool getCheckCompatibilityOnStartup();
|
||||
int getBackgroundImageOpacity();
|
||||
bool getShowBackgroundImage();
|
||||
|
||||
std::string getLogFilter();
|
||||
std::string getLogType();
|
||||
@ -110,7 +107,6 @@ void setSaveDataPath(const std::filesystem::path& path);
|
||||
void setCompatibilityEnabled(bool use);
|
||||
void setCheckCompatibilityOnStartup(bool use);
|
||||
void setBackgroundImageOpacity(int opacity);
|
||||
void setShowBackgroundImage(bool show);
|
||||
|
||||
void setCursorState(s16 cursorState);
|
||||
void setCursorHideTimeout(int newcursorHideTimeout);
|
||||
|
@ -171,7 +171,7 @@ void GameGridFrame::SetGridBackgroundImage(int row, int column) {
|
||||
}
|
||||
|
||||
// If background images are hidden, clear the background image
|
||||
if (!Config::getShowBackgroundImage()) {
|
||||
if (!m_gui_settings->GetValue(gui::gl_showBackgroundImage).toBool()) {
|
||||
backgroundImage = QImage();
|
||||
m_last_opacity = -1; // Reset opacity tracking when disabled
|
||||
m_current_game_path.clear(); // Reset current game path
|
||||
@ -198,7 +198,8 @@ void GameGridFrame::SetGridBackgroundImage(int row, int column) {
|
||||
|
||||
void GameGridFrame::RefreshGridBackgroundImage() {
|
||||
QPalette palette;
|
||||
if (!backgroundImage.isNull() && Config::getShowBackgroundImage()) {
|
||||
if (!backgroundImage.isNull() &&
|
||||
m_gui_settings->GetValue(gui::gl_showBackgroundImage).toBool()) {
|
||||
QSize widgetSize = size();
|
||||
QPixmap scaledPixmap =
|
||||
QPixmap::fromImage(backgroundImage)
|
||||
|
@ -174,7 +174,7 @@ void GameListFrame::SetListBackgroundImage(QTableWidgetItem* item) {
|
||||
}
|
||||
|
||||
// If background images are hidden, clear the background image
|
||||
if (!Config::getShowBackgroundImage()) {
|
||||
if (!m_gui_settings->GetValue(gui::gl_showBackgroundImage).toBool()) {
|
||||
backgroundImage = QImage();
|
||||
m_last_opacity = -1; // Reset opacity tracking when disabled
|
||||
m_current_game_path.clear(); // Reset current game path
|
||||
@ -202,7 +202,8 @@ void GameListFrame::SetListBackgroundImage(QTableWidgetItem* item) {
|
||||
|
||||
void GameListFrame::RefreshListBackgroundImage() {
|
||||
QPalette palette;
|
||||
if (!backgroundImage.isNull() && Config::getShowBackgroundImage()) {
|
||||
if (!backgroundImage.isNull() &&
|
||||
m_gui_settings->GetValue(gui::gl_showBackgroundImage).toBool()) {
|
||||
QSize widgetSize = size();
|
||||
QPixmap scaledPixmap =
|
||||
QPixmap::fromImage(backgroundImage)
|
||||
|
@ -6,4 +6,4 @@
|
||||
gui_settings::gui_settings(QObject* parent) : settings(parent) {
|
||||
m_settings = std::make_unique<QSettings>(ComputeSettingsDir() + "qt_ui.ini",
|
||||
QSettings::Format::IniFormat, parent);
|
||||
}
|
||||
}
|
||||
|
@ -14,11 +14,13 @@ const QString game_grid = "game_grid";
|
||||
|
||||
// main window settings
|
||||
const gui_value mw_geometry = gui_value(main_window, "geometry", QByteArray());
|
||||
const gui_value mw_showLabelsUnderIcons = gui_value(main_window, "showLabelsUnderIcons", true);
|
||||
|
||||
// game list settings
|
||||
const gui_value gl_mode = gui_value(game_list, "tableMode", 0);
|
||||
const gui_value gl_icon_size = gui_value(game_list, "icon_size", 36);
|
||||
const gui_value gl_slider_pos = gui_value(game_list, "slider_pos", 0);
|
||||
const gui_value gl_showBackgroundImage = gui_value(game_list, "showBackgroundImage", true);
|
||||
|
||||
// game grid settings
|
||||
const gui_value gg_icon_size = gui_value(game_grid, "icon_size", 69);
|
||||
@ -31,4 +33,5 @@ class gui_settings : public settings {
|
||||
|
||||
public:
|
||||
explicit gui_settings(QObject* parent = nullptr);
|
||||
~gui_settings() override = default;
|
||||
};
|
||||
|
@ -33,6 +33,8 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi
|
||||
installEventFilter(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
m_gui_settings = std::make_shared<gui_settings>();
|
||||
ui->toggleLabelsAct->setChecked(
|
||||
m_gui_settings->GetValue(gui::mw_showLabelsUnderIcons).toBool());
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
@ -148,7 +150,7 @@ void MainWindow::PauseGame() {
|
||||
|
||||
void MainWindow::toggleLabelsUnderIcons() {
|
||||
bool showLabels = ui->toggleLabelsAct->isChecked();
|
||||
Config::setShowLabelsUnderIcons();
|
||||
m_gui_settings->SetValue(gui::mw_showLabelsUnderIcons, showLabels);
|
||||
UpdateToolbarLabels();
|
||||
if (isGameRunning) {
|
||||
UpdateToolbarButtons();
|
||||
@ -414,7 +416,7 @@ void MainWindow::CreateConnects() {
|
||||
&MainWindow::StartGame);
|
||||
|
||||
connect(ui->configureAct, &QAction::triggered, this, [this]() {
|
||||
auto settingsDialog = new SettingsDialog(m_compat_info, this);
|
||||
auto settingsDialog = new SettingsDialog(m_gui_settings, m_compat_info, this);
|
||||
|
||||
connect(settingsDialog, &SettingsDialog::LanguageChanged, this,
|
||||
&MainWindow::OnLanguageChanged);
|
||||
@ -447,7 +449,7 @@ void MainWindow::CreateConnects() {
|
||||
});
|
||||
|
||||
connect(ui->settingsButton, &QPushButton::clicked, this, [this]() {
|
||||
auto settingsDialog = new SettingsDialog(m_compat_info, this);
|
||||
auto settingsDialog = new SettingsDialog(m_gui_settings,m_compat_info, this);
|
||||
|
||||
connect(settingsDialog, &SettingsDialog::LanguageChanged, this,
|
||||
&MainWindow::OnLanguageChanged);
|
||||
|
@ -107,7 +107,6 @@ public:
|
||||
toggleLabelsAct = new QAction(MainWindow);
|
||||
toggleLabelsAct->setObjectName("toggleLabelsAct");
|
||||
toggleLabelsAct->setCheckable(true);
|
||||
toggleLabelsAct->setChecked(Config::getShowLabelsUnderIcons());
|
||||
|
||||
setIconSizeTinyAct = new QAction(MainWindow);
|
||||
setIconSizeTinyAct->setObjectName("setIconSizeTinyAct");
|
||||
|
@ -71,9 +71,10 @@ int bgm_volume_backup;
|
||||
|
||||
static std::vector<QString> m_physical_devices;
|
||||
|
||||
SettingsDialog::SettingsDialog(std::shared_ptr<CompatibilityInfoClass> m_compat_info,
|
||||
SettingsDialog::SettingsDialog(std::shared_ptr<gui_settings> gui_settings,
|
||||
std::shared_ptr<CompatibilityInfoClass> m_compat_info,
|
||||
QWidget* parent)
|
||||
: QDialog(parent), ui(new Ui::SettingsDialog) {
|
||||
: QDialog(parent), ui(new Ui::SettingsDialog), m_gui_settings(std::move(gui_settings)) {
|
||||
ui->setupUi(this);
|
||||
ui->tabWidgetSettings->setUsesScrollButtons(false);
|
||||
|
||||
@ -147,6 +148,7 @@ SettingsDialog::SettingsDialog(std::shared_ptr<CompatibilityInfoClass> m_compat_
|
||||
Config::save(config_dir / "config.toml");
|
||||
} else if (button == ui->buttonBox->button(QDialogButtonBox::RestoreDefaults)) {
|
||||
Config::setDefaultValues();
|
||||
setDefaultValues();
|
||||
Config::save(config_dir / "config.toml");
|
||||
LoadValuesFromConfig();
|
||||
} else if (button == ui->buttonBox->button(QDialogButtonBox::Close)) {
|
||||
@ -235,12 +237,12 @@ SettingsDialog::SettingsDialog(std::shared_ptr<CompatibilityInfoClass> m_compat_
|
||||
[](const QString& hometab) { Config::setChooseHomeTab(hometab.toStdString()); });
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 7, 0))
|
||||
connect(ui->showBackgroundImageCheckBox, &QCheckBox::stateChanged, this, [](int state) {
|
||||
connect(ui->showBackgroundImageCheckBox, &QCheckBox::stateChanged, this, [this](int state) {
|
||||
#else
|
||||
connect(ui->showBackgroundImageCheckBox, &QCheckBox::checkStateChanged, this,
|
||||
[](Qt::CheckState state) {
|
||||
#endif
|
||||
Config::setShowBackgroundImage(state == Qt::Checked);
|
||||
m_gui_settings->SetValue(gui::gl_showBackgroundImage, state == Qt::Checked);
|
||||
});
|
||||
}
|
||||
|
||||
@ -537,7 +539,8 @@ void SettingsDialog::LoadValuesFromConfig() {
|
||||
ui->removeFolderButton->setEnabled(!ui->gameFoldersListWidget->selectedItems().isEmpty());
|
||||
ResetInstallFolders();
|
||||
ui->backgroundImageOpacitySlider->setValue(Config::getBackgroundImageOpacity());
|
||||
ui->showBackgroundImageCheckBox->setChecked(Config::getShowBackgroundImage());
|
||||
ui->showBackgroundImageCheckBox->setChecked(
|
||||
m_gui_settings->GetValue(gui::gl_showBackgroundImage).toBool());
|
||||
|
||||
backgroundImageOpacitySlider_backup = Config::getBackgroundImageOpacity();
|
||||
bgm_volume_backup = Config::getBGMvolume();
|
||||
@ -793,7 +796,8 @@ void SettingsDialog::UpdateSettings() {
|
||||
Config::setCheckCompatibilityOnStartup(ui->checkCompatibilityOnStartupCheckBox->isChecked());
|
||||
Config::setBackgroundImageOpacity(ui->backgroundImageOpacitySlider->value());
|
||||
emit BackgroundOpacityChanged(ui->backgroundImageOpacitySlider->value());
|
||||
Config::setShowBackgroundImage(ui->showBackgroundImageCheckBox->isChecked());
|
||||
m_gui_settings->SetValue(gui::gl_showBackgroundImage,
|
||||
ui->showBackgroundImageCheckBox->isChecked());
|
||||
|
||||
std::vector<Config::GameInstallDir> dirs_with_states;
|
||||
for (int i = 0; i < ui->gameFoldersListWidget->count(); i++) {
|
||||
@ -862,3 +866,6 @@ void SettingsDialog::ResetInstallFolders() {
|
||||
Config::setAllGameInstallDirs(settings_install_dirs_config);
|
||||
}
|
||||
}
|
||||
void SettingsDialog::setDefaultValues() {
|
||||
m_gui_settings->SetValue(gui::gl_showBackgroundImage, true);
|
||||
}
|
@ -11,6 +11,7 @@
|
||||
|
||||
#include "common/config.h"
|
||||
#include "common/path_util.h"
|
||||
#include "gui_settings.h"
|
||||
#include "qt_gui/compatibility_info.h"
|
||||
|
||||
namespace Ui {
|
||||
@ -20,7 +21,8 @@ class SettingsDialog;
|
||||
class SettingsDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SettingsDialog(std::shared_ptr<CompatibilityInfoClass> m_compat_info,
|
||||
explicit SettingsDialog(std::shared_ptr<gui_settings> gui_settings,
|
||||
std::shared_ptr<CompatibilityInfoClass> m_compat_info,
|
||||
QWidget* parent = nullptr);
|
||||
~SettingsDialog();
|
||||
|
||||
@ -42,6 +44,7 @@ private:
|
||||
void OnLanguageChanged(int index);
|
||||
void OnCursorStateChanged(s16 index);
|
||||
void closeEvent(QCloseEvent* event) override;
|
||||
void setDefaultValues();
|
||||
|
||||
std::unique_ptr<Ui::SettingsDialog> ui;
|
||||
|
||||
@ -52,4 +55,5 @@ private:
|
||||
int initialHeight;
|
||||
|
||||
bool is_saving = false;
|
||||
std::shared_ptr<gui_settings> m_gui_settings;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user