fix saving region map layout

This commit is contained in:
garak 2019-01-05 13:02:14 -05:00
parent a9098cfd7a
commit 0f02d7b955
2 changed files with 11 additions and 4 deletions

View file

@ -211,10 +211,9 @@ void RegionMap::readLayout() {
int i = img_index_(n,m); int i = img_index_(n,m);
map_squares[i].secid = static_cast<uint8_t>(mapBinData.at(layout_index_(n,m))); map_squares[i].secid = static_cast<uint8_t>(mapBinData.at(layout_index_(n,m)));
QString secname = (*(project->regionMapSections))[static_cast<uint8_t>(mapBinData.at(layout_index_(n,m)))]; QString secname = (*(project->regionMapSections))[static_cast<uint8_t>(mapBinData.at(layout_index_(n,m)))];
//qDebug() << i << map_squares[i].secid << secname;
if (secname != "MAPSEC_NONE") map_squares[i].has_map = true; if (secname != "MAPSEC_NONE") map_squares[i].has_map = true;
map_squares[i].mapsec = secname; map_squares[i].mapsec = secname;
map_squares[i].map_name = sMapNames.value(mapSecToMapEntry.value(secname).name);//[mapSecToMapEntry[secname].name]; map_squares[i].map_name = sMapNames.value(mapSecToMapEntry.value(secname).name);
map_squares[i].x = n; map_squares[i].x = n;
map_squares[i].y = m; map_squares[i].y = m;
} }
@ -352,9 +351,15 @@ void RegionMap::saveOptions(int index, QString sec, QString name, int x, int y)
// TODO:req need to reindex in city_maps if changing x and y // TODO:req need to reindex in city_maps if changing x and y
// TODO: save [sec] sMapName_ properly // TODO: save [sec] sMapName_ properly
// so instead of taking index, maybe go by img_index_(x,y) // so instead of taking index, maybe go by img_index_(x,y)
this->project->mapSecToMapHoverName->insert(sec, name); if (!sec.isEmpty()) {
this->map_squares[index].has_map = true;
this->map_squares[index].secid = static_cast<uint8_t>(project->regionMapSections->indexOf(sec));
}
this->map_squares[index].mapsec = sec; this->map_squares[index].mapsec = sec;
if (!name.isEmpty()) {
this->map_squares[index].map_name = name;// TODO: display in editor with this map & remove this field this->map_squares[index].map_name = name;// TODO: display in editor with this map & remove this field
this->project->mapSecToMapHoverName->insert(sec, name);
}
this->map_squares[index].x = x; this->map_squares[index].x = x;
this->map_squares[index].y = y; this->map_squares[index].y = y;
} }

View file

@ -28,6 +28,7 @@ void Editor::saveProject() {
project->saveAllDataStructures(); project->saveAllDataStructures();
if (region_map) { if (region_map) {
region_map->save(); region_map->save();
displayRegionMap();
} }
} }
} }
@ -39,6 +40,7 @@ void Editor::save() {
} }
if (project && region_map) { if (project && region_map) {
region_map->save(); region_map->save();
displayRegionMap();
} }
} }