Move heal location logic out of event class
This commit is contained in:
parent
0d33c3aa64
commit
083e8e6101
5 changed files with 21 additions and 22 deletions
|
@ -175,21 +175,6 @@ QString Event::buildWarpEventMacro(QMap<QString, QString> *mapNamesToMapConstant
|
|||
return text;
|
||||
}
|
||||
|
||||
HealLocation Event::buildHealLocation()
|
||||
{
|
||||
HealLocation hl;
|
||||
hl.name = this->get("loc_name");
|
||||
try {
|
||||
hl.index = this->get("index").toInt();
|
||||
}
|
||||
catch(...) {
|
||||
hl.index = 0;
|
||||
}
|
||||
hl.x = this->getU16("x");
|
||||
hl.y = this->getU16("y");
|
||||
return hl;
|
||||
}
|
||||
|
||||
QString Event::buildCoordScriptEventMacro()
|
||||
{
|
||||
QString text = "";
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef EVENT_H
|
||||
#define EVENT_H
|
||||
|
||||
#include "heallocation.h"
|
||||
#include <QString>
|
||||
#include <QPixmap>
|
||||
#include <QMap>
|
||||
|
@ -68,7 +67,6 @@ public:
|
|||
|
||||
QString buildObjectEventMacro(int);
|
||||
QString buildWarpEventMacro(QMap<QString, QString>*);
|
||||
HealLocation buildHealLocation();
|
||||
QString buildCoordScriptEventMacro();
|
||||
QString buildCoordWeatherEventMacro();
|
||||
QString buildSignEventMacro();
|
||||
|
|
|
@ -8,6 +8,21 @@ HealLocation::HealLocation(QString map, int i, uint16_t x, uint16_t y)
|
|||
this->y = y;
|
||||
}
|
||||
|
||||
HealLocation HealLocation::fromEvent(Event *event)
|
||||
{
|
||||
HealLocation hl;
|
||||
hl.name = event->get("loc_name");
|
||||
try {
|
||||
hl.index = event->get("index").toInt();
|
||||
}
|
||||
catch(...) {
|
||||
hl.index = 0;
|
||||
}
|
||||
hl.x = event->getU16("x");
|
||||
hl.y = event->getU16("y");
|
||||
return hl;
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, const HealLocation &hl)
|
||||
{
|
||||
debug << "HealLocation_" + hl.name << "(" << hl.x << ',' << hl.y << ")";
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef HEALLOCATION_H
|
||||
#define HEALLOCATION_H
|
||||
|
||||
#include "event.h"
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
|
||||
|
@ -17,7 +18,7 @@ public:
|
|||
int index;
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
|
||||
static HealLocation fromEvent(Event*);
|
||||
};
|
||||
|
||||
#endif // HEALLOCATION_H
|
||||
|
|
|
@ -534,8 +534,8 @@ void Project::saveHealLocationStruct(Map *map) {
|
|||
|
||||
// set new location in flyableMapsList
|
||||
if (map->events["heal_event_group"].length() > 0) {
|
||||
for (Event *heal : map->events["heal_event_group"]) {
|
||||
HealLocation hl = heal->buildHealLocation();
|
||||
for (Event *healEvent : map->events["heal_event_group"]) {
|
||||
HealLocation hl = HealLocation::fromEvent(healEvent);
|
||||
flyableMaps[hl.index - 1] = hl;
|
||||
}
|
||||
}
|
||||
|
@ -1475,8 +1475,8 @@ void Project::saveMapEvents(Map *map) {
|
|||
|
||||
// save heal event changes
|
||||
if (map->events["heal_event_group"].length() > 0) {
|
||||
for (Event *heal : map->events["heal_event_group"]) {
|
||||
HealLocation hl = heal->buildHealLocation();
|
||||
for (Event *healEvent : map->events["heal_event_group"]) {
|
||||
HealLocation hl = HealLocation::fromEvent(healEvent);
|
||||
flyableMaps[hl.index - 1] = hl;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue