mirror of https://github.com/mgba-emu/mgba.git
Add command line parsing to Qt frontend
This commit is contained in:
parent
acd0e58235
commit
4b7883e1fd
|
@ -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()) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue