Merge pull request #6328 from spycrab/qt_fix_gc_amnesia

Qt/GameCubePane: Various fixes
This commit is contained in:
Léo Lam 2018-01-29 21:58:59 +01:00 committed by GitHub
commit 3bceb3c52a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 38 additions and 28 deletions

View File

@ -25,17 +25,26 @@
constexpr int SLOT_A_INDEX = 0; constexpr int SLOT_A_INDEX = 0;
constexpr int SLOT_B_INDEX = 1; constexpr int SLOT_B_INDEX = 1;
constexpr int SLOT_SP1_INDEX = 2;
constexpr int SLOT_COUNT = 3; constexpr int SLOT_COUNT = 3;
constexpr int EXP_MEMORYCARD_INDEX = 2; enum ExpansionSelection
constexpr int EXP_GECKO_INDEX = 4; {
EXP_NOTHING = 0,
EXP_DUMMY = 1,
EXP_MEMORYCARD = 2,
EXP_BROADBAND = 2,
EXP_GCI_FOLDER = 3,
EXP_GECKO = 4,
EXP_AGP = 5,
EXP_MICROPHONE = 6
};
GameCubePane::GameCubePane() GameCubePane::GameCubePane()
{ {
CreateWidgets(); CreateWidgets();
ConnectWidgets();
LoadSettings(); LoadSettings();
ConnectWidgets();
} }
void GameCubePane::CreateWidgets() void GameCubePane::CreateWidgets()
@ -172,6 +181,7 @@ void GameCubePane::OnConfigPressed(int slot)
QMessageBox::critical(this, tr("Error"), tr("Cannot use that file as a memory card.\n%s\n" QMessageBox::critical(this, tr("Error"), tr("Cannot use that file as a memory card.\n%s\n"
"is not a valid GameCube memory card file") "is not a valid GameCube memory card file")
.arg(filename)); .arg(filename));
return; return;
} }
@ -241,29 +251,32 @@ void GameCubePane::LoadSettings()
for (int i = 0; i < SLOT_COUNT; i++) for (int i = 0; i < SLOT_COUNT; i++)
{ {
int index = 0; int index = EXP_NOTHING;
switch (SConfig::GetInstance().m_EXIDevice[i]) switch (SConfig::GetInstance().m_EXIDevice[i])
{ {
case ExpansionInterface::EXIDEVICE_NONE: case ExpansionInterface::EXIDEVICE_NONE:
index = 0; index = EXP_NOTHING;
break; break;
case ExpansionInterface::EXIDEVICE_DUMMY: case ExpansionInterface::EXIDEVICE_DUMMY:
index = 1; index = EXP_DUMMY;
break; break;
case ExpansionInterface::EXIDEVICE_MEMORYCARD: case ExpansionInterface::EXIDEVICE_MEMORYCARD:
index = 2; index = EXP_MEMORYCARD;
break;
case ExpansionInterface::EXIDEVICE_ETH:
index = EXP_BROADBAND;
break; break;
case ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER: case ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER:
index = 3; index = EXP_GCI_FOLDER;
break; break;
case ExpansionInterface::EXIDEVICE_GECKO: case ExpansionInterface::EXIDEVICE_GECKO:
index = 4; index = EXP_GECKO;
break; break;
case ExpansionInterface::EXIDEVICE_AGP: case ExpansionInterface::EXIDEVICE_AGP:
index = 5; index = EXP_AGP;
break; break;
case ExpansionInterface::EXIDEVICE_MIC: case ExpansionInterface::EXIDEVICE_MIC:
index = 6; index = EXP_MICROPHONE;
break; break;
default: default:
break; break;
@ -271,7 +284,7 @@ void GameCubePane::LoadSettings()
if (i <= SLOT_B_INDEX) if (i <= SLOT_B_INDEX)
{ {
bool has_config = (index == EXP_MEMORYCARD_INDEX || index > EXP_GECKO_INDEX); bool has_config = (index == EXP_MEMORYCARD || index > EXP_GECKO);
m_slot_buttons[i]->setEnabled(has_config); m_slot_buttons[i]->setEnabled(has_config);
} }
@ -290,37 +303,34 @@ void GameCubePane::SaveSettings()
for (int i = 0; i < SLOT_COUNT; i++) for (int i = 0; i < SLOT_COUNT; i++)
{ {
auto& dev = SConfig::GetInstance().m_EXIDevice[i]; auto dev = SConfig::GetInstance().m_EXIDevice[i];
int index = m_slot_combos[i]->currentIndex(); int index = m_slot_combos[i]->currentIndex();
if (i <= SLOT_B_INDEX)
{
bool has_config = (index == 3 || index > 4);
m_slot_buttons[i]->setEnabled(has_config);
}
switch (index) switch (index)
{ {
case 0: case EXP_NOTHING:
dev = ExpansionInterface::EXIDEVICE_NONE; dev = ExpansionInterface::EXIDEVICE_NONE;
break; break;
case 1: case EXP_DUMMY:
dev = ExpansionInterface::EXIDEVICE_DUMMY; dev = ExpansionInterface::EXIDEVICE_DUMMY;
break; break;
case 2: case EXP_MEMORYCARD:
dev = ExpansionInterface::EXIDEVICE_MEMORYCARD; if (i == SLOT_SP1_INDEX)
dev = ExpansionInterface::EXIDEVICE_ETH;
else
dev = ExpansionInterface::EXIDEVICE_MEMORYCARD;
break; break;
case 3: case EXP_GCI_FOLDER:
dev = ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER; dev = ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER;
break; break;
case 4: case EXP_GECKO:
dev = ExpansionInterface::EXIDEVICE_GECKO; dev = ExpansionInterface::EXIDEVICE_GECKO;
break; break;
case 5: case EXP_AGP:
dev = ExpansionInterface::EXIDEVICE_AGP; dev = ExpansionInterface::EXIDEVICE_AGP;
break; break;
case 6: case EXP_MICROPHONE:
dev = ExpansionInterface::EXIDEVICE_MIC; dev = ExpansionInterface::EXIDEVICE_MIC;
break; break;
} }