2018-01-04 00:41:31 +00:00
|
|
|
// Copyright 2018 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2018-01-04 00:41:31 +00:00
|
|
|
|
2018-07-06 22:40:15 +00:00
|
|
|
#include "DolphinQt/Settings/GameCubePane.h"
|
2018-01-04 00:41:31 +00:00
|
|
|
|
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QComboBox>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QFileInfo>
|
2021-09-08 20:08:43 +00:00
|
|
|
#include <QFormLayout>
|
2018-01-04 00:41:31 +00:00
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QGroupBox>
|
2022-01-19 00:32:32 +00:00
|
|
|
#include <QHBoxLayout>
|
2019-01-24 20:08:21 +00:00
|
|
|
#include <QInputDialog>
|
2018-01-04 00:41:31 +00:00
|
|
|
#include <QLabel>
|
2021-07-04 10:53:53 +00:00
|
|
|
#include <QLineEdit>
|
2018-01-04 00:41:31 +00:00
|
|
|
#include <QPushButton>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
2022-01-12 01:10:13 +00:00
|
|
|
#include <array>
|
2019-01-24 20:08:21 +00:00
|
|
|
#include <utility>
|
|
|
|
|
2022-01-11 20:25:17 +00:00
|
|
|
#include "Common/Assert.h"
|
2018-01-04 00:41:31 +00:00
|
|
|
#include "Common/CommonPaths.h"
|
2018-07-04 21:01:50 +00:00
|
|
|
#include "Common/Config/Config.h"
|
2018-01-04 00:41:31 +00:00
|
|
|
#include "Common/FileUtil.h"
|
2021-07-04 10:53:53 +00:00
|
|
|
#include "Common/MsgHandler.h"
|
2018-05-28 01:48:04 +00:00
|
|
|
|
2018-07-04 21:01:50 +00:00
|
|
|
#include "Core/Config/MainSettings.h"
|
2018-01-04 00:41:31 +00:00
|
|
|
#include "Core/ConfigManager.h"
|
|
|
|
#include "Core/Core.h"
|
|
|
|
#include "Core/HW/EXI/EXI.h"
|
|
|
|
#include "Core/HW/GCMemcard/GCMemcard.h"
|
2021-07-04 10:53:53 +00:00
|
|
|
#include "Core/NetPlayServer.h"
|
2023-03-10 19:16:37 +00:00
|
|
|
#include "Core/System.h"
|
2018-05-28 01:48:04 +00:00
|
|
|
|
2018-07-06 22:40:15 +00:00
|
|
|
#include "DolphinQt/Config/Mapping/MappingWindow.h"
|
2019-08-15 02:08:20 +00:00
|
|
|
#include "DolphinQt/GCMemcardManager.h"
|
2021-10-10 02:28:59 +00:00
|
|
|
#include "DolphinQt/QtUtils/DolphinFileDialog.h"
|
2019-03-04 19:49:00 +00:00
|
|
|
#include "DolphinQt/QtUtils/ModalMessageBox.h"
|
2022-03-08 07:51:29 +00:00
|
|
|
#include "DolphinQt/QtUtils/NonDefaultQPushButton.h"
|
2023-07-30 22:42:15 +00:00
|
|
|
#include "DolphinQt/QtUtils/SetWindowDecorations.h"
|
2022-04-18 22:39:37 +00:00
|
|
|
#include "DolphinQt/QtUtils/SignalBlocking.h"
|
2021-07-04 10:53:53 +00:00
|
|
|
#include "DolphinQt/Settings.h"
|
2021-09-08 20:08:43 +00:00
|
|
|
#include "DolphinQt/Settings/BroadbandAdapterSettingsDialog.h"
|
2018-01-04 00:41:31 +00:00
|
|
|
|
2019-01-24 20:08:21 +00:00
|
|
|
enum
|
2018-01-25 19:39:03 +00:00
|
|
|
{
|
2019-01-24 20:08:21 +00:00
|
|
|
SLOT_A_INDEX,
|
|
|
|
SLOT_B_INDEX,
|
|
|
|
SLOT_SP1_INDEX,
|
|
|
|
SLOT_COUNT
|
2018-01-25 19:39:03 +00:00
|
|
|
};
|
2018-01-04 00:41:31 +00:00
|
|
|
|
|
|
|
GameCubePane::GameCubePane()
|
|
|
|
{
|
|
|
|
CreateWidgets();
|
|
|
|
LoadSettings();
|
2018-01-25 19:39:03 +00:00
|
|
|
ConnectWidgets();
|
2018-01-04 00:41:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GameCubePane::CreateWidgets()
|
|
|
|
{
|
2020-08-17 07:07:38 +00:00
|
|
|
using ExpansionInterface::EXIDeviceType;
|
|
|
|
|
2019-01-24 20:08:21 +00:00
|
|
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
2018-01-04 00:41:31 +00:00
|
|
|
|
|
|
|
// IPL Settings
|
2019-01-24 20:08:21 +00:00
|
|
|
QGroupBox* ipl_box = new QGroupBox(tr("IPL Settings"), this);
|
2021-09-08 20:08:43 +00:00
|
|
|
QVBoxLayout* ipl_box_layout = new QVBoxLayout(ipl_box);
|
|
|
|
ipl_box->setLayout(ipl_box_layout);
|
2018-01-04 00:41:31 +00:00
|
|
|
|
2019-01-24 20:08:21 +00:00
|
|
|
m_skip_main_menu = new QCheckBox(tr("Skip Main Menu"), ipl_box);
|
2021-09-08 20:08:43 +00:00
|
|
|
ipl_box_layout->addWidget(m_skip_main_menu);
|
|
|
|
|
|
|
|
QFormLayout* ipl_language_layout = new QFormLayout;
|
|
|
|
ipl_language_layout->setFormAlignment(Qt::AlignLeft | Qt::AlignTop);
|
|
|
|
ipl_language_layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
|
|
|
|
ipl_box_layout->addLayout(ipl_language_layout);
|
|
|
|
|
2019-01-24 20:08:21 +00:00
|
|
|
m_language_combo = new QComboBox(ipl_box);
|
|
|
|
m_language_combo->setCurrentIndex(-1);
|
2021-09-08 20:08:43 +00:00
|
|
|
ipl_language_layout->addRow(tr("System Language:"), m_language_combo);
|
2018-01-04 00:41:31 +00:00
|
|
|
|
|
|
|
// Add languages
|
2019-01-24 20:08:21 +00:00
|
|
|
for (const auto& entry : {std::make_pair(tr("English"), 0), std::make_pair(tr("German"), 1),
|
|
|
|
std::make_pair(tr("French"), 2), std::make_pair(tr("Spanish"), 3),
|
|
|
|
std::make_pair(tr("Italian"), 4), std::make_pair(tr("Dutch"), 5)})
|
|
|
|
{
|
|
|
|
m_language_combo->addItem(entry.first, entry.second);
|
|
|
|
}
|
2018-01-04 00:41:31 +00:00
|
|
|
|
|
|
|
// Device Settings
|
2019-01-24 20:08:21 +00:00
|
|
|
QGroupBox* device_box = new QGroupBox(tr("Device Settings"), this);
|
|
|
|
QGridLayout* device_layout = new QGridLayout(device_box);
|
2018-01-04 00:41:31 +00:00
|
|
|
device_box->setLayout(device_layout);
|
|
|
|
|
2022-01-11 20:25:17 +00:00
|
|
|
for (ExpansionInterface::Slot slot : ExpansionInterface::SLOTS)
|
2019-01-24 20:08:21 +00:00
|
|
|
{
|
2022-01-11 20:25:17 +00:00
|
|
|
m_slot_combos[slot] = new QComboBox(device_box);
|
|
|
|
m_slot_combos[slot]->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
2022-03-08 07:51:29 +00:00
|
|
|
m_slot_buttons[slot] = new NonDefaultQPushButton(tr("..."), device_box);
|
2022-01-11 20:25:17 +00:00
|
|
|
m_slot_buttons[slot]->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
2019-01-24 20:08:21 +00:00
|
|
|
}
|
2018-01-04 00:41:31 +00:00
|
|
|
|
2022-01-19 00:32:32 +00:00
|
|
|
for (ExpansionInterface::Slot slot : ExpansionInterface::MEMCARD_SLOTS)
|
|
|
|
{
|
|
|
|
m_memcard_path_layouts[slot] = new QHBoxLayout();
|
|
|
|
m_memcard_path_labels[slot] = new QLabel(tr("Memory Card Path:"));
|
|
|
|
m_memcard_paths[slot] = new QLineEdit();
|
|
|
|
m_memcard_path_layouts[slot]->addWidget(m_memcard_path_labels[slot]);
|
|
|
|
m_memcard_path_layouts[slot]->addWidget(m_memcard_paths[slot]);
|
|
|
|
|
|
|
|
m_agp_path_layouts[slot] = new QHBoxLayout();
|
|
|
|
m_agp_path_labels[slot] = new QLabel(tr("GBA Cartridge Path:"));
|
|
|
|
m_agp_paths[slot] = new QLineEdit();
|
|
|
|
m_agp_path_layouts[slot]->addWidget(m_agp_path_labels[slot]);
|
|
|
|
m_agp_path_layouts[slot]->addWidget(m_agp_paths[slot]);
|
2022-01-19 02:05:05 +00:00
|
|
|
|
2022-11-07 04:59:39 +00:00
|
|
|
m_gci_path_layouts[slot] = new QVBoxLayout();
|
2022-01-19 02:05:05 +00:00
|
|
|
m_gci_path_labels[slot] = new QLabel(tr("GCI Folder Path:"));
|
2022-11-07 04:59:39 +00:00
|
|
|
m_gci_override_labels[slot] =
|
|
|
|
new QLabel(tr("Warning: A GCI folder override path is currently configured for this slot. "
|
|
|
|
"Adjusting the GCI path here will have no effect."));
|
|
|
|
m_gci_override_labels[slot]->setHidden(true);
|
|
|
|
m_gci_override_labels[slot]->setWordWrap(true);
|
2022-01-19 02:05:05 +00:00
|
|
|
m_gci_paths[slot] = new QLineEdit();
|
2022-11-07 04:59:39 +00:00
|
|
|
auto* hlayout = new QHBoxLayout();
|
|
|
|
hlayout->addWidget(m_gci_path_labels[slot]);
|
|
|
|
hlayout->addWidget(m_gci_paths[slot]);
|
|
|
|
m_gci_path_layouts[slot]->addWidget(m_gci_override_labels[slot]);
|
|
|
|
m_gci_path_layouts[slot]->addLayout(hlayout);
|
2022-01-19 00:32:32 +00:00
|
|
|
}
|
|
|
|
|
2018-01-04 00:41:31 +00:00
|
|
|
// Add slot devices
|
2022-01-12 01:10:13 +00:00
|
|
|
for (const auto device : {EXIDeviceType::None, EXIDeviceType::Dummy, EXIDeviceType::MemoryCard,
|
|
|
|
EXIDeviceType::MemoryCardFolder, EXIDeviceType::Gecko,
|
|
|
|
EXIDeviceType::AGP, EXIDeviceType::Microphone})
|
2018-01-04 00:41:31 +00:00
|
|
|
{
|
2022-01-12 01:10:13 +00:00
|
|
|
const QString name = tr(fmt::format("{:n}", device).c_str());
|
|
|
|
const int value = static_cast<int>(device);
|
2022-01-11 20:25:17 +00:00
|
|
|
m_slot_combos[ExpansionInterface::Slot::A]->addItem(name, value);
|
|
|
|
m_slot_combos[ExpansionInterface::Slot::B]->addItem(name, value);
|
2018-01-04 00:41:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add SP1 devices
|
2022-01-12 01:10:13 +00:00
|
|
|
for (const auto device : {
|
|
|
|
EXIDeviceType::None,
|
|
|
|
EXIDeviceType::Dummy,
|
|
|
|
EXIDeviceType::Ethernet,
|
|
|
|
EXIDeviceType::EthernetXLink,
|
|
|
|
EXIDeviceType::EthernetTapServer,
|
2022-05-22 16:21:28 +00:00
|
|
|
EXIDeviceType::EthernetBuiltIn,
|
2023-12-03 07:37:28 +00:00
|
|
|
EXIDeviceType::ModemTapServer,
|
2022-01-12 01:10:13 +00:00
|
|
|
})
|
2018-01-04 00:41:31 +00:00
|
|
|
{
|
2022-01-11 20:25:17 +00:00
|
|
|
m_slot_combos[ExpansionInterface::Slot::SP1]->addItem(tr(fmt::format("{:n}", device).c_str()),
|
|
|
|
static_cast<int>(device));
|
2018-01-04 00:41:31 +00:00
|
|
|
}
|
|
|
|
|
2022-01-19 00:32:32 +00:00
|
|
|
{
|
|
|
|
int row = 0;
|
|
|
|
device_layout->addWidget(new QLabel(tr("Slot A:")), row, 0);
|
|
|
|
device_layout->addWidget(m_slot_combos[ExpansionInterface::Slot::A], row, 1);
|
|
|
|
device_layout->addWidget(m_slot_buttons[ExpansionInterface::Slot::A], row, 2);
|
|
|
|
|
|
|
|
++row;
|
|
|
|
device_layout->addLayout(m_memcard_path_layouts[ExpansionInterface::Slot::A], row, 0, 1, 3);
|
|
|
|
|
|
|
|
++row;
|
|
|
|
device_layout->addLayout(m_agp_path_layouts[ExpansionInterface::Slot::A], row, 0, 1, 3);
|
|
|
|
|
2022-01-19 02:05:05 +00:00
|
|
|
++row;
|
|
|
|
device_layout->addLayout(m_gci_path_layouts[ExpansionInterface::Slot::A], row, 0, 1, 3);
|
|
|
|
|
2022-01-19 00:32:32 +00:00
|
|
|
++row;
|
|
|
|
device_layout->addWidget(new QLabel(tr("Slot B:")), row, 0);
|
|
|
|
device_layout->addWidget(m_slot_combos[ExpansionInterface::Slot::B], row, 1);
|
|
|
|
device_layout->addWidget(m_slot_buttons[ExpansionInterface::Slot::B], row, 2);
|
|
|
|
|
|
|
|
++row;
|
|
|
|
device_layout->addLayout(m_memcard_path_layouts[ExpansionInterface::Slot::B], row, 0, 1, 3);
|
|
|
|
|
|
|
|
++row;
|
|
|
|
device_layout->addLayout(m_agp_path_layouts[ExpansionInterface::Slot::B], row, 0, 1, 3);
|
|
|
|
|
2022-01-19 02:05:05 +00:00
|
|
|
++row;
|
|
|
|
device_layout->addLayout(m_gci_path_layouts[ExpansionInterface::Slot::B], row, 0, 1, 3);
|
|
|
|
|
2022-01-19 00:32:32 +00:00
|
|
|
++row;
|
|
|
|
device_layout->addWidget(new QLabel(tr("SP1:")), row, 0);
|
|
|
|
device_layout->addWidget(m_slot_combos[ExpansionInterface::Slot::SP1], row, 1);
|
|
|
|
device_layout->addWidget(m_slot_buttons[ExpansionInterface::Slot::SP1], row, 2);
|
|
|
|
}
|
2018-01-04 00:41:31 +00:00
|
|
|
|
2021-07-04 10:53:53 +00:00
|
|
|
#ifdef HAS_LIBMGBA
|
|
|
|
// GBA Settings
|
|
|
|
auto* gba_box = new QGroupBox(tr("GBA Settings"), this);
|
|
|
|
auto* gba_layout = new QGridLayout(gba_box);
|
|
|
|
gba_box->setLayout(gba_layout);
|
|
|
|
int gba_row = 0;
|
|
|
|
|
|
|
|
m_gba_threads = new QCheckBox(tr("Run GBA Cores in Dedicated Threads"));
|
|
|
|
gba_layout->addWidget(m_gba_threads, gba_row, 0, 1, -1);
|
|
|
|
gba_row++;
|
|
|
|
|
|
|
|
m_gba_bios_edit = new QLineEdit();
|
2022-03-08 07:51:29 +00:00
|
|
|
m_gba_browse_bios = new NonDefaultQPushButton(QStringLiteral("..."));
|
2021-07-04 10:53:53 +00:00
|
|
|
gba_layout->addWidget(new QLabel(tr("BIOS:")), gba_row, 0);
|
|
|
|
gba_layout->addWidget(m_gba_bios_edit, gba_row, 1);
|
|
|
|
gba_layout->addWidget(m_gba_browse_bios, gba_row, 2);
|
|
|
|
gba_row++;
|
|
|
|
|
|
|
|
for (size_t i = 0; i < m_gba_rom_edits.size(); ++i)
|
|
|
|
{
|
|
|
|
m_gba_rom_edits[i] = new QLineEdit();
|
2022-03-08 07:51:29 +00:00
|
|
|
m_gba_browse_roms[i] = new NonDefaultQPushButton(QStringLiteral("..."));
|
2021-07-04 10:53:53 +00:00
|
|
|
gba_layout->addWidget(new QLabel(tr("Port %1 ROM:").arg(i + 1)), gba_row, 0);
|
|
|
|
gba_layout->addWidget(m_gba_rom_edits[i], gba_row, 1);
|
|
|
|
gba_layout->addWidget(m_gba_browse_roms[i], gba_row, 2);
|
|
|
|
gba_row++;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_gba_save_rom_path = new QCheckBox(tr("Save in Same Directory as the ROM"));
|
|
|
|
gba_layout->addWidget(m_gba_save_rom_path, gba_row, 0, 1, -1);
|
|
|
|
gba_row++;
|
|
|
|
|
|
|
|
m_gba_saves_edit = new QLineEdit();
|
2022-03-08 07:51:29 +00:00
|
|
|
m_gba_browse_saves = new NonDefaultQPushButton(QStringLiteral("..."));
|
2021-07-04 10:53:53 +00:00
|
|
|
gba_layout->addWidget(new QLabel(tr("Saves:")), gba_row, 0);
|
|
|
|
gba_layout->addWidget(m_gba_saves_edit, gba_row, 1);
|
|
|
|
gba_layout->addWidget(m_gba_browse_saves, gba_row, 2);
|
|
|
|
gba_row++;
|
|
|
|
#endif
|
|
|
|
|
2018-01-04 00:41:31 +00:00
|
|
|
layout->addWidget(ipl_box);
|
|
|
|
layout->addWidget(device_box);
|
2021-07-04 10:53:53 +00:00
|
|
|
#ifdef HAS_LIBMGBA
|
|
|
|
layout->addWidget(gba_box);
|
|
|
|
#endif
|
2018-01-04 00:41:31 +00:00
|
|
|
|
2018-03-24 17:18:17 +00:00
|
|
|
layout->addStretch();
|
|
|
|
|
2018-01-04 00:41:31 +00:00
|
|
|
setLayout(layout);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameCubePane::ConnectWidgets()
|
|
|
|
{
|
|
|
|
// IPL Settings
|
|
|
|
connect(m_skip_main_menu, &QCheckBox::stateChanged, this, &GameCubePane::SaveSettings);
|
2023-11-04 21:01:39 +00:00
|
|
|
connect(m_language_combo, &QComboBox::currentIndexChanged, this, &GameCubePane::SaveSettings);
|
2018-01-04 00:41:31 +00:00
|
|
|
|
|
|
|
// Device Settings
|
2022-01-11 20:25:17 +00:00
|
|
|
for (ExpansionInterface::Slot slot : ExpansionInterface::SLOTS)
|
2018-01-04 00:41:31 +00:00
|
|
|
{
|
2023-11-04 21:01:39 +00:00
|
|
|
connect(m_slot_combos[slot], &QComboBox::currentIndexChanged, this,
|
2022-01-11 20:25:17 +00:00
|
|
|
[this, slot] { UpdateButton(slot); });
|
2023-11-04 21:01:39 +00:00
|
|
|
connect(m_slot_combos[slot], &QComboBox::currentIndexChanged, this,
|
2018-01-04 00:41:31 +00:00
|
|
|
&GameCubePane::SaveSettings);
|
2022-01-11 20:25:17 +00:00
|
|
|
connect(m_slot_buttons[slot], &QPushButton::clicked, [this, slot] { OnConfigPressed(slot); });
|
2019-01-24 20:08:21 +00:00
|
|
|
}
|
2021-07-04 10:53:53 +00:00
|
|
|
|
2022-01-19 00:32:32 +00:00
|
|
|
for (ExpansionInterface::Slot slot : ExpansionInterface::MEMCARD_SLOTS)
|
|
|
|
{
|
|
|
|
connect(m_memcard_paths[slot], &QLineEdit::editingFinished, [this, slot] {
|
|
|
|
// revert path change on failure
|
|
|
|
if (!SetMemcard(slot, m_memcard_paths[slot]->text()))
|
|
|
|
LoadSettings();
|
|
|
|
});
|
|
|
|
connect(m_agp_paths[slot], &QLineEdit::editingFinished,
|
|
|
|
[this, slot] { SetAGPRom(slot, m_agp_paths[slot]->text()); });
|
2022-01-19 02:05:05 +00:00
|
|
|
connect(m_gci_paths[slot], &QLineEdit::editingFinished, [this, slot] {
|
|
|
|
// revert path change on failure
|
|
|
|
if (!SetGCIFolder(slot, m_gci_paths[slot]->text()))
|
|
|
|
LoadSettings();
|
|
|
|
});
|
2022-01-19 00:32:32 +00:00
|
|
|
}
|
|
|
|
|
2021-07-04 10:53:53 +00:00
|
|
|
#ifdef HAS_LIBMGBA
|
|
|
|
// GBA Settings
|
|
|
|
connect(m_gba_threads, &QCheckBox::stateChanged, this, &GameCubePane::SaveSettings);
|
|
|
|
connect(m_gba_bios_edit, &QLineEdit::editingFinished, this, &GameCubePane::SaveSettings);
|
|
|
|
connect(m_gba_browse_bios, &QPushButton::clicked, this, &GameCubePane::BrowseGBABios);
|
|
|
|
connect(m_gba_save_rom_path, &QCheckBox::stateChanged, this, &GameCubePane::SaveRomPathChanged);
|
|
|
|
connect(m_gba_saves_edit, &QLineEdit::editingFinished, this, &GameCubePane::SaveSettings);
|
|
|
|
connect(m_gba_browse_saves, &QPushButton::clicked, this, &GameCubePane::BrowseGBASaves);
|
|
|
|
for (size_t i = 0; i < m_gba_browse_roms.size(); ++i)
|
|
|
|
{
|
|
|
|
connect(m_gba_rom_edits[i], &QLineEdit::editingFinished, this, &GameCubePane::SaveSettings);
|
|
|
|
connect(m_gba_browse_roms[i], &QPushButton::clicked, this, [this, i] { BrowseGBARom(i); });
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Emulation State
|
|
|
|
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this,
|
|
|
|
&GameCubePane::OnEmulationStateChanged);
|
|
|
|
OnEmulationStateChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameCubePane::OnEmulationStateChanged()
|
|
|
|
{
|
|
|
|
#ifdef HAS_LIBMGBA
|
|
|
|
bool gba_enabled = !NetPlay::IsNetPlayRunning();
|
|
|
|
m_gba_threads->setEnabled(gba_enabled);
|
|
|
|
m_gba_bios_edit->setEnabled(gba_enabled);
|
|
|
|
m_gba_browse_bios->setEnabled(gba_enabled);
|
|
|
|
m_gba_save_rom_path->setEnabled(gba_enabled);
|
|
|
|
m_gba_saves_edit->setEnabled(gba_enabled);
|
|
|
|
m_gba_browse_saves->setEnabled(gba_enabled);
|
|
|
|
for (size_t i = 0; i < m_gba_browse_roms.size(); ++i)
|
|
|
|
{
|
|
|
|
m_gba_rom_edits[i]->setEnabled(gba_enabled);
|
|
|
|
m_gba_browse_roms[i]->setEnabled(gba_enabled);
|
|
|
|
}
|
|
|
|
#endif
|
2019-01-24 20:08:21 +00:00
|
|
|
}
|
|
|
|
|
2022-01-11 20:25:17 +00:00
|
|
|
void GameCubePane::UpdateButton(ExpansionInterface::Slot slot)
|
2019-01-24 20:08:21 +00:00
|
|
|
{
|
2020-08-17 07:07:38 +00:00
|
|
|
const auto device =
|
|
|
|
static_cast<ExpansionInterface::EXIDeviceType>(m_slot_combos[slot]->currentData().toInt());
|
2019-01-24 20:08:21 +00:00
|
|
|
bool has_config = false;
|
|
|
|
|
|
|
|
switch (slot)
|
|
|
|
{
|
2022-01-11 20:25:17 +00:00
|
|
|
case ExpansionInterface::Slot::A:
|
|
|
|
case ExpansionInterface::Slot::B:
|
2022-07-11 20:33:57 +00:00
|
|
|
{
|
2020-08-17 07:07:38 +00:00
|
|
|
has_config = (device == ExpansionInterface::EXIDeviceType::MemoryCard ||
|
2022-01-19 02:05:05 +00:00
|
|
|
device == ExpansionInterface::EXIDeviceType::MemoryCardFolder ||
|
2020-08-17 07:07:38 +00:00
|
|
|
device == ExpansionInterface::EXIDeviceType::AGP ||
|
|
|
|
device == ExpansionInterface::EXIDeviceType::Microphone);
|
2022-07-11 20:33:57 +00:00
|
|
|
const bool hide_memory_card = device != ExpansionInterface::EXIDeviceType::MemoryCard ||
|
|
|
|
Config::IsDefaultMemcardPathConfigured(slot);
|
2022-01-19 02:05:05 +00:00
|
|
|
const bool hide_gci_path = device != ExpansionInterface::EXIDeviceType::MemoryCardFolder ||
|
|
|
|
Config::IsDefaultGCIFolderPathConfigured(slot);
|
2022-07-11 20:33:57 +00:00
|
|
|
m_memcard_path_labels[slot]->setHidden(hide_memory_card);
|
|
|
|
m_memcard_paths[slot]->setHidden(hide_memory_card);
|
2022-01-19 00:32:32 +00:00
|
|
|
m_agp_path_labels[slot]->setHidden(device != ExpansionInterface::EXIDeviceType::AGP);
|
|
|
|
m_agp_paths[slot]->setHidden(device != ExpansionInterface::EXIDeviceType::AGP);
|
2022-01-19 02:05:05 +00:00
|
|
|
m_gci_path_labels[slot]->setHidden(hide_gci_path);
|
|
|
|
m_gci_paths[slot]->setHidden(hide_gci_path);
|
2022-11-07 04:59:39 +00:00
|
|
|
|
|
|
|
// In the years before we introduced the GCI folder configuration paths it has become somewhat
|
|
|
|
// popular to use the GCI override path instead. Check if this is the case and display a warning
|
|
|
|
// if it is set, so users aren't confused why configuring the normal GCI path doesn't do
|
|
|
|
// anything.
|
|
|
|
m_gci_override_labels[slot]->setHidden(
|
|
|
|
device != ExpansionInterface::EXIDeviceType::MemoryCardFolder ||
|
|
|
|
Config::Get(Config::GetInfoForGCIPathOverride(slot)).empty());
|
|
|
|
|
2019-01-24 20:08:21 +00:00
|
|
|
break;
|
2022-07-11 20:33:57 +00:00
|
|
|
}
|
2022-01-11 20:25:17 +00:00
|
|
|
case ExpansionInterface::Slot::SP1:
|
2020-08-17 07:07:38 +00:00
|
|
|
has_config = (device == ExpansionInterface::EXIDeviceType::Ethernet ||
|
2022-05-22 16:21:28 +00:00
|
|
|
device == ExpansionInterface::EXIDeviceType::EthernetXLink ||
|
2023-02-13 01:58:17 +00:00
|
|
|
device == ExpansionInterface::EXIDeviceType::EthernetTapServer ||
|
2023-12-03 07:37:28 +00:00
|
|
|
device == ExpansionInterface::EXIDeviceType::EthernetBuiltIn ||
|
|
|
|
device == ExpansionInterface::EXIDeviceType::ModemTapServer);
|
2019-01-24 20:08:21 +00:00
|
|
|
break;
|
2018-01-04 00:41:31 +00:00
|
|
|
}
|
2019-01-24 20:08:21 +00:00
|
|
|
|
|
|
|
m_slot_buttons[slot]->setEnabled(has_config);
|
2018-01-04 00:41:31 +00:00
|
|
|
}
|
|
|
|
|
2022-01-11 20:25:17 +00:00
|
|
|
void GameCubePane::OnConfigPressed(ExpansionInterface::Slot slot)
|
2018-01-04 00:41:31 +00:00
|
|
|
{
|
2020-08-17 07:07:38 +00:00
|
|
|
const ExpansionInterface::EXIDeviceType device =
|
|
|
|
static_cast<ExpansionInterface::EXIDeviceType>(m_slot_combos[slot]->currentData().toInt());
|
|
|
|
|
|
|
|
switch (device)
|
2018-01-04 00:41:31 +00:00
|
|
|
{
|
2020-08-17 07:07:38 +00:00
|
|
|
case ExpansionInterface::EXIDeviceType::MemoryCard:
|
2022-01-11 20:25:17 +00:00
|
|
|
BrowseMemcard(slot);
|
|
|
|
return;
|
2022-01-19 02:05:05 +00:00
|
|
|
case ExpansionInterface::EXIDeviceType::MemoryCardFolder:
|
|
|
|
BrowseGCIFolder(slot);
|
|
|
|
return;
|
2020-08-17 07:07:38 +00:00
|
|
|
case ExpansionInterface::EXIDeviceType::AGP:
|
2022-01-11 20:25:17 +00:00
|
|
|
BrowseAGPRom(slot);
|
|
|
|
return;
|
2020-08-17 07:07:38 +00:00
|
|
|
case ExpansionInterface::EXIDeviceType::Microphone:
|
2023-07-30 22:42:15 +00:00
|
|
|
{
|
2022-01-11 20:25:17 +00:00
|
|
|
// TODO: convert MappingWindow to use Slot?
|
2023-07-30 22:42:15 +00:00
|
|
|
MappingWindow dialog(this, MappingWindow::Type::MAPPING_GC_MICROPHONE, static_cast<int>(slot));
|
|
|
|
SetQWidgetWindowDecorations(&dialog);
|
|
|
|
dialog.exec();
|
2018-01-04 00:41:31 +00:00
|
|
|
return;
|
2023-07-30 22:42:15 +00:00
|
|
|
}
|
2020-08-17 07:07:38 +00:00
|
|
|
case ExpansionInterface::EXIDeviceType::Ethernet:
|
2019-01-24 20:08:21 +00:00
|
|
|
{
|
2023-07-30 22:42:15 +00:00
|
|
|
BroadbandAdapterSettingsDialog dialog(this, BroadbandAdapterSettingsDialog::Type::Ethernet);
|
|
|
|
SetQWidgetWindowDecorations(&dialog);
|
|
|
|
dialog.exec();
|
2019-01-24 20:08:21 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-08-17 07:07:38 +00:00
|
|
|
case ExpansionInterface::EXIDeviceType::EthernetXLink:
|
2020-06-08 03:25:45 +00:00
|
|
|
{
|
2023-07-30 22:42:15 +00:00
|
|
|
BroadbandAdapterSettingsDialog dialog(this, BroadbandAdapterSettingsDialog::Type::XLinkKai);
|
|
|
|
SetQWidgetWindowDecorations(&dialog);
|
|
|
|
dialog.exec();
|
2019-01-24 20:08:21 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-02-13 01:58:17 +00:00
|
|
|
case ExpansionInterface::EXIDeviceType::EthernetTapServer:
|
|
|
|
{
|
|
|
|
BroadbandAdapterSettingsDialog dialog(this, BroadbandAdapterSettingsDialog::Type::TapServer);
|
|
|
|
SetQWidgetWindowDecorations(&dialog);
|
|
|
|
dialog.exec();
|
|
|
|
return;
|
|
|
|
}
|
2023-12-03 07:37:28 +00:00
|
|
|
case ExpansionInterface::EXIDeviceType::ModemTapServer:
|
|
|
|
{
|
|
|
|
BroadbandAdapterSettingsDialog dialog(this,
|
|
|
|
BroadbandAdapterSettingsDialog::Type::ModemTapServer);
|
|
|
|
SetQWidgetWindowDecorations(&dialog);
|
|
|
|
dialog.exec();
|
|
|
|
return;
|
|
|
|
}
|
2022-05-22 16:21:28 +00:00
|
|
|
case ExpansionInterface::EXIDeviceType::EthernetBuiltIn:
|
|
|
|
{
|
2023-07-30 22:42:15 +00:00
|
|
|
BroadbandAdapterSettingsDialog dialog(this, BroadbandAdapterSettingsDialog::Type::BuiltIn);
|
|
|
|
SetQWidgetWindowDecorations(&dialog);
|
|
|
|
dialog.exec();
|
2022-05-22 16:21:28 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-01-24 20:08:21 +00:00
|
|
|
default:
|
2020-08-17 07:07:38 +00:00
|
|
|
PanicAlertFmt("Unknown settings pressed for {}", device);
|
|
|
|
return;
|
2018-01-04 00:41:31 +00:00
|
|
|
}
|
2022-01-11 20:25:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GameCubePane::BrowseMemcard(ExpansionInterface::Slot slot)
|
|
|
|
{
|
|
|
|
ASSERT(ExpansionInterface::IsMemcardSlot(slot));
|
2018-01-04 00:41:31 +00:00
|
|
|
|
2022-01-18 23:40:48 +00:00
|
|
|
const QString filename = DolphinFileDialog::getSaveFileName(
|
2024-07-28 12:24:38 +00:00
|
|
|
this, tr("Choose a File to Open or Create"),
|
2022-01-18 23:40:48 +00:00
|
|
|
QString::fromStdString(File::GetUserPath(D_GCUSER_IDX)),
|
2023-04-15 04:55:53 +00:00
|
|
|
tr("GameCube Memory Cards (*.raw *.gcp)"), nullptr, QFileDialog::DontConfirmOverwrite);
|
2018-01-04 00:41:31 +00:00
|
|
|
|
2022-01-19 00:32:32 +00:00
|
|
|
if (!filename.isEmpty())
|
|
|
|
SetMemcard(slot, filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GameCubePane::SetMemcard(ExpansionInterface::Slot slot, const QString& filename)
|
|
|
|
{
|
2018-06-26 04:37:08 +00:00
|
|
|
if (filename.isEmpty())
|
2022-01-19 00:32:32 +00:00
|
|
|
{
|
|
|
|
ModalMessageBox::critical(this, tr("Error"), tr("Cannot set memory card to an empty path."));
|
|
|
|
return false;
|
|
|
|
}
|
2018-01-04 00:41:31 +00:00
|
|
|
|
2022-01-18 23:40:48 +00:00
|
|
|
const std::string raw_path =
|
|
|
|
WithUnifiedPathSeparators(QFileInfo(filename).absoluteFilePath().toStdString());
|
2018-01-04 00:41:31 +00:00
|
|
|
|
2022-01-18 23:40:48 +00:00
|
|
|
// Figure out if the user selected a card that has a valid region specifier in the filename.
|
|
|
|
const std::string jp_path = Config::GetMemcardPath(raw_path, slot, DiscIO::Region::NTSC_J);
|
|
|
|
const std::string us_path = Config::GetMemcardPath(raw_path, slot, DiscIO::Region::NTSC_U);
|
|
|
|
const std::string eu_path = Config::GetMemcardPath(raw_path, slot, DiscIO::Region::PAL);
|
|
|
|
const bool raw_path_valid = raw_path == jp_path || raw_path == us_path || raw_path == eu_path;
|
2018-06-26 04:37:08 +00:00
|
|
|
|
2022-01-18 23:40:48 +00:00
|
|
|
if (!raw_path_valid)
|
|
|
|
{
|
|
|
|
// TODO: We could try to autodetect the card region here and offer automatic renaming.
|
|
|
|
ModalMessageBox::critical(this, tr("Error"),
|
|
|
|
tr("The filename %1 does not conform to Dolphin's region code format "
|
|
|
|
"for memory cards. Please rename this file to either %2, %3, or "
|
|
|
|
"%4, matching the region of the save files that are on it.")
|
|
|
|
.arg(QString::fromStdString(PathToFileName(raw_path)))
|
|
|
|
.arg(QString::fromStdString(PathToFileName(us_path)))
|
|
|
|
.arg(QString::fromStdString(PathToFileName(eu_path)))
|
|
|
|
.arg(QString::fromStdString(PathToFileName(jp_path))));
|
2022-01-19 00:32:32 +00:00
|
|
|
return false;
|
2022-01-11 20:25:17 +00:00
|
|
|
}
|
2018-01-04 00:41:31 +00:00
|
|
|
|
2022-01-18 23:40:48 +00:00
|
|
|
// Memcard validity checks
|
|
|
|
for (const std::string& path : {jp_path, us_path, eu_path})
|
2022-01-11 20:25:17 +00:00
|
|
|
{
|
2022-01-18 23:40:48 +00:00
|
|
|
if (File::Exists(path))
|
2018-01-04 00:41:31 +00:00
|
|
|
{
|
2022-01-18 23:40:48 +00:00
|
|
|
auto [error_code, mc] = Memcard::GCMemcard::Open(path);
|
2018-02-02 11:28:57 +00:00
|
|
|
|
2022-01-18 23:40:48 +00:00
|
|
|
if (error_code.HasCriticalErrors() || !mc || !mc->IsValid())
|
2018-02-02 11:28:57 +00:00
|
|
|
{
|
2022-01-11 20:25:17 +00:00
|
|
|
ModalMessageBox::critical(
|
|
|
|
this, tr("Error"),
|
2022-01-18 23:40:48 +00:00
|
|
|
tr("The file\n%1\nis either corrupted or not a GameCube memory card file.\n%2")
|
|
|
|
.arg(QString::fromStdString(path))
|
|
|
|
.arg(GCMemcardManager::GetErrorMessagesForErrorCode(error_code)));
|
2022-01-19 00:32:32 +00:00
|
|
|
return false;
|
2018-02-02 11:28:57 +00:00
|
|
|
}
|
2018-01-04 00:41:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-18 23:40:48 +00:00
|
|
|
// Check if the other slot has the same memory card configured and refuse to use this card if so.
|
|
|
|
// The EU path is compared here, but it doesn't actually matter which one we compare since they
|
|
|
|
// follow a known pattern, so if the EU path matches the other match too and vice-versa.
|
|
|
|
for (ExpansionInterface::Slot other_slot : ExpansionInterface::MEMCARD_SLOTS)
|
|
|
|
{
|
|
|
|
if (other_slot == slot)
|
|
|
|
continue;
|
2018-06-17 07:18:22 +00:00
|
|
|
|
2022-01-18 23:40:48 +00:00
|
|
|
const std::string other_eu_path = Config::GetMemcardPath(other_slot, DiscIO::Region::PAL);
|
|
|
|
if (eu_path == other_eu_path)
|
|
|
|
{
|
|
|
|
ModalMessageBox::critical(
|
|
|
|
this, tr("Error"),
|
|
|
|
tr("The same file can't be used in multiple slots; it is already used by %1.")
|
|
|
|
.arg(QString::fromStdString(fmt::to_string(other_slot))));
|
2022-01-19 00:32:32 +00:00
|
|
|
return false;
|
2022-01-18 23:40:48 +00:00
|
|
|
}
|
|
|
|
}
|
2022-01-11 20:25:17 +00:00
|
|
|
|
2022-06-15 08:42:14 +00:00
|
|
|
const std::string old_eu_path = Config::GetMemcardPath(slot, DiscIO::Region::PAL);
|
2022-01-18 23:40:48 +00:00
|
|
|
Config::SetBase(Config::GetInfoForMemcardPath(slot), raw_path);
|
|
|
|
|
2024-04-09 03:33:55 +00:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
if (Core::IsRunning(system))
|
2018-01-04 00:41:31 +00:00
|
|
|
{
|
2022-01-18 23:40:48 +00:00
|
|
|
// If emulation is running and the new card is different from the old one, notify the system to
|
|
|
|
// eject the old and insert the new card.
|
|
|
|
// TODO: This should probably done by a config change callback instead.
|
|
|
|
if (eu_path != old_eu_path)
|
|
|
|
{
|
|
|
|
// ChangeDevice unplugs the device for 1 second, which means that games should notice that
|
|
|
|
// the path has changed and thus the memory card contents have changed
|
2024-04-09 03:33:55 +00:00
|
|
|
system.GetExpansionInterface().ChangeDevice(slot,
|
|
|
|
ExpansionInterface::EXIDeviceType::MemoryCard);
|
2022-01-18 23:40:48 +00:00
|
|
|
}
|
2018-01-04 00:41:31 +00:00
|
|
|
}
|
2022-01-19 00:32:32 +00:00
|
|
|
|
|
|
|
LoadSettings();
|
|
|
|
return true;
|
2022-01-11 20:25:17 +00:00
|
|
|
}
|
|
|
|
|
2022-01-19 02:05:05 +00:00
|
|
|
void GameCubePane::BrowseGCIFolder(ExpansionInterface::Slot slot)
|
|
|
|
{
|
|
|
|
ASSERT(ExpansionInterface::IsMemcardSlot(slot));
|
|
|
|
|
|
|
|
const QString path = DolphinFileDialog::getExistingDirectory(
|
2024-07-28 12:24:38 +00:00
|
|
|
this, tr("Choose GCI Base Folder"), QString::fromStdString(File::GetUserPath(D_GCUSER_IDX)));
|
2022-01-19 02:05:05 +00:00
|
|
|
|
|
|
|
if (!path.isEmpty())
|
|
|
|
SetGCIFolder(slot, path);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GameCubePane::SetGCIFolder(ExpansionInterface::Slot slot, const QString& path)
|
|
|
|
{
|
|
|
|
if (path.isEmpty())
|
|
|
|
{
|
|
|
|
ModalMessageBox::critical(this, tr("Error"), tr("Cannot set GCI folder to an empty path."));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string raw_path =
|
|
|
|
WithUnifiedPathSeparators(QFileInfo(path).absoluteFilePath().toStdString());
|
2023-01-24 19:25:49 +00:00
|
|
|
while (raw_path.ends_with('/'))
|
2022-01-19 02:05:05 +00:00
|
|
|
raw_path.pop_back();
|
|
|
|
|
|
|
|
// The user might be attempting to reset this path to its default, check for this.
|
|
|
|
const std::string default_jp_path = Config::GetGCIFolderPath("", slot, DiscIO::Region::NTSC_J);
|
|
|
|
const std::string default_us_path = Config::GetGCIFolderPath("", slot, DiscIO::Region::NTSC_U);
|
|
|
|
const std::string default_eu_path = Config::GetGCIFolderPath("", slot, DiscIO::Region::PAL);
|
|
|
|
const bool is_default_path =
|
|
|
|
raw_path == default_jp_path || raw_path == default_us_path || raw_path == default_eu_path;
|
|
|
|
|
|
|
|
bool path_changed;
|
|
|
|
if (is_default_path)
|
|
|
|
{
|
|
|
|
// Reset to default.
|
|
|
|
// Note that this does not need to check if the same card is in the other slot, because that's
|
|
|
|
// impossible given our constraints for folder names.
|
|
|
|
raw_path = "";
|
|
|
|
path_changed = !Config::IsDefaultGCIFolderPathConfigured(slot);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Figure out if the user selected a folder that ends in a valid region specifier.
|
|
|
|
const std::string jp_path = Config::GetGCIFolderPath(raw_path, slot, DiscIO::Region::NTSC_J);
|
|
|
|
const std::string us_path = Config::GetGCIFolderPath(raw_path, slot, DiscIO::Region::NTSC_U);
|
|
|
|
const std::string eu_path = Config::GetGCIFolderPath(raw_path, slot, DiscIO::Region::PAL);
|
|
|
|
const bool raw_path_valid = raw_path == jp_path || raw_path == us_path || raw_path == eu_path;
|
|
|
|
|
|
|
|
if (!raw_path_valid)
|
|
|
|
{
|
|
|
|
// TODO: We could try to autodetect the card region here and offer automatic renaming.
|
|
|
|
ModalMessageBox::critical(
|
|
|
|
this, tr("Error"),
|
|
|
|
tr("The folder %1 does not conform to Dolphin's region code format "
|
|
|
|
"for GCI folders. Please rename this folder to either %2, %3, or "
|
|
|
|
"%4, matching the region of the save files that are in it.")
|
|
|
|
.arg(QString::fromStdString(PathToFileName(raw_path)))
|
|
|
|
.arg(QString::fromStdString(PathToFileName(us_path)))
|
|
|
|
.arg(QString::fromStdString(PathToFileName(eu_path)))
|
|
|
|
.arg(QString::fromStdString(PathToFileName(jp_path))));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the other slot has the same folder configured and refuse to use this folder if so.
|
|
|
|
// The EU path is compared here, but it doesn't actually matter which one we compare since they
|
|
|
|
// follow a known pattern, so if the EU path matches the other match too and vice-versa.
|
|
|
|
for (ExpansionInterface::Slot other_slot : ExpansionInterface::MEMCARD_SLOTS)
|
|
|
|
{
|
|
|
|
if (other_slot == slot)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
const std::string other_eu_path = Config::GetGCIFolderPath(other_slot, DiscIO::Region::PAL);
|
|
|
|
if (eu_path == other_eu_path)
|
|
|
|
{
|
|
|
|
ModalMessageBox::critical(
|
|
|
|
this, tr("Error"),
|
|
|
|
tr("The same folder can't be used in multiple slots; it is already used by %1.")
|
|
|
|
.arg(QString::fromStdString(fmt::to_string(other_slot))));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
path_changed = eu_path != Config::GetGCIFolderPath(slot, DiscIO::Region::PAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
Config::SetBase(Config::GetInfoForGCIPath(slot), raw_path);
|
|
|
|
|
2024-04-09 03:33:55 +00:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
if (Core::IsRunning(system))
|
2022-01-19 02:05:05 +00:00
|
|
|
{
|
|
|
|
// If emulation is running and the new card is different from the old one, notify the system to
|
|
|
|
// eject the old and insert the new card.
|
|
|
|
// TODO: This should probably be done by a config change callback instead.
|
|
|
|
if (path_changed)
|
|
|
|
{
|
|
|
|
// ChangeDevice unplugs the device for 1 second, which means that games should notice that
|
|
|
|
// the path has changed and thus the memory card contents have changed
|
2024-04-09 03:33:55 +00:00
|
|
|
system.GetExpansionInterface().ChangeDevice(
|
2023-03-10 19:16:37 +00:00
|
|
|
slot, ExpansionInterface::EXIDeviceType::MemoryCardFolder);
|
2022-01-19 02:05:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LoadSettings();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-01-11 20:25:17 +00:00
|
|
|
void GameCubePane::BrowseAGPRom(ExpansionInterface::Slot slot)
|
|
|
|
{
|
|
|
|
ASSERT(ExpansionInterface::IsMemcardSlot(slot));
|
|
|
|
|
|
|
|
QString filename = DolphinFileDialog::getSaveFileName(
|
2024-07-28 12:24:38 +00:00
|
|
|
this, tr("Choose a File to Open"), QString::fromStdString(File::GetUserPath(D_GCUSER_IDX)),
|
2023-04-15 04:55:53 +00:00
|
|
|
tr("Game Boy Advance Carts (*.gba)"), nullptr, QFileDialog::DontConfirmOverwrite);
|
2022-01-11 20:25:17 +00:00
|
|
|
|
2022-01-19 00:32:32 +00:00
|
|
|
if (!filename.isEmpty())
|
|
|
|
SetAGPRom(slot, filename);
|
|
|
|
}
|
2022-01-11 20:25:17 +00:00
|
|
|
|
2022-01-19 00:32:32 +00:00
|
|
|
void GameCubePane::SetAGPRom(ExpansionInterface::Slot slot, const QString& filename)
|
|
|
|
{
|
|
|
|
QString path_abs = filename.isEmpty() ? QString() : QFileInfo(filename).absoluteFilePath();
|
2022-01-11 20:25:17 +00:00
|
|
|
|
|
|
|
QString path_old =
|
|
|
|
QFileInfo(QString::fromStdString(Config::Get(Config::GetInfoForAGPCartPath(slot))))
|
|
|
|
.absoluteFilePath();
|
|
|
|
|
|
|
|
Config::SetBase(Config::GetInfoForAGPCartPath(slot), path_abs.toStdString());
|
2018-06-17 07:18:22 +00:00
|
|
|
|
2024-04-09 03:33:55 +00:00
|
|
|
auto& system = Core::System::GetInstance();
|
|
|
|
if (Core::IsRunning(system) && path_abs != path_old)
|
2018-06-17 07:18:22 +00:00
|
|
|
{
|
2022-01-11 20:25:17 +00:00
|
|
|
// ChangeDevice unplugs the device for 1 second. For an actual AGP, you can remove the
|
|
|
|
// cartridge without unplugging it, and it's not clear if the AGP software actually notices
|
|
|
|
// that it's been unplugged or the cartridge has changed, but this was done for memcards so
|
|
|
|
// we might as well do it for the AGP too.
|
2024-04-09 03:33:55 +00:00
|
|
|
system.GetExpansionInterface().ChangeDevice(slot, ExpansionInterface::EXIDeviceType::AGP);
|
2018-06-17 07:18:22 +00:00
|
|
|
}
|
2022-01-19 00:32:32 +00:00
|
|
|
|
|
|
|
LoadSettings();
|
2018-01-04 00:41:31 +00:00
|
|
|
}
|
|
|
|
|
2021-07-04 10:53:53 +00:00
|
|
|
void GameCubePane::BrowseGBABios()
|
|
|
|
{
|
2021-10-10 02:28:59 +00:00
|
|
|
QString file = QDir::toNativeSeparators(DolphinFileDialog::getOpenFileName(
|
2021-07-04 10:53:53 +00:00
|
|
|
this, tr("Select GBA BIOS"), QString::fromStdString(File::GetUserPath(F_GBABIOS_IDX)),
|
|
|
|
tr("All Files (*)")));
|
|
|
|
if (!file.isEmpty())
|
|
|
|
{
|
|
|
|
m_gba_bios_edit->setText(file);
|
|
|
|
SaveSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameCubePane::BrowseGBARom(size_t index)
|
|
|
|
{
|
|
|
|
QString file = QString::fromStdString(GetOpenGBARom({}));
|
|
|
|
if (!file.isEmpty())
|
|
|
|
{
|
|
|
|
m_gba_rom_edits[index]->setText(file);
|
|
|
|
SaveSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameCubePane::SaveRomPathChanged()
|
|
|
|
{
|
|
|
|
m_gba_saves_edit->setEnabled(!m_gba_save_rom_path->isChecked());
|
|
|
|
m_gba_browse_saves->setEnabled(!m_gba_save_rom_path->isChecked());
|
|
|
|
SaveSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameCubePane::BrowseGBASaves()
|
|
|
|
{
|
2021-10-10 02:28:59 +00:00
|
|
|
QString dir = QDir::toNativeSeparators(DolphinFileDialog::getExistingDirectory(
|
|
|
|
this, tr("Select GBA Saves Path"),
|
|
|
|
QString::fromStdString(File::GetUserPath(D_GBASAVES_IDX))));
|
2021-07-04 10:53:53 +00:00
|
|
|
if (!dir.isEmpty())
|
|
|
|
{
|
|
|
|
m_gba_saves_edit->setText(dir);
|
|
|
|
SaveSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-04 00:41:31 +00:00
|
|
|
void GameCubePane::LoadSettings()
|
|
|
|
{
|
|
|
|
// IPL Settings
|
2022-04-18 22:39:37 +00:00
|
|
|
SignalBlocking(m_skip_main_menu)->setChecked(Config::Get(Config::MAIN_SKIP_IPL));
|
|
|
|
SignalBlocking(m_language_combo)
|
|
|
|
->setCurrentIndex(m_language_combo->findData(Config::Get(Config::MAIN_GC_LANGUAGE)));
|
2018-01-04 00:41:31 +00:00
|
|
|
|
|
|
|
bool have_menu = false;
|
|
|
|
|
2021-05-17 19:00:13 +00:00
|
|
|
for (const std::string dir : {USA_DIR, JAP_DIR, EUR_DIR})
|
2018-01-04 00:41:31 +00:00
|
|
|
{
|
2018-03-23 11:35:34 +00:00
|
|
|
const auto path = DIR_SEP + dir + DIR_SEP GC_IPL;
|
2018-01-04 00:41:31 +00:00
|
|
|
if (File::Exists(File::GetUserPath(D_GCUSER_IDX) + path) ||
|
2018-03-23 11:35:34 +00:00
|
|
|
File::Exists(File::GetSysDirectory() + GC_SYS_DIR + path))
|
2018-01-04 00:41:31 +00:00
|
|
|
{
|
|
|
|
have_menu = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_skip_main_menu->setEnabled(have_menu);
|
2021-09-08 20:08:43 +00:00
|
|
|
m_skip_main_menu->setToolTip(have_menu ? QString{} : tr("Put IPL ROMs in User/GC/<region>."));
|
2018-01-04 00:41:31 +00:00
|
|
|
|
|
|
|
// Device Settings
|
2022-01-11 20:25:17 +00:00
|
|
|
for (ExpansionInterface::Slot slot : ExpansionInterface::SLOTS)
|
2018-01-04 00:41:31 +00:00
|
|
|
{
|
2020-08-17 07:07:38 +00:00
|
|
|
const ExpansionInterface::EXIDeviceType exi_device =
|
2022-01-11 20:25:17 +00:00
|
|
|
Config::Get(Config::GetInfoForEXIDevice(slot));
|
2022-04-18 22:39:37 +00:00
|
|
|
SignalBlocking(m_slot_combos[slot])
|
|
|
|
->setCurrentIndex(m_slot_combos[slot]->findData(static_cast<int>(exi_device)));
|
2022-01-11 20:25:17 +00:00
|
|
|
UpdateButton(slot);
|
2018-01-04 00:41:31 +00:00
|
|
|
}
|
2021-07-04 10:53:53 +00:00
|
|
|
|
2022-01-19 00:32:32 +00:00
|
|
|
for (ExpansionInterface::Slot slot : ExpansionInterface::MEMCARD_SLOTS)
|
|
|
|
{
|
|
|
|
SignalBlocking(m_memcard_paths[slot])
|
|
|
|
->setText(QString::fromStdString(Config::GetMemcardPath(slot, std::nullopt)));
|
|
|
|
SignalBlocking(m_agp_paths[slot])
|
|
|
|
->setText(QString::fromStdString(Config::Get(Config::GetInfoForAGPCartPath(slot))));
|
2022-01-19 02:05:05 +00:00
|
|
|
SignalBlocking(m_gci_paths[slot])
|
|
|
|
->setText(QString::fromStdString(Config::GetGCIFolderPath(slot, std::nullopt)));
|
2022-01-19 00:32:32 +00:00
|
|
|
}
|
|
|
|
|
2021-07-04 10:53:53 +00:00
|
|
|
#ifdef HAS_LIBMGBA
|
|
|
|
// GBA Settings
|
2022-04-18 22:39:37 +00:00
|
|
|
SignalBlocking(m_gba_threads)->setChecked(Config::Get(Config::MAIN_GBA_THREADS));
|
|
|
|
SignalBlocking(m_gba_bios_edit)
|
|
|
|
->setText(QString::fromStdString(File::GetUserPath(F_GBABIOS_IDX)));
|
|
|
|
SignalBlocking(m_gba_save_rom_path)->setChecked(Config::Get(Config::MAIN_GBA_SAVES_IN_ROM_PATH));
|
|
|
|
SignalBlocking(m_gba_saves_edit)
|
|
|
|
->setText(QString::fromStdString(File::GetUserPath(D_GBASAVES_IDX)));
|
2021-07-04 10:53:53 +00:00
|
|
|
for (size_t i = 0; i < m_gba_rom_edits.size(); ++i)
|
2022-04-18 22:39:37 +00:00
|
|
|
{
|
|
|
|
SignalBlocking(m_gba_rom_edits[i])
|
|
|
|
->setText(QString::fromStdString(Config::Get(Config::MAIN_GBA_ROM_PATHS[i])));
|
|
|
|
}
|
2021-07-04 10:53:53 +00:00
|
|
|
#endif
|
2018-01-04 00:41:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GameCubePane::SaveSettings()
|
|
|
|
{
|
2019-03-03 16:58:37 +00:00
|
|
|
Config::ConfigChangeCallbackGuard config_guard;
|
|
|
|
|
2018-01-04 00:41:31 +00:00
|
|
|
// IPL Settings
|
2018-07-19 22:10:37 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_SKIP_IPL, m_skip_main_menu->isChecked());
|
2019-01-24 20:08:21 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_GC_LANGUAGE, m_language_combo->currentData().toInt());
|
2018-01-04 00:41:31 +00:00
|
|
|
|
2024-04-09 03:33:55 +00:00
|
|
|
auto& system = Core::System::GetInstance();
|
2021-07-04 10:53:53 +00:00
|
|
|
// Device Settings
|
2022-01-11 20:25:17 +00:00
|
|
|
for (ExpansionInterface::Slot slot : ExpansionInterface::SLOTS)
|
2018-01-04 00:41:31 +00:00
|
|
|
{
|
2020-08-17 07:07:38 +00:00
|
|
|
const auto dev =
|
2022-01-11 20:25:17 +00:00
|
|
|
static_cast<ExpansionInterface::EXIDeviceType>(m_slot_combos[slot]->currentData().toInt());
|
2020-08-17 07:07:38 +00:00
|
|
|
const ExpansionInterface::EXIDeviceType current_exi_device =
|
2022-01-11 20:25:17 +00:00
|
|
|
Config::Get(Config::GetInfoForEXIDevice(slot));
|
2018-01-04 00:41:31 +00:00
|
|
|
|
2024-04-09 03:33:55 +00:00
|
|
|
if (Core::IsRunning(system) && current_exi_device != dev)
|
2018-01-04 00:41:31 +00:00
|
|
|
{
|
2024-04-09 03:33:55 +00:00
|
|
|
system.GetExpansionInterface().ChangeDevice(slot, dev);
|
2018-01-04 00:41:31 +00:00
|
|
|
}
|
|
|
|
|
2022-01-11 20:25:17 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::GetInfoForEXIDevice(slot), dev);
|
2018-01-04 00:41:31 +00:00
|
|
|
}
|
2021-07-04 10:53:53 +00:00
|
|
|
|
|
|
|
#ifdef HAS_LIBMGBA
|
|
|
|
// GBA Settings
|
|
|
|
if (!NetPlay::IsNetPlayRunning())
|
|
|
|
{
|
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_GBA_THREADS, m_gba_threads->isChecked());
|
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_GBA_BIOS_PATH, m_gba_bios_edit->text().toStdString());
|
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_GBA_SAVES_IN_ROM_PATH, m_gba_save_rom_path->isChecked());
|
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_GBA_SAVES_PATH, m_gba_saves_edit->text().toStdString());
|
|
|
|
File::SetUserPath(F_GBABIOS_IDX, Config::Get(Config::MAIN_GBA_BIOS_PATH));
|
|
|
|
File::SetUserPath(D_GBASAVES_IDX, Config::Get(Config::MAIN_GBA_SAVES_PATH));
|
|
|
|
for (size_t i = 0; i < m_gba_rom_edits.size(); ++i)
|
|
|
|
{
|
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_GBA_ROM_PATHS[i],
|
|
|
|
m_gba_rom_edits[i]->text().toStdString());
|
|
|
|
}
|
2021-07-04 11:33:58 +00:00
|
|
|
|
|
|
|
auto server = Settings::Instance().GetNetPlayServer();
|
|
|
|
if (server)
|
|
|
|
server->SetGBAConfig(server->GetGBAConfig(), true);
|
2021-07-04 10:53:53 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-01-04 00:41:31 +00:00
|
|
|
LoadSettings();
|
|
|
|
}
|
2021-07-04 10:53:53 +00:00
|
|
|
|
|
|
|
std::string GameCubePane::GetOpenGBARom(std::string_view title)
|
|
|
|
{
|
|
|
|
QString caption = tr("Select GBA ROM");
|
|
|
|
if (!title.empty())
|
|
|
|
caption += QStringLiteral(": %1").arg(QString::fromStdString(std::string(title)));
|
|
|
|
return QDir::toNativeSeparators(
|
2021-10-10 02:28:59 +00:00
|
|
|
DolphinFileDialog::getOpenFileName(
|
2021-07-04 10:53:53 +00:00
|
|
|
nullptr, caption, QString(),
|
|
|
|
tr("Game Boy Advance ROMs (*.gba *.gbc *.gb *.7z *.zip *.agb *.mb *.rom *.bin);;"
|
|
|
|
"All Files (*)")))
|
|
|
|
.toStdString();
|
|
|
|
}
|