RMG: hook up state callback

This commit is contained in:
Rosalie Wanders
2023-02-24 21:37:24 +01:00
parent 81cbf82ddc
commit a5ec31ffef
4 changed files with 34 additions and 1 deletions
+12 -1
View File
@@ -36,11 +36,12 @@ bool CoreCallbacks::Init(void)
{
// needed for Qt
qRegisterMetaType<CoreDebugMessageType>("CoreDebugMessageType");
qRegisterMetaType<CoreDebugMessageType>("CoreStateCallbackType");
this->LoadSettings();
l_CoreCallbacks = this;
return CoreSetupCallbacks(this->coreDebugCallback);
return CoreSetupCallbacks(this->coreDebugCallback, this->coreStateCallback);
}
void CoreCallbacks::Stop(void)
@@ -78,3 +79,13 @@ void CoreCallbacks::coreDebugCallback(CoreDebugMessageType type, std::string con
emit l_CoreCallbacks->OnCoreDebugCallback(type, QString::fromStdString(context), QString::fromStdString(message));
}
void CoreCallbacks::coreStateCallback(CoreStateCallbackType type, int value)
{
if (l_CoreCallbacks == nullptr)
{
return;
}
emit l_CoreCallbacks->OnCoreStateCallback(type, value);
}
+2
View File
@@ -31,9 +31,11 @@ public:
private:
static void coreDebugCallback(CoreDebugMessageType type, std::string context, std::string message);
static void coreStateCallback(CoreStateCallbackType type, int value);
signals:
void OnCoreDebugCallback(CoreDebugMessageType type, QString context, QString message);
void OnCoreStateCallback(CoreStateCallbackType type, int value);
};
#endif // RMG_CALLBACKS_HPP
+19
View File
@@ -94,6 +94,7 @@ bool MainWindow::Init(QApplication* app, bool showUI)
connect(coreCallBacks, &CoreCallbacks::OnCoreDebugCallback, this, &MainWindow::on_Core_DebugCallback);
connect(coreCallBacks, &CoreCallbacks::OnCoreDebugCallback, &this->logDialog, &Dialog::LogDialog::AddLogLine);
connect(coreCallBacks, &CoreCallbacks::OnCoreStateCallback, this, &MainWindow::on_Core_StateCallback);
connect(app, &QGuiApplication::applicationStateChanged, this, &MainWindow::on_QGuiApplication_applicationStateChanged);
return true;
@@ -2019,3 +2020,21 @@ void MainWindow::on_Core_DebugCallback(CoreDebugMessageType type, QString contex
}
this->ui_TimerId = this->startTimer(this->ui_TimerTimeout * 1000);
}
void MainWindow::on_Core_StateCallback(CoreStateCallbackType type, int value)
{
if (type == CoreStateCallbackType::SaveStateLoaded)
{
if (value == 0)
{
OnScreenDisplaySetMessage("Failed to load save state.");
}
}
else if (type == CoreStateCallbackType::SaveStateSaved)
{
if (value == 0)
{
OnScreenDisplaySetMessage("Failed to save state.");
}
}
}
+1
View File
@@ -198,6 +198,7 @@ class MainWindow : public QMainWindow, private Ui::MainWindow
void on_VidExt_ToggleFS(bool fullscreen);
void on_Core_DebugCallback(CoreDebugMessageType type, QString context, QString message);
void on_Core_StateCallback(CoreStateCallbackType type, int value);
};
} // namespace UserInterface