2023-08-06 08:48:11 -04:00
|
|
|
// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2022-04-14 08:24:06 -04:00
|
|
|
#include "mainwindow.h"
|
|
|
|
|
2023-07-08 10:33:12 -04:00
|
|
|
#include <QApplication>
|
2023-08-06 08:48:11 -04:00
|
|
|
#include <QDesktopServices>
|
2023-10-12 19:04:19 -04:00
|
|
|
#include <QFileDialog>
|
2022-04-14 08:24:06 -04:00
|
|
|
#include <QHBoxLayout>
|
2023-08-06 08:48:11 -04:00
|
|
|
#include <QMenuBar>
|
2022-04-14 08:24:06 -04:00
|
|
|
|
2023-07-08 10:33:12 -04:00
|
|
|
#include "filepropertieswindow.h"
|
2023-09-23 15:45:38 -04:00
|
|
|
#include "filetreewindow.h"
|
2023-07-08 10:33:12 -04:00
|
|
|
|
2023-10-10 18:02:13 -04:00
|
|
|
MainWindow::MainWindow(GameData *data)
|
2023-10-10 18:22:38 -04:00
|
|
|
: NovusMainWindow()
|
|
|
|
, data(data)
|
2023-10-10 18:02:13 -04:00
|
|
|
{
|
2023-10-10 18:22:38 -04:00
|
|
|
setupMenubar();
|
2023-07-08 10:33:12 -04:00
|
|
|
|
2023-04-09 15:32:09 -04:00
|
|
|
mdiArea = new QMdiArea();
|
|
|
|
setCentralWidget(mdiArea);
|
2022-04-14 08:24:06 -04:00
|
|
|
|
2023-04-09 15:32:09 -04:00
|
|
|
auto tree = new FileTreeWindow(data);
|
|
|
|
connect(tree, &FileTreeWindow::openFileProperties, this, [=](QString path) {
|
|
|
|
auto window = mdiArea->addSubWindow(new FilePropertiesWindow(data, path));
|
|
|
|
window->show();
|
|
|
|
});
|
2023-10-12 19:04:19 -04:00
|
|
|
connect(tree, &FileTreeWindow::extractFile, this, [this, data](QString path) {
|
|
|
|
const QFileInfo info(path);
|
|
|
|
|
|
|
|
const QString savePath = QFileDialog::getSaveFileName(this, tr("Save File"), info.fileName(), QStringLiteral("*.%1").arg(info.completeSuffix()));
|
|
|
|
if (!savePath.isEmpty()) {
|
|
|
|
qInfo() << "Saving to" << savePath;
|
|
|
|
|
|
|
|
std::string savePathStd = path.toStdString();
|
|
|
|
|
|
|
|
auto fileData = physis_gamedata_extract_file(data, savePathStd.c_str());
|
|
|
|
QFile file(savePath);
|
|
|
|
file.open(QIODevice::WriteOnly);
|
|
|
|
file.write(reinterpret_cast<const char *>(fileData.data), fileData.size);
|
|
|
|
}
|
|
|
|
});
|
2022-04-14 08:24:06 -04:00
|
|
|
|
2023-04-09 15:32:09 -04:00
|
|
|
mdiArea->addSubWindow(tree);
|
2022-04-14 08:24:06 -04:00
|
|
|
}
|