Add command line parsing to Qt frontend
Jeffrey Pfau jeffrey@endrift.com
Sat, 18 Oct 2014 01:54:51 -0700
3 files changed,
40 insertions(+),
1 deletions(-)
M
src/platform/qt/Window.cpp
→
src/platform/qt/Window.cpp
@@ -12,6 +12,10 @@ #include "GDBController.h"
#include "LoadSaveState.h" #include "LogView.h" +extern "C" { +#include "platform/commandline.h" +} + using namespace QGBA; Window::Window(QWidget* parent)@@ -97,6 +101,25 @@ break;
default: return GBA_KEY_NONE; } +} + +void Window::optionsPassed(StartupOptions* opts) { + if (opts->fname) { + m_controller->loadGame(opts->fname, opts->dirmode); + } + + if (opts->logLevel) { + m_logView->setLevels(opts->logLevel); + } + + // TODO: + // - bios + // - patch + // - frameskip; + // - rewindBufferCapacity + // - rewindBufferInterval + // - DebuggerType debuggerType + // - debugAtStart } void Window::selectROM() {
M
src/platform/qt/Window.h
→
src/platform/qt/Window.h
@@ -11,6 +11,8 @@
#include "Display.h" #include "LoadSaveState.h" +struct StartupOptions; + namespace QGBA { class GameController;@@ -25,6 +27,8 @@ Window(QWidget* parent = nullptr);
virtual ~Window(); static GBAKey mapKey(int qtKey); + + void optionsPassed(StartupOptions*); signals: void startDrawing(const uint32_t*, GBAThread*);
M
src/platform/qt/main.cpp
→
src/platform/qt/main.cpp
@@ -1,12 +1,24 @@
#include <QApplication> #include "Window.h" +extern "C" { +#include "platform/commandline.h" +} + int main(int argc, char* argv[]) { QApplication application(argc, argv); QApplication::setApplicationName(PROJECT_NAME); QApplication::setApplicationVersion(PROJECT_VERSION); + QGBA::Window window; + + struct StartupOptions opts; + if (parseCommandArgs(&opts, argc, argv, 0)) { + window.optionsPassed(&opts); + } window.show(); - return application.exec(); + int rcode = application.exec(); + freeOptions(&opts); + return rcode; }