mirror of
https://github.com/redstrate/Novus.git
synced 2025-05-14 12:37:46 +00:00
Map Editor: Move the map list widget to an open dialog
This commit is contained in:
parent
0aca596662
commit
442a13a612
3 changed files with 42 additions and 19 deletions
|
@ -8,6 +8,7 @@
|
||||||
#include "filecache.h"
|
#include "filecache.h"
|
||||||
|
|
||||||
struct GameData;
|
struct GameData;
|
||||||
|
class MapView;
|
||||||
|
|
||||||
class MainWindow : public KXmlGuiWindow
|
class MainWindow : public KXmlGuiWindow
|
||||||
{
|
{
|
||||||
|
@ -18,7 +19,9 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupActions();
|
void setupActions();
|
||||||
|
void openMap(const QString &basePath);
|
||||||
|
|
||||||
GameData *data = nullptr;
|
GameData *data = nullptr;
|
||||||
FileCache cache;
|
FileCache cache;
|
||||||
|
MapView *mapView = nullptr;
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
<MenuBar>
|
<MenuBar>
|
||||||
<Menu name="file" >
|
<Menu name="file" >
|
||||||
<text>File</text>
|
<text>File</text>
|
||||||
|
<Action name="open/>
|
||||||
|
<Separator/>
|
||||||
<Action name="quit"/>
|
<Action name="quit"/>
|
||||||
</Menu>
|
</Menu>
|
||||||
</MenuBar>
|
</MenuBar>
|
||||||
|
|
|
@ -6,11 +6,10 @@
|
||||||
#include <KActionCollection>
|
#include <KActionCollection>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
#include <QDialog>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QListWidget>
|
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
#include <QUrl>
|
|
||||||
#include <physis.hpp>
|
#include <physis.hpp>
|
||||||
|
|
||||||
#include "maplistwidget.h"
|
#include "maplistwidget.h"
|
||||||
|
@ -27,25 +26,9 @@ MainWindow::MainWindow(GameData *data)
|
||||||
dummyWidget->setChildrenCollapsible(false);
|
dummyWidget->setChildrenCollapsible(false);
|
||||||
setCentralWidget(dummyWidget);
|
setCentralWidget(dummyWidget);
|
||||||
|
|
||||||
auto listWidget = new MapListWidget(data);
|
mapView = new MapView(data, cache);
|
||||||
listWidget->setMaximumWidth(400);
|
|
||||||
dummyWidget->addWidget(listWidget);
|
|
||||||
|
|
||||||
auto mapView = new MapView(data, cache);
|
|
||||||
dummyWidget->addWidget(mapView);
|
dummyWidget->addWidget(mapView);
|
||||||
|
|
||||||
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);
|
|
||||||
});
|
|
||||||
|
|
||||||
setupActions();
|
setupActions();
|
||||||
setupGUI(Keys | Save | Create);
|
setupGUI(Keys | Save | Create);
|
||||||
|
|
||||||
|
@ -57,7 +40,42 @@ MainWindow::MainWindow(GameData *data)
|
||||||
|
|
||||||
void MainWindow::setupActions()
|
void MainWindow::setupActions()
|
||||||
{
|
{
|
||||||
|
KStandardAction::open(
|
||||||
|
qApp,
|
||||||
|
[this] {
|
||||||
|
auto dialog = new QDialog();
|
||||||
|
|
||||||
|
auto layout = new QVBoxLayout();
|
||||||
|
layout->setContentsMargins({});
|
||||||
|
dialog->setLayout(layout);
|
||||||
|
|
||||||
|
auto listWidget = new MapListWidget(data);
|
||||||
|
connect(listWidget, &MapListWidget::mapSelected, this, [this, dialog](const QString &basePath) {
|
||||||
|
dialog->close();
|
||||||
|
openMap(basePath);
|
||||||
|
});
|
||||||
|
layout->addWidget(listWidget);
|
||||||
|
|
||||||
|
dialog->exec();
|
||||||
|
},
|
||||||
|
actionCollection());
|
||||||
|
|
||||||
KStandardAction::quit(qApp, &QCoreApplication::quit, actionCollection());
|
KStandardAction::quit(qApp, &QCoreApplication::quit, actionCollection());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::openMap(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);
|
||||||
|
|
||||||
|
setWindowTitle(basePath);
|
||||||
|
}
|
||||||
|
|
||||||
#include "moc_mainwindow.cpp"
|
#include "moc_mainwindow.cpp"
|
||||||
|
|
Loading…
Add table
Reference in a new issue