mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 16:32:39 +00:00
Added show background image button
This commit is contained in:
parent
681c1bbf64
commit
faebea56eb
@ -96,6 +96,7 @@ std::vector<std::string> m_elf_viewer;
|
||||
std::vector<std::string> m_recent_files;
|
||||
std::string emulator_language = "en";
|
||||
static int backgroundImageOpacity = 50;
|
||||
static bool showBackgroundImage = true;
|
||||
|
||||
// Language
|
||||
u32 m_language = 1; // english
|
||||
@ -620,6 +621,14 @@ 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;
|
||||
@ -665,6 +674,7 @@ void load(const std::filesystem::path& path) {
|
||||
toml::find_or<bool>(general, "checkCompatibilityOnStartup", false);
|
||||
chooseHomeTab = toml::find_or<std::string>(general, "chooseHomeTab", "Release");
|
||||
backgroundImageOpacity = toml::find_or<int>(general, "backgroundImageOpacity", 50);
|
||||
showBackgroundImage = toml::find_or<bool>(general, "showBackgroundImage", true);
|
||||
}
|
||||
|
||||
if (data.contains("Input")) {
|
||||
@ -794,6 +804,7 @@ void save(const std::filesystem::path& path) {
|
||||
data["General"]["compatibilityEnabled"] = compatibilityData;
|
||||
data["General"]["checkCompatibilityOnStartup"] = checkCompatibilityOnStartup;
|
||||
data["General"]["backgroundImageOpacity"] = backgroundImageOpacity;
|
||||
data["General"]["showBackgroundImage"] = showBackgroundImage;
|
||||
data["Input"]["cursorState"] = cursorState;
|
||||
data["Input"]["cursorHideTimeout"] = cursorHideTimeout;
|
||||
data["Input"]["backButtonBehavior"] = backButtonBehavior;
|
||||
@ -926,6 +937,7 @@ void setDefaultValues() {
|
||||
compatibilityData = false;
|
||||
checkCompatibilityOnStartup = false;
|
||||
backgroundImageOpacity = 50;
|
||||
showBackgroundImage = true;
|
||||
}
|
||||
|
||||
constexpr std::string_view GetDefaultKeyboardConfig() {
|
||||
|
@ -31,6 +31,7 @@ bool getSeparateUpdateEnabled();
|
||||
bool getCompatibilityEnabled();
|
||||
bool getCheckCompatibilityOnStartup();
|
||||
int getBackgroundImageOpacity();
|
||||
bool getShowBackgroundImage();
|
||||
|
||||
std::string getLogFilter();
|
||||
std::string getLogType();
|
||||
@ -90,6 +91,7 @@ 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);
|
||||
|
@ -162,6 +162,12 @@ void GameGridFrame::SetGridBackgroundImage(int row, int column) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Config::getShowBackgroundImage()) {
|
||||
backgroundImage = QImage();
|
||||
RefreshGridBackgroundImage();
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& game = (*m_games_shared)[itemID];
|
||||
const int opacity = Config::getBackgroundImageOpacity();
|
||||
const auto cache_path = Common::FS::GetUserPath(Common::FS::PathType::MetaDataDir) /
|
||||
@ -195,14 +201,14 @@ void GameGridFrame::SetGridBackgroundImage(int row, int column) {
|
||||
}
|
||||
|
||||
void GameGridFrame::RefreshGridBackgroundImage() {
|
||||
if (!backgroundImage.isNull()) {
|
||||
QPalette palette;
|
||||
QPalette palette;
|
||||
if (!backgroundImage.isNull() && Config::getShowBackgroundImage()) {
|
||||
palette.setBrush(QPalette::Base,
|
||||
QBrush(backgroundImage.scaled(size(), Qt::IgnoreAspectRatio)));
|
||||
QColor transparentColor = QColor(135, 206, 235, 40);
|
||||
palette.setColor(QPalette::Highlight, transparentColor);
|
||||
this->setPalette(palette);
|
||||
}
|
||||
QColor transparentColor = QColor(135, 206, 235, 40);
|
||||
palette.setColor(QPalette::Highlight, transparentColor);
|
||||
this->setPalette(palette);
|
||||
}
|
||||
|
||||
bool GameGridFrame::IsValidCellSelected() {
|
||||
|
@ -167,6 +167,13 @@ void GameListFrame::SetListBackgroundImage(QTableWidgetItem* item) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If background images are hidden, clear the background image
|
||||
if (!Config::getShowBackgroundImage()) {
|
||||
backgroundImage = QImage();
|
||||
RefreshListBackgroundImage();
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& game = m_game_info->m_games[item->row()];
|
||||
const int opacity = Config::getBackgroundImageOpacity();
|
||||
const auto cache_path = Common::FS::GetUserPath(Common::FS::PathType::MetaDataDir) /
|
||||
@ -200,14 +207,14 @@ void GameListFrame::SetListBackgroundImage(QTableWidgetItem* item) {
|
||||
}
|
||||
|
||||
void GameListFrame::RefreshListBackgroundImage() {
|
||||
if (!backgroundImage.isNull()) {
|
||||
QPalette palette;
|
||||
QPalette palette;
|
||||
if (!backgroundImage.isNull() && Config::getShowBackgroundImage()) {
|
||||
palette.setBrush(QPalette::Base,
|
||||
QBrush(backgroundImage.scaled(size(), Qt::IgnoreAspectRatio)));
|
||||
QColor transparentColor = QColor(135, 206, 235, 40);
|
||||
palette.setColor(QPalette::Highlight, transparentColor);
|
||||
this->setPalette(palette);
|
||||
}
|
||||
QColor transparentColor = QColor(135, 206, 235, 40);
|
||||
palette.setColor(QPalette::Highlight, transparentColor);
|
||||
this->setPalette(palette);
|
||||
}
|
||||
|
||||
void GameListFrame::SortNameAscending(int columnIndex) {
|
||||
|
@ -174,7 +174,8 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices,
|
||||
connect(ui->chooseHomeTabComboBox, &QComboBox::currentTextChanged, this,
|
||||
[](const QString& hometab) { Config::setChooseHomeTab(hometab.toStdString()); });
|
||||
|
||||
// Add background image opacity slider connection
|
||||
connect(ui->showBackgroundImageCheckBox, &QCheckBox::stateChanged, this,
|
||||
[](int state) { Config::setShowBackgroundImage(state == Qt::Checked); });
|
||||
connect(ui->backgroundImageOpacitySlider, &QSlider::valueChanged, this,
|
||||
[](int value) { Config::setBackgroundImageOpacity(value); });
|
||||
}
|
||||
@ -416,6 +417,7 @@ void SettingsDialog::LoadValuesFromConfig() {
|
||||
ui->removeFolderButton->setEnabled(!ui->gameFoldersListWidget->selectedItems().isEmpty());
|
||||
ResetInstallFolders();
|
||||
ui->backgroundImageOpacitySlider->setValue(Config::getBackgroundImageOpacity());
|
||||
ui->showBackgroundImageCheckBox->setChecked(Config::getShowBackgroundImage());
|
||||
}
|
||||
|
||||
void SettingsDialog::InitializeEmulatorLanguages() {
|
||||
@ -646,6 +648,8 @@ void SettingsDialog::UpdateSettings() {
|
||||
Config::setChooseHomeTab(ui->chooseHomeTabComboBox->currentText().toStdString());
|
||||
Config::setCompatibilityEnabled(ui->enableCompatibilityCheckBox->isChecked());
|
||||
Config::setCheckCompatibilityOnStartup(ui->checkCompatibilityOnStartupCheckBox->isChecked());
|
||||
Config::setBackgroundImageOpacity(ui->backgroundImageOpacitySlider->value());
|
||||
Config::setShowBackgroundImage(ui->showBackgroundImageCheckBox->isChecked());
|
||||
|
||||
#ifdef ENABLE_DISCORD_RPC
|
||||
auto* rpc = Common::Singleton<DiscordRPCHandler::RPC>::Instance();
|
||||
|
Loading…
Reference in New Issue
Block a user