fix new map heal location generation

This commit is contained in:
garak 2018-10-14 08:54:00 -04:00
parent bb855f8c3f
commit 1222954175
5 changed files with 12 additions and 8 deletions

View file

@ -33,7 +33,7 @@ public:
QString layout_id; QString layout_id;
QString location; QString location;
QString requiresFlash; QString requiresFlash;
QString isFlyable; // TODO: implement this QString isFlyable;
QString weather; QString weather;
QString type; QString type;
QString unknown; QString unknown;

View file

@ -1103,6 +1103,9 @@ DraggablePixmapItem* Editor::addNewEvent(QString event_type) {
if (project && map) { if (project && map) {
Event *event = Event::createNewEvent(event_type, map->name); Event *event = Event::createNewEvent(event_type, map->name);
event->put("map_name", map->name); event->put("map_name", map->name);
if (event_type == "event_heal_location") {
event->put("index", project->flyableMaps.length());
}
map->addEvent(event); map->addEvent(event);
project->loadEventPixmaps(map->getAllEvents()); project->loadEventPixmaps(map->getAllEvents());
DraggablePixmapItem *object = addMapEvent(event); DraggablePixmapItem *object = addMapEvent(event);

View file

@ -673,6 +673,7 @@ void MainWindow::onNewMapCreated() {
QString newMapName = this->newmapprompt->map->name; QString newMapName = this->newmapprompt->map->name;
int newMapGroup = this->newmapprompt->group; int newMapGroup = this->newmapprompt->group;
Map *newMap_ = this->newmapprompt->map; Map *newMap_ = this->newmapprompt->map;
Map *newMap = editor->project->addNewMapToGroup(newMapName, newMapGroup, newMap_); Map *newMap = editor->project->addNewMapToGroup(newMapName, newMapGroup, newMap_);
qDebug() << "Created a new map named" << newMapName; qDebug() << "Created a new map named" << newMapName;
@ -689,6 +690,11 @@ void MainWindow::onNewMapCreated() {
setMap(newMapName, true); setMap(newMapName, true);
if (newMap->isFlyable == "TRUE") {
addNewEvent("event_heal_location");
editor->project->saveHealLocationStruct(newMap);
}
disconnect(this->newmapprompt, SIGNAL(applied()), this, SLOT(onNewMapCreated())); disconnect(this->newmapprompt, SIGNAL(applied()), this, SLOT(onNewMapCreated()));
} }

View file

@ -1209,7 +1209,7 @@ Map* Project::addNewMapToGroup(QString mapName, int groupNum, Map *newMap) {
loadMapTilesets(map); loadMapTilesets(map);
setNewMapBlockdata(map); setNewMapBlockdata(map);
setNewMapBorder(map); setNewMapBorder(map);
//setNewMapEvents(map); setNewMapEvents(map);
setNewMapConnections(map); setNewMapConnections(map);
map->commit(); map->commit();
map->metatileHistory.save(); map->metatileHistory.save();

View file

@ -82,13 +82,8 @@ void NewMapPopup::on_pushButton_NewMap_Accept_clicked() {
layout->blockdata_label = QString("%1_MapBlockdata").arg(newMap->name); layout->blockdata_label = QString("%1_MapBlockdata").arg(newMap->name);
layout->blockdata_path = QString("data/layouts/%1/map.bin").arg(newMap->name); layout->blockdata_path = QString("data/layouts/%1/map.bin").arg(newMap->name);
// EMERGENCY (MUST FIX):causes a segfault...
// how do I add new event to newMap without behavior being undefined???
if (this->ui->checkBox_NewMap_Flyable->isChecked()) { if (this->ui->checkBox_NewMap_Flyable->isChecked()) {
Event *healSpot = new Event; newMap->isFlyable = "TRUE";
healSpot = Event::createNewEvent("event_heal_location", newMapName);
healSpot->put("map_name", newMapName);
newMap->addEvent(healSpot);
} }
newMap->layout = layout; newMap->layout = layout;