mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-22 22:01:06 -06:00
resurrect some of the OSD, properly dispatch it to all windows
This commit is contained in:
@ -134,6 +134,25 @@ void EmuInstance::createWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void EmuInstance::osdAddMessage(unsigned int color, const char* fmt, ...)
|
||||||
|
{
|
||||||
|
if (fmt == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
|
char msg[256];
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
vsnprintf(msg, 256, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
for (int i = 0; i < kMaxWindows; i++)
|
||||||
|
{
|
||||||
|
if (windowList[i])
|
||||||
|
windowList[i]->osdAddMessage(color, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int EmuInstance::lastSep(const std::string& path)
|
int EmuInstance::lastSep(const std::string& path)
|
||||||
{
|
{
|
||||||
int i = path.length() - 1;
|
int i = path.length() - 1;
|
||||||
|
@ -86,6 +86,8 @@ public:
|
|||||||
|
|
||||||
void createWindow();
|
void createWindow();
|
||||||
|
|
||||||
|
void osdAddMessage(unsigned int color, const char* fmt, ...);
|
||||||
|
|
||||||
// return: empty string = setup OK, non-empty = error message
|
// return: empty string = setup OK, non-empty = error message
|
||||||
QString verifySetup();
|
QString verifySetup();
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ void EmuThread::run()
|
|||||||
int level = emuInstance->nds->GBACartSlot.SetInput(GBACart::Input_SolarSensorDown, true);
|
int level = emuInstance->nds->GBACartSlot.SetInput(GBACart::Input_SolarSensorDown, true);
|
||||||
if (level != -1)
|
if (level != -1)
|
||||||
{
|
{
|
||||||
//mainWindow->osdAddMessage(0, "Solar sensor level: %d", level);
|
emuInstance->osdAddMessage(0, "Solar sensor level: %d", level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (emuInstance->hotkeyPressed(HK_SolarSensorIncrease))
|
if (emuInstance->hotkeyPressed(HK_SolarSensorIncrease))
|
||||||
@ -224,7 +224,7 @@ void EmuThread::run()
|
|||||||
int level = emuInstance->nds->GBACartSlot.SetInput(GBACart::Input_SolarSensorUp, true);
|
int level = emuInstance->nds->GBACartSlot.SetInput(GBACart::Input_SolarSensorUp, true);
|
||||||
if (level != -1)
|
if (level != -1)
|
||||||
{
|
{
|
||||||
//mainWindow->osdAddMessage(0, "Solar sensor level: %d", level);
|
emuInstance->osdAddMessage(0, "Solar sensor level: %d", level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,7 +300,7 @@ void EmuThread::run()
|
|||||||
{
|
{
|
||||||
bool lid = !emuInstance->nds->IsLidClosed();
|
bool lid = !emuInstance->nds->IsLidClosed();
|
||||||
emuInstance->nds->SetLidClosed(lid);
|
emuInstance->nds->SetLidClosed(lid);
|
||||||
//mainWindow->osdAddMessage(0, lid ? "Lid closed" : "Lid opened");
|
emuInstance->osdAddMessage(0, lid ? "Lid closed" : "Lid opened");
|
||||||
}
|
}
|
||||||
|
|
||||||
// microphone input
|
// microphone input
|
||||||
@ -648,5 +648,5 @@ void EmuThread::compileShaders()
|
|||||||
emuInstance->nds->GPU.GetRenderer3D().ShaderCompileStep(currentShader, shadersCount);
|
emuInstance->nds->GPU.GetRenderer3D().ShaderCompileStep(currentShader, shadersCount);
|
||||||
} while (emuInstance->nds->GPU.GetRenderer3D().NeedsShaderCompile() &&
|
} while (emuInstance->nds->GPU.GetRenderer3D().NeedsShaderCompile() &&
|
||||||
(SDL_GetPerformanceCounter() - startTime) * perfCountsSec < 1.0 / 6.0);
|
(SDL_GetPerformanceCounter() - startTime) * perfCountsSec < 1.0 / 6.0);
|
||||||
mainWindow->osdAddMessage(0, "Compiling shader %d/%d", currentShader+1, shadersCount);
|
emuInstance->osdAddMessage(0, "Compiling shader %d/%d", currentShader+1, shadersCount);
|
||||||
}
|
}
|
||||||
|
@ -709,17 +709,9 @@ void MainWindow::attachEmuThread(EmuThread* thread)
|
|||||||
emuThread = thread;
|
emuThread = thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::osdAddMessage(unsigned int color, const char* fmt, ...)
|
void MainWindow::osdAddMessage(unsigned int color, const char* msg)
|
||||||
{
|
{
|
||||||
if (fmt == nullptr)
|
if (!showOSD) return;
|
||||||
return;
|
|
||||||
|
|
||||||
char msg[256];
|
|
||||||
va_list args;
|
|
||||||
va_start(args, fmt);
|
|
||||||
vsnprintf(msg, 256, fmt, args);
|
|
||||||
va_end(args);
|
|
||||||
|
|
||||||
panel->osdAddMessage(color, msg);
|
panel->osdAddMessage(color, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1454,14 +1446,14 @@ void MainWindow::onSaveState()
|
|||||||
|
|
||||||
if (emuInstance->saveState(filename))
|
if (emuInstance->saveState(filename))
|
||||||
{
|
{
|
||||||
if (slot > 0) osdAddMessage(0, "State saved to slot %d", slot);
|
if (slot > 0) emuInstance->osdAddMessage(0, "State saved to slot %d", slot);
|
||||||
else osdAddMessage(0, "State saved to file");
|
else emuInstance->osdAddMessage(0, "State saved to file");
|
||||||
|
|
||||||
actLoadState[slot]->setEnabled(true);
|
actLoadState[slot]->setEnabled(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
osdAddMessage(0xFFA0A0, "State save failed");
|
emuInstance->osdAddMessage(0xFFA0A0, "State save failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
emuThread->emuUnpause();
|
emuThread->emuUnpause();
|
||||||
@ -1496,8 +1488,8 @@ void MainWindow::onLoadState()
|
|||||||
|
|
||||||
if (!Platform::FileExists(filename))
|
if (!Platform::FileExists(filename))
|
||||||
{
|
{
|
||||||
if (slot > 0) osdAddMessage(0xFFA0A0, "State slot %d is empty", slot);
|
if (slot > 0) emuInstance->osdAddMessage(0xFFA0A0, "State slot %d is empty", slot);
|
||||||
else osdAddMessage(0xFFA0A0, "State file does not exist");
|
else emuInstance->osdAddMessage(0xFFA0A0, "State file does not exist");
|
||||||
|
|
||||||
emuThread->emuUnpause();
|
emuThread->emuUnpause();
|
||||||
return;
|
return;
|
||||||
@ -1505,14 +1497,14 @@ void MainWindow::onLoadState()
|
|||||||
|
|
||||||
if (emuInstance->loadState(filename))
|
if (emuInstance->loadState(filename))
|
||||||
{
|
{
|
||||||
if (slot > 0) osdAddMessage(0, "State loaded from slot %d", slot);
|
if (slot > 0) emuInstance->osdAddMessage(0, "State loaded from slot %d", slot);
|
||||||
else osdAddMessage(0, "State loaded from file");
|
else emuInstance->osdAddMessage(0, "State loaded from file");
|
||||||
|
|
||||||
actUndoStateLoad->setEnabled(true);
|
actUndoStateLoad->setEnabled(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
osdAddMessage(0xFFA0A0, "State load failed");
|
emuInstance->osdAddMessage(0xFFA0A0, "State load failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
emuThread->emuUnpause();
|
emuThread->emuUnpause();
|
||||||
@ -1524,7 +1516,7 @@ void MainWindow::onUndoStateLoad()
|
|||||||
emuInstance->undoStateLoad();
|
emuInstance->undoStateLoad();
|
||||||
emuThread->emuUnpause();
|
emuThread->emuUnpause();
|
||||||
|
|
||||||
osdAddMessage(0, "State load undone");
|
emuInstance->osdAddMessage(0, "State load undone");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onImportSavefile()
|
void MainWindow::onImportSavefile()
|
||||||
@ -1592,13 +1584,13 @@ void MainWindow::onPause(bool checked)
|
|||||||
if (checked)
|
if (checked)
|
||||||
{
|
{
|
||||||
emuThread->emuPause();
|
emuThread->emuPause();
|
||||||
osdAddMessage(0, "Paused");
|
emuInstance->osdAddMessage(0, "Paused");
|
||||||
pausedManually = true;
|
pausedManually = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
emuThread->emuUnpause();
|
emuThread->emuUnpause();
|
||||||
osdAddMessage(0, "Resumed");
|
emuInstance->osdAddMessage(0, "Resumed");
|
||||||
pausedManually = false;
|
pausedManually = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1613,7 +1605,7 @@ void MainWindow::onReset()
|
|||||||
|
|
||||||
emuInstance->reset();
|
emuInstance->reset();
|
||||||
|
|
||||||
osdAddMessage(0, "Reset");
|
emuInstance->osdAddMessage(0, "Reset");
|
||||||
emuThread->emuRun();
|
emuThread->emuRun();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ public:
|
|||||||
|
|
||||||
void onAppStateChanged(Qt::ApplicationState state);
|
void onAppStateChanged(Qt::ApplicationState state);
|
||||||
|
|
||||||
void osdAddMessage(unsigned int color, const char* fmt, ...);
|
void osdAddMessage(unsigned int color, const char* msg);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent* event) override;
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
|
Reference in New Issue
Block a user