First game ever launched using EmuFront was Blue Print for Commodore 64
authorMikko Keinänen <mikko.keinanen@gmail.com>
Fri, 8 Oct 2010 21:07:09 +0000 (00:07 +0300)
committerMikko Keinänen <mikko.keinanen@gmail.com>
Fri, 8 Oct 2010 21:07:09 +0000 (00:07 +0300)
B)

src/emulauncher.cpp
src/emulauncher.h

index 4c6ab4d..8d1c48f 100644 (file)
@@ -18,6 +18,7 @@
 // along with EmuFront.  If not, see <http://www.gnu.org/licenses/>.
 
 #include <QtGui>
+#include <QProcess>
 #include <QSqlTableModel>
 #include "utils/OSDaB-Zip/unzip.h"
 #include "emulauncher.h"
@@ -36,11 +37,20 @@ EmuLauncher::EmuLauncher(QWidget *parent) :
     dbMediaType = new DbMediaType(this);
     dbExec = new DbExecutable(this);
     dbMic = 0;
+    proc = 0;
     initWidgets();
     layout();
     connectSignals();
 }
 
+EmuLauncher::~EmuLauncher()
+{
+    if (proc) {
+        proc->kill(); // TODO: do this in a more sophisticated way
+        delete proc;
+    }
+}
+
 void EmuLauncher::updateData()
 {
     platformSelectBox->updateDataModel();
@@ -154,7 +164,7 @@ void EmuLauncher::launchEmu()
     }
 }
 
-void EmuLauncher::launch(const Executable * ex, const MediaImageContainer * mic) const
+void EmuLauncher::launch(const Executable * ex, const MediaImageContainer * mic)
 {
     // extract the media image container to tmp folder
     // (TODO: tmp folder configuration)
@@ -171,4 +181,12 @@ void EmuLauncher::launch(const Executable * ex, const MediaImageContainer * mic)
     // or if emulator command options has a place for more than one
     // media image assign the media images in the list order
     // to emulator command line.
+    QString cmdWithParams;
+    cmdWithParams.append(ex->getExecutable());
+    // TODO: tmp will be set dynamically
+    // TODO: command parameters and assigning multiple media images
+    cmdWithParams.append(" -cartcrt \"/tmp/").append(mic->getMediaImages().first()->getName()).append("\"");
+    qDebug() << "Command with params " << cmdWithParams;
+    if (!proc) proc = new QProcess(this); // This has to be done in the heap
+    proc->start(cmdWithParams, QIODevice::ReadOnly);
 }
index 00e69f0..2217487 100644 (file)
@@ -32,12 +32,14 @@ class EFFileObjectComboBox;
 class ExecutableComboBox;
 class Executable;
 class MediaImageContainer;
+class QProcess;
 
 class EmuLauncher : public QWidget
 {
 Q_OBJECT
 public:
     explicit EmuLauncher(QWidget *parent = 0);
+    ~EmuLauncher();
     void updateData();
 
 signals:
@@ -57,12 +59,13 @@ private:
     DbMediaType *dbMediaType;
     DbMediaImageContainer *dbMic;
     DbExecutable *dbExec;
+    QProcess *proc;
     void initWidgets();
     void layout();
     void connectSignals();
     void populatePlatformSelectBox();
     void populateMediaTypeSelectBox();
-    void launch(const Executable*, const MediaImageContainer*) const;
+    void launch(const Executable*, const MediaImageContainer*);
 };
 
 #endif // EMULAUNCHER_H