mirror of
https://github.com/Rosalie241/RMG.git
synced 2026-07-25 08:04:01 +02:00
RMG: hook up state callback
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user