Add map list sorting and filtering
This commit is contained in:
parent
54a9d8b23b
commit
0e58fed23b
5 changed files with 275 additions and 62 deletions
|
@ -10,12 +10,6 @@
|
||||||
<height>747</height>
|
<height>747</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>porymap</string>
|
<string>porymap</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -71,12 +65,6 @@
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../resources/images.qrc">
|
<iconset resource="../resources/images.qrc">
|
||||||
<normaloff>:/icons/sort_alphabet.ico</normaloff>:/icons/sort_alphabet.ico</iconset>
|
<normaloff>:/icons/sort_alphabet.ico</normaloff>:/icons/sort_alphabet.ico</iconset>
|
||||||
|
@ -88,7 +76,7 @@
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="popupMode">
|
<property name="popupMode">
|
||||||
<enum>QToolButton::MenuButtonPopup</enum>
|
<enum>QToolButton::InstantPopup</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolButtonStyle">
|
<property name="toolButtonStyle">
|
||||||
<enum>Qt::ToolButtonIconOnly</enum>
|
<enum>Qt::ToolButtonIconOnly</enum>
|
||||||
|
@ -111,7 +99,7 @@
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>24</width>
|
<width>12</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
@ -122,12 +110,6 @@
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
|
@ -2391,6 +2373,45 @@
|
||||||
<string>Tileset Editor</string>
|
<string>Tileset Editor</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionSort_by_Name">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../resources/images.qrc">
|
||||||
|
<normaloff>:/icons/sort_alphabet.ico</normaloff>:/icons/sort_alphabet.ico</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Sort by &Name</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionSort_by_Group">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../resources/images.qrc">
|
||||||
|
<normaloff>:/icons/sort_number.ico</normaloff>:/icons/sort_number.ico</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Sort by &Group</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Sort by Group</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionSort_by_Layout">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../resources/images.qrc">
|
||||||
|
<normaloff>:/icons/sort_map.ico</normaloff>:/icons/sort_map.ico</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Sort by &Layout</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "editor.h"
|
#include "editor.h"
|
||||||
#include "tileseteditor.h"
|
#include "tileseteditor.h"
|
||||||
|
#include "filterchildrenproxymodel.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
|
@ -128,19 +129,32 @@ private slots:
|
||||||
|
|
||||||
void on_actionTileset_Editor_triggered();
|
void on_actionTileset_Editor_triggered();
|
||||||
|
|
||||||
|
void mapSortOrder_changed(QAction *action);
|
||||||
|
|
||||||
|
void on_lineEdit_filterBox_textChanged(const QString &arg1);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
TilesetEditor *tilesetEditor = nullptr;
|
TilesetEditor *tilesetEditor = nullptr;
|
||||||
|
FilterChildrenProxyModel *mapListProxyModel;
|
||||||
QStandardItemModel *mapListModel;
|
QStandardItemModel *mapListModel;
|
||||||
QList<QStandardItem*> *mapGroupsModel;
|
QList<QStandardItem*> *mapGroupItemsList;
|
||||||
QMap<QString, QModelIndex> mapListIndexes;
|
QMap<QString, QModelIndex> mapListIndexes;
|
||||||
Editor *editor = nullptr;
|
Editor *editor = nullptr;
|
||||||
QIcon* mapIcon;
|
QIcon* mapIcon;
|
||||||
QIcon* mapEditedIcon;
|
QIcon* mapEditedIcon;
|
||||||
|
|
||||||
|
enum MapSortOrder {
|
||||||
|
Group = 0,
|
||||||
|
Name = 1,
|
||||||
|
Layout = 2,
|
||||||
|
} mapSortOrder;
|
||||||
|
|
||||||
void setMap(QString, bool scrollTreeView = false);
|
void setMap(QString, bool scrollTreeView = false);
|
||||||
void redrawMapScene();
|
void redrawMapScene();
|
||||||
void loadDataStructures();
|
void loadDataStructures();
|
||||||
void populateMapList();
|
void populateMapList();
|
||||||
|
void sortMapList();
|
||||||
QString getExistingDirectory(QString);
|
QString getExistingDirectory(QString);
|
||||||
void openProject(QString dir);
|
void openProject(QString dir);
|
||||||
QString getDefaultMap();
|
QString getDefaultMap();
|
||||||
|
@ -157,14 +171,18 @@ private:
|
||||||
void initExtraShortcuts();
|
void initExtraShortcuts();
|
||||||
void initExtraSignals();
|
void initExtraSignals();
|
||||||
void initEditor();
|
void initEditor();
|
||||||
|
void initMiscHeapObjects();
|
||||||
|
void initMapSortOrder();
|
||||||
void loadUserSettings();
|
void loadUserSettings();
|
||||||
void openRecentProject();
|
void openRecentProject();
|
||||||
void updateTilesetEditor();
|
void updateTilesetEditor();
|
||||||
|
|
||||||
|
bool isProjectOpen();
|
||||||
};
|
};
|
||||||
|
|
||||||
enum MapListUserRoles {
|
enum MapListUserRoles {
|
||||||
GroupRole = Qt::UserRole + 1, // Used to hold the map group number.
|
GroupRole = Qt::UserRole + 1, // Used to hold the map group number.
|
||||||
TypeRole = Qt::UserRole + 2, // Used to differentiate between the different layers of the map list tree view.
|
TypeRole, // Used to differentiate between the different layers of the map list tree view.
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
@ -64,6 +64,9 @@ public:
|
||||||
QString getNewMapName();
|
QString getNewMapName();
|
||||||
QString getProjectTitle();
|
QString getProjectTitle();
|
||||||
|
|
||||||
|
QString readMapLayoutId(QString map_name);
|
||||||
|
QString readMapLocation(QString map_name);
|
||||||
|
|
||||||
QList<QStringList>* getLabelMacros(QList<QStringList>*, QString);
|
QList<QStringList>* getLabelMacros(QList<QStringList>*, QString);
|
||||||
QStringList* getLabelValues(QList<QStringList>*, QString);
|
QStringList* getLabelValues(QList<QStringList>*, QString);
|
||||||
void readMapHeader(Map*);
|
void readMapHeader(Map*);
|
||||||
|
|
|
@ -39,6 +39,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
this->initExtraSignals();
|
this->initExtraSignals();
|
||||||
this->initExtraShortcuts();
|
this->initExtraShortcuts();
|
||||||
this->initEditor();
|
this->initEditor();
|
||||||
|
this->initMiscHeapObjects();
|
||||||
|
this->initMapSortOrder();
|
||||||
this->openRecentProject();
|
this->openRecentProject();
|
||||||
|
|
||||||
on_toolButton_Paint_clicked();
|
on_toolButton_Paint_clicked();
|
||||||
|
@ -72,12 +74,89 @@ void MainWindow::initEditor() {
|
||||||
this->loadUserSettings();
|
this->loadUserSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::initMiscHeapObjects() {
|
||||||
|
mapIcon = new QIcon;
|
||||||
|
mapIcon->addFile(QStringLiteral(":/icons/map.ico"), QSize(), QIcon::Normal, QIcon::Off);
|
||||||
|
mapIcon->addFile(QStringLiteral(":/icons/map_opened.ico"), QSize(), QIcon::Normal, QIcon::On);
|
||||||
|
|
||||||
|
mapEditedIcon = new QIcon;
|
||||||
|
mapEditedIcon->addFile(QStringLiteral(":/icons/map_edited.ico"), QSize(), QIcon::Normal, QIcon::Off);
|
||||||
|
mapEditedIcon->addFile(QStringLiteral(":/icons/map_opened.ico"), QSize(), QIcon::Normal , QIcon::On);
|
||||||
|
|
||||||
|
mapListModel = new QStandardItemModel;
|
||||||
|
mapGroupItemsList = new QList<QStandardItem*>;
|
||||||
|
mapListProxyModel = new FilterChildrenProxyModel;
|
||||||
|
|
||||||
|
mapListProxyModel->setSourceModel(mapListModel);
|
||||||
|
ui->mapList->setModel(mapListProxyModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::initMapSortOrder() {
|
||||||
|
QMenu *mapSortOrderMenu = new QMenu();
|
||||||
|
QActionGroup *mapSortOrderActionGroup = new QActionGroup(ui->toolButton_MapSortOrder);
|
||||||
|
|
||||||
|
mapSortOrderMenu->addAction(ui->actionSort_by_Group);
|
||||||
|
mapSortOrderMenu->addAction(ui->actionSort_by_Name);
|
||||||
|
mapSortOrderMenu->addAction(ui->actionSort_by_Layout);
|
||||||
|
ui->toolButton_MapSortOrder->setMenu(mapSortOrderMenu);
|
||||||
|
|
||||||
|
mapSortOrderActionGroup->addAction(ui->actionSort_by_Group);
|
||||||
|
mapSortOrderActionGroup->addAction(ui->actionSort_by_Name);
|
||||||
|
mapSortOrderActionGroup->addAction(ui->actionSort_by_Layout);
|
||||||
|
|
||||||
|
connect(ui->toolButton_MapSortOrder, &QToolButton::triggered, this, &MainWindow::mapSortOrder_changed);
|
||||||
|
|
||||||
|
QAction* sortOrder = ui->toolButton_MapSortOrder->menu()->actions()[mapSortOrder];
|
||||||
|
ui->toolButton_MapSortOrder->setIcon(sortOrder->icon());
|
||||||
|
sortOrder->setChecked(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::mapSortOrder_changed(QAction *action)
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
QList<QAction*> items = ui->toolButton_MapSortOrder->menu()->actions();
|
||||||
|
int i = 0;
|
||||||
|
for (; i < items.count(); i++)
|
||||||
|
{
|
||||||
|
if(items[i] == action)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i != mapSortOrder)
|
||||||
|
{
|
||||||
|
ui->toolButton_MapSortOrder->setIcon(action->icon());
|
||||||
|
mapSortOrder = static_cast<MapSortOrder>(i);
|
||||||
|
settings.setValue("map_sort_order", i);
|
||||||
|
|
||||||
|
if (isProjectOpen())
|
||||||
|
{
|
||||||
|
sortMapList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_lineEdit_filterBox_textChanged(const QString &arg1)
|
||||||
|
{
|
||||||
|
mapListProxyModel->setFilterRegExp(QRegExp(arg1, Qt::CaseInsensitive, QRegExp::FixedString));
|
||||||
|
ui->mapList->expandToDepth(0);
|
||||||
|
ui->mapList->setExpanded(mapListProxyModel->mapFromSource(mapListIndexes.value(editor->map->name)), true);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::loadUserSettings() {
|
void MainWindow::loadUserSettings() {
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
bool betterCursors = settings.contains("cursor_mode") && settings.value("cursor_mode") != "0";
|
bool betterCursors = settings.contains("cursor_mode") && settings.value("cursor_mode") != "0";
|
||||||
ui->actionBetter_Cursors->setChecked(betterCursors);
|
ui->actionBetter_Cursors->setChecked(betterCursors);
|
||||||
this->editor->settings->betterCursors = betterCursors;
|
this->editor->settings->betterCursors = betterCursors;
|
||||||
|
|
||||||
|
if (!settings.contains("map_sort_order"))
|
||||||
|
{
|
||||||
|
settings.setValue("map_sort_order", 0);
|
||||||
|
}
|
||||||
|
mapSortOrder = static_cast<MapSortOrder>(settings.value("map_sort_order").toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::openRecentProject() {
|
void MainWindow::openRecentProject() {
|
||||||
|
@ -99,11 +178,7 @@ void MainWindow::openProject(QString dir) {
|
||||||
|
|
||||||
this->statusBar()->showMessage(QString("Opening project %1").arg(dir));
|
this->statusBar()->showMessage(QString("Opening project %1").arg(dir));
|
||||||
|
|
||||||
bool already_open = (
|
bool already_open = isProjectOpen() && (editor->project->root == dir);
|
||||||
(editor && editor != nullptr)
|
|
||||||
&& (editor->project && editor->project != nullptr)
|
|
||||||
&& (editor->project->root == dir)
|
|
||||||
);
|
|
||||||
if (!already_open) {
|
if (!already_open) {
|
||||||
editor->project = new Project;
|
editor->project = new Project;
|
||||||
editor->project->root = dir;
|
editor->project->root = dir;
|
||||||
|
@ -120,6 +195,11 @@ void MainWindow::openProject(QString dir) {
|
||||||
this->statusBar()->showMessage(QString("Opened project %1").arg(dir));
|
this->statusBar()->showMessage(QString("Opened project %1").arg(dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MainWindow::isProjectOpen() {
|
||||||
|
return (editor && editor != nullptr)
|
||||||
|
&& (editor->project && editor->project != nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
QString MainWindow::getDefaultMap() {
|
QString MainWindow::getDefaultMap() {
|
||||||
if (editor && editor->project) {
|
if (editor && editor->project) {
|
||||||
QList<QStringList> names = editor->project->groupedMapNames;
|
QList<QStringList> names = editor->project->groupedMapNames;
|
||||||
|
@ -181,15 +261,15 @@ void MainWindow::setMap(QString map_name, bool scrollTreeView) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (editor->map != nullptr && !editor->map->name.isNull()) {
|
if (editor->map != nullptr && !editor->map->name.isNull()) {
|
||||||
ui->mapList->setExpanded(mapListIndexes.value(editor->map->name), false);
|
ui->mapList->setExpanded(mapListProxyModel->mapFromSource(mapListIndexes.value(editor->map->name)), false);
|
||||||
}
|
}
|
||||||
ui->mapList->setExpanded(mapListIndexes.value(map_name), true);
|
ui->mapList->setExpanded(mapListProxyModel->mapFromSource(mapListIndexes.value(map_name)), true);
|
||||||
editor->setMap(map_name);
|
editor->setMap(map_name);
|
||||||
redrawMapScene();
|
redrawMapScene();
|
||||||
displayMapProperties();
|
displayMapProperties();
|
||||||
|
|
||||||
if (scrollTreeView) {
|
if (scrollTreeView) {
|
||||||
ui->mapList->setCurrentIndex(mapListIndexes.value(map_name));
|
ui->mapList->setCurrentIndex(mapListProxyModel->mapFromSource(mapListIndexes.value(map_name)));
|
||||||
ui->mapList->scrollTo(ui->mapList->currentIndex(), QAbstractItemView::PositionAtCenter);
|
ui->mapList->scrollTo(ui->mapList->currentIndex(), QAbstractItemView::PositionAtCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,6 +338,7 @@ void MainWindow::openWarpMap(QString map_name, QString warp_num) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open the destination map, and select the target warp event.
|
// Open the destination map, and select the target warp event.
|
||||||
|
mapListProxyModel->setFilterRegExp(QString::null);
|
||||||
setMap(map_name, true);
|
setMap(map_name, true);
|
||||||
QList<Event*> warp_events = editor->map->events["warp_event_group"];
|
QList<Event*> warp_events = editor->map->events["warp_event_group"];
|
||||||
if (warp_events.length() > warpNum) {
|
if (warp_events.length() > warpNum) {
|
||||||
|
@ -416,6 +497,11 @@ void MainWindow::loadDataStructures() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::populateMapList() {
|
void MainWindow::populateMapList() {
|
||||||
|
editor->project->readMapGroups();
|
||||||
|
sortMapList();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::sortMapList() {
|
||||||
Project *project = editor->project;
|
Project *project = editor->project;
|
||||||
|
|
||||||
QIcon mapFolderIcon;
|
QIcon mapFolderIcon;
|
||||||
|
@ -424,37 +510,93 @@ void MainWindow::populateMapList() {
|
||||||
|
|
||||||
QIcon folderIcon;
|
QIcon folderIcon;
|
||||||
folderIcon.addFile(QStringLiteral(":/icons/folder_closed.ico"), QSize(), QIcon::Normal, QIcon::Off);
|
folderIcon.addFile(QStringLiteral(":/icons/folder_closed.ico"), QSize(), QIcon::Normal, QIcon::Off);
|
||||||
folderIcon.addFile(QStringLiteral(":/icons/folder.ico"), QSize(), QIcon::Normal, QIcon::On);
|
//folderIcon.addFile(QStringLiteral(":/icons/folder.ico"), QSize(), QIcon::Normal, QIcon::On);
|
||||||
|
|
||||||
mapIcon = new QIcon;
|
ui->mapList->setUpdatesEnabled(false);
|
||||||
mapIcon->addFile(QStringLiteral(":/icons/map.ico"), QSize(), QIcon::Normal, QIcon::Off);
|
mapListModel->clear();
|
||||||
mapIcon->addFile(QStringLiteral(":/icons/map_opened.ico"), QSize(), QIcon::Normal, QIcon::On);
|
mapGroupItemsList->clear();
|
||||||
|
QStandardItem *root = mapListModel->invisibleRootItem();
|
||||||
|
|
||||||
mapEditedIcon = new QIcon;
|
switch (mapSortOrder)
|
||||||
mapEditedIcon->addFile(QStringLiteral(":/icons/map_edited.ico"), QSize(), QIcon::Normal, QIcon::Off);
|
{
|
||||||
mapEditedIcon->addFile(QStringLiteral(":/icons/map_opened.ico"), QSize(), QIcon::Normal , QIcon::On);
|
case MapSortOrder::Group:
|
||||||
|
for (int i = 0; i < project->groupNames->length(); i++) {
|
||||||
mapListModel = new QStandardItemModel;
|
QString group_name = project->groupNames->value(i);
|
||||||
mapGroupsModel = new QList<QStandardItem*>;
|
QStandardItem *group = new QStandardItem;
|
||||||
|
group->setText(group_name);
|
||||||
project->readMapGroups();
|
group->setIcon(mapFolderIcon);
|
||||||
for (int i = 0; i < project->groupNames->length(); i++) {
|
group->setEditable(false);
|
||||||
QString group_name = project->groupNames->value(i);
|
group->setData(group_name, Qt::UserRole);
|
||||||
QStandardItem *group = new QStandardItem;
|
group->setData("map_group", MapListUserRoles::TypeRole);
|
||||||
group->setText(group_name);
|
group->setData(i, MapListUserRoles::GroupRole);
|
||||||
group->setIcon(mapFolderIcon);
|
root->appendRow(group);
|
||||||
group->setEditable(false);
|
mapGroupItemsList->append(group);
|
||||||
group->setData(group_name, Qt::UserRole);
|
QStringList names = project->groupedMapNames.value(i);
|
||||||
group->setData("map_group", MapListUserRoles::TypeRole);
|
for (int j = 0; j < names.length(); j++) {
|
||||||
group->setData(i, MapListUserRoles::GroupRole);
|
QString map_name = names.value(j);
|
||||||
mapListModel->appendRow(group);
|
QStandardItem *map = createMapItem(map_name, i, j);
|
||||||
mapGroupsModel->append(group);
|
group->appendRow(map);
|
||||||
QStringList names = project->groupedMapNames.value(i);
|
mapListIndexes.insert(map_name, map->index());
|
||||||
for (int j = 0; j < names.length(); j++) {
|
}
|
||||||
QString map_name = names.value(j);
|
}
|
||||||
QStandardItem *map = createMapItem(map_name, i, j);
|
break;
|
||||||
group->appendRow(map);
|
case MapSortOrder::Name:
|
||||||
mapListIndexes.insert(map_name, map->index());
|
{
|
||||||
|
QMap<QString, int> mapsecToGroupNum;
|
||||||
|
for (int i = 0; i < project->regionMapSections->length(); i++) {
|
||||||
|
QString mapsec_name = project->regionMapSections->value(i);
|
||||||
|
QStandardItem *mapsec = new QStandardItem;
|
||||||
|
mapsec->setText(mapsec_name);
|
||||||
|
mapsec->setIcon(folderIcon);
|
||||||
|
mapsec->setEditable(false);
|
||||||
|
mapsec->setData(mapsec_name, Qt::UserRole);
|
||||||
|
mapsec->setData("map_sec", MapListUserRoles::TypeRole);
|
||||||
|
mapsec->setData(i, MapListUserRoles::GroupRole);
|
||||||
|
root->appendRow(mapsec);
|
||||||
|
mapGroupItemsList->append(mapsec);
|
||||||
|
mapsecToGroupNum.insert(mapsec_name, i);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < project->groupNames->length(); i++) {
|
||||||
|
QStringList names = project->groupedMapNames.value(i);
|
||||||
|
for (int j = 0; j < names.length(); j++) {
|
||||||
|
QString map_name = names.value(j);
|
||||||
|
QStandardItem *map = createMapItem(map_name, i, j);
|
||||||
|
QString location = project->readMapLocation(map_name);
|
||||||
|
QStandardItem *mapsecItem = mapGroupItemsList->at(mapsecToGroupNum[location]);
|
||||||
|
mapsecItem->setIcon(mapFolderIcon);
|
||||||
|
mapsecItem->appendRow(map);
|
||||||
|
mapListIndexes.insert(map_name, map->index());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MapSortOrder::Layout:
|
||||||
|
{
|
||||||
|
for (int i = 0; i < project->mapLayoutsTable.length(); i++) {
|
||||||
|
QString layoutName = project->mapLayoutsTable.value(i);
|
||||||
|
QStandardItem *layout = new QStandardItem;
|
||||||
|
layout->setText(layoutName);
|
||||||
|
layout->setIcon(folderIcon);
|
||||||
|
layout->setEditable(false);
|
||||||
|
layout->setData(layoutName, Qt::UserRole);
|
||||||
|
layout->setData("map_layout", MapListUserRoles::TypeRole);
|
||||||
|
layout->setData(i, MapListUserRoles::GroupRole);
|
||||||
|
root->appendRow(layout);
|
||||||
|
mapGroupItemsList->append(layout);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < project->groupNames->length(); i++) {
|
||||||
|
QStringList names = project->groupedMapNames.value(i);
|
||||||
|
for (int j = 0; j < names.length(); j++) {
|
||||||
|
QString map_name = names.value(j);
|
||||||
|
QStandardItem *map = createMapItem(map_name, i, j);
|
||||||
|
QString layoutId = project->readMapLayoutId(map_name);
|
||||||
|
QStandardItem *layoutItem = mapGroupItemsList->at(layoutId.toInt() - 1);
|
||||||
|
layoutItem->setIcon(mapFolderIcon);
|
||||||
|
layoutItem->appendRow(map);
|
||||||
|
mapListIndexes.insert(map_name, map->index());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,7 +605,6 @@ void MainWindow::populateMapList() {
|
||||||
connect(ui->mapList, SIGNAL(customContextMenuRequested(const QPoint &)),
|
connect(ui->mapList, SIGNAL(customContextMenuRequested(const QPoint &)),
|
||||||
this, SLOT(onOpenMapListContextMenu(const QPoint &)));
|
this, SLOT(onOpenMapListContextMenu(const QPoint &)));
|
||||||
|
|
||||||
ui->mapList->setModel(mapListModel);
|
|
||||||
ui->mapList->setUpdatesEnabled(true);
|
ui->mapList->setUpdatesEnabled(true);
|
||||||
ui->mapList->expandToDepth(0);
|
ui->mapList->expandToDepth(0);
|
||||||
ui->mapList->repaint();
|
ui->mapList->repaint();
|
||||||
|
@ -481,7 +622,7 @@ QStandardItem* MainWindow::createMapItem(QString mapName, int groupNum, int inGr
|
||||||
|
|
||||||
void MainWindow::onOpenMapListContextMenu(const QPoint &point)
|
void MainWindow::onOpenMapListContextMenu(const QPoint &point)
|
||||||
{
|
{
|
||||||
QModelIndex index = ui->mapList->indexAt(point);
|
QModelIndex index = mapListProxyModel->mapToSource(ui->mapList->indexAt(point));
|
||||||
if (!index.isValid()) {
|
if (!index.isValid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -507,7 +648,7 @@ void MainWindow::onOpenMapListContextMenu(const QPoint &point)
|
||||||
void MainWindow::onAddNewMapToGroupClick(QAction* triggeredAction)
|
void MainWindow::onAddNewMapToGroupClick(QAction* triggeredAction)
|
||||||
{
|
{
|
||||||
int groupNum = triggeredAction->data().toInt();
|
int groupNum = triggeredAction->data().toInt();
|
||||||
QStandardItem* groupItem = mapGroupsModel->at(groupNum);
|
QStandardItem* groupItem = mapGroupItemsList->at(groupNum);
|
||||||
|
|
||||||
QString newMapName = editor->project->getNewMapName();
|
QString newMapName = editor->project->getNewMapName();
|
||||||
Map* newMap = editor->project->addNewMapToGroup(newMapName, groupNum);
|
Map* newMap = editor->project->addNewMapToGroup(newMapName, groupNum);
|
||||||
|
|
|
@ -189,6 +189,36 @@ void Project::readMapHeader(Map* map) {
|
||||||
map->battle_scene = header->value(12);
|
map->battle_scene = header->value(12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Project::readMapLayoutId(QString map_name) {
|
||||||
|
if (map_cache->contains(map_name)) {
|
||||||
|
return map_cache->value(map_name)->layout_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
ParseUtil *parser = new ParseUtil;
|
||||||
|
|
||||||
|
QString header_text = readTextFile(root + "/data/maps/" + map_name + "/header.inc");
|
||||||
|
if (header_text.isNull()) {
|
||||||
|
return QString::null;
|
||||||
|
}
|
||||||
|
QStringList *header = getLabelValues(parser->parseAsm(header_text), map_name);
|
||||||
|
return header->value(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Project::readMapLocation(QString map_name) {
|
||||||
|
if (map_cache->contains(map_name)) {
|
||||||
|
return map_cache->value(map_name)->location;
|
||||||
|
}
|
||||||
|
|
||||||
|
ParseUtil *parser = new ParseUtil;
|
||||||
|
|
||||||
|
QString header_text = readTextFile(root + "/data/maps/" + map_name + "/header.inc");
|
||||||
|
if (header_text.isNull()) {
|
||||||
|
return QString::null;
|
||||||
|
}
|
||||||
|
QStringList *header = getLabelValues(parser->parseAsm(header_text), map_name);
|
||||||
|
return header->value(6);
|
||||||
|
}
|
||||||
|
|
||||||
void Project::setNewMapHeader(Map* map, int mapIndex) {
|
void Project::setNewMapHeader(Map* map, int mapIndex) {
|
||||||
map->layout_label = QString("%1_Layout").arg(map->name);
|
map->layout_label = QString("%1_Layout").arg(map->name);
|
||||||
map->events_label = QString("%1_MapEvents").arg(map->name);;
|
map->events_label = QString("%1_MapEvents").arg(map->name);;
|
||||||
|
|
Loading…
Reference in a new issue