From 861928d12a25ade175917c18879340472dbc2895 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 17 Aug 2015 22:02:34 -0700 Subject: [PATCH] Qt: Window size command line options are now supported --- CHANGES | 4 ++++ doc/mgba-qt.6 | 15 +++++++++++++++ src/platform/commandline.c | 2 ++ src/platform/commandline.h | 1 + src/platform/qt/ConfigController.cpp | 4 ++-- src/platform/qt/ConfigController.h | 3 ++- src/platform/qt/GBAApp.cpp | 15 +++++++++++++-- 7 files changed, 39 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index d45a92a76..85669fc3e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +0.4.0: (Future) +Misc: + - Qt: Window size command line options are now supported + 0.3.0: (2015-08-16) Features: - Ability to hide individual background layers, or OBJs diff --git a/doc/mgba-qt.6 b/doc/mgba-qt.6 index 256384721..4ab76aafc 100644 --- a/doc/mgba-qt.6 +++ b/doc/mgba-qt.6 @@ -11,6 +11,7 @@ .Nd Game Boy Advance emulator .Sh SYNOPSIS .Nm mgba-qt +.Op Fl 123456f .Op Fl b Ar biosfile .Op Fl l Ar loglevel .Op Fl p Ar patchfile @@ -21,12 +22,26 @@ is a Game Boy Advance emulator. The options are as follows: .Bl -tag -width Ds +.It Fl 1 +Scale the window 1\(mu. +.It Fl 2 +Scale the window 2\(mu. +.It Fl 3 +Scale the window 3\(mu. +.It Fl 4 +Scale the window 4\(mu. +.It Fl 5 +Scale the window 5\(mu. +.It Fl 6 +Scale the window 6\(mu. .It Fl b Ar biosfile , Fl -bios Ar biosfile Specify a BIOS file to use during boot. If this flag is omitted, .Nm will use the BIOS specified in the configuration file, or a high\(hylevel emulated BIOS if none is specified. +.It Fl f +Start the emulator full\(hyscreen. .It Fl l Ar loglevel Log messages during emulation. .Ar loglevel diff --git a/src/platform/commandline.c b/src/platform/commandline.c index ff63f7c7a..e4142fffd 100644 --- a/src/platform/commandline.c +++ b/src/platform/commandline.c @@ -145,6 +145,7 @@ void initParserForGraphics(struct SubParser* parser, struct GraphicsOpts* opts) parser->parse = _parseGraphicsArg; parser->extraOptions = GRAPHICS_OPTIONS; opts->multiplier = 0; + opts->fullscreen = false; } bool _parseGraphicsArg(struct SubParser* parser, struct GBAConfig* config, int option, const char* arg) { @@ -152,6 +153,7 @@ bool _parseGraphicsArg(struct SubParser* parser, struct GBAConfig* config, int o struct GraphicsOpts* graphicsOpts = parser->opts; switch (option) { case 'f': + graphicsOpts->fullscreen = true; GBAConfigSetDefaultIntValue(config, "fullscreen", 1); return true; case '1': diff --git a/src/platform/commandline.h b/src/platform/commandline.h index 32275633b..203895088 100644 --- a/src/platform/commandline.h +++ b/src/platform/commandline.h @@ -42,6 +42,7 @@ struct SubParser { struct GraphicsOpts { int multiplier; + bool fullscreen; }; struct GBAThread; diff --git a/src/platform/qt/ConfigController.cpp b/src/platform/qt/ConfigController.cpp index 2a0ae0184..4fd374c1b 100644 --- a/src/platform/qt/ConfigController.cpp +++ b/src/platform/qt/ConfigController.cpp @@ -126,8 +126,8 @@ ConfigController::~ConfigController() { GBAConfigFreeOpts(&m_opts); } -bool ConfigController::parseArguments(GBAArguments* args, int argc, char* argv[]) { - if (::parseArguments(args, &m_config, argc, argv, 0)) { +bool ConfigController::parseArguments(GBAArguments* args, int argc, char* argv[], SubParser* subparser) { + if (::parseArguments(args, &m_config, argc, argv, subparser)) { GBAConfigMap(&m_config, &m_opts); return true; } diff --git a/src/platform/qt/ConfigController.h b/src/platform/qt/ConfigController.h index 3b0de11b2..439c14653 100644 --- a/src/platform/qt/ConfigController.h +++ b/src/platform/qt/ConfigController.h @@ -16,6 +16,7 @@ extern "C" { #include "gba/supervisor/config.h" #include "util/configuration.h" +#include "platform/commandline.h" } class QAction; @@ -64,7 +65,7 @@ public: ~ConfigController(); const GBAOptions* options() const { return &m_opts; } - bool parseArguments(GBAArguments* args, int argc, char* argv[]); + bool parseArguments(GBAArguments* args, int argc, char* argv[], SubParser* subparser = nullptr); ConfigOption* addOption(const char* key); void updateOption(const char* key); diff --git a/src/platform/qt/GBAApp.cpp b/src/platform/qt/GBAApp.cpp index ed9645ec9..72c72cda8 100644 --- a/src/platform/qt/GBAApp.cpp +++ b/src/platform/qt/GBAApp.cpp @@ -50,9 +50,12 @@ GBAApp::GBAApp(int& argc, char* argv[]) } GBAArguments args; - bool loaded = m_configController.parseArguments(&args, argc, argv); + GraphicsOpts graphicsOpts; + SubParser subparser; + initParserForGraphics(&subparser, &graphicsOpts); + bool loaded = m_configController.parseArguments(&args, argc, argv, &subparser); if (loaded && args.showHelp) { - usage(argv[0], 0); + usage(argv[0], subparser.usage); ::exit(0); return; } @@ -72,6 +75,14 @@ GBAApp::GBAApp(int& argc, char* argv[]) w->loadConfig(); } freeArguments(&args); + + if (graphicsOpts.multiplier) { + w->resizeFrame(VIDEO_HORIZONTAL_PIXELS * graphicsOpts.multiplier, VIDEO_VERTICAL_PIXELS * graphicsOpts.multiplier); + } + if (graphicsOpts.fullscreen) { + w->enterFullScreen(); + } + w->show(); w->controller()->setMultiplayerController(&m_multiplayer);