Qt: Add option for memory card type/mode

This commit is contained in:
Connor McLaughlin 2020-04-27 16:16:14 +10:00
parent bae4945c7a
commit 79111e4e03
4 changed files with 29 additions and 7 deletions

View File

@ -30,6 +30,7 @@ Other features include:
- Namco GunCon lightgun support (simulated with mouse) - Namco GunCon lightgun support (simulated with mouse)
- Qt and SDL frontends for desktop - Qt and SDL frontends for desktop
- Automatic content scanning - game titles/regions are provided by redump.org - Automatic content scanning - game titles/regions are provided by redump.org
- Optional automatic switching of memory cards for each game
## System Requirements ## System Requirements
- A CPU faster than a potato. - A CPU faster than a potato.

View File

@ -78,6 +78,18 @@ void PortSettingsWidget::createPortSettingsUi(int index, PortSettingsUI* ui)
ui->widget = new QWidget(m_tab_widget); ui->widget = new QWidget(m_tab_widget);
ui->layout = new QVBoxLayout(ui->widget); ui->layout = new QVBoxLayout(ui->widget);
ui->memory_card_type = new QComboBox(ui->widget);
for (int i = 0; i < static_cast<int>(MemoryCardType::Count); i++)
{
ui->memory_card_type->addItem(
QString::fromUtf8(Settings::GetMemoryCardTypeDisplayName(static_cast<MemoryCardType>(i))));
}
SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, ui->memory_card_type,
QStringLiteral("MemoryCards/Card%1Type").arg(index + 1),
&Settings::ParseMemoryCardTypeName, &Settings::GetMemoryCardTypeName);
ui->layout->addWidget(new QLabel(tr("Memory Card Type:"), ui->widget));
ui->layout->addWidget(ui->memory_card_type);
QHBoxLayout* memory_card_layout = new QHBoxLayout(); QHBoxLayout* memory_card_layout = new QHBoxLayout();
ui->memory_card_path = new QLineEdit(ui->widget); ui->memory_card_path = new QLineEdit(ui->widget);
SettingWidgetBinder::BindWidgetToStringSetting(m_host_interface, ui->memory_card_path, SettingWidgetBinder::BindWidgetToStringSetting(m_host_interface, ui->memory_card_path,
@ -92,7 +104,7 @@ void PortSettingsWidget::createPortSettingsUi(int index, PortSettingsUI* ui)
connect(memory_card_remove, &QPushButton::clicked, [this, index]() { onEjectMemoryCardClicked(index); }); connect(memory_card_remove, &QPushButton::clicked, [this, index]() { onEjectMemoryCardClicked(index); });
memory_card_layout->addWidget(memory_card_remove); memory_card_layout->addWidget(memory_card_remove);
ui->layout->addWidget(new QLabel(tr("Memory Card Path:"), ui->widget)); ui->layout->addWidget(new QLabel(tr("Shared Memory Card Path:"), ui->widget));
ui->layout->addLayout(memory_card_layout); ui->layout->addLayout(memory_card_layout);
ui->layout->addWidget(new QLabel(tr("Controller Type:"), ui->widget)); ui->layout->addWidget(new QLabel(tr("Controller Type:"), ui->widget));
@ -101,7 +113,7 @@ void PortSettingsWidget::createPortSettingsUi(int index, PortSettingsUI* ui)
for (int i = 0; i < static_cast<int>(ControllerType::Count); i++) for (int i = 0; i < static_cast<int>(ControllerType::Count); i++)
{ {
ui->controller_type->addItem( ui->controller_type->addItem(
QString::fromLocal8Bit(Settings::GetControllerTypeDisplayName(static_cast<ControllerType>(i)))); QString::fromUtf8(Settings::GetControllerTypeDisplayName(static_cast<ControllerType>(i))));
} }
ControllerType ctype = Settings::ParseControllerTypeName( ControllerType ctype = Settings::ParseControllerTypeName(
m_host_interface->getSettingValue(QStringLiteral("Controller%1/Type").arg(index + 1)) m_host_interface->getSettingValue(QStringLiteral("Controller%1/Type").arg(index + 1))
@ -327,8 +339,10 @@ void PortSettingsWidget::onBrowseMemoryCardPathClicked(int index)
void PortSettingsWidget::onEjectMemoryCardClicked(int index) void PortSettingsWidget::onEjectMemoryCardClicked(int index)
{ {
QSignalBlocker blocker(m_port_ui[index].memory_card_path); QSignalBlocker blocker(m_port_ui[index].memory_card_path);
m_port_ui[index].memory_card_type->setCurrentIndex(0);
m_port_ui[index].memory_card_path->setText(QString()); m_port_ui[index].memory_card_path->setText(QString());
m_host_interface->removeSettingValue(QStringLiteral("MemoryCards/Card%1Path").arg(index + 1)); m_host_interface->putSettingValue(QStringLiteral("MemoryCards/Card%1Type").arg(index + 1), QStringLiteral("None"));
m_host_interface->putSettingValue(QStringLiteral("MemoryCards/Card%1Path").arg(index + 1), QString());
m_host_interface->applySettings(); m_host_interface->applySettings();
} }

View File

@ -36,6 +36,7 @@ private:
QWidget* widget; QWidget* widget;
QVBoxLayout* layout; QVBoxLayout* layout;
QComboBox* controller_type; QComboBox* controller_type;
QComboBox* memory_card_type;
QLineEdit* memory_card_path; QLineEdit* memory_card_path;
QWidget* button_binding_container; QWidget* button_binding_container;
InputBindingWidget* first_button; InputBindingWidget* first_button;

View File

@ -9,8 +9,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>700</width> <width>780</width>
<height>500</height> <height>820</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -30,7 +30,7 @@
<widget class="QListWidget" name="settingsCategory"> <widget class="QListWidget" name="settingsCategory">
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>200</width> <width>230</width>
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>
@ -122,7 +122,13 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>16777215</width> <width>16777215</width>
<height>110</height> <height>120</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>120</height>
</size> </size>
</property> </property>
</widget> </widget>