mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-26 15:50:00 -06:00
Rebase: Make archive detection more robust and add it to the CLI (#1560)
* Rebase/recreate my changes and add MIME support
This commit recreates the changes proposed in #1394 on top of the
current master (b069a2acf1
).
This also adds support for determining filetypes using the MIME database
provided by `QMimeDatabase`.
* Move member syntax warning to a more appropriate place
* Deduplicate member syntax warning
* Change warning from "vertical bars" to "|"
* Conform brace placement to coding style
* Fix QFileDialog filter when ArchiveExtensions is empty
* Final cleanup and fixes
- Changes the NDS and GBA ROM MIME-Type constants to QStrings.
- Removes a leftover warning message.
- Uses Type() syntax instead of Type{} syntax for temporaries.
* Explain the origin of the supported archive list
Co-authored-by: Jan Felix Langenbach <insert-penguin@protonmail.com>
This commit is contained in:
@ -39,7 +39,7 @@ CommandLineOptions* ManageArgs(QApplication& melon)
|
||||
|
||||
parser.addOption(QCommandLineOption({"b", "boot"}, "Whether to boot firmware on startup. Defaults to \"auto\" (boot if NDS rom given)", "auto/always/never", "auto"));
|
||||
parser.addOption(QCommandLineOption({"f", "fullscreen"}, "Start melonDS in fullscreen mode"));
|
||||
|
||||
|
||||
#ifdef ARCHIVE_SUPPORT_ENABLED
|
||||
parser.addOption(QCommandLineOption({"a", "archive-file"}, "Specify file to load inside an archive given (NDS)", "rom"));
|
||||
parser.addOption(QCommandLineOption({"A", "archive-file-gba"}, "Specify file to load inside an archive given (GBA)", "rom"));
|
||||
@ -50,16 +50,16 @@ CommandLineOptions* ManageArgs(QApplication& melon)
|
||||
CommandLineOptions* options = new CommandLineOptions;
|
||||
|
||||
options->fullscreen = parser.isSet("fullscreen");
|
||||
|
||||
|
||||
QStringList posargs = parser.positionalArguments();
|
||||
switch (posargs.size())
|
||||
{
|
||||
default:
|
||||
printf("Too many positional arguments; ignoring 3 onwards\n");
|
||||
case 2:
|
||||
options->gbaRomPath = QStringList(posargs[1]);
|
||||
options->gbaRomPath = posargs[1];
|
||||
case 1:
|
||||
options->dsRomPath = QStringList(posargs[0]);
|
||||
options->dsRomPath = posargs[0];
|
||||
case 0:
|
||||
break;
|
||||
}
|
||||
@ -67,8 +67,8 @@ CommandLineOptions* ManageArgs(QApplication& melon)
|
||||
QString bootMode = parser.value("boot");
|
||||
if (bootMode == "auto")
|
||||
{
|
||||
options->boot = posargs.size() > 0;
|
||||
}
|
||||
options->boot = !posargs.empty();
|
||||
}
|
||||
else if (bootMode == "always")
|
||||
{
|
||||
options->boot = true;
|
||||
@ -86,45 +86,25 @@ CommandLineOptions* ManageArgs(QApplication& melon)
|
||||
#ifdef ARCHIVE_SUPPORT_ENABLED
|
||||
if (parser.isSet("archive-file"))
|
||||
{
|
||||
if (options->dsRomPath.isEmpty())
|
||||
if (options->dsRomPath.has_value())
|
||||
{
|
||||
options->errorsToDisplay += "Option -a/--archive-file given, but no archive specified!";
|
||||
options->dsRomArchivePath = parser.value("archive-file");
|
||||
}
|
||||
else
|
||||
{
|
||||
options->dsRomPath += parser.value("archive-file");
|
||||
}
|
||||
}
|
||||
else if (!options->dsRomPath.isEmpty())
|
||||
{
|
||||
//TODO-CLI: try to automatically find ROM
|
||||
QStringList paths = options->dsRomPath[0].split("|");
|
||||
if (paths.size() >= 2)
|
||||
{
|
||||
printf("Warning: use the a.zip|b.nds format at your own risk!\n");
|
||||
options->dsRomPath = paths;
|
||||
options->errorsToDisplay += "Option -a/--archive-file given, but no archive specified!";
|
||||
}
|
||||
}
|
||||
|
||||
if (parser.isSet("archive-file-gba"))
|
||||
{
|
||||
if (options->gbaRomPath.isEmpty())
|
||||
if (options->gbaRomPath.has_value())
|
||||
{
|
||||
options->errorsToDisplay += "Option -A/--archive-file-gba given, but no archive specified!";
|
||||
options->gbaRomArchivePath = parser.value("archive-file-gba");
|
||||
}
|
||||
else
|
||||
{
|
||||
options->gbaRomPath += parser.value("archive-file-gba");
|
||||
}
|
||||
}
|
||||
else if (!options->gbaRomPath.isEmpty())
|
||||
{
|
||||
//TODO-CLI: try to automatically find ROM
|
||||
QStringList paths = options->gbaRomPath[0].split("|");
|
||||
if (paths.size() >= 2)
|
||||
{
|
||||
printf("Warning: use the a.zip|b.gba format at your own risk!\n");
|
||||
options->gbaRomPath = paths;
|
||||
options->errorsToDisplay += "Option -A/--archive-file-gba given, but no archive specified!";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -132,4 +112,4 @@ CommandLineOptions* ManageArgs(QApplication& melon)
|
||||
return options;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user