all repos — mgba @ 6ab7e178be1cd076965b035276e66491c41ee454

mGBA Game Boy Advance Emulator

Qt: Fix up OverrideView a bit
Vicki Pfau vi@endrift.com
Wed, 02 Aug 2017 14:47:46 -0700
commit

6ab7e178be1cd076965b035276e66491c41ee454

parent

871c21fb6cf9041b4ac7c7f7074e0b2eb77484fe

2 files changed, 9 insertions(+), 28 deletions(-)

jump to
M src/platform/qt/OverrideView.cppsrc/platform/qt/OverrideView.cpp

@@ -66,18 +66,6 @@ m_ui.hwTilt->setEnabled(!enabled);

m_ui.hwRumble->setEnabled(!enabled); }); - connect(m_ui.savetype, &QComboBox::currentTextChanged, this, &OverrideView::updateOverrides); - connect(m_ui.hwAutodetect, &QAbstractButton::clicked, this, &OverrideView::updateOverrides); - connect(m_ui.hwRTC, &QAbstractButton::clicked, this, &OverrideView::updateOverrides); - connect(m_ui.hwGyro, &QAbstractButton::clicked, this, &OverrideView::updateOverrides); - connect(m_ui.hwLight, &QAbstractButton::clicked, this, &OverrideView::updateOverrides); - connect(m_ui.hwTilt, &QAbstractButton::clicked, this, &OverrideView::updateOverrides); - connect(m_ui.hwRumble, &QAbstractButton::clicked, this, &OverrideView::updateOverrides); - connect(m_ui.hwGBPlayer, &QAbstractButton::clicked, this, &OverrideView::updateOverrides); - - connect(m_ui.gbModel, &QComboBox::currentTextChanged, this, &OverrideView::updateOverrides); - connect(m_ui.mbc, &QComboBox::currentTextChanged, this, &OverrideView::updateOverrides); - m_colorPickers[0] = ColorPicker(m_ui.color0, QColor(0xF8, 0xF8, 0xF8)); m_colorPickers[1] = ColorPicker(m_ui.color1, QColor(0xA8, 0xA8, 0xA8)); m_colorPickers[2] = ColorPicker(m_ui.color2, QColor(0x50, 0x50, 0x50));

@@ -85,11 +73,9 @@ m_colorPickers[3] = ColorPicker(m_ui.color3, QColor(0x00, 0x00, 0x00));

for (int colorId = 0; colorId < 4; ++colorId) { connect(&m_colorPickers[colorId], &ColorPicker::colorChanged, this, [this, colorId](const QColor& color) { m_gbColors[colorId] = color.rgb(); - updateOverrides(); }); } - connect(m_ui.tabWidget, &QTabWidget::currentChanged, this, &OverrideView::updateOverrides); #ifndef M_CORE_GBA m_ui.tabWidget->removeTab(m_ui.tabWidget->indexOf(m_ui.tabGBA)); #endif

@@ -104,13 +90,9 @@ }

void OverrideView::setController(std::shared_ptr<CoreController> controller) { m_controller = controller; - gameStarted(); + connect(controller.get(), &CoreController::started, this, &OverrideView::gameStarted); connect(controller.get(), &CoreController::stopping, this, &OverrideView::gameStopped); - if (m_override) { - m_controller->setOverride(std::move(m_override)); - } else { - m_controller->clearOverride(); - } + updateOverrides(); } void OverrideView::saveOverride() {

@@ -121,6 +103,9 @@ m_config->saveOverride(*m_controller->override());

} void OverrideView::updateOverrides() { + if (!m_controller) { + return; + } #ifdef M_CORE_GBA if (m_ui.tabWidget->currentWidget() == m_ui.tabGBA) { std::unique_ptr<GBAOverride> gba(new GBAOverride);

@@ -158,12 +143,11 @@ if (ok) {

gba->override.idleLoop = parsedIdleLoop; } - if (gba->override.savetype != SAVEDATA_AUTODETECT || gba->override.hardware != HW_NO_OVERRIDE || gba->override.idleLoop != IDLE_LOOP_NONE) { - m_override = std::move(gba); + m_controller->setOverride(std::move(gba)); } else { - m_override.reset(); + m_controller->clearOverride(); } } #endif

@@ -179,9 +163,9 @@ gb->override.gbColors[3] = m_gbColors[3];

bool hasOverride = gb->override.mbc != GB_MBC_AUTODETECT || gb->override.model != GB_MODEL_AUTODETECT; hasOverride = hasOverride || (m_gbColors[0] | m_gbColors[1] | m_gbColors[2] | m_gbColors[3]); if (hasOverride) { - m_override = std::move(gb); + m_controller->setOverride(std::move(gb)); } else { - m_override.reset(); + m_controller->clearOverride(); } } #endif

@@ -248,6 +232,4 @@ m_ui.buttonBox->button(QDialogButtonBox::Save)->setEnabled(false);

m_ui.mbc->setCurrentIndex(0); m_ui.gbModel->setCurrentIndex(0); - - updateOverrides(); }
M src/platform/qt/OverrideView.hsrc/platform/qt/OverrideView.h

@@ -47,7 +47,6 @@ private:

Ui::OverrideView m_ui; std::shared_ptr<CoreController> m_controller; - std::unique_ptr<Override> m_override; ConfigController* m_config; #ifdef M_CORE_GB