mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-25 18:16:57 -05:00
Begin new layout dialog redesign
This commit is contained in:
@@ -14,6 +14,8 @@ class LayoutPixmapItem;
|
||||
class CollisionPixmapItem;
|
||||
class BorderMetatilesPixmapItem;
|
||||
|
||||
// TODO: Privatize members as appropriate
|
||||
|
||||
class Layout : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -70,14 +72,16 @@ public:
|
||||
QUndoStack editHistory;
|
||||
|
||||
// to simplify new layout settings transfer between functions
|
||||
struct SimpleSettings {
|
||||
// TODO: Make this the equivalent of struct MapHeader
|
||||
struct Settings {
|
||||
QString id;
|
||||
QString name;
|
||||
int width;
|
||||
int height;
|
||||
QString tileset_primary_label;
|
||||
QString tileset_secondary_label;
|
||||
QString from_id = QString();
|
||||
int borderWidth;
|
||||
int borderHeight;
|
||||
QString primaryTilesetLabel;
|
||||
QString secondaryTilesetLabel;
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "filterchildrenproxymodel.h"
|
||||
#include "maplistmodels.h"
|
||||
#include "newmapdialog.h"
|
||||
#include "newlayoutdialog.h"
|
||||
#include "newtilesetdialog.h"
|
||||
#include "shortcutseditor.h"
|
||||
#include "preferenceeditor.h"
|
||||
@@ -188,6 +189,7 @@ private slots:
|
||||
void onOpenConnectedMap(MapConnection*);
|
||||
void onTilesetsSaved(QString, QString);
|
||||
void openNewMapDialog();
|
||||
void openNewLayoutDialog();
|
||||
void onNewMapCreated(Map *newMap, const QString &groupName);
|
||||
void onNewMapGroupCreated(const QString &groupName);
|
||||
void onNewLayoutCreated(Layout *layout);
|
||||
@@ -306,6 +308,7 @@ private:
|
||||
QPointer<ShortcutsEditor> shortcutsEditor = nullptr;
|
||||
QPointer<MapImageExporter> mapImageExporter = nullptr;
|
||||
QPointer<NewMapDialog> newMapDialog = nullptr;
|
||||
QPointer<NewLayoutDialog> newLayoutDialog = nullptr;
|
||||
QPointer<PreferenceEditor> preferenceEditor = nullptr;
|
||||
QPointer<ProjectSettingsEditor> projectSettingsEditor = nullptr;
|
||||
QPointer<GridSettingsDialog> gridSettingsDialog = nullptr;
|
||||
@@ -334,7 +337,6 @@ private:
|
||||
QMap<Event::Group, DraggablePixmapItem*> lastSelectedEvent;
|
||||
|
||||
bool isProgrammaticEventTabChange;
|
||||
bool newMapDefaultsSet = false;
|
||||
|
||||
bool tilesetNeedsRedraw = false;
|
||||
|
||||
|
||||
@@ -81,6 +81,16 @@ public:
|
||||
bool wildEncountersLoaded;
|
||||
bool saveEmptyMapsec;
|
||||
|
||||
struct NewMapSettings {
|
||||
QString mapName;
|
||||
QString mapId;
|
||||
QString group;
|
||||
bool canFlyTo;
|
||||
Layout::Settings layout;
|
||||
MapHeader header;
|
||||
};
|
||||
NewMapSettings newMapSettings;
|
||||
|
||||
void set_root(QString);
|
||||
|
||||
void clearMapCache();
|
||||
@@ -124,6 +134,8 @@ public:
|
||||
void addNewMapGroup(const QString &groupName);
|
||||
void addNewLayout(Layout* newLayout);
|
||||
QString getNewMapName();
|
||||
QString getNewLayoutName();
|
||||
bool isLayoutNameUnique(const QString &name);
|
||||
QString getProjectTitle();
|
||||
|
||||
bool readWildMonData();
|
||||
@@ -147,7 +159,7 @@ public:
|
||||
bool loadMapData(Map*);
|
||||
bool readMapLayouts();
|
||||
Layout *loadLayout(QString layoutId);
|
||||
Layout *createNewLayout(Layout::SimpleSettings &layoutSettings);
|
||||
Layout *createNewLayout(const Layout::Settings &layoutSettings);
|
||||
bool loadLayout(Layout *);
|
||||
bool loadMapLayout(Map*);
|
||||
bool loadLayoutTilesets(Layout *);
|
||||
@@ -222,6 +234,8 @@ public:
|
||||
|
||||
static QString getExistingFilepath(QString filepath);
|
||||
void applyParsedLimits();
|
||||
void initNewMapSettings();
|
||||
void initNewLayoutSettings();
|
||||
|
||||
static QString getDynamicMapDefineName();
|
||||
static QString getDynamicMapName();
|
||||
|
||||
51
include/ui/newlayoutdialog.h
Normal file
51
include/ui/newlayoutdialog.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef NEWLAYOUTDIALOG_H
|
||||
#define NEWLAYOUTDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QString>
|
||||
#include "editor.h"
|
||||
#include "project.h"
|
||||
#include "map.h"
|
||||
#include "mapheaderform.h"
|
||||
#include "newlayoutform.h"
|
||||
#include "lib/collapsiblesection.h"
|
||||
|
||||
namespace Ui {
|
||||
class NewLayoutDialog;
|
||||
}
|
||||
|
||||
class NewLayoutDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit NewLayoutDialog(QWidget *parent = nullptr, Project *project = nullptr);
|
||||
~NewLayoutDialog();
|
||||
void init(Layout *);
|
||||
void accept() override;
|
||||
|
||||
signals:
|
||||
void applied(const QString &newLayoutId);
|
||||
|
||||
private:
|
||||
Ui::NewLayoutDialog *ui;
|
||||
Project *project;
|
||||
Layout *importedLayout = nullptr;
|
||||
Layout::Settings *settings = nullptr;
|
||||
|
||||
// Each of these validation functions will allow empty names up until `OK` is selected,
|
||||
// because clearing the text during editing is common and we don't want to flash errors for this.
|
||||
bool validateLayoutID(bool allowEmpty = false);
|
||||
bool validateName(bool allowEmpty = false);
|
||||
|
||||
void saveSettings();
|
||||
bool isExistingLayout() const;
|
||||
void useLayoutSettings(Layout *mapLayout);
|
||||
|
||||
private slots:
|
||||
//void on_comboBox_Layout_currentTextChanged(const QString &text);//TODO
|
||||
void dialogButtonClicked(QAbstractButton *button);
|
||||
void on_lineEdit_Name_textChanged(const QString &);
|
||||
void on_lineEdit_LayoutID_textChanged(const QString &);
|
||||
};
|
||||
|
||||
#endif // NEWLAYOUTDIALOG_H
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "maplayout.h"
|
||||
|
||||
class Project;
|
||||
|
||||
namespace Ui {
|
||||
@@ -19,18 +21,8 @@ public:
|
||||
|
||||
void initUi(Project *project);
|
||||
|
||||
struct Settings {
|
||||
QString id; // TODO: Support in UI (toggleable line edit)
|
||||
int width;
|
||||
int height;
|
||||
int borderWidth;
|
||||
int borderHeight;
|
||||
QString primaryTilesetLabel;
|
||||
QString secondaryTilesetLabel;
|
||||
};
|
||||
|
||||
void setSettings(const Settings &settings);
|
||||
NewLayoutForm::Settings settings() const;
|
||||
void setSettings(const Layout::Settings &settings);
|
||||
Layout::Settings settings() const;
|
||||
|
||||
void setDisabled(bool disabled);
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ public:
|
||||
void init(int tabIndex, QString data);
|
||||
void init(Layout *);
|
||||
void accept() override;
|
||||
static void setDefaultSettings(const Project *project);
|
||||
|
||||
signals:
|
||||
void applied(const QString &newMapName);
|
||||
@@ -35,27 +34,20 @@ private:
|
||||
CollapsibleSection *headerSection;
|
||||
MapHeaderForm *headerForm;
|
||||
Layout *importedLayout = nullptr;
|
||||
Project::NewMapSettings *settings = nullptr;
|
||||
|
||||
// Each of these validation functions will allow empty names up until `OK` is selected,
|
||||
// because clearing the text during editing is common and we don't want to flash errors for this.
|
||||
bool validateID(bool allowEmpty = false);
|
||||
bool validateMapID(bool allowEmpty = false);
|
||||
bool validateName(bool allowEmpty = false);
|
||||
bool validateGroup(bool allowEmpty = false);
|
||||
|
||||
void saveSettings();
|
||||
bool isExistingLayout() const;
|
||||
void useLayoutSettings(Layout *mapLayout);
|
||||
|
||||
struct Settings {
|
||||
QString group;
|
||||
bool canFlyTo;
|
||||
NewLayoutForm::Settings layout;
|
||||
MapHeader header;
|
||||
};
|
||||
static struct Settings settings;
|
||||
void useLayoutSettings(const Layout *mapLayout);
|
||||
void useLayoutIdSettings(const QString &layoutId);
|
||||
|
||||
private slots:
|
||||
//void on_comboBox_Layout_currentTextChanged(const QString &text);//TODO
|
||||
void dialogButtonClicked(QAbstractButton *button);
|
||||
void on_lineEdit_Name_textChanged(const QString &);
|
||||
void on_lineEdit_MapID_textChanged(const QString &);
|
||||
|
||||
Reference in New Issue
Block a user