mirror of
https://github.com/huderlem/porymap.git
synced 2026-09-08 08:55:37 -05:00
Port changes from Custom Attributes redesign
This commit is contained in:
@@ -160,10 +160,10 @@ public:
|
||||
virtual void setDefaultValues(Project *project);
|
||||
|
||||
virtual QSet<QString> getExpectedFields() = 0;
|
||||
void readCustomValues(QJsonObject values);
|
||||
void addCustomValuesTo(OrderedJson::object *obj);
|
||||
const QMap<QString, QJsonValue> getCustomValues() { return this->customValues; }
|
||||
void setCustomValues(const QMap<QString, QJsonValue> newCustomValues) { this->customValues = newCustomValues; }
|
||||
void readCustomAttributes(const QJsonObject &json);
|
||||
void addCustomAttributesTo(OrderedJson::object *obj) const;
|
||||
const QMap<QString, QJsonValue> getCustomAttributes() const { return this->customAttributes; }
|
||||
void setCustomAttributes(const QMap<QString, QJsonValue> newCustomAttributes) { this->customAttributes = newCustomAttributes; }
|
||||
|
||||
virtual void loadPixmap(Project *project);
|
||||
|
||||
@@ -206,7 +206,7 @@ protected:
|
||||
int spriteHeight = 16;
|
||||
bool usingSprite = false;
|
||||
|
||||
QMap<QString, QJsonValue> customValues;
|
||||
QMap<QString, QJsonValue> customAttributes;
|
||||
|
||||
QPixmap pixmap;
|
||||
DraggablePixmapItem *pixmapItem = nullptr;
|
||||
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
void updatePrimaryTileset(QString tilesetLabel, bool forceLoad = false);
|
||||
void updateSecondaryTileset(QString tilesetLabel, bool forceLoad = false);
|
||||
void toggleBorderVisibility(bool visible, bool enableScriptCallback = true);
|
||||
void updateCustomMapHeaderValues(QTableWidget *);
|
||||
void updateCustomMapAttributes();
|
||||
|
||||
DraggablePixmapItem *addMapEvent(Event *event);
|
||||
bool eventLimitReached(Map *, Event::Type);
|
||||
|
||||
@@ -274,9 +274,6 @@ private slots:
|
||||
void on_actionAbout_Porymap_triggered();
|
||||
void on_actionOpen_Log_File_triggered();
|
||||
void on_actionOpen_Config_Folder_triggered();
|
||||
void on_pushButton_AddCustomHeaderField_clicked();
|
||||
void on_pushButton_DeleteCustomHeaderField_clicked();
|
||||
void on_tableWidget_CustomHeaderFields_cellChanged(int row, int column);
|
||||
void on_horizontalSlider_MetatileZoom_valueChanged(int value);
|
||||
void on_horizontalSlider_CollisionZoom_valueChanged(int value);
|
||||
void on_pushButton_NewWildMonGroup_clicked();
|
||||
@@ -406,7 +403,7 @@ private:
|
||||
Event::Group getEventGroupFromTabWidget(QWidget *tab);
|
||||
bool closeSupplementaryWindows();
|
||||
void setWindowDisabled(bool);
|
||||
|
||||
void resetMapCustomAttributesTable();
|
||||
void initTilesetEditor();
|
||||
bool initRegionMapEditor(bool silent = false);
|
||||
bool askToFixRegionMapEditor();
|
||||
|
||||
34
include/ui/customattributesdialog.h
Normal file
34
include/ui/customattributesdialog.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef CUSTOMATTRIBUTESDIALOG_H
|
||||
#define CUSTOMATTRIBUTESDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QAbstractButton>
|
||||
|
||||
#include "customattributestable.h"
|
||||
|
||||
namespace Ui {
|
||||
class CustomAttributesDialog;
|
||||
}
|
||||
|
||||
class CustomAttributesDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CustomAttributesDialog(CustomAttributesTable *table);
|
||||
~CustomAttributesDialog();
|
||||
|
||||
private:
|
||||
Ui::CustomAttributesDialog *ui;
|
||||
CustomAttributesTable *const m_table;
|
||||
|
||||
void setInputType(int inputType);
|
||||
void onNameChanged(const QString &);
|
||||
bool validateName(bool allowEmpty = false);
|
||||
void clickedButton(QAbstractButton *button);
|
||||
void addNewAttribute();
|
||||
QVariant getValue() const;
|
||||
};
|
||||
|
||||
|
||||
#endif // CUSTOMATTRIBUTESDIALOG_H
|
||||
36
include/ui/customattributesframe.h
Normal file
36
include/ui/customattributesframe.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef CUSTOMATTRIBUTESFRAME_H
|
||||
#define CUSTOMATTRIBUTESFRAME_H
|
||||
|
||||
/*
|
||||
The frame containing the Custom Attributes table and its Add/Delete buttons.
|
||||
Shared by the map's Header tab and Events.
|
||||
*/
|
||||
|
||||
#include "customattributestable.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QFrame>
|
||||
|
||||
namespace Ui {
|
||||
class CustomAttributesFrame;
|
||||
}
|
||||
|
||||
class CustomAttributesFrame : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CustomAttributesFrame(QWidget *parent = nullptr);
|
||||
~CustomAttributesFrame();
|
||||
|
||||
CustomAttributesTable* table() const;
|
||||
|
||||
private:
|
||||
Ui::CustomAttributesFrame *ui;
|
||||
|
||||
void addAttribute();
|
||||
void deleteAttribute();
|
||||
void updateDeleteButton();
|
||||
};
|
||||
|
||||
#endif // CUSTOMATTRIBUTESFRAME_H
|
||||
@@ -1,25 +1,44 @@
|
||||
#ifndef CUSTOMATTRIBUTESTABLE_H
|
||||
#define CUSTOMATTRIBUTESTABLE_H
|
||||
|
||||
#include "events.h"
|
||||
#include <QObject>
|
||||
#include <QFrame>
|
||||
#include <QJsonValue>
|
||||
#include <QTableWidget>
|
||||
|
||||
class CustomAttributesTable : public QFrame
|
||||
class CustomAttributesTable : public QTableWidget
|
||||
{
|
||||
public:
|
||||
explicit CustomAttributesTable(Event *event, QWidget *parent = nullptr);
|
||||
~CustomAttributesTable();
|
||||
Q_OBJECT
|
||||
|
||||
static const QMap<QString, QJsonValue> getAttributes(QTableWidget * table);
|
||||
static QJsonValue pickType(QWidget * parent, bool * ok = nullptr);
|
||||
static void addAttribute(QTableWidget * table, QString key, QJsonValue value, bool isNew = false);
|
||||
static bool deleteSelectedAttributes(QTableWidget * table);
|
||||
public:
|
||||
explicit CustomAttributesTable(QWidget *parent = nullptr);
|
||||
~CustomAttributesTable() {};
|
||||
|
||||
QMap<QString, QJsonValue> getAttributes() const;
|
||||
void setAttributes(const QMap<QString, QJsonValue> &attributes);
|
||||
|
||||
void addNewAttribute(const QString &key, const QJsonValue &value);
|
||||
bool deleteSelectedAttributes();
|
||||
|
||||
bool isEmpty() const;
|
||||
bool isSelectionEmpty() const;
|
||||
|
||||
QSet<QString> keys() const { return m_keys; }
|
||||
QSet<QString> restrictedKeys() const { return m_restrictedKeys; }
|
||||
void setRestrictedKeys(const QSet<QString> &keys) { m_restrictedKeys = keys; }
|
||||
|
||||
signals:
|
||||
void edited();
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent *event) override;
|
||||
|
||||
private:
|
||||
Event *event;
|
||||
QTableWidget *table;
|
||||
QSet<QString> m_keys; // All keys currently in the table
|
||||
QSet<QString> m_restrictedKeys; // All keys not allowed in the table
|
||||
|
||||
QPair<QString, QJsonValue> getAttribute(int row) const;
|
||||
int addAttribute(const QString &key, const QJsonValue &value);
|
||||
void removeAttribute(const QString &key);
|
||||
void resizeVertically();
|
||||
};
|
||||
|
||||
|
||||
@@ -52,6 +52,8 @@ public:
|
||||
QFrame *frame_contents;
|
||||
QVBoxLayout *layout_contents;
|
||||
|
||||
CustomAttributesFrame *custom_attributes;
|
||||
|
||||
protected:
|
||||
bool populated = false;
|
||||
bool initialized = false;
|
||||
|
||||
Reference in New Issue
Block a user