2016-09-06 00:12:56 +01:00
|
|
|
#include <QApplication>
|
2018-10-08 02:43:23 +01:00
|
|
|
#include <QCommandLineParser>
|
2025-03-11 12:48:26 -04:00
|
|
|
#include <QtGlobal>
|
2016-07-26 15:20:18 +01:00
|
|
|
#include "mainwindow.h"
|
2025-03-11 12:48:26 -04:00
|
|
|
#include "PathUtils.h"
|
2018-10-08 02:43:23 +01:00
|
|
|
#include "QStringUtils.h"
|
2016-09-06 00:12:56 +01:00
|
|
|
|
2022-01-18 17:56:47 +00:00
|
|
|
Q_DECLARE_METATYPE(std::string)
|
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
int main(int argc, char* argv[])
|
2016-09-06 00:12:56 +01:00
|
|
|
{
|
2020-04-10 05:06:45 +01:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
|
2018-09-26 12:50:25 -04:00
|
|
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
2020-04-10 05:06:45 +01:00
|
|
|
#endif
|
2018-04-30 21:01:23 +01:00
|
|
|
QApplication a(argc, argv);
|
2018-10-08 02:43:23 +01:00
|
|
|
|
|
|
|
QCoreApplication::setApplicationName("Play!");
|
|
|
|
QCoreApplication::setApplicationVersion("Version: " PLAY_VERSION);
|
|
|
|
|
2022-01-18 17:56:47 +00:00
|
|
|
qRegisterMetaType<std::string>();
|
|
|
|
|
2018-10-08 02:43:23 +01:00
|
|
|
QCommandLineParser parser;
|
|
|
|
parser.setApplicationDescription("Description: A multiplatform PS2 emulator.");
|
|
|
|
parser.addHelpOption();
|
|
|
|
parser.addVersionOption();
|
|
|
|
|
2019-03-21 17:52:43 -04:00
|
|
|
#ifdef DEBUGGER_INCLUDED
|
|
|
|
QCommandLineOption debugger_option("debugger", "Show debugger");
|
|
|
|
parser.addOption(debugger_option);
|
2020-05-18 18:08:30 +01:00
|
|
|
QCommandLineOption frame_debugger_option("framedebugger", "Show frame debugger");
|
|
|
|
parser.addOption(frame_debugger_option);
|
2019-03-21 17:52:43 -04:00
|
|
|
#endif
|
2023-05-25 09:45:33 -04:00
|
|
|
|
|
|
|
QCommandLineOption fullscreen_option("fullscreen", "Start the emulator fullscreen.");
|
|
|
|
parser.addOption(fullscreen_option);
|
|
|
|
|
2018-10-08 02:43:23 +01:00
|
|
|
QCommandLineOption cdrom_image_option("cdrom0", "Boot last booted cdvd image");
|
|
|
|
parser.addOption(cdrom_image_option);
|
2019-06-27 20:50:49 -04:00
|
|
|
|
2018-10-08 02:43:23 +01:00
|
|
|
QCommandLineOption disc_image_option("disc", "Boot any supported disc image", "disc_image");
|
|
|
|
parser.addOption(disc_image_option);
|
2019-06-27 20:50:49 -04:00
|
|
|
|
2018-10-08 02:43:23 +01:00
|
|
|
QCommandLineOption elf_image_option("elf", "Boot supported elf image", "elf_image");
|
|
|
|
parser.addOption(elf_image_option);
|
2019-06-27 20:50:49 -04:00
|
|
|
|
2022-11-08 12:53:55 -05:00
|
|
|
QCommandLineOption arcade_id_option("arcade", "Boot arcade game with specified id", "arcade_id");
|
|
|
|
parser.addOption(arcade_id_option);
|
2022-12-20 15:39:16 -05:00
|
|
|
|
2019-06-27 20:50:49 -04:00
|
|
|
QCommandLineOption load_state_option("state", "Load state at index", "state_index");
|
|
|
|
parser.addOption(load_state_option);
|
|
|
|
|
2018-10-08 02:43:23 +01:00
|
|
|
parser.process(a);
|
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
MainWindow w;
|
|
|
|
w.show();
|
2018-10-08 02:43:23 +01:00
|
|
|
|
|
|
|
if(parser.isSet(cdrom_image_option))
|
|
|
|
{
|
2020-01-31 18:21:16 -05:00
|
|
|
try
|
|
|
|
{
|
|
|
|
w.BootCDROM();
|
|
|
|
}
|
|
|
|
catch(const std::exception& e)
|
|
|
|
{
|
|
|
|
printf("Error: %s\r\n", e.what());
|
|
|
|
}
|
2018-10-08 02:43:23 +01:00
|
|
|
}
|
|
|
|
else if(parser.isSet(disc_image_option))
|
|
|
|
{
|
|
|
|
QString disc_image = parser.value(disc_image_option);
|
|
|
|
w.LoadCDROM(QStringToPath(disc_image));
|
|
|
|
w.BootCDROM();
|
|
|
|
}
|
|
|
|
else if(parser.isSet(elf_image_option))
|
|
|
|
{
|
|
|
|
QString elf_image = parser.value(elf_image_option);
|
|
|
|
w.BootElf(QStringToPath(elf_image));
|
|
|
|
}
|
2022-11-08 12:53:55 -05:00
|
|
|
else if(parser.isSet(arcade_id_option))
|
|
|
|
{
|
|
|
|
QString arcade_id = parser.value(arcade_id_option);
|
2022-12-11 16:23:09 -05:00
|
|
|
w.BootArcadeMachine(arcade_id.toStdString() + ".arcadedef");
|
2022-11-08 12:53:55 -05:00
|
|
|
}
|
2018-10-08 02:43:23 +01:00
|
|
|
|
2023-05-25 09:45:33 -04:00
|
|
|
if(parser.isSet(fullscreen_option))
|
|
|
|
{
|
|
|
|
w.showFullScreen();
|
|
|
|
}
|
|
|
|
|
2019-06-27 20:50:49 -04:00
|
|
|
if(parser.isSet(load_state_option))
|
|
|
|
{
|
|
|
|
QString stateIndex = parser.value(load_state_option);
|
|
|
|
w.loadState(stateIndex.toInt());
|
|
|
|
}
|
|
|
|
|
2019-03-21 17:52:43 -04:00
|
|
|
#ifdef DEBUGGER_INCLUDED
|
|
|
|
if(parser.isSet(debugger_option))
|
|
|
|
{
|
|
|
|
w.ShowDebugger();
|
|
|
|
}
|
2020-05-18 18:08:30 +01:00
|
|
|
if(parser.isSet(frame_debugger_option))
|
|
|
|
{
|
|
|
|
w.ShowFrameDebugger();
|
|
|
|
}
|
2019-03-21 17:52:43 -04:00
|
|
|
#endif
|
2018-04-30 21:01:23 +01:00
|
|
|
return a.exec();
|
2016-09-06 00:12:56 +01:00
|
|
|
}
|
2025-03-11 12:48:26 -04:00
|
|
|
|
|
|
|
fs::path CAppConfig::GetBasePath() const
|
|
|
|
{
|
|
|
|
static const char* BASE_DATA_PATH = "Play Data Files";
|
|
|
|
static const auto basePath =
|
|
|
|
[]() {
|
|
|
|
fs::path result;
|
|
|
|
if(fs::exists("portable.txt"))
|
|
|
|
{
|
|
|
|
result = BASE_DATA_PATH;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = Framework::PathUtils::GetPersonalDataPath() / BASE_DATA_PATH;
|
|
|
|
}
|
|
|
|
Framework::PathUtils::EnsurePathExists(result);
|
|
|
|
return result;
|
|
|
|
}();
|
|
|
|
return basePath;
|
|
|
|
}
|