Support reading/saving pokefirered heal locations

This commit is contained in:
GriffinR
2020-03-20 03:09:48 -04:00
parent 083874ce9e
commit d365ebb664
4 changed files with 134 additions and 39 deletions

View File

@@ -87,10 +87,16 @@ Event* Event::createNewWarpEvent(QString map_name)
Event* Event::createNewHealLocationEvent(QString map_name)
{
Event *event = new Event;
QString mapConstant = QString(Map::mapConstantFromName(map_name)).remove(0,4);
event->put("event_group_type", "heal_event_group");
event->put("event_type", EventType::HealLocation);
event->put("loc_name", QString(Map::mapConstantFromName(map_name)).remove(0,4));
event->put("loc_name", mapConstant);
event->put("id_name", map_name.replace(QRegularExpression("([a-z])([A-Z])"), "\\1_\\2").toUpper());
event->put("elevation", 3);
if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered) {
event->put("respawn_map", mapConstant);
event->put("respawn_npc", 1);
}
return event;
}

View File

@@ -1,17 +1,33 @@
#include "heallocation.h"
#include "config.h"
HealLocation::HealLocation(QString map, int i, uint16_t x, uint16_t y)
HealLocation::HealLocation(QString id, QString map, int i, uint16_t x, uint16_t y)
{
this->name = map;
this->idName = id;
this->mapName = map;
this->index = i;
this->x = x;
this->y = y;
this->respawnMap = "";
this->respawnNPC = 0;
}
HealLocation::HealLocation(QString id, QString map, int i, uint16_t x, uint16_t y, QString respawnMap, uint16_t respawnNPC)
{
this->idName = id;
this->mapName = map;
this->index = i;
this->x = x;
this->y = y;
this->respawnMap = respawnMap;
this->respawnNPC = respawnNPC;
}
HealLocation HealLocation::fromEvent(Event *event)
{
HealLocation hl;
hl.name = event->get("loc_name");
hl.idName = event->get("id_name");
hl.mapName = event->get("loc_name");
try {
hl.index = event->get("index").toInt();
}
@@ -20,11 +36,15 @@ HealLocation HealLocation::fromEvent(Event *event)
}
hl.x = event->getU16("x");
hl.y = event->getU16("y");
if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered) {
hl.respawnNPC = event->getU16("respawn_npc");
hl.respawnMap = event->get("respawn_map");
}
return hl;
}
QDebug operator<<(QDebug debug, const HealLocation &hl)
{
debug << "HealLocation_" + hl.name << "(" << hl.x << ',' << hl.y << ")";
debug << "HealLocation_" + hl.mapName << "(" << hl.x << ',' << hl.y << ")";
return debug;
}