2024-02-02 14:29:48 -05:00
|
|
|
// SPDX-FileCopyrightText: 2024 Joshua Goins <josh@redstrate.com>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
2024-05-27 18:18:54 -04:00
|
|
|
#include <KActionCollection>
|
2024-02-02 14:29:48 -05:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QDesktopServices>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QListWidget>
|
|
|
|
#include <QMenuBar>
|
2024-02-04 14:47:12 -05:00
|
|
|
#include <QSplitter>
|
2024-02-02 14:29:48 -05:00
|
|
|
#include <QUrl>
|
|
|
|
#include <physis.hpp>
|
|
|
|
|
|
|
|
#include "maplistwidget.h"
|
|
|
|
#include "mapview.h"
|
|
|
|
|
|
|
|
MainWindow::MainWindow(GameData *data)
|
2024-05-27 18:18:54 -04:00
|
|
|
: KXmlGuiWindow()
|
2024-02-02 14:29:48 -05:00
|
|
|
, data(data)
|
|
|
|
, cache(*data)
|
|
|
|
{
|
|
|
|
setMinimumSize(1280, 720);
|
|
|
|
|
2024-02-04 14:47:12 -05:00
|
|
|
auto dummyWidget = new QSplitter();
|
2024-02-04 14:58:21 -05:00
|
|
|
dummyWidget->setChildrenCollapsible(false);
|
2024-02-02 14:29:48 -05:00
|
|
|
setCentralWidget(dummyWidget);
|
|
|
|
|
|
|
|
auto listWidget = new MapListWidget(data);
|
|
|
|
listWidget->setMaximumWidth(400);
|
2024-02-04 14:47:12 -05:00
|
|
|
dummyWidget->addWidget(listWidget);
|
2024-02-02 14:29:48 -05:00
|
|
|
|
|
|
|
auto mapView = new MapView(data, cache);
|
2024-02-04 14:47:12 -05:00
|
|
|
dummyWidget->addWidget(mapView);
|
2024-02-02 14:29:48 -05:00
|
|
|
|
|
|
|
connect(listWidget, &MapListWidget::mapSelected, this, [data, mapView](const QString &basePath) {
|
|
|
|
QString base2Path = basePath.left(basePath.lastIndexOf(QStringLiteral("/level/")));
|
|
|
|
QString bgPath = QStringLiteral("bg/%1/bgplate/").arg(base2Path);
|
|
|
|
|
|
|
|
std::string bgPathStd = bgPath.toStdString() + "terrain.tera";
|
|
|
|
|
|
|
|
auto tera_buffer = physis_gamedata_extract_file(data, bgPathStd.c_str());
|
|
|
|
|
|
|
|
auto tera = physis_parse_tera(tera_buffer);
|
|
|
|
mapView->addTerrain(bgPath, tera);
|
|
|
|
});
|
2024-05-27 18:18:54 -04:00
|
|
|
|
|
|
|
setupGUI(Keys | Save | Create);
|
|
|
|
|
|
|
|
// We don't provide help (yet)
|
|
|
|
actionCollection()->removeAction(actionCollection()->action(KStandardAction::name(KStandardAction::HelpContents)));
|
|
|
|
// This isn't KDE software
|
|
|
|
actionCollection()->removeAction(actionCollection()->action(KStandardAction::name(KStandardAction::AboutKDE)));
|
2024-02-02 14:29:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#include "moc_mainwindow.cpp"
|