mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 21:37:42 -07:00
lay down basic idea of multi-instance support
This commit is contained in:
parent
83c9b8dd42
commit
153f01ec54
@ -29,7 +29,7 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
// REMOVE ME
|
// REMOVE ME
|
||||||
extern EmuInstance* testinst;
|
//extern EmuInstance* testinst;
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
#include <iphlpapi.h>
|
#include <iphlpapi.h>
|
||||||
@ -322,7 +322,8 @@ bool Init(bool open_adapter)
|
|||||||
if (PCapAdapter) pcap_close(PCapAdapter);
|
if (PCapAdapter) pcap_close(PCapAdapter);
|
||||||
|
|
||||||
// open pcap device
|
// open pcap device
|
||||||
std::string devicename = testinst->getGlobalConfig().GetString("LAN.Device");
|
//std::string devicename = testinst->getGlobalConfig().GetString("LAN.Device");
|
||||||
|
std::string devicename = "FIXME";
|
||||||
PCapAdapterData = &Adapters[0];
|
PCapAdapterData = &Adapters[0];
|
||||||
for (int i = 0; i < NumAdapters; i++)
|
for (int i = 0; i < NumAdapters; i++)
|
||||||
{
|
{
|
||||||
|
@ -222,7 +222,6 @@ static void signalHandler(int)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int test = 0;
|
|
||||||
|
|
||||||
MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
|
MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
@ -233,7 +232,6 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
|
|||||||
windowCfg(localCfg.GetTable("Window"+std::to_string(id), "Window0")),
|
windowCfg(localCfg.GetTable("Window"+std::to_string(id), "Window0")),
|
||||||
emuThread(inst->getEmuThread())
|
emuThread(inst->getEmuThread())
|
||||||
{
|
{
|
||||||
test_num = test++;
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
if (!parent)
|
if (!parent)
|
||||||
{
|
{
|
||||||
@ -749,16 +747,21 @@ void MainWindow::closeEvent(QCloseEvent* event)
|
|||||||
|
|
||||||
Config::Save();
|
Config::Save();
|
||||||
|
|
||||||
if (hasOGL)
|
if (hasOGL && (windowID == 0))
|
||||||
{
|
{
|
||||||
// we intentionally don't unpause here
|
// we intentionally don't unpause here
|
||||||
// TODO this ought to change if we do multi-window shiz
|
|
||||||
emuThread->emuPause();
|
emuThread->emuPause();
|
||||||
emuThread->deinitContext();
|
emuThread->deinitContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
emuThread->detachWindow(this);
|
emuThread->detachWindow(this);
|
||||||
|
|
||||||
|
if (windowID == 0)
|
||||||
|
{
|
||||||
|
int inst = emuInstance->instanceID;
|
||||||
|
deleteEmuInstance(inst);
|
||||||
|
}
|
||||||
|
|
||||||
QMainWindow::closeEvent(event);
|
QMainWindow::closeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1575,9 +1578,10 @@ void MainWindow::onImportSavefile()
|
|||||||
void MainWindow::onQuit()
|
void MainWindow::onQuit()
|
||||||
{
|
{
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
if (!parentWidget())
|
||||||
signalSn->setEnabled(false);
|
signalSn->setEnabled(false);
|
||||||
#endif
|
#endif
|
||||||
QApplication::quit();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1676,19 +1680,7 @@ void MainWindow::onOpenTitleManager()
|
|||||||
|
|
||||||
void MainWindow::onMPNewInstance()
|
void MainWindow::onMPNewInstance()
|
||||||
{
|
{
|
||||||
//QProcess::startDetached(QApplication::applicationFilePath());
|
createEmuInstance();
|
||||||
QProcess newinst;
|
|
||||||
newinst.setProgram(QApplication::applicationFilePath());
|
|
||||||
newinst.setArguments(QApplication::arguments().mid(1, QApplication::arguments().length()-1));
|
|
||||||
|
|
||||||
#ifdef __WIN32__
|
|
||||||
newinst.setCreateProcessArgumentsModifier([] (QProcess::CreateProcessArguments *args)
|
|
||||||
{
|
|
||||||
args->flags |= CREATE_NEW_CONSOLE;
|
|
||||||
});
|
|
||||||
#endif
|
|
||||||
|
|
||||||
newinst.startDetached();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onOpenEmuSettings()
|
void MainWindow::onOpenEmuSettings()
|
||||||
@ -2015,7 +2007,7 @@ void MainWindow::onChangeAudioSync(bool checked)
|
|||||||
|
|
||||||
void MainWindow::onTitleUpdate(QString title)
|
void MainWindow::onTitleUpdate(QString title)
|
||||||
{
|
{
|
||||||
setWindowTitle(test_num ? "SECOND WINDOW" : title);
|
setWindowTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToggleFullscreen(MainWindow* mainWindow)
|
void ToggleFullscreen(MainWindow* mainWindow)
|
||||||
|
@ -237,8 +237,6 @@ private:
|
|||||||
bool pauseOnLostFocus;
|
bool pauseOnLostFocus;
|
||||||
bool pausedManually;
|
bool pausedManually;
|
||||||
|
|
||||||
int test_num;
|
|
||||||
|
|
||||||
int windowID;
|
int windowID;
|
||||||
|
|
||||||
EmuInstance* emuInstance;
|
EmuInstance* emuInstance;
|
||||||
|
@ -85,10 +85,6 @@ QString* systemThemeName;
|
|||||||
|
|
||||||
QString emuDirectory;
|
QString emuDirectory;
|
||||||
|
|
||||||
//MainWindow* mainWindow;
|
|
||||||
//EmuThread* emuThread;
|
|
||||||
EmuInstance* testinst;
|
|
||||||
|
|
||||||
const int kMaxEmuInstances = 16;
|
const int kMaxEmuInstances = 16;
|
||||||
EmuInstance* emuInstances[kMaxEmuInstances];
|
EmuInstance* emuInstances[kMaxEmuInstances];
|
||||||
|
|
||||||
@ -282,7 +278,7 @@ int main(int argc, char** argv)
|
|||||||
emuThread->start();
|
emuThread->start();
|
||||||
emuThread->emuPause();*/
|
emuThread->emuPause();*/
|
||||||
|
|
||||||
testinst = new EmuInstance(0);
|
createEmuInstance();
|
||||||
|
|
||||||
/*AudioInOut::Init(emuThread);
|
/*AudioInOut::Init(emuThread);
|
||||||
ROMManager::EnableCheats(*emuThread->NDS, Config::EnableCheats != 0);
|
ROMManager::EnableCheats(*emuThread->NDS, Config::EnableCheats != 0);
|
||||||
@ -318,7 +314,9 @@ int main(int argc, char** argv)
|
|||||||
/*emuThread->emuStop();
|
/*emuThread->emuStop();
|
||||||
emuThread->wait();
|
emuThread->wait();
|
||||||
delete emuThread;*/
|
delete emuThread;*/
|
||||||
delete testinst;
|
// if we get here, all the existing emu instances should have been deleted already
|
||||||
|
// but with this we make extra sure they are all deleted
|
||||||
|
deleteAllEmuInstances();
|
||||||
|
|
||||||
//AudioInOut::DeInit();
|
//AudioInOut::DeInit();
|
||||||
delete camManager[0];
|
delete camManager[0];
|
||||||
|
@ -48,4 +48,8 @@ public:
|
|||||||
extern QString* systemThemeName;
|
extern QString* systemThemeName;
|
||||||
extern QString emuDirectory;
|
extern QString emuDirectory;
|
||||||
|
|
||||||
|
bool createEmuInstance();
|
||||||
|
void deleteEmuInstance(int id);
|
||||||
|
void deleteAllEmuInstances();
|
||||||
|
|
||||||
#endif // MAIN_H
|
#endif // MAIN_H
|
||||||
|
Loading…
Reference in New Issue
Block a user