From 19cb30261693d5c56c79d87030cfe8e1dc9ca033 Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Sun, 8 Apr 2012 17:38:38 +0000 Subject: [PATCH] Preliminary support for passing in filenames from the command line. --- src/gui/about.h | 2 +- src/gui/app.cpp | 11 ++++++++++- src/gui/app.h | 6 +++++- src/gui/configdialog.h | 2 +- src/gui/filelistmodel.h | 2 +- src/gui/glwidget.h | 2 +- src/gui/help.h | 2 +- src/gui/keygrabber.h | 2 +- src/gui/mainwin.cpp | 24 +++++++++++++++++++----- src/gui/mainwin.h | 5 +++-- 10 files changed, 43 insertions(+), 15 deletions(-) diff --git a/src/gui/about.h b/src/gui/about.h index e8e5771..9c5f086 100644 --- a/src/gui/about.h +++ b/src/gui/about.h @@ -1,7 +1,7 @@ // // about.h: Credits where credits are due ;-) // -// by James L. Hammons +// by James Hammons // (C) 2010 Underground Software // diff --git a/src/gui/app.cpp b/src/gui/app.cpp index 6abfe15..7a905a9 100644 --- a/src/gui/app.cpp +++ b/src/gui/app.cpp @@ -30,6 +30,8 @@ //hm. :-/ // This is stuff we pass into the mainWindow... bool noUntunedTankPlease = false; +bool loadAndGo = false; +QString filename; // Here's the main application loop--short and simple... int main(int argc, char * argv[]) @@ -69,6 +71,13 @@ int main(int argc, char * argv[]) { noUntunedTankPlease = true; } + + // Check for filename + if (argv[1][0] != '-') + { + loadAndGo = true; + filename = argv[1]; + } } Q_INIT_RESOURCE(virtualjaguar); // This must the same name as the exe filename @@ -106,7 +115,7 @@ int main(int argc, char * argv[]) App::App(int argc, char * argv[]): QApplication(argc, argv) { - mainWindow = new MainWin(); + mainWindow = new MainWin(filename); mainWindow->plzDontKillMyComputer = noUntunedTankPlease; mainWindow->show(); } diff --git a/src/gui/app.h b/src/gui/app.h index 9de170a..85462ff 100644 --- a/src/gui/app.h +++ b/src/gui/app.h @@ -1,7 +1,7 @@ // // app.h: Header file // -// by James L. Hammons +// by James Hammons // (C) 2009 Underground Software // @@ -25,7 +25,11 @@ class App: public QApplication // Globally accessible stuff goes here... // Although... Globally accessible stuff should go into settings.cpp... + // Unless it's stuff related to the GUI, then it should go here. :-P + // And we make these class variables so we don't have to muck around with + // chasing down instances of the object... // public: +// static QString filenameToRun; }; #endif // __APP_H__ diff --git a/src/gui/configdialog.h b/src/gui/configdialog.h index ee121c2..532c47f 100644 --- a/src/gui/configdialog.h +++ b/src/gui/configdialog.h @@ -1,7 +1,7 @@ // // configdialog.h - Configuration dialog // -// by James L. Hammons +// by James Hammons // (C) 2010 Underground Software // diff --git a/src/gui/filelistmodel.h b/src/gui/filelistmodel.h index a3ab660..10f2e2a 100644 --- a/src/gui/filelistmodel.h +++ b/src/gui/filelistmodel.h @@ -1,7 +1,7 @@ // // filelistmodel.h: Class definition // -// by James L. Hammons +// by James Hammons // (C) 2010 Underground Software // diff --git a/src/gui/glwidget.h b/src/gui/glwidget.h index 7c8f995..39ed181 100644 --- a/src/gui/glwidget.h +++ b/src/gui/glwidget.h @@ -1,6 +1,6 @@ // Implementation of OpenGL widget using Qt // -// by James L. Hammons +// by James Hammons // (C) 2010 Underground Software #ifndef __GLWIDGET_H__ diff --git a/src/gui/help.h b/src/gui/help.h index 23aa947..5969083 100644 --- a/src/gui/help.h +++ b/src/gui/help.h @@ -1,7 +1,7 @@ // // help.h: Built-in help system // -// by James L. Hammons +// by James Hammons // (C) 2011 Underground Software // diff --git a/src/gui/keygrabber.h b/src/gui/keygrabber.h index 6ea19d2..aae5961 100644 --- a/src/gui/keygrabber.h +++ b/src/gui/keygrabber.h @@ -1,7 +1,7 @@ // // keygrabber.h - Widget to grab a key and dismiss itself // -// by James L. Hammons +// by James Hammons // (C) 2011 Underground Software // diff --git a/src/gui/mainwin.cpp b/src/gui/mainwin.cpp index ba0b21e..ea4f8d4 100644 --- a/src/gui/mainwin.cpp +++ b/src/gui/mainwin.cpp @@ -34,6 +34,7 @@ #include "mainwin.h" #include "SDL.h" +#include "app.h" #include "glwidget.h" #include "about.h" #include "help.h" @@ -70,9 +71,10 @@ // We'll make the VJ core modular so that it doesn't matter what GUI is in // use, we can drop it in anywhere and use it as-is. -MainWin::MainWin(): running(true), powerButtonOn(false), showUntunedTankCircuit(true), - cartridgeLoaded(false), CDActive(false),//, alpineLoadSuccessful(false), - pauseForFileSelector(false), plzDontKillMyComputer(false) +MainWin::MainWin(QString filenameToRun): running(true), powerButtonOn(false), + showUntunedTankCircuit(true), cartridgeLoaded(false), CDActive(false), + //, alpineLoadSuccessful(false), + pauseForFileSelector(false), loadAndGo(false), plzDontKillMyComputer(false) { videoWidget = new GLWidget(this); setCentralWidget(videoWidget); @@ -259,7 +261,15 @@ MainWin::MainWin(): running(true), powerButtonOn(false), showUntunedTankCircuit( WriteLog("VJ: Initializing jaguar subsystem...\n"); JaguarInit(); - filePickWin->ScanSoftwareFolder(allowUnknownSoftware); + if (!filenameToRun.isEmpty()) + { + loadAndGo = true; + // Attempt to load/run the file the user passed in... + LoadSoftware(filenameToRun); + memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Use the stock BIOS + // Prevent the scanner from running... + return; + } // Load up the default ROM if in Alpine mode: if (vjs.hardwareTypeAlpine) @@ -279,9 +289,13 @@ MainWin::MainWin(): running(true), powerButtonOn(false), showUntunedTankCircuit( // Attempt to load/run the ABS file... LoadSoftware(vjs.absROMPath); memcpy(jagMemSpace + 0xE00000, jaguarDevBootROM2, 0x20000); // Use the stub BIOS + // Prevent the scanner from running... + return; } else memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Otherwise, use the stock BIOS + + filePickWin->ScanSoftwareFolder(allowUnknownSoftware); } void MainWin::closeEvent(QCloseEvent * event) @@ -622,7 +636,7 @@ void MainWin::LoadSoftware(QString file) powerButtonOn = false; TogglePowerState(); - if (!vjs.hardwareTypeAlpine) + if (!vjs.hardwareTypeAlpine && !loadAndGo) { QString newTitle = QString("Virtual Jaguar " VJ_RELEASE_VERSION " - Now playing: %1") .arg(filePickWin->GetSelectedPrettyName()); diff --git a/src/gui/mainwin.h b/src/gui/mainwin.h index 37902b2..d9d0447 100644 --- a/src/gui/mainwin.h +++ b/src/gui/mainwin.h @@ -1,7 +1,7 @@ // // mainwin.h: Header file // -// by James L. Hammons +// by James Hammons // (C) 2010 Underground Software // @@ -23,7 +23,7 @@ class MainWin: public QMainWindow Q_OBJECT public: - MainWin(); + MainWin(QString); protected: void closeEvent(QCloseEvent *); @@ -71,6 +71,7 @@ class MainWin: public QMainWindow bool CDActive; // bool alpineLoadSuccessful; bool pauseForFileSelector; + bool loadAndGo; public: bool plzDontKillMyComputer; private: -- 2.37.2