2023-08-31 14:21:19 +02:00
|
|
|
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-09-23 15:21:36 -04:00
|
|
|
#include <KConfig>
|
|
|
|
#include <KConfigGroup>
|
2024-02-04 15:17:15 -05:00
|
|
|
#include <KLocalizedString>
|
2023-08-31 14:18:50 +02:00
|
|
|
#include <QApplication>
|
2023-09-23 15:21:36 -04:00
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <physis.hpp>
|
2023-08-31 14:18:50 +02:00
|
|
|
|
2023-10-10 18:09:14 -04:00
|
|
|
#include "aboutdata.h"
|
2023-08-31 14:18:50 +02:00
|
|
|
#include "mainwindow.h"
|
|
|
|
|
2023-10-10 18:02:13 -04:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
2023-08-31 14:18:50 +02:00
|
|
|
QApplication app(argc, argv);
|
|
|
|
|
2024-02-04 15:36:08 -05:00
|
|
|
KLocalizedString::setApplicationDomain(QByteArrayLiteral("novus"));
|
|
|
|
|
2023-10-10 18:09:14 -04:00
|
|
|
customizeAboutData(QStringLiteral("launcher"),
|
2023-12-31 12:11:42 -05:00
|
|
|
QStringLiteral("zone.xiv.novus"),
|
|
|
|
QStringLiteral("Novus SDK"),
|
2024-02-04 15:17:15 -05:00
|
|
|
i18n("Handles setting up and launching various Novus SDK components."));
|
2023-10-10 18:09:14 -04:00
|
|
|
|
2023-12-09 16:01:13 -05:00
|
|
|
// Default to a sensible message pattern
|
|
|
|
if (qEnvironmentVariableIsEmpty("QT_MESSAGE_PATTERN")) {
|
|
|
|
qputenv("QT_MESSAGE_PATTERN", "[%{time yyyy-MM-dd h:mm:ss.zzz}] %{if-category}[%{category}] %{endif}[%{type}] %{message}");
|
|
|
|
}
|
|
|
|
|
2023-09-26 00:37:55 -04:00
|
|
|
KConfig config(QStringLiteral("novusrc"));
|
|
|
|
KConfigGroup game = config.group(QStringLiteral("Game"));
|
2023-09-23 15:21:36 -04:00
|
|
|
|
|
|
|
if (!game.hasKey("GameDir")) {
|
|
|
|
while (true) {
|
|
|
|
QMessageBox msgBox;
|
2024-02-04 15:17:15 -05:00
|
|
|
msgBox.setText(i18n("The game directory has not been set, please select it now. Select the 'game' folder."));
|
2023-09-23 15:21:36 -04:00
|
|
|
msgBox.exec();
|
|
|
|
|
2023-09-26 00:37:55 -04:00
|
|
|
const QString dir = QFileDialog::getExistingDirectory(nullptr,
|
2024-02-04 15:17:15 -05:00
|
|
|
i18nc("@title:window", "Open Game Directory"),
|
2023-09-26 00:37:55 -04:00
|
|
|
QStandardPaths::standardLocations(QStandardPaths::StandardLocation::HomeLocation).last(),
|
|
|
|
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
2023-09-23 15:21:36 -04:00
|
|
|
|
|
|
|
const std::string dirStd = dir.toStdString();
|
|
|
|
|
|
|
|
if (!physis_gamedata_initialize(dirStd.c_str()))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
game.writeEntry("GameDir", dir);
|
|
|
|
config.sync();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-31 14:18:50 +02:00
|
|
|
MainWindow window;
|
|
|
|
window.show();
|
|
|
|
|
|
|
|
return app.exec();
|
|
|
|
}
|