all repos — mgba @ b920758dc10371c79cede9374a14b1d2386f8d5d

mGBA Game Boy Advance Emulator

Qt: Fix up override view
Vicki Pfau vi@endrift.com
Fri, 13 Oct 2017 18:40:49 -0700
commit

b920758dc10371c79cede9374a14b1d2386f8d5d

parent

22807c6274057e4bac42de986c182db864542ffb

M src/platform/qt/CoreController.cppsrc/platform/qt/CoreController.cpp

@@ -209,6 +209,10 @@ bool CoreController::isPaused() {

return mCoreThreadIsPaused(&m_threadContext); } +bool CoreController::hasStarted() { + return mCoreThreadHasStarted(&m_threadContext); +} + mPlatform CoreController::platform() const { return m_threadContext.core->platform(m_threadContext.core); }
M src/platform/qt/CoreController.hsrc/platform/qt/CoreController.h

@@ -61,6 +61,7 @@

color_t* drawContext(); bool isPaused(); + bool hasStarted(); mPlatform platform() const; QSize screenDimensions() const;
M src/platform/qt/OverrideView.cppsrc/platform/qt/OverrideView.cpp

@@ -93,13 +93,16 @@ #endif

connect(m_ui.buttonBox, &QDialogButtonBox::accepted, this, &OverrideView::saveOverride); connect(m_ui.buttonBox, &QDialogButtonBox::rejected, this, &QWidget::close); + + m_recheck.setInterval(200); + connect(&m_recheck, &QTimer::timeout, this, &OverrideView::recheck); } void OverrideView::setController(std::shared_ptr<CoreController> controller) { m_controller = controller; connect(controller.get(), &CoreController::started, this, &OverrideView::gameStarted); connect(controller.get(), &CoreController::stopping, this, &OverrideView::gameStopped); - updateOverrides(); + recheck(); } void OverrideView::saveOverride() {

@@ -115,6 +118,17 @@ }

m_config->saveOverride(*override); } +void OverrideView::recheck() { + if (!m_controller) { + return; + } + if (m_controller->hasStarted()) { + gameStarted(); + } else { + updateOverrides(); + } +} + void OverrideView::updateOverrides() { if (!m_controller) { return;

@@ -190,6 +204,7 @@ CoreController::Interrupter interrupter(m_controller);

mCoreThread* thread = m_controller->thread(); m_ui.tabWidget->setEnabled(false); + m_recheck.start(); switch (thread->core->platform(thread->core)) { #ifdef M_CORE_GBA

@@ -242,6 +257,7 @@ }

} void OverrideView::gameStopped() { + m_recheck.stop(); m_controller.reset(); m_ui.tabWidget->setEnabled(true); m_ui.savetype->setCurrentIndex(0);
M src/platform/qt/OverrideView.hsrc/platform/qt/OverrideView.h

@@ -6,6 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#pragma once #include <QDialog> +#include <QTimer> #include <memory>

@@ -36,6 +37,7 @@ void setController(std::shared_ptr<CoreController> controller);

public slots: void saveOverride(); + void recheck(); private slots: void updateOverrides();

@@ -48,6 +50,7 @@

std::shared_ptr<CoreController> m_controller; ConfigController* m_config; bool m_savePending = false; + QTimer m_recheck; #ifdef M_CORE_GB uint32_t m_gbColors[12]{};
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -1442,6 +1442,7 @@ }

connect(this, &Window::shutdown, m_overrideView.get(), &QWidget::close); } m_overrideView->show(); + m_overrideView->recheck(); }); addControlledAction(toolsMenu, overrides, "overrideWindow");