mirror of
https://github.com/azahar-emu/azahar
synced 2025-11-07 07:29:58 +01:00
citra_qt: Text output for -h, -v and -i options are displayed using a Qt message box on Windows
This commit is contained in:
parent
471d3e035c
commit
fb71e9977c
@ -3,7 +3,6 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <clocale>
|
#include <clocale>
|
||||||
#include <iostream>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
@ -23,6 +22,9 @@
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#else
|
||||||
|
#include <iostream>
|
||||||
|
#include <getopt.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef __unix__
|
#ifdef __unix__
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
@ -158,6 +160,14 @@ static QString PrettyProductName() {
|
|||||||
return QSysInfo::prettyProductName();
|
return QSysInfo::prettyProductName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GMainWindow::ShowCommandOutput(std::string title, std::string message) {
|
||||||
|
#ifdef _WIN32
|
||||||
|
QMessageBox::information(this, QString::fromStdString(title), QString::fromStdString(message));
|
||||||
|
#else
|
||||||
|
std::cout << message << std::endl;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
GMainWindow::GMainWindow(Core::System& system_)
|
GMainWindow::GMainWindow(Core::System& system_)
|
||||||
: ui{std::make_unique<Ui::MainWindow>()}, system{system_}, movie{system.Movie()},
|
: ui{std::make_unique<Ui::MainWindow>()}, system{system_}, movie{system.Movie()},
|
||||||
config{std::make_unique<Config>()}, emu_thread{nullptr} {
|
config{std::make_unique<Config>()}, emu_thread{nullptr} {
|
||||||
@ -215,6 +225,134 @@ GMainWindow::GMainWindow(Core::System& system_)
|
|||||||
SetDefaultUIGeometry();
|
SetDefaultUIGeometry();
|
||||||
RestoreUIState();
|
RestoreUIState();
|
||||||
|
|
||||||
|
QStringList args = QApplication::arguments();
|
||||||
|
QString game_path;
|
||||||
|
for (int i = 1; i < args.size(); ++i) {
|
||||||
|
// Preserves drag/drop functionality
|
||||||
|
if (args.size() == 2 && !args[1].startsWith(QChar::fromLatin1('-'))) {
|
||||||
|
game_path = args[1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dump video
|
||||||
|
if (args[i] == QStringLiteral("-d")) {
|
||||||
|
if (i >= args.size() - 1 || args[i + 1].startsWith(QChar::fromLatin1('-'))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!DynamicLibrary::FFmpeg::LoadFFmpeg()) {
|
||||||
|
ShowFFmpegErrorMessage();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
video_dumping_path = args[++i];
|
||||||
|
video_dumping_on_start = true;
|
||||||
|
ui->action_Dump_Video->setChecked(true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Launch game in fullscreen mode
|
||||||
|
if (args[i] == QStringLiteral("-f")) {
|
||||||
|
ui->action_Fullscreen->setChecked(true);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable GDB stub
|
||||||
|
if (args[i] == QStringLiteral("-g")) {
|
||||||
|
if (i >= args.size() - 1 || args[i + 1].startsWith(QChar::fromLatin1('-'))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Settings::values.use_gdbstub = true;
|
||||||
|
Settings::values.gdbstub_port = strtoul(args[++i].toLatin1(), NULL, 0);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[i] == QStringLiteral("-h")) {
|
||||||
|
const std::string help_string =
|
||||||
|
std::string("Usage: ") + args[0].toStdString() +
|
||||||
|
" [options] <file path>\n"
|
||||||
|
"-d [path] Dump video recording of emulator playback to the given file path\n"
|
||||||
|
"-g [port] Enable gdb stub on the given port\n"
|
||||||
|
"-f Start in fullscreen mode\n"
|
||||||
|
"-h Display this help and exit\n"
|
||||||
|
"-i [path] Install a CIA file at the given path\n"
|
||||||
|
"-p [path] Play a TAS movie located at the given path\n"
|
||||||
|
"-r [path] Record a TAS movie to the given file path\n"
|
||||||
|
"-v Output version information and exit";
|
||||||
|
|
||||||
|
ShowCommandOutput("Help", help_string);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[i] == QStringLiteral("-i")) {
|
||||||
|
if (i >= args.size() - 1 || args[i + 1].startsWith(QChar::fromLatin1('-'))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Service::AM::InstallStatus result = Service::AM::InstallCIA(args[++i].toStdString());
|
||||||
|
if (result != Service::AM::InstallStatus::Success) {
|
||||||
|
std::string failure_reason;
|
||||||
|
|
||||||
|
if (result == Service::AM::InstallStatus::ErrorFailedToOpenFile)
|
||||||
|
failure_reason = "Unable to open file.";
|
||||||
|
|
||||||
|
if (result == Service::AM::InstallStatus::ErrorFileNotFound)
|
||||||
|
failure_reason = "File not found.";
|
||||||
|
|
||||||
|
if (result == Service::AM::InstallStatus::ErrorAborted)
|
||||||
|
failure_reason = "Install was aborted.";
|
||||||
|
|
||||||
|
if (result == Service::AM::InstallStatus::ErrorInvalid)
|
||||||
|
failure_reason = "CIA is invalid.";
|
||||||
|
|
||||||
|
if (result == Service::AM::InstallStatus::ErrorEncrypted)
|
||||||
|
failure_reason = "CIA is encrypted.";
|
||||||
|
|
||||||
|
std::string failure_string = "Failed to install CIA: " + failure_reason;
|
||||||
|
ShowCommandOutput("Failure", failure_string);
|
||||||
|
exit((int)result +
|
||||||
|
2); // 2 is added here to avoid stepping on the toes of
|
||||||
|
// exit codes 1 and 2 which have pre-established conventional meanings
|
||||||
|
}
|
||||||
|
ShowCommandOutput("Success", "Installed CIA successfully.");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[i] == QStringLiteral("-p")) {
|
||||||
|
if (i >= args.size() - 1 || args[i + 1].startsWith(QChar::fromLatin1('-'))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
movie_playback_path = args[++i];
|
||||||
|
movie_playback_on_start = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[i] == QStringLiteral("-r")) {
|
||||||
|
if (i >= args.size() - 1 || args[i + 1].startsWith(QChar::fromLatin1('-'))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
movie_record_path = args[++i];
|
||||||
|
movie_record_on_start = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[i] == QStringLiteral("-v")) {
|
||||||
|
const std::string version_string =
|
||||||
|
std::string("Lime3DS ") + Common::g_scm_branch + " " + Common::g_scm_desc;
|
||||||
|
ShowCommandOutput("Version", version_string);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Launch game in windowed mode
|
||||||
|
if (args[i] == QStringLiteral("-w")) {
|
||||||
|
ui->action_Fullscreen->setChecked(false);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Launch game at path
|
||||||
|
if (i == args.size() - 1 && !args[i].startsWith(QChar::fromLatin1('-'))) {
|
||||||
|
game_path = args[i];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ConnectAppEvents();
|
ConnectAppEvents();
|
||||||
ConnectMenuEvents();
|
ConnectMenuEvents();
|
||||||
ConnectWidgetEvents();
|
ConnectWidgetEvents();
|
||||||
@ -281,71 +419,6 @@ GMainWindow::GMainWindow(Core::System& system_)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QStringList args = QApplication::arguments();
|
|
||||||
if (args.size() < 2) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString game_path;
|
|
||||||
for (int i = 1; i < args.size(); ++i) {
|
|
||||||
// Preserves drag/drop functionality
|
|
||||||
if (args.size() == 2 && !args[1].startsWith(QChar::fromLatin1('-'))) {
|
|
||||||
game_path = args[1];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dump video
|
|
||||||
if (args[i] == QStringLiteral("-d")) {
|
|
||||||
if (i >= args.size() - 1 || args[i + 1].startsWith(QChar::fromLatin1('-'))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!DynamicLibrary::FFmpeg::LoadFFmpeg()) {
|
|
||||||
ShowFFmpegErrorMessage();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
video_dumping_path = args[++i];
|
|
||||||
video_dumping_on_start = true;
|
|
||||||
ui->action_Dump_Video->setChecked(true);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Launch game in fullscreen mode
|
|
||||||
if (args[i] == QStringLiteral("-f")) {
|
|
||||||
ui->action_Fullscreen->setChecked(true);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[i] == QStringLiteral("-p")) {
|
|
||||||
if (i >= args.size() - 1 || args[i + 1].startsWith(QChar::fromLatin1('-'))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
movie_playback_path = args[++i];
|
|
||||||
movie_playback_on_start = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args[i] == QStringLiteral("-r")) {
|
|
||||||
if (i >= args.size() - 1 || args[i + 1].startsWith(QChar::fromLatin1('-'))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
movie_record_path = args[++i];
|
|
||||||
movie_record_on_start = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Launch game in windowed mode
|
|
||||||
if (args[i] == QStringLiteral("-w")) {
|
|
||||||
ui->action_Fullscreen->setChecked(false);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Launch game at path
|
|
||||||
if (i == args.size() - 1 && !args[i].startsWith(QChar::fromLatin1('-'))) {
|
|
||||||
game_path = args[i];
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!game_path.isEmpty()) {
|
if (!game_path.isEmpty()) {
|
||||||
BootGame(game_path);
|
BootGame(game_path);
|
||||||
}
|
}
|
||||||
@ -3605,67 +3678,7 @@ static Qt::HighDpiScaleFactorRoundingPolicy GetHighDpiRoundingPolicy() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PrintHelp(const char* argv0) {
|
|
||||||
std::cout << "Usage: " << argv0
|
|
||||||
<< " [options] <file path>\n"
|
|
||||||
"-d [path] Dump video recording of emulator playback to the given file path\n"
|
|
||||||
"-f Start in fullscreen mode\n"
|
|
||||||
"-h Display this help and exit\n"
|
|
||||||
"-i [path] Install a CIA file at the given path\n"
|
|
||||||
"-p [path] Play a TAS movie located at the given path\n"
|
|
||||||
"-r [path] Record a TAS movie to the given file path\n"
|
|
||||||
"-v Output version information and exit\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
static void PrintVersion() {
|
|
||||||
std::cout << "Lime3DS " << Common::g_scm_branch << " " << Common::g_scm_desc << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
while (optind < argc) {
|
|
||||||
int arg = getopt(argc, argv, "d:fg:hi:p:r:v");
|
|
||||||
if (arg != -1) {
|
|
||||||
switch (static_cast<char>(arg)) {
|
|
||||||
case 'h':
|
|
||||||
PrintHelp(argv[0]);
|
|
||||||
return 0;
|
|
||||||
case 'i': {
|
|
||||||
Service::AM::InstallStatus result = Service::AM::InstallCIA(std::string(optarg));
|
|
||||||
if (result != Service::AM::InstallStatus::Success) {
|
|
||||||
std::string failure_reason;
|
|
||||||
|
|
||||||
if (result == Service::AM::InstallStatus::ErrorFailedToOpenFile)
|
|
||||||
failure_reason = "Unable to open file.";
|
|
||||||
|
|
||||||
if (result == Service::AM::InstallStatus::ErrorFileNotFound)
|
|
||||||
failure_reason = "File not found.";
|
|
||||||
|
|
||||||
if (result == Service::AM::InstallStatus::ErrorAborted)
|
|
||||||
failure_reason = "Install was aborted.";
|
|
||||||
|
|
||||||
if (result == Service::AM::InstallStatus::ErrorInvalid)
|
|
||||||
failure_reason = "CIA is invalid.";
|
|
||||||
|
|
||||||
if (result == Service::AM::InstallStatus::ErrorEncrypted)
|
|
||||||
failure_reason = "CIA is encrypted.";
|
|
||||||
|
|
||||||
std::cout << "Failed to install CIA: " << failure_reason << std::endl;
|
|
||||||
return (int)result +
|
|
||||||
2; // 2 is added here to avoid stepping on the toes of
|
|
||||||
// exit codes 1 and 2 which have pre-established conventional meanings
|
|
||||||
}
|
|
||||||
std::cout << "Installed CIA successfully." << std::endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
case 'v':
|
|
||||||
PrintVersion();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
optind++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Common::DetachedTasks detached_tasks;
|
Common::DetachedTasks detached_tasks;
|
||||||
MicroProfileOnThreadCreate("Frontend");
|
MicroProfileOnThreadCreate("Frontend");
|
||||||
SCOPE_EXIT({ MicroProfileShutdown(); });
|
SCOPE_EXIT({ MicroProfileShutdown(); });
|
||||||
|
|||||||
@ -219,6 +219,7 @@ private:
|
|||||||
const std::string& keywords, const std::string& name,
|
const std::string& keywords, const std::string& name,
|
||||||
const bool& skip_tryexec);
|
const bool& skip_tryexec);
|
||||||
|
|
||||||
|
void ShowCommandOutput(std::string title, std::string message);
|
||||||
void ShowFFmpegErrorMessage();
|
void ShowFFmpegErrorMessage();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user