Remember window sizes, add new map popup window (#54)

* save window state on app close

* new map popup window

* window title, groupItem fix

* fix new map heal location generation

* fix newmappopup form size

* empty map name check, increase max dimensions

* tool tips

* delete new window

* fix mainwindow.ui new map action

* use new config for window state

* clean window restore config settings

* extend "Add New Map" to different MapSortOrders

* fix crash when creating new map from unloaded layout

* fix new map from layout extra files
This commit is contained in:
garak
2019-01-07 18:14:44 -05:00
committed by huderlem
parent aa0709243d
commit d13a4da50a
14 changed files with 736 additions and 31 deletions

View File

@@ -3,6 +3,7 @@
#include <QString>
#include <QObject>
#include <QByteArrayList>
enum MapSortOrder {
Group = 0,
@@ -37,11 +38,13 @@ public:
void setRecentMap(QString map);
void setMapSortOrder(MapSortOrder order);
void setPrettyCursors(bool enabled);
void setGeometry(QByteArray, QByteArray, QByteArray, QByteArray, QByteArray);
void setCollisionOpacity(int opacity);
QString getRecentProject();
QString getRecentMap();
MapSortOrder getMapSortOrder();
bool getPrettyCursors();
QMap<QString, QByteArray> getGeometry();
int getCollisionOpacity();
protected:
QString getConfigFilepath();
@@ -51,8 +54,15 @@ protected:
private:
QString recentProject;
QString recentMap;
QString stringFromByteArray(QByteArray);
QByteArray bytesFromString(QString);
MapSortOrder mapSortOrder;
bool prettyCursors;
QByteArray windowGeometry;
QByteArray windowState;
QByteArray mapSplitterState;
QByteArray eventsSlpitterState;
QByteArray mainSplitterState;
int collisionOpacity;
};

View File

@@ -32,7 +32,7 @@ public:
QString layout_id;
QString location;
QString requiresFlash;
QString isFlyable; // TODO: implement this
QString isFlyable;
QString weather;
QString type;
QString unknown;
@@ -43,6 +43,7 @@ public:
QString battle_scene;
MapLayout *layout;
bool isPersistedToFile = true;
bool needsLayoutDir = true;
QImage collision_image;
QPixmap collision_pixmap;
QImage image;

View File

@@ -16,6 +16,7 @@
#include "editor.h"
#include "tileseteditor.h"
#include "filterchildrenproxymodel.h"
#include "newmappopup.h"
namespace Ui {
class MainWindow;
@@ -47,7 +48,10 @@ private slots:
void onMapChanged(Map *map);
void onMapNeedsRedrawing();
void onTilesetsSaved(QString, QString);
void openNewMapPopupWindow(int, QVariant);
void onNewMapCreated();
void on_action_NewMap_triggered();
void on_action_Save_triggered();
void on_tabWidget_2_currentChanged(int index);
void on_action_Exit_triggered();
@@ -98,6 +102,8 @@ private slots:
void onOpenMapListContextMenu(const QPoint &point);
void onAddNewMapToGroupClick(QAction* triggeredAction);
void onAddNewMapToAreaClick(QAction* triggeredAction);
void onAddNewMapToLayoutClick(QAction* triggeredAction);
void onTilesetChanged(QString);
void currentMetatilesSelectionChanged();
@@ -149,6 +155,7 @@ private:
Ui::MainWindow *ui;
TilesetEditor *tilesetEditor = nullptr;
FilterChildrenProxyModel *mapListProxyModel;
NewMapPopup *newmapprompt = nullptr;
QStandardItemModel *mapListModel;
QList<QStandardItem*> *mapGroupItemsList;
QMap<QString, QModelIndex> mapListIndexes;
@@ -200,6 +207,7 @@ private:
void initMapSortOrder();
void setProjectSpecificUIVisibility();
void loadUserSettings();
void restoreWindowState();
bool openRecentProject();
void updateTilesetEditor();
QString getEventGroupFromTabWidget(QWidget *tab);

View File

@@ -61,6 +61,7 @@ public:
void readMapGroups();
Map* addNewMapToGroup(QString mapName, int groupNum);
Map* addNewMapToGroup(QString, int, Map*, bool);
QString getNewMapName();
QString getProjectTitle();

40
include/ui/newmappopup.h Normal file
View File

@@ -0,0 +1,40 @@
#ifndef NEWMAPPOPUP_H
#define NEWMAPPOPUP_H
#include <QMainWindow>
#include <QString>
#include "editor.h"
#include "project.h"
#include "map.h"
namespace Ui {
class NewMapPopup;
}
class NewMapPopup : public QMainWindow
{
Q_OBJECT
public:
explicit NewMapPopup(QWidget *parent = nullptr, Project *project = nullptr);
~NewMapPopup();
Map *map;
int group;
bool changeLayout;
QString layoutName;
void init(int, int, QString, QString);
void useLayout(QString);
signals:
void applied();
private:
Ui::NewMapPopup *ui;
Project *project;
void setDefaultValues(int, QString);
private slots:
void on_pushButton_NewMap_Accept_clicked();
void on_lineEdit_NewMap_Name_textChanged(const QString &);
};
#endif // NEWMAPPOPUP_H