add convenience method to Window class for OSD messages
This commit is contained in:
parent
6a1232b9a9
commit
80c6dd524b
|
@ -69,7 +69,7 @@ QMutex Rendering;
|
||||||
|
|
||||||
|
|
||||||
bool Init(bool openGL)
|
bool Init(bool openGL)
|
||||||
{
|
{printf("%d\n", sizeof(Item));
|
||||||
if (openGL)
|
if (openGL)
|
||||||
{
|
{
|
||||||
OpenGL::BuildShaderProgram(kScreenVS_OSD, kScreenFS_OSD, Shader, "OSDShader");
|
OpenGL::BuildShaderProgram(kScreenVS_OSD, kScreenFS_OSD, Shader, "OSDShader");
|
||||||
|
|
|
@ -685,6 +685,20 @@ MainWindow::~MainWindow()
|
||||||
delete[] actScreenAspectBot;
|
delete[] actScreenAspectBot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::osdAddMessage(unsigned int color, const char* fmt, ...)
|
||||||
|
{
|
||||||
|
if (fmt == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
char msg[1024];
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
vsnprintf(msg, 1024, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
OSD::AddMessage(color, msg);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent* event)
|
void MainWindow::closeEvent(QCloseEvent* event)
|
||||||
{
|
{
|
||||||
if (hasOGL)
|
if (hasOGL)
|
||||||
|
@ -1394,16 +1408,14 @@ void MainWindow::onSaveState()
|
||||||
|
|
||||||
if (ROMManager::SaveState(*emuThread->NDS, filename))
|
if (ROMManager::SaveState(*emuThread->NDS, filename))
|
||||||
{
|
{
|
||||||
char msg[64];
|
if (slot > 0) osdAddMessage(0, "State saved to slot %d", slot);
|
||||||
if (slot > 0) sprintf(msg, "State saved to slot %d", slot);
|
else osdAddMessage(0, "State saved to file");
|
||||||
else sprintf(msg, "State saved to file");
|
|
||||||
OSD::AddMessage(0, msg);
|
|
||||||
|
|
||||||
actLoadState[slot]->setEnabled(true);
|
actLoadState[slot]->setEnabled(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
OSD::AddMessage(0xFFA0A0, "State save failed");
|
osdAddMessage(0xFFA0A0, "State save failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
emuThread->emuUnpause();
|
emuThread->emuUnpause();
|
||||||
|
@ -1438,10 +1450,8 @@ void MainWindow::onLoadState()
|
||||||
|
|
||||||
if (!Platform::FileExists(filename))
|
if (!Platform::FileExists(filename))
|
||||||
{
|
{
|
||||||
char msg[64];
|
if (slot > 0) osdAddMessage(0xFFA0A0, "State slot %d is empty", slot);
|
||||||
if (slot > 0) sprintf(msg, "State slot %d is empty", slot);
|
else osdAddMessage(0xFFA0A0, "State file does not exist");
|
||||||
else sprintf(msg, "State file does not exist");
|
|
||||||
OSD::AddMessage(0xFFA0A0, msg);
|
|
||||||
|
|
||||||
emuThread->emuUnpause();
|
emuThread->emuUnpause();
|
||||||
return;
|
return;
|
||||||
|
@ -1449,16 +1459,14 @@ void MainWindow::onLoadState()
|
||||||
|
|
||||||
if (ROMManager::LoadState(*emuThread->NDS, filename))
|
if (ROMManager::LoadState(*emuThread->NDS, filename))
|
||||||
{
|
{
|
||||||
char msg[64];
|
if (slot > 0) osdAddMessage(0, "State loaded from slot %d", slot);
|
||||||
if (slot > 0) sprintf(msg, "State loaded from slot %d", slot);
|
else osdAddMessage(0, "State loaded from file");
|
||||||
else sprintf(msg, "State loaded from file");
|
|
||||||
OSD::AddMessage(0, msg);
|
|
||||||
|
|
||||||
actUndoStateLoad->setEnabled(true);
|
actUndoStateLoad->setEnabled(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
OSD::AddMessage(0xFFA0A0, "State load failed");
|
osdAddMessage(0xFFA0A0, "State load failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
emuThread->emuUnpause();
|
emuThread->emuUnpause();
|
||||||
|
@ -1470,7 +1478,7 @@ void MainWindow::onUndoStateLoad()
|
||||||
ROMManager::UndoStateLoad(*emuThread->NDS);
|
ROMManager::UndoStateLoad(*emuThread->NDS);
|
||||||
emuThread->emuUnpause();
|
emuThread->emuUnpause();
|
||||||
|
|
||||||
OSD::AddMessage(0, "State load undone");
|
osdAddMessage(0, "State load undone");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onImportSavefile()
|
void MainWindow::onImportSavefile()
|
||||||
|
@ -1538,13 +1546,13 @@ void MainWindow::onPause(bool checked)
|
||||||
if (checked)
|
if (checked)
|
||||||
{
|
{
|
||||||
emuThread->emuPause();
|
emuThread->emuPause();
|
||||||
OSD::AddMessage(0, "Paused");
|
osdAddMessage(0, "Paused");
|
||||||
pausedManually = true;
|
pausedManually = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
emuThread->emuUnpause();
|
emuThread->emuUnpause();
|
||||||
OSD::AddMessage(0, "Resumed");
|
osdAddMessage(0, "Resumed");
|
||||||
pausedManually = false;
|
pausedManually = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1559,7 +1567,7 @@ void MainWindow::onReset()
|
||||||
|
|
||||||
ROMManager::Reset(emuThread);
|
ROMManager::Reset(emuThread);
|
||||||
|
|
||||||
OSD::AddMessage(0, "Reset");
|
osdAddMessage(0, "Reset");
|
||||||
emuThread->emuRun();
|
emuThread->emuRun();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,63 @@
|
||||||
|
|
||||||
class EmuThread;
|
class EmuThread;
|
||||||
|
|
||||||
|
/*
|
||||||
|
class WindowBase : public QMainWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit WindowBase(QWidget* parent = nullptr);
|
||||||
|
~WindowBase();
|
||||||
|
|
||||||
|
bool hasOGL;
|
||||||
|
GL::Context* getOGLContext();
|
||||||
|
|
||||||
|
//void onAppStateChanged(Qt::ApplicationState state);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
|
void changeEvent(QEvent* event) override;
|
||||||
|
|
||||||
|
void keyPressEvent(QKeyEvent* event) override;
|
||||||
|
void keyReleaseEvent(QKeyEvent* event) override;
|
||||||
|
|
||||||
|
void dragEnterEvent(QDragEnterEvent* event) override;
|
||||||
|
void dropEvent(QDropEvent* event) override;
|
||||||
|
|
||||||
|
void focusInEvent(QFocusEvent* event) override;
|
||||||
|
void focusOutEvent(QFocusEvent* event) override;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void screenLayoutChange();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
//void onQuit();
|
||||||
|
|
||||||
|
//void onTitleUpdate(QString title);
|
||||||
|
|
||||||
|
//void onEmuStart();
|
||||||
|
//void onEmuStop();
|
||||||
|
|
||||||
|
//void onUpdateVideoSettings(bool glchange);
|
||||||
|
|
||||||
|
void onFullscreenToggled();
|
||||||
|
void onScreenEmphasisToggled();
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual void closeEvent(QCloseEvent* event) override;
|
||||||
|
|
||||||
|
void createScreenPanel();
|
||||||
|
|
||||||
|
//bool pausedManually = false;
|
||||||
|
|
||||||
|
int oldW, oldH;
|
||||||
|
bool oldMax;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ScreenHandler* panel;
|
||||||
|
QWidget* panelWidget;
|
||||||
|
};*/
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
|
@ -55,6 +112,8 @@ public:
|
||||||
|
|
||||||
void onAppStateChanged(Qt::ApplicationState state);
|
void onAppStateChanged(Qt::ApplicationState state);
|
||||||
|
|
||||||
|
void osdAddMessage(unsigned int color, const char* fmt, ...);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent* event) override;
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
void changeEvent(QEvent* event) override;
|
void changeEvent(QEvent* event) override;
|
||||||
|
|
Loading…
Reference in New Issue