From 7f974ea2cb3b8e32ddbfaeefc7f7c45a7d271b3a Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 8 Jan 2025 16:34:41 +1000 Subject: [PATCH] Qt: Disable shared memcard settings outside of shared mode --- src/core/gpu_sw_rasterizer.inl | 2 + .../memorycardsettingswidget.cpp | 46 +++++++++++++++---- src/duckstation-qt/memorycardsettingswidget.h | 18 ++++++-- 3 files changed, 52 insertions(+), 14 deletions(-) diff --git a/src/core/gpu_sw_rasterizer.inl b/src/core/gpu_sw_rasterizer.inl index 9ad5ff02cb..9697d335c9 100644 --- a/src/core/gpu_sw_rasterizer.inl +++ b/src/core/gpu_sw_rasterizer.inl @@ -611,6 +611,8 @@ ALWAYS_INLINE_RELEASE static void ShadePixel(const PixelVectors& color = RG_BAToRGB5A1(rg, ba); } + if (!transparency_enable && preserve_mask.allfalse()) { StoreVector(start_x, y, color); return; } + GSVectorNi bg_color = LoadVector(start_x, y); if constexpr (transparency_enable) diff --git a/src/duckstation-qt/memorycardsettingswidget.cpp b/src/duckstation-qt/memorycardsettingswidget.cpp index 8bbab06a36..037cb9bacf 100644 --- a/src/duckstation-qt/memorycardsettingswidget.cpp +++ b/src/duckstation-qt/memorycardsettingswidget.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2025 Connor McLaughlin // SPDX-License-Identifier: CC-BY-NC-ND-4.0 #include "memorycardsettingswidget.h" @@ -18,8 +18,14 @@ #include "fmt/format.h" #include +#include #include +#include #include +#include +#include + +#include static constexpr char MEMORY_CARD_IMAGE_FILTER[] = QT_TRANSLATE_NOOP("MemoryCardSettingsWidget", "All Memory Card Types (*.mcd *.mcr *.mc)"); @@ -41,10 +47,11 @@ void MemoryCardSettingsWidget::createUi(SettingsWindow* dialog) { createPortSettingsUi(dialog, i, &m_port_ui[i]); layout->addWidget(m_port_ui[i].container); + onMemoryCardTypeChanged(i); } { - QGroupBox* box = new QGroupBox(tr("Shared Settings"), this); + QGroupBox* box = new QGroupBox(tr("Game-Specific Card Settings"), this); QVBoxLayout* box_layout = new QVBoxLayout(box); QPushButton* browse = new QPushButton(tr("Browse..."), box); QPushButton* open_memcards = new QPushButton(tr("Open..."), box); @@ -118,6 +125,8 @@ void MemoryCardSettingsWidget::createPortSettingsUi(SettingsWindow* dialog, int SettingWidgetBinder::BindWidgetToEnumSetting(m_dialog->getSettingsInterface(), ui->memory_card_type, "MemoryCards", fmt::format("Card{}Type", index + 1), &Settings::ParseMemoryCardTypeName, &Settings::GetMemoryCardTypeName, default_value); + connect(ui->memory_card_type, &QComboBox::currentIndexChanged, this, + std::bind(&MemoryCardSettingsWidget::onMemoryCardTypeChanged, this, index)); ui->layout->addWidget(new QLabel(tr("Memory Card Type:"), ui->container)); ui->layout->addWidget(ui->memory_card_type); @@ -132,22 +141,41 @@ void MemoryCardSettingsWidget::createPortSettingsUi(SettingsWindow* dialog, int } memory_card_layout->addWidget(ui->memory_card_path); - QPushButton* memory_card_path_browse = new QPushButton(tr("Browse..."), ui->container); - connect(memory_card_path_browse, &QPushButton::clicked, this, + ui->memory_card_path_browse = new QPushButton(tr("Browse..."), ui->container); + connect(ui->memory_card_path_browse, &QPushButton::clicked, this, [this, index]() { onBrowseMemoryCardPathClicked(index); }); - memory_card_layout->addWidget(memory_card_path_browse); + memory_card_layout->addWidget(ui->memory_card_path_browse); - QPushButton* memory_card_path_reset = new QPushButton(tr("Reset"), ui->container); - connect(memory_card_path_reset, &QPushButton::clicked, this, + ui->memory_card_path_reset = new QPushButton(tr("Reset"), ui->container); + connect(ui->memory_card_path_reset, &QPushButton::clicked, this, [this, index]() { onResetMemoryCardPathClicked(index); }); - memory_card_layout->addWidget(memory_card_path_reset); + memory_card_layout->addWidget(ui->memory_card_path_reset); - ui->layout->addWidget(new QLabel(tr("Shared Memory Card Path:"), ui->container)); + ui->memory_card_path_label = new QLabel(tr("Shared Memory Card Path:"), ui->container); + ui->layout->addWidget(ui->memory_card_path_label); ui->layout->addLayout(memory_card_layout); ui->layout->addStretch(1); } +void MemoryCardSettingsWidget::onMemoryCardTypeChanged(int index) +{ + const MemoryCardType default_type = + (index == 0) ? Settings::DEFAULT_MEMORY_CARD_1_TYPE : Settings::DEFAULT_MEMORY_CARD_2_TYPE; + const MemoryCardType type = + Settings::ParseMemoryCardTypeName(m_dialog + ->getEffectiveStringValue("MemoryCards", + TinyString::from_format("Card{}Type", index + 1), + Settings::GetMemoryCardTypeName(default_type)) + .c_str()) + .value_or(default_type); + const bool shared_enabled = (type == MemoryCardType::Shared); + m_port_ui[index].memory_card_path_label->setEnabled(shared_enabled); + m_port_ui[index].memory_card_path->setEnabled(shared_enabled); + m_port_ui[index].memory_card_path_browse->setEnabled(shared_enabled); + m_port_ui[index].memory_card_path_reset->setEnabled(shared_enabled); +} + void MemoryCardSettingsWidget::onBrowseMemoryCardPathClicked(int index) { QString path = QDir::toNativeSeparators(QFileDialog::getOpenFileName(this, tr("Select path to memory card image"), diff --git a/src/duckstation-qt/memorycardsettingswidget.h b/src/duckstation-qt/memorycardsettingswidget.h index 4426fc0df3..ddccbd9cea 100644 --- a/src/duckstation-qt/memorycardsettingswidget.h +++ b/src/duckstation-qt/memorycardsettingswidget.h @@ -1,18 +1,22 @@ -// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin +// SPDX-FileCopyrightText: 2019-2025 Connor McLaughlin // SPDX-License-Identifier: CC-BY-NC-ND-4.0 #pragma once #include "core/types.h" -#include -#include -#include -#include #include + #include #include +class QLabel; +class QGroupBox; +class QVBoxLayout; +class QComboBox; +class QLineEdit; +class QPushButton; + class SettingsWindow; class MemoryCardSettingsWidget : public QWidget @@ -31,11 +35,15 @@ class MemoryCardSettingsWidget : public QWidget QGroupBox* container; QVBoxLayout* layout; QComboBox* memory_card_type; + QLabel* memory_card_path_label; QLineEdit* memory_card_path; + QPushButton* memory_card_path_browse; + QPushButton* memory_card_path_reset; }; void createUi(SettingsWindow* dialog); void createPortSettingsUi(SettingsWindow* dialog, int index, PortSettingsUI* ui); + void onMemoryCardTypeChanged(int index); void onBrowseMemoryCardPathClicked(int index); void onResetMemoryCardPathClicked(int index); void onMemoryCardPathChanged(int index);