Add command line parsing to Qt frontend

This commit is contained in:
Jeffrey Pfau 2014-10-18 01:54:51 -07:00
parent acd0e58235
commit 4b7883e1fd
3 changed files with 40 additions and 1 deletions

View File

@ -12,6 +12,10 @@
#include "LoadSaveState.h"
#include "LogView.h"
extern "C" {
#include "platform/commandline.h"
}
using namespace QGBA;
Window::Window(QWidget* parent)
@ -99,6 +103,25 @@ GBAKey Window::mapKey(int qtKey) {
}
}
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() {
QString filename = QFileDialog::getOpenFileName(this, tr("Select ROM"));
if (!filename.isEmpty()) {

View File

@ -11,6 +11,8 @@ extern "C" {
#include "Display.h"
#include "LoadSaveState.h"
struct StartupOptions;
namespace QGBA {
class GameController;
@ -26,6 +28,8 @@ public:
static GBAKey mapKey(int qtKey);
void optionsPassed(StartupOptions*);
signals:
void startDrawing(const uint32_t*, GBAThread*);
void shutdown();

View File

@ -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;
}