Support custom event icons

This commit is contained in:
GriffinR
2023-12-05 02:01:44 -05:00
parent b88d62ecc1
commit 1b9b980121
10 changed files with 103 additions and 37 deletions

View File

@@ -9,6 +9,8 @@
#include <QKeySequence>
#include <QMultiMap>
#include "events.h"
// In both versions the default new map border is a generic tree
#define DEFAULT_BORDER_RSE (QList<uint16_t>{0x1D4, 0x1D5, 0x1DC, 0x1DD})
#define DEFAULT_BORDER_FRLG (QList<uint16_t>{0x14, 0x15, 0x1C, 0x1D})
@@ -295,6 +297,11 @@ public:
void setMetatileLayerTypeMask(uint32_t mask);
bool getMapAllowFlagsEnabled();
void setMapAllowFlagsEnabled(bool enabled);
void setEventIconPath(Event::Group group, const QString &path);
QString getEventIconPath(Event::Group group);
void setCollisionMapPath(const QString &path);
QString getCollisionMapPath();
protected:
virtual QString getConfigFilepath() override;
virtual void parseConfigKeyValue(QString key, QString value) override;
@@ -332,6 +339,8 @@ private:
uint32_t metatileEncounterTypeMask;
uint32_t metatileLayerTypeMask;
bool enableMapAllowFlags;
QMap<Event::Group, QString> eventIconPaths;
QString collisionMapPath;
};
extern ProjectConfig projectConfig;

View File

@@ -111,6 +111,7 @@ public:
}
}
static QMap<Event::Group, const QPixmap*> icons;
// standard public methods
public:
@@ -155,7 +156,7 @@ public:
const QMap<QString, QJsonValue> getCustomValues() { return this->customValues; }
void setCustomValues(const QMap<QString, QJsonValue> newCustomValues) { this->customValues = newCustomValues; }
virtual void loadPixmap(Project *project) = 0;
virtual void loadPixmap(Project *project);
void setPixmap(QPixmap newPixmap) { this->pixmap = newPixmap; }
QPixmap getPixmap() { return this->pixmap; }
@@ -177,6 +178,7 @@ public:
static QString eventGroupToString(Event::Group group);
static QString eventTypeToString(Event::Type type);
static Event::Type eventTypeFromString(QString type);
static void initIcons();
// protected attributes
protected:
@@ -258,6 +260,8 @@ public:
void setFrameFromMovement(QString movement);
void setPixmapFromSpritesheet(QImage, int, int, bool);
static const QPixmap * defaultIcon;
protected:
QString gfx;
@@ -337,14 +341,14 @@ public:
virtual QSet<QString> getExpectedFields() override;
virtual void loadPixmap(Project *) override;
void setDestinationMap(QString newDestinationMap) { this->destinationMap = newDestinationMap; }
QString getDestinationMap() { return this->destinationMap; }
void setDestinationWarpID(QString newDestinationWarpID) { this->destinationWarpID = newDestinationWarpID; }
QString getDestinationWarpID() { return this->destinationWarpID; }
static const QPixmap * defaultIcon;
private:
QString destinationMap;
QString destinationWarpID;
@@ -372,7 +376,7 @@ public:
virtual QSet<QString> getExpectedFields() override = 0;
virtual void loadPixmap(Project *) override;
static const QPixmap * defaultIcon;
};
@@ -473,7 +477,7 @@ public:
virtual QSet<QString> getExpectedFields() override = 0;
virtual void loadPixmap(Project *project) override;
static const QPixmap * defaultIcon;
};
@@ -614,8 +618,6 @@ public:
virtual QSet<QString> getExpectedFields() override { return QSet<QString>(); }
virtual void loadPixmap(Project *project) override;
void setIndex(int newIndex) { this->index = newIndex; }
int getIndex() { return this->index; }
@@ -631,6 +633,8 @@ public:
void setRespawnNPC(uint8_t newRespawnNPC) { this->respawnNPC = newRespawnNPC; }
uint8_t getRespawnNPC() { return this->respawnNPC; }
static const QPixmap * defaultIcon;
private:
int index = -1;
QString locationName;

View File

@@ -86,8 +86,6 @@ public:
bool usingAsmTilesets;
QString importExportPath;
const QPixmap entitiesPixmap = QPixmap(":/images/Entities_16x16.png");
void set_root(QString);
void initSignals();

View File

@@ -6,7 +6,9 @@
class MovementPermissionsSelector: public SelectablePixmapItem {
Q_OBJECT
public:
MovementPermissionsSelector(): SelectablePixmapItem(32, 32, 1, 1) {
MovementPermissionsSelector(QPixmap basePixmap) :
SelectablePixmapItem(32, 32, 1, 1),
basePixmap(basePixmap) {
setAcceptHoverEvents(true);
}
void draw();
@@ -20,6 +22,7 @@ protected:
private:
void setSelectedMovementPermissions(QPointF);
const QPixmap basePixmap;
signals:
void hoveredMovementPermissionChanged(uint16_t, uint16_t);