35#include <QApplication>
39#include <QCommandLineParser>
40#include <QCommandLineOption>
53 QCommandLineParser parser;
54 QCommandLineOption savOpt(QStringList() <<
"sav" <<
"save",
55 QStringLiteral(
"DEBUG: load this .sav file on startup."), QStringLiteral(
"path"));
56 QCommandLineOption screenOpt(QStringList() <<
"screen",
57 QStringLiteral(
"DEBUG: jump to this screen after load "
58 "(trainerCard, pokedex, bag, pokemart, pokemon, rival, maps, home)."),
59 QStringLiteral(
"name"));
60 QCommandLineOption selectOpt(QStringList() <<
"select",
61 QStringLiteral(
"DEBUG: selection for screens that need one -- 'random' or 'source:id'."),
62 QStringLiteral(
"spec"));
63 QCommandLineOption shotOpt(QStringList() <<
"shot",
64 QStringLiteral(
"DEBUG: after navigating, grab the screen to this PNG file."),
65 QStringLiteral(
"path"));
66 parser.addOption(savOpt);
67 parser.addOption(screenOpt);
68 parser.addOption(selectOpt);
69 parser.addOption(shotOpt);
72 parser.parse(app->arguments());
74 const QString sav = parser.value(savOpt);
75 const QString screen = parser.value(screenOpt);
76 const QString select = parser.value(selectOpt);
77 const QString shot = parser.value(shotOpt);
79 if(sav.isEmpty() && screen.isEmpty() && shot.isEmpty())
87 QTimer* timer =
new QTimer(app);
88 int* tries =
new int(0);
89 QObject::connect(timer, &QTimer::timeout, app, [timer, tries, sav, screen, select, shot]() {
91 const bool ready = (brg !=
nullptr) &&
Router::stack.size() >= 2;
92 if(!ready && ++(*tries) < 200)
100 qWarning() <<
"[debug-launch] Bridge not ready; skipping.";
105 qInfo() <<
"[debug-launch] loading save:" << sav;
108 qInfo() <<
"[debug-launch] loaded path=" << brg->
file->
getPath();
111 if(!screen.isEmpty()) {
113 qWarning() <<
"[debug-launch] unknown screen:" << screen
119 qInfo() <<
"[debug-launch] pre-nav stack size=" <<
Router::stack.size();
121 qInfo() <<
"[debug-launch] post-close stack size=" <<
Router::stack.size();
122 qInfo() <<
"[debug-launch] screen:" << screen
123 << (select.isEmpty() ? QString() : QStringLiteral(
"select=") + select);
124 if(screen == QStringLiteral(
"pokemonDetails")) {
126 const int idx = select.startsWith(QStringLiteral(
"party:"))
127 ? select.mid(6).toInt() : 0;
128 qInfo() <<
"[debug-launch] pokemonDetails party index" << idx;
134 qInfo() <<
"[debug-launch] post-change stack size=" <<
Router::stack.size()
145 if(!shot.isEmpty()) {
146 QTimer::singleShot(600, qApp, [shot]() {
148 const bool ok = mw->saveShot(shot);
149 qInfo() <<
"[debug-launch] shot" << (ok ?
"saved:" :
"FAILED:") << shot;
154 timer->setInterval(50);
The single QML<->C++ doorway – everything the UI touches hangs off here.
void setPath(QString path)
Set the active path (backs the path property).
void reopenFile()
Reload the current path from disk, discarding edits.
QString getPath()
Current file path.
bool debugOpenPartyDetails(int index)
DEBUG: open the details editor for party mon index (drives the QML AppWindow.debugOpenPartyDetails).
static MainWindow * getInstance()
The single MainWindow instance.
static Bridge * bridge
The brg aggregate (created here, injected into QML).
void changeScreen(QString name)
Navigate to the registered screen name.
static QVector< Screen * > stack
The live navigation stack.
void closeScreen()
Close the top screen.
static QHash< QString, Screen * > screens
The registry of named screens.
void applyDebugLaunch(QApplication *)