2024-02-29 23:00:35 +01:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
#include <QtWidgets/QApplication>
|
|
|
|
|
2024-06-11 04:42:21 +02:00
|
|
|
#include "common/config.h"
|
|
|
|
#include "core/file_sys/fs.h"
|
2024-02-29 23:00:35 +01:00
|
|
|
#include "qt_gui/game_install_dialog.h"
|
|
|
|
#include "qt_gui/main_window.h"
|
2024-04-15 21:51:36 +02:00
|
|
|
|
2024-07-06 17:55:24 +02:00
|
|
|
#include <emulator.h>
|
|
|
|
#include <fmt/core.h>
|
|
|
|
|
2024-07-05 23:20:19 +02:00
|
|
|
// Custom message handler to ignore Qt logs
|
2024-06-11 04:42:21 +02:00
|
|
|
void customMessageHandler(QtMsgType, const QMessageLogContext&, const QString&) {}
|
2024-02-29 23:00:35 +01:00
|
|
|
|
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
QApplication a(argc, argv);
|
2024-07-05 23:20:19 +02:00
|
|
|
|
|
|
|
// Load configurations and initialize Qt application
|
2024-06-11 04:42:21 +02:00
|
|
|
const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
|
|
|
|
Config::load(config_dir / "config.toml");
|
2024-07-14 01:19:02 +02:00
|
|
|
QString gameDataPath = QDir::currentPath() + "/user/game_data/";
|
2024-06-11 04:42:21 +02:00
|
|
|
std::string stdStr = gameDataPath.toStdString();
|
|
|
|
std::filesystem::path path(stdStr);
|
|
|
|
#ifdef _WIN64
|
|
|
|
std::wstring wstdStr = gameDataPath.toStdWString();
|
|
|
|
path = std::filesystem::path(wstdStr);
|
|
|
|
#endif
|
|
|
|
std::filesystem::create_directory(path);
|
|
|
|
|
2024-07-05 23:20:19 +02:00
|
|
|
// Check if the game install directory is set
|
2024-06-11 04:42:21 +02:00
|
|
|
if (Config::getGameInstallDir() == "") {
|
|
|
|
GameInstallDialog dlg;
|
2024-02-29 23:00:35 +01:00
|
|
|
dlg.exec();
|
|
|
|
}
|
2024-06-11 04:42:21 +02:00
|
|
|
|
2024-07-05 23:20:19 +02:00
|
|
|
// Ignore Qt logs
|
|
|
|
qInstallMessageHandler(customMessageHandler);
|
|
|
|
|
|
|
|
// Initialize the main window
|
2024-06-11 04:42:21 +02:00
|
|
|
MainWindow* m_main_window = new MainWindow(nullptr);
|
2024-02-29 23:00:35 +01:00
|
|
|
m_main_window->Init();
|
|
|
|
|
2024-07-05 23:20:19 +02:00
|
|
|
// Check for command line arguments
|
|
|
|
if (argc > 1) {
|
|
|
|
Core::Emulator emulator;
|
|
|
|
emulator.Run(argv[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Run the Qt application
|
2024-02-29 23:00:35 +01:00
|
|
|
return a.exec();
|
2024-07-05 23:20:19 +02:00
|
|
|
}
|