mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-22 16:46:45 -05:00
Only load event sprites when requested
This commit is contained in:
@@ -41,14 +41,6 @@ public:
|
||||
virtual void visitSign(SignEvent *) = 0;
|
||||
};
|
||||
|
||||
struct EventGraphics
|
||||
{
|
||||
QImage spritesheet;
|
||||
int spriteWidth;
|
||||
int spriteHeight;
|
||||
bool inanimate;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// Event base class -- purely virtual
|
||||
@@ -64,11 +56,7 @@ public:
|
||||
Event& operator=(const Event &other) = delete;
|
||||
|
||||
protected:
|
||||
Event() {
|
||||
this->spriteWidth = 16;
|
||||
this->spriteHeight = 16;
|
||||
this->usingSprite = false;
|
||||
}
|
||||
Event() {}
|
||||
|
||||
// public enums & static methods
|
||||
public:
|
||||
@@ -143,8 +131,8 @@ public:
|
||||
int getZ() const { return this->elevation; }
|
||||
int getElevation() const { return this->elevation; }
|
||||
|
||||
int getPixelX() const { return (this->x * 16) - qMax(0, (this->spriteWidth - 16) / 2); }
|
||||
int getPixelY() const { return (this->y * 16) - qMax(0, this->spriteHeight - 16); }
|
||||
int getPixelX() const { return (this->x * 16) - qMax(0, (pixmap.width() - 16) / 2); }
|
||||
int getPixelY() const { return (this->y * 16) - qMax(0, pixmap.height() - 16); }
|
||||
|
||||
virtual EventFrame *getEventFrame();
|
||||
virtual EventFrame *createEventFrame() = 0;
|
||||
@@ -172,14 +160,8 @@ public:
|
||||
void setPixmapItem(DraggablePixmapItem *item);
|
||||
DraggablePixmapItem *getPixmapItem() const { return this->pixmapItem; }
|
||||
|
||||
void setUsingSprite(bool newUsingSprite) { this->usingSprite = newUsingSprite; }
|
||||
bool getUsingSprite() const { return this->usingSprite; }
|
||||
|
||||
void setSpriteWidth(int newSpriteWidth) { this->spriteWidth = newSpriteWidth; }
|
||||
int getspriteWidth() const { return this->spriteWidth; }
|
||||
|
||||
void setSpriteHeight(int newSpriteHeight) { this->spriteHeight = newSpriteHeight; }
|
||||
int getspriteHeight() const { return this->spriteHeight; }
|
||||
void setUsesDefaultPixmap(bool newUsesDefaultPixmap) { this->usesDefaultPixmap = newUsesDefaultPixmap; }
|
||||
bool getUsesDefaultPixmap() const { return this->usesDefaultPixmap; }
|
||||
|
||||
int getEventIndex();
|
||||
|
||||
@@ -204,9 +186,7 @@ protected:
|
||||
int y = 0;
|
||||
int elevation = 0;
|
||||
|
||||
int spriteWidth = 16;
|
||||
int spriteHeight = 16;
|
||||
bool usingSprite = false;
|
||||
bool usesDefaultPixmap = true;
|
||||
|
||||
// Some events can have an associated #define name that should be unique to this event.
|
||||
// e.g. object events can have a 'LOCALID', or Heal Locations have a 'HEAL_LOCATION' id.
|
||||
@@ -273,10 +253,6 @@ public:
|
||||
void setFlag(QString newFlag) { this->flag = newFlag; }
|
||||
QString getFlag() const { return this->flag; }
|
||||
|
||||
public:
|
||||
void setFrameFromMovement(QString movement);
|
||||
void setPixmapFromSpritesheet(EventGraphics * gfx);
|
||||
|
||||
|
||||
protected:
|
||||
QString gfx;
|
||||
|
||||
@@ -45,7 +45,6 @@ public:
|
||||
QStringList layoutIdsMaster;
|
||||
QMap<QString, Layout*> mapLayouts;
|
||||
QMap<QString, Layout*> mapLayoutsMaster;
|
||||
QMap<QString, EventGraphics*> eventGraphicsMap;
|
||||
QMap<QString, int> gfxDefines;
|
||||
QString defaultSong;
|
||||
QStringList songNames;
|
||||
@@ -68,7 +67,6 @@ public:
|
||||
QMap<QString, uint16_t> unusedMetatileLabels;
|
||||
QMap<QString, uint32_t> metatileBehaviorMap;
|
||||
QMap<uint32_t, QString> metatileBehaviorMapInverse;
|
||||
QMap<QString, QString> facingDirections;
|
||||
ParseUtil parser;
|
||||
QFileSystemWatcher fileWatcher;
|
||||
QSet<QString> modifiedFiles;
|
||||
@@ -210,7 +208,10 @@ public:
|
||||
bool readFieldmapMasks();
|
||||
QMap<QString, QMap<QString, QString>> readObjEventGfxInfo();
|
||||
|
||||
void setEventPixmap(Event *event, bool forceLoad = false);
|
||||
QPixmap getEventPixmap(const QString &gfxName, const QString &movementName);
|
||||
QPixmap getEventPixmap(const QString &gfxName, int frame, bool hFlip);
|
||||
QPixmap getEventPixmap(Event::Group group);
|
||||
void loadEventPixmap(Event *event, bool forceLoad = false);
|
||||
|
||||
QString fixPalettePath(QString path);
|
||||
QString fixGraphicPath(QString path);
|
||||
@@ -254,6 +255,18 @@ public:
|
||||
private:
|
||||
QMap<QString, QString> mapSectionDisplayNames;
|
||||
QMap<QString, qint64> modifiedFileTimestamps;
|
||||
QMap<QString, QString> facingDirections;
|
||||
|
||||
struct EventGraphics
|
||||
{
|
||||
QString filepath;
|
||||
bool loaded = false;
|
||||
QImage spritesheet;
|
||||
int spriteWidth = -1;
|
||||
int spriteHeight = -1;
|
||||
bool inanimate = false;
|
||||
};
|
||||
QMap<QString, EventGraphics*> eventGraphicsMap;
|
||||
|
||||
void updateLayout(Layout *);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user