porymap/event.h

88 lines
2.1 KiB
C
Raw Normal View History

2016-09-07 04:50:47 +01:00
#ifndef EVENT_H
#define EVENT_H
2018-09-12 01:37:36 +01:00
#include "heallocation.h"
2016-09-07 04:50:47 +01:00
#include <QString>
#include <QPixmap>
2017-11-28 04:46:27 +00:00
#include <QMap>
2018-07-07 16:58:25 +01:00
#include <QDebug>
2016-09-07 04:50:47 +01:00
2018-07-06 17:08:20 +01:00
class EventType
{
public:
static QString Object;
static QString Warp;
static QString CoordScript;
static QString CoordWeather;
static QString Sign;
static QString HiddenItem;
static QString SecretBase;
2018-09-12 01:37:36 +01:00
static QString HealLocation;
2018-07-06 17:08:20 +01:00
};
2016-09-07 04:50:47 +01:00
class Event
{
public:
Event();
public:
int x() {
2017-11-28 04:46:27 +00:00
return getInt("x");
2016-09-07 04:50:47 +01:00
}
int y() {
2017-11-28 04:46:27 +00:00
return getInt("y");
2016-09-07 04:50:47 +01:00
}
int elevation() {
2017-11-28 04:46:27 +00:00
return getInt("elevation");
2016-09-07 04:50:47 +01:00
}
void setX(int x) {
2017-11-28 04:46:27 +00:00
put("x", x);
2016-09-07 04:50:47 +01:00
}
void setY(int y) {
2017-11-28 04:46:27 +00:00
put("y", y);
2016-09-07 04:50:47 +01:00
}
2017-11-28 04:46:27 +00:00
QString get(QString key) {
return values.value(key);
}
int getInt(QString key) {
return values.value(key).toInt(nullptr, 0);
}
2018-09-15 00:37:36 +01:00
uint16_t getU16(QString key) {
return values.value(key).toUShort(nullptr, 0);
}
2017-11-28 04:46:27 +00:00
void put(QString key, int value) {
put(key, QString("%1").arg(value));
}
void put(QString key, QString value) {
values.insert(key, value);
2016-09-07 04:50:47 +01:00
}
2018-07-07 16:58:25 +01:00
static Event* createNewEvent(QString, QString);
static Event* createNewObjectEvent();
static Event* createNewWarpEvent(QString);
2018-09-12 01:37:36 +01:00
static Event* createNewHealLocationEvent(QString);
2018-07-07 16:58:25 +01:00
static Event* createNewCoordScriptEvent();
static Event* createNewCoordWeatherEvent();
static Event* createNewSignEvent();
static Event* createNewHiddenItemEvent();
static Event* createNewSecretBaseEvent();
QString buildObjectEventMacro(int);
QString buildWarpEventMacro(QMap<QString, QString>*);
2018-09-12 01:37:36 +01:00
HealLocation buildHealLocation();
2018-07-07 16:58:25 +01:00
QString buildCoordScriptEventMacro();
QString buildCoordWeatherEventMacro();
QString buildSignEventMacro();
QString buildHiddenItemEventMacro();
QString buildSecretBaseEventMacro();
void setPixmapFromSpritesheet(QImage, int, int);
int getPixelX();
int getPixelY();
2018-07-07 16:58:25 +01:00
2017-11-28 04:46:27 +00:00
QMap<QString, QString> values;
QPixmap pixmap;
int spriteWidth;
int spriteHeight;
2016-09-07 04:50:47 +01:00
};
#endif // EVENT_H