Support new map layouts structure

This commit is contained in:
Marcus Huderle 2018-06-20 17:43:20 -05:00
parent 39abd40ee0
commit a2b42de541
7 changed files with 339 additions and 426 deletions

View file

@ -349,14 +349,14 @@ void Editor::displayMap() {
connect(map_item, SIGNAL(mouseEvent(QGraphicsSceneMouseEvent*,MapPixmapItem*)),
this, SLOT(mouseEvent_map(QGraphicsSceneMouseEvent*,MapPixmapItem*)));
map_item->draw();
map_item->draw(true);
scene->addItem(map_item);
collision_item = new CollisionPixmapItem(map);
connect(collision_item, SIGNAL(mouseEvent(QGraphicsSceneMouseEvent*,CollisionPixmapItem*)),
this, SLOT(mouseEvent_collision(QGraphicsSceneMouseEvent*,CollisionPixmapItem*)));
collision_item->draw();
collision_item->draw(true);
scene->addItem(collision_item);
events_group = new EventGroup;
@ -1077,9 +1077,9 @@ void MapPixmapItem::select(QGraphicsSceneMouseEvent *event) {
}
}
void MapPixmapItem::draw() {
void MapPixmapItem::draw(bool ignoreCache) {
if (map) {
setPixmap(map->render());
setPixmap(map->render(ignoreCache));
}
}
@ -1104,7 +1104,7 @@ void MapPixmapItem::updateCurHoveredTile(QPointF pos) {
if (x < 0 || x >= map->getWidth() || y < 0 || y >= map->getHeight()) {
map->clearHoveredTile();
} else {
int tile = map->blockdata->blocks->at(blockIndex).tile;
int tile = map->layout->blockdata->blocks->at(blockIndex).tile;
map->hoveredTileChanged(x, y, tile);
}
}
@ -1141,9 +1141,9 @@ void CollisionPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
emit mouseEvent(event, this);
}
void CollisionPixmapItem::draw() {
void CollisionPixmapItem::draw(bool ignoreCache) {
if (map) {
setPixmap(map->renderCollision());
setPixmap(map->renderCollision(ignoreCache));
}
}

View file

@ -237,7 +237,7 @@ public:
virtual void select(QGraphicsSceneMouseEvent*);
virtual void undo();
virtual void redo();
virtual void draw();
virtual void draw(bool ignoreCache = false);
private:
void updateCurHoveredTile(QPointF pos);
@ -266,7 +266,7 @@ public:
virtual void paint(QGraphicsSceneMouseEvent*);
virtual void floodFill(QGraphicsSceneMouseEvent*);
virtual void pick(QGraphicsSceneMouseEvent*);
virtual void draw();
virtual void draw(bool ignoreCache = false);
signals:
void mouseEvent(QGraphicsSceneMouseEvent *, CollisionPixmapItem *);

View file

@ -285,8 +285,8 @@ void MainWindow::on_checkBox_ShowLocation_clicked(bool checked)
void MainWindow::loadDataStructures() {
Project *project = editor->project;
project->readMapAttributesTable();
project->readAllMapAttributes();
project->readMapLayoutsTable();
project->readAllMapLayouts();
project->readItemNames();
project->readFlagNames();
project->readVarNames();
@ -761,6 +761,7 @@ void MainWindow::onLoadMapRequested(QString mapName, QString fromMapName) {
}
void MainWindow::onMapChanged(Map *map) {
map->layout->has_unsaved_changes = true;
updateMapList();
}

145
map.cpp
View file

@ -8,10 +8,6 @@
Map::Map(QObject *parent) : QObject(parent)
{
blockdata = new Blockdata;
cached_blockdata = new Blockdata;
cached_collision = new Blockdata;
cached_border = new Blockdata;
paint_tile_index = 1;
paint_collision = 0;
paint_elevation = 3;
@ -36,29 +32,29 @@ QString Map::mapConstantFromName(QString mapName) {
}
int Map::getWidth() {
return width.toInt(nullptr, 0);
return layout->width.toInt(nullptr, 0);
}
int Map::getHeight() {
return height.toInt(nullptr, 0);
return layout->height.toInt(nullptr, 0);
}
Tileset* Map::getBlockTileset(int metatile_index) {
int primary_size = 0x200;//tileset_primary->metatiles->length();
int primary_size = 0x200;
if (metatile_index < primary_size) {
return tileset_primary;
return layout->tileset_primary;
} else {
return tileset_secondary;
return layout->tileset_secondary;
}
}
QList<QList<QRgb>> Map::getBlockPalettes(int metatile_index) {
QList<QList<QRgb>> palettes;
for (int i = 0; i < 6; i++) {
palettes.append(tileset_primary->palettes->at(i));
palettes.append(layout->tileset_primary->palettes->at(i));
}
for (int i = 6; i < tileset_secondary->palettes->length(); i++) {
palettes.append(tileset_secondary->palettes->at(i));
for (int i = 6; i < layout->tileset_secondary->palettes->length(); i++) {
palettes.append(layout->tileset_secondary->palettes->at(i));
}
return palettes;
}
@ -73,18 +69,18 @@ int Map::getBlockIndex(int index) {
}
int Map::getSelectedBlockIndex(int index) {
if (index < tileset_primary->metatiles->length()) {
if (index < layout->tileset_primary->metatiles->length()) {
return index;
} else {
return 0x200 + (index - tileset_primary->metatiles->length());
return 0x200 + (index - layout->tileset_primary->metatiles->length());
}
}
int Map::getDisplayedBlockIndex(int index) {
if (index < tileset_primary->metatiles->length()) {
if (index < layout->tileset_primary->metatiles->length()) {
return index;
} else {
return index - 0x200 + tileset_primary->metatiles->length();
return index - 0x200 + layout->tileset_primary->metatiles->length();
}
}
@ -205,58 +201,58 @@ bool Map::blockChanged(int i, Blockdata *cache) {
if (cache == NULL || cache == nullptr) {
return true;
}
if (blockdata == NULL || blockdata == nullptr) {
if (layout->blockdata == NULL || layout->blockdata == nullptr) {
return true;
}
if (cache->blocks == NULL || cache->blocks == nullptr) {
return true;
}
if (blockdata->blocks == NULL || blockdata->blocks == nullptr) {
if (layout->blockdata->blocks == NULL || layout->blockdata->blocks == nullptr) {
return true;
}
if (cache->blocks->length() <= i) {
return true;
}
if (blockdata->blocks->length() <= i) {
if (layout->blockdata->blocks->length() <= i) {
return true;
}
return blockdata->blocks->value(i) != cache->blocks->value(i);
return layout->blockdata->blocks->value(i) != cache->blocks->value(i);
}
void Map::cacheBorder() {
if (cached_border) delete cached_border;
cached_border = new Blockdata;
if (border && border->blocks) {
for (int i = 0; i < border->blocks->length(); i++) {
Block block = border->blocks->value(i);
cached_border->blocks->append(block);
if (layout->cached_border) delete layout->cached_border;
layout->cached_border = new Blockdata;
if (layout->border && layout->border->blocks) {
for (int i = 0; i < layout->border->blocks->length(); i++) {
Block block = layout->border->blocks->value(i);
layout->cached_border->blocks->append(block);
}
}
}
void Map::cacheBlockdata() {
if (cached_blockdata) delete cached_blockdata;
cached_blockdata = new Blockdata;
if (blockdata && blockdata->blocks) {
for (int i = 0; i < blockdata->blocks->length(); i++) {
Block block = blockdata->blocks->value(i);
cached_blockdata->blocks->append(block);
if (layout->cached_blockdata) delete layout->cached_blockdata;
layout->cached_blockdata = new Blockdata;
if (layout->blockdata && layout->blockdata->blocks) {
for (int i = 0; i < layout->blockdata->blocks->length(); i++) {
Block block = layout->blockdata->blocks->value(i);
layout->cached_blockdata->blocks->append(block);
}
}
}
void Map::cacheCollision() {
if (cached_collision) delete cached_collision;
cached_collision = new Blockdata;
if (blockdata && blockdata->blocks) {
for (int i = 0; i < blockdata->blocks->length(); i++) {
Block block = blockdata->blocks->value(i);
cached_collision->blocks->append(block);
if (layout->cached_collision) delete layout->cached_collision;
layout->cached_collision = new Blockdata;
if (layout->blockdata && layout->blockdata->blocks) {
for (int i = 0; i < layout->blockdata->blocks->length(); i++) {
Block block = layout->blockdata->blocks->value(i);
layout->cached_collision->blocks->append(block);
}
}
}
QPixmap Map::renderCollision() {
QPixmap Map::renderCollision(bool ignoreCache) {
bool changed_any = false;
int width_ = getWidth();
int height_ = getHeight();
@ -268,17 +264,17 @@ QPixmap Map::renderCollision() {
collision_image = QImage(width_ * 16, height_ * 16, QImage::Format_RGBA8888);
changed_any = true;
}
if (!(blockdata && blockdata->blocks && width_ && height_)) {
if (!(layout->blockdata && layout->blockdata->blocks && width_ && height_)) {
collision_pixmap = collision_pixmap.fromImage(collision_image);
return collision_pixmap;
}
QPainter painter(&collision_image);
for (int i = 0; i < blockdata->blocks->length(); i++) {
if (cached_collision && !blockChanged(i, cached_collision)) {
for (int i = 0; i < layout->blockdata->blocks->length(); i++) {
if (!ignoreCache && layout->cached_collision && !blockChanged(i, layout->cached_collision)) {
continue;
}
changed_any = true;
Block block = blockdata->blocks->value(i);
Block block = layout->blockdata->blocks->value(i);
QImage metatile_image = getMetatileImage(block.tile);
QImage collision_metatile_image = getCollisionMetatileImage(block);
QImage elevation_metatile_image = getElevationMetatileImage(block);
@ -324,7 +320,7 @@ QPixmap Map::renderCollision() {
return collision_pixmap;
}
QPixmap Map::render() {
QPixmap Map::render(bool ignoreCache = false) {
bool changed_any = false;
int width_ = getWidth();
int height_ = getHeight();
@ -336,18 +332,18 @@ QPixmap Map::render() {
image = QImage(width_ * 16, height_ * 16, QImage::Format_RGBA8888);
changed_any = true;
}
if (!(blockdata && blockdata->blocks && width_ && height_)) {
if (!(layout->blockdata && layout->blockdata->blocks && width_ && height_)) {
pixmap = pixmap.fromImage(image);
return pixmap;
}
QPainter painter(&image);
for (int i = 0; i < blockdata->blocks->length(); i++) {
if (!blockChanged(i, cached_blockdata)) {
for (int i = 0; i < layout->blockdata->blocks->length(); i++) {
if (!ignoreCache && !blockChanged(i, layout->cached_blockdata)) {
continue;
}
changed_any = true;
Block block = blockdata->blocks->value(i);
Block block = layout->blockdata->blocks->value(i);
QImage metatile_image = getMetatileImage(block.tile);
int map_y = width_ ? i / width_ : 0;
int map_x = width_ ? i % width_ : 0;
@ -366,21 +362,21 @@ QPixmap Map::renderBorder() {
bool changed_any = false;
int width_ = 2;
int height_ = 2;
if (border_image.isNull()) {
border_image = QImage(width_ * 16, height_ * 16, QImage::Format_RGBA8888);
if (layout->border_image.isNull()) {
layout->border_image = QImage(width_ * 16, height_ * 16, QImage::Format_RGBA8888);
changed_any = true;
}
if (!(border && border->blocks)) {
border_pixmap = border_pixmap.fromImage(border_image);
return border_pixmap;
if (!(layout->border && layout->border->blocks)) {
layout->border_pixmap = layout->border_pixmap.fromImage(layout->border_image);
return layout->border_pixmap;
}
QPainter painter(&border_image);
for (int i = 0; i < border->blocks->length(); i++) {
if (!blockChanged(i, cached_border)) {
QPainter painter(&layout->border_image);
for (int i = 0; i < layout->border->blocks->length(); i++) {
if (!blockChanged(i, layout->cached_border)) {
continue;
}
changed_any = true;
Block block = border->blocks->value(i);
Block block = layout->border->blocks->value(i);
QImage metatile_image = getMetatileImage(block.tile);
int map_y = i / width_;
int map_x = i % width_;
@ -389,9 +385,9 @@ QPixmap Map::renderBorder() {
painter.end();
if (changed_any) {
cacheBorder();
border_pixmap = border_pixmap.fromImage(border_image);
layout->border_pixmap = layout->border_pixmap.fromImage(layout->border_image);
}
return border_pixmap;
return layout->border_pixmap;
}
QPixmap Map::renderConnection(Connection connection) {
@ -482,11 +478,12 @@ void Map::drawSelection(int i, int w, int selectionWidth, int selectionHeight, Q
}
QPixmap Map::renderMetatiles() {
if (!tileset_primary || !tileset_primary->metatiles || !tileset_secondary || !tileset_secondary->metatiles) {
if (!layout->tileset_primary || !layout->tileset_primary->metatiles
|| !layout->tileset_secondary || !layout->tileset_secondary->metatiles) {
return QPixmap();
}
int primary_length = tileset_primary->metatiles->length();
int length_ = primary_length + tileset_secondary->metatiles->length();
int primary_length = layout->tileset_primary->metatiles->length();
int length_ = primary_length + layout->tileset_secondary->metatiles->length();
int width_ = 8;
int height_ = length_ / width_;
QImage image(width_ * 16, height_ * 16, QImage::Format_RGBA8888);
@ -510,11 +507,11 @@ QPixmap Map::renderMetatiles() {
}
Block* Map::getBlock(int x, int y) {
if (blockdata && blockdata->blocks) {
if (layout->blockdata && layout->blockdata->blocks) {
if (x >= 0 && x < getWidth())
if (y >= 0 && y < getHeight()) {
int i = y * getWidth() + x;
return new Block(blockdata->blocks->value(i));
return new Block(layout->blockdata->blocks->value(i));
}
}
return NULL;
@ -522,8 +519,8 @@ Block* Map::getBlock(int x, int y) {
void Map::_setBlock(int x, int y, Block block) {
int i = y * getWidth() + x;
if (blockdata && blockdata->blocks) {
blockdata->blocks->replace(i, block);
if (layout->blockdata && layout->blockdata->blocks) {
layout->blockdata->blocks->replace(i, block);
}
}
@ -660,29 +657,29 @@ void Map::_floodFillCollisionElevation(int x, int y, uint collision, uint elevat
void Map::undo() {
if (blockdata) {
if (layout->blockdata) {
Blockdata *commit = history.back();
if (commit != NULL) {
blockdata->copyFrom(commit);
layout->blockdata->copyFrom(commit);
emit mapChanged(this);
}
}
}
void Map::redo() {
if (blockdata) {
if (layout->blockdata) {
Blockdata *commit = history.next();
if (commit != NULL) {
blockdata->copyFrom(commit);
layout->blockdata->copyFrom(commit);
emit mapChanged(this);
}
}
}
void Map::commit() {
if (blockdata) {
if (!blockdata->equals(history.current())) {
Blockdata* commit = blockdata->copy();
if (layout->blockdata) {
if (!layout->blockdata->equals(history.current())) {
Blockdata* commit = layout->blockdata->copy();
history.push(commit);
emit mapChanged(this);
}
@ -752,7 +749,7 @@ void Map::addEvent(Event *event) {
}
bool Map::hasUnsavedChanges() {
return !history.isSaved() || !isPersistedToFile;
return !history.isSaved() || !isPersistedToFile || layout->has_unsaved_changes;
}
void Map::hoveredTileChanged(int x, int y, int block) {

64
map.h
View file

@ -68,6 +68,37 @@ public:
QString map_name;
};
class MapLayout {
public:
MapLayout() {}
int index;
QString name;
QString label;
QString width;
QString height;
QString border_label;
QString border_path;
QString blockdata_label;
QString blockdata_path;
QString tileset_primary_label;
QString tileset_secondary_label;
Tileset *tileset_primary = NULL;
Tileset *tileset_secondary = NULL;
Blockdata* blockdata = NULL;
QImage border_image;
QPixmap border_pixmap;
Blockdata *border = NULL;
Blockdata *cached_blockdata = NULL;
Blockdata *cached_collision = NULL;
Blockdata *cached_border = NULL;
bool has_unsaved_changes = false;
public:
static QString getNameFromLabel(QString label) {
// ASSUMPTION: strip off "_Layout" from layout label. Directories in 'data/layouts/' must be well-formed.
return label.replace(label.lastIndexOf("_Layout"), label.length(), "");
}
};
class Map : public QObject
{
Q_OBJECT
@ -78,12 +109,12 @@ public:
QString name;
QString constantName;
QString group_num;
QString attributes_label;
QString layout_label;
QString events_label;
QString scripts_label;
QString connections_label;
QString song;
QString index;
QString layout_id;
QString location;
QString visibility;
QString weather;
@ -91,18 +122,7 @@ public:
QString unknown;
QString show_location;
QString battle_scene;
QString width;
QString height;
QString border_label;
QString blockdata_label;
QString tileset_primary_label;
QString tileset_secondary_label;
Tileset *tileset_primary = NULL;
Tileset *tileset_secondary = NULL;
Blockdata* blockdata = NULL;
MapLayout *layout;
bool isPersistedToFile = true;
@ -112,16 +132,16 @@ public:
int getWidth();
int getHeight();
Tileset* getBlockTileset(int);
int getBlockIndex(int index);
int getSelectedBlockIndex(int index);
int getDisplayedBlockIndex(int index);
int getBlockIndex(int layout_id);
int getSelectedBlockIndex(int layout_id);
int getDisplayedBlockIndex(int layout_id);
Metatile* getMetatile(int);
QImage getMetatileImage(int);
QImage getMetatileTile(int);
QPixmap render();
QPixmap render(bool ignoreCache);
QPixmap renderMetatiles();
QPixmap renderCollision();
QPixmap renderCollision(bool ignoreCache);
QImage collision_image;
QPixmap collision_pixmap;
QImage getCollisionMetatileImage(Block);
@ -134,9 +154,7 @@ public:
void drawSelection(int i, int w, int selectionWidth, int selectionHeight, QPainter *painter);
bool blockChanged(int, Blockdata*);
Blockdata* cached_blockdata = NULL;
void cacheBlockdata();
Blockdata* cached_collision = NULL;
void cacheCollision();
QImage image;
QPixmap pixmap;
@ -185,10 +203,6 @@ public:
QList<QGraphicsPixmapItem*> connection_items;
QPixmap renderConnection(Connection);
QImage border_image;
QPixmap border_pixmap;
Blockdata *border = NULL;
Blockdata *cached_border = NULL;
QPixmap renderBorder();
void cacheBorder();

View file

@ -49,10 +49,7 @@ Map* Project::loadMap(QString map_name) {
}
readMapHeader(map);
readMapAttributes(map);
getTilesets(map);
loadBlockdata(map);
loadMapBorder(map);
readMapLayout(map);
readMapEvents(map);
loadMapConnections(map);
map->commit();
@ -136,9 +133,12 @@ QStringList* Project::getLabelValues(QList<QStringList> *list, QString label) {
QStringList params = list->value(i);
QString macro = params.value(0);
// Ignore .align
if (macro == ".align") {
if (macro == ".align")
continue;
if (macro == ".ifdef")
continue;
if (macro == ".ifndef")
continue;
}
for (int j = 1; j < params.length(); j++) {
values->append(params.value(j));
}
@ -159,12 +159,12 @@ void Project::readMapHeader(Map* map) {
return;
}
QStringList *header = getLabelValues(parser->parseAsm(header_text), label);
map->attributes_label = header->value(0);
map->layout_label = header->value(0);
map->events_label = header->value(1);
map->scripts_label = header->value(2);
map->connections_label = header->value(3);
map->song = header->value(4);
map->index = header->value(5);
map->layout_id = header->value(5);
map->location = header->value(6);
map->visibility = header->value(7);
map->weather = header->value(8);
@ -175,12 +175,12 @@ void Project::readMapHeader(Map* map) {
}
void Project::setNewMapHeader(Map* map, int mapIndex) {
map->attributes_label = QString("%1_MapAttributes").arg(map->name);
map->layout_label = QString("%1_Layout").arg(map->name);
map->events_label = QString("%1_MapEvents").arg(map->name);;
map->scripts_label = QString("%1_MapScripts").arg(map->name);;
map->connections_label = "0x0";
map->song = "BGM_DAN02";
map->index = QString("%1").arg(mapIndex);
map->layout_id = QString("%1").arg(mapIndex);
map->location = "0";
map->visibility = "0";
map->weather = "2";
@ -195,7 +195,7 @@ void Project::saveMapHeader(Map *map) {
QString header_path = root + "/data/maps/" + label + "/header.inc";
QString text = "";
text += QString("%1::\n").arg(label);
text += QString("\t.4byte %1\n").arg(map->attributes_label);
text += QString("\t.4byte %1\n").arg(map->layout_label);
text += QString("\t.4byte %1\n").arg(map->events_label);
text += QString("\t.4byte %1\n").arg(map->scripts_label);
@ -207,7 +207,7 @@ void Project::saveMapHeader(Map *map) {
text += QString("\t.4byte %1\n").arg(map->connections_label);
text += QString("\t.2byte %1\n").arg(map->song);
text += QString("\t.2byte %1\n").arg(map->index);
text += QString("\t.2byte %1\n").arg(map->layout_id);
text += QString("\t.byte %1\n").arg(map->location);
text += QString("\t.byte %1\n").arg(map->visibility);
text += QString("\t.byte %1\n").arg(map->weather);
@ -260,269 +260,180 @@ void Project::updateMapsWithConnections(Map *map) {
}
}
void Project::readMapAttributesTable() {
int curMapIndex = 1;
QString attributesText = readTextFile(getMapAttributesTableFilepath());
QList<QStringList>* values = parseAsm(attributesText);
bool inAttributePointers = false;
void Project::readMapLayoutsTable() {
int curIndex = 1;
QString layoutsText = readTextFile(getMapLayoutsTableFilepath());
QList<QStringList>* values = parseAsm(layoutsText);
bool inLayoutPointers = false;
for (int i = 0; i < values->length(); i++) {
QStringList params = values->value(i);
QString macro = params.value(0);
if (macro == ".label") {
if (inAttributePointers) {
if (inLayoutPointers) {
break;
}
if (params.value(1) == "gMapAttributes") {
inAttributePointers = true;
if (params.value(1) == "gMapLayouts") {
inLayoutPointers = true;
}
} else if (macro == ".4byte" && inAttributePointers) {
QString mapName = params.value(1);
if (!mapName.contains("UnknownMapAttributes")) {
// Strip off "_MapAttributes" from the label if it's a real map label.
mapName = mapName.remove(mapName.length() - 14, 14);
}
mapAttributesTable.insert(curMapIndex, mapName);
curMapIndex++;
} else if (macro == ".4byte" && inLayoutPointers) {
QString layoutName = params.value(1);
mapLayoutsTable.append(layoutName);
}
}
// Deep copy
mapAttributesTableMaster = mapAttributesTable;
mapAttributesTableMaster.detach();
mapLayoutsTableMaster = mapLayoutsTable;
mapLayoutsTableMaster.detach();
}
void Project::saveMapAttributesTable() {
void Project::saveMapLayoutsTable() {
QString text = "";
text += QString("\t.align 2\n");
text += QString("gMapAttributes::\n");
for (int i = 0; i < mapAttributesTableMaster.count(); i++) {
int mapIndex = i + 1;
QString mapName = mapAttributesTableMaster.value(mapIndex);
if (!mapName.contains("UnknownMapAttributes")) {
text += QString("\t.4byte %1_MapAttributes\n").arg(mapName);
} else {
text += QString("\t.4byte %1\n").arg(mapName);
}
text += QString("gMapLayouts::\n");
for (QString layoutName : mapLayoutsTableMaster) {
text += QString("\t.4byte %1\n").arg(layoutName);
}
saveTextFile(getMapAttributesTableFilepath(), text);
saveTextFile(getMapLayoutsTableFilepath(), text);
}
QString Project::getMapAttributesTableFilepath() {
return QString("%1/data/maps/attributes_table.inc").arg(root);
QString Project::getMapLayoutsTableFilepath() {
return QString("%1/data/layouts_table.inc").arg(root);
}
void Project::readMapAttributes(Map* map) {
QStringList* Project::readLayoutValues(QString layoutLabel) {
ParseUtil *parser = new ParseUtil;
QString layoutText = readTextFile(getMapLayoutFilepath(layoutLabel));
if (layoutText.isNull()) {
return NULL;
}
QStringList *layoutValues = getLabelValues(parser->parseAsm(layoutText), layoutLabel);
QString borderLabel = layoutValues->value(2);
QString blockdataLabel = layoutValues->value(3);
QStringList *borderValues = getLabelValues(parser->parseAsm(layoutText), borderLabel);
QString borderPath = borderValues->value(0).replace("\"", "");
layoutValues->append(borderPath);
QStringList *blockdataValues = getLabelValues(parser->parseAsm(layoutText), blockdataLabel);
QString blockdataPath = blockdataValues->value(0).replace("\"", "");
layoutValues->append(blockdataPath);
if (layoutValues->size() != 8) {
qDebug() << "Error: Unexpected number of properties in layout '" << layoutLabel << "'";
return NULL;
}
return layoutValues;
}
void Project::readMapLayout(Map* map) {
if (!map->isPersistedToFile) {
return;
}
ParseUtil *parser = new ParseUtil;
MapLayout *layout;
if (!mapLayouts.contains(map->layout_label)) {
QStringList *layoutValues = readLayoutValues(map->layout->label);
if (layoutValues == NULL) {
return;
}
QString assets_text = readTextFile(getMapAssetsFilepath());
if (assets_text.isNull()) {
return;
layout = new MapLayout();
mapLayouts.insert(map->layout_label, layout);
layout->name = MapLayout::getNameFromLabel(map->layout_label);
layout->label = map->layout_label;
layout->width = layoutValues->value(0);
layout->height = layoutValues->value(1);
layout->border_label = layoutValues->value(2);
layout->blockdata_label = layoutValues->value(3);
layout->tileset_primary_label = layoutValues->value(4);
layout->tileset_secondary_label = layoutValues->value(5);
layout->border_path = layoutValues->value(6);
layout->blockdata_path = layoutValues->value(7);
map->layout = layout;
} else {
map->layout = mapLayouts[map->layout_label];
}
QStringList *attributes = getLabelValues(parser->parseAsm(assets_text), map->attributes_label);
map->width = attributes->value(0);
map->height = attributes->value(1);
map->border_label = attributes->value(2);
map->blockdata_label = attributes->value(3);
map->tileset_primary_label = attributes->value(4);
map->tileset_secondary_label = attributes->value(5);
getTilesets(map);
loadBlockdata(map);
loadMapBorder(map);
}
void Project::readAllMapAttributes() {
mapAttributes.clear();
void Project::readAllMapLayouts() {
mapLayouts.clear();
ParseUtil *parser = new ParseUtil;
QString assets_text = readTextFile(getMapAssetsFilepath());
if (assets_text.isNull()) {
return;
}
QList<QStringList> *commands = parser->parseAsm(assets_text);
// Assume the _assets.inc file is grouped consistently in the order of:
// 1. <map_name>_MapBorder
// 2. <map_name>_MapBlockdata
// 3. <map_name>_MapAttributes
int i = 0;
while (i < commands->length()) {
// Read MapBorder assets.
QStringList borderParams = commands->value(i++);
bool isUnknownMapBorder = borderParams.value(1).startsWith("UnknownMapBorder_");
if (borderParams.value(0) != ".label" || (!borderParams.value(1).endsWith("_MapBorder") && !isUnknownMapBorder)) {
qDebug() << QString("Expected MapBorder label, but found %1").arg(borderParams.value(1));
continue;
}
QString borderLabel = borderParams.value(1);
QString mapName;
if (!isUnknownMapBorder) {
mapName = borderLabel.remove(borderLabel.length() - 10, 10);
} else {
// Unknown map name has to match the MapAttributes label.
mapName = borderLabel.replace("Border", "Attributes");
for (int i = 0; i < mapLayoutsTable.size(); i++) {
QString layoutLabel = mapLayoutsTable[i];
QStringList *layoutValues = readLayoutValues(layoutLabel);
if (layoutValues == NULL) {
return;
}
mapAttributes[mapName].insert("border_label", borderParams.value(1));
borderParams = commands->value(i++);
mapAttributes[mapName].insert("border_filepath", borderParams.value(1).replace("\"", ""));
// Read MapBlockData assets.
QStringList blockDataParams = commands->value(i++);
bool isUnknownMapBlockdata = blockDataParams.value(1).startsWith("UnknownMapBlockdata_");
if (blockDataParams.value(0) != ".label" || (!blockDataParams.value(1).endsWith("_MapBlockdata") && !isUnknownMapBlockdata)) {
qDebug() << QString("Expected MapBlockdata label, but found %1").arg(blockDataParams.value(1));
continue;
}
QString blockDataLabel = blockDataParams.value(1);
mapAttributes[mapName].insert("blockdata_label", blockDataLabel);
blockDataParams = commands->value(i++);
mapAttributes[mapName].insert("blockdata_filepath", blockDataParams.value(1).replace("\"", ""));
// Read MapAttributes assets.
i++; // skip .align
// Maps can share MapAttributes, so gather a list of them.
QStringList attributeMapLabels;
QStringList attributesParams;
QStringList* sharedAttrMaps = new QStringList;
while (i < commands->length()) {
attributesParams = commands->value(i);
if (attributesParams.value(0) != ".label") {
break;
}
QString attrLabel = attributesParams.value(1);
attributeMapLabels.append(attrLabel);
sharedAttrMaps->append(attrLabel);
i++;
}
// Apply the map attributes to each of the shared maps.
QString attrWidth = commands->value(i++).value(1);
QString attrHeight = commands->value(i++).value(1);
QString attrBorderLabel = commands->value(i++).value(1);
QString attrBlockdataLabel = commands->value(i++).value(1);
QString attrTilesetPrimary = commands->value(i++).value(1);
QString attrTilesetSecondary = commands->value(i++).value(1);
for (QString attributeMapLabel: attributeMapLabels) {
QString altMapName = attributeMapLabel;
if (!altMapName.startsWith("UnknownMapAttributes_")) {
altMapName.remove(altMapName.length() - 14, 14);
}
if (!mapAttributes.contains(altMapName)) {
mapAttributes.insert(altMapName, QMap<QString, QString>());
}
mapAttributes[altMapName].insert("attributes_label", attributeMapLabel);
mapAttributes[altMapName].insert("width", attrWidth);
mapAttributes[altMapName].insert("height", attrHeight);
mapAttributes[altMapName].insert("border_label", attrBorderLabel);
mapAttributes[altMapName].insert("blockdata_label", attrBlockdataLabel);
mapAttributes[altMapName].insert("tileset_primary", attrTilesetPrimary);
mapAttributes[altMapName].insert("tileset_secondary", attrTilesetSecondary);
if (sharedAttrMaps->length() > 1) {
mapAttributes[altMapName].insert("shared_attr_maps", sharedAttrMaps->join(":"));
}
}
MapLayout *layout = new MapLayout();
layout->name = MapLayout::getNameFromLabel(layoutLabel);
layout->label = layoutLabel;
layout->index = i;
layout->width = layoutValues->value(0);
layout->height = layoutValues->value(1);
layout->border_label = layoutValues->value(2);
layout->blockdata_label = layoutValues->value(3);
layout->tileset_primary_label = layoutValues->value(4);
layout->tileset_secondary_label = layoutValues->value(5);
layout->border_path = layoutValues->value(6);
layout->blockdata_path = layoutValues->value(7);
mapLayouts.insert(layoutLabel, layout);
}
// Deep copy
mapAttributesMaster = mapAttributes;
mapAttributesMaster.detach();
mapLayoutsMaster = mapLayouts;
mapLayoutsMaster.detach();
}
void Project::saveAllMapAttributes() {
QString text = "";
for (int i = 0; i < mapAttributesTableMaster.count(); i++) {
int mapIndex = i + 1;
QString mapName = mapAttributesTableMaster.value(mapIndex);
QMap<QString, QString> attrs = mapAttributesMaster.value(mapName);
// Find the map attributes object that contains the border data.
QMap<QString, QString> attrsWithBorder;
if (attrs.contains("border_filepath")) {
attrsWithBorder = attrs;
} else {
QStringList labels = attrs.value("shared_attr_maps").split(":");
for (QString label : labels) {
label.remove(label.length() - 14, 14);
if (mapAttributesMaster.contains(label) && mapAttributesMaster.value(label).contains("border_filepath")) {
attrsWithBorder = mapAttributesMaster.value(label);
break;
}
}
}
if (!attrsWithBorder.isEmpty()) {
text += QString("%1::\n").arg(attrsWithBorder.value("border_label"));
text += QString("\t.incbin \"%1\"\n").arg(attrsWithBorder.value("border_filepath"));
text += QString("\n");
}
// Find the map attributes object that contains the blockdata.
QMap<QString, QString> attrsWithBlockdata;
if (attrs.contains("blockdata_filepath")) {
attrsWithBlockdata = attrs;
} else {
QStringList labels = attrs["shared_attr_maps"].split(":");
for (QString label : labels) {
label.remove(label.length() - 14, 14);
if (mapAttributesMaster.contains(label) && mapAttributesMaster.value(label).contains("blockdata_filepath")) {
attrsWithBlockdata = mapAttributesMaster.value(label);
break;
}
}
}
if (!attrsWithBlockdata.isEmpty()) {
text += QString("%1::\n").arg(attrsWithBlockdata.value("blockdata_label"));
text += QString("\t.incbin \"%1\"\n").arg(attrsWithBorder.value("blockdata_filepath"));
text += QString("\n");
}
text += QString("\t.align 2\n");
if (attrs.contains("shared_attr_maps")) {
QStringList labels = attrs.value("shared_attr_maps").split(":");
for (QString label : labels) {
text += QString("%1::\n").arg(label);
}
} else {
text += QString("%1::\n").arg(attrs.value("attributes_label"));
}
text += QString("\t.4byte %1\n").arg(attrs.value("width"));
text += QString("\t.4byte %1\n").arg(attrs.value("height"));
text += QString("\t.4byte %1\n").arg(attrs.value("border_label"));
text += QString("\t.4byte %1\n").arg(attrs.value("blockdata_label"));
text += QString("\t.4byte %1\n").arg(attrs.value("tileset_primary"));
text += QString("\t.4byte %1\n").arg(attrs.value("tileset_secondary"));
void Project::saveAllMapLayouts() {
for (QString layoutName : mapLayoutsTableMaster) {
MapLayout *layout = mapLayouts.value(layoutName);
QString text = QString("%1::\n").arg(layout->border_label);
text += QString("\t.incbin \"%1\"\n").arg(layout->border_path);
text += QString("\n");
text += QString("%1::\n").arg(layout->blockdata_label);
text += QString("\t.incbin \"%1\"\n").arg(layout->blockdata_path);
text += QString("\n");
text += QString("\t.align 2\n");
text += QString("%1::\n").arg(layoutName);
text += QString("\t.4byte %1\n").arg(layout->width);
text += QString("\t.4byte %1\n").arg(layout->height);
text += QString("\t.4byte %1\n").arg(layout->border_label);
text += QString("\t.4byte %1\n").arg(layout->blockdata_label);
text += QString("\t.4byte %1\n").arg(layout->tileset_primary_label);
text += QString("\t.4byte %1\n").arg(layout->tileset_secondary_label);
text += QString("\n");
saveTextFile(getMapLayoutFilepath(layout->label), text);
}
saveTextFile(getMapAssetsFilepath(), text);
}
QString Project::getMapAssetsFilepath() {
return root + "/data/maps/_assets.inc";
QString Project::getMapLayoutFilepath(QString layoutLabel) {
return QString("%1/data/layouts/%2/layout.inc").arg(root).arg(MapLayout::getNameFromLabel(layoutLabel));
}
void Project::setNewMapAttributes(Map* map) {
map->width = "20";
map->height = "20";
map->border_label = QString("%1_MapBorder").arg(map->name);
map->blockdata_label = QString("%1_MapBlockdata").arg(map->name);
map->tileset_primary_label = "gTileset_General";
map->tileset_secondary_label = "gTileset_Petalburg";
void Project::setNewMapLayout(Map* map) {
MapLayout *layout = new MapLayout();
layout->label = QString("%1_Layout").arg(map->name);
layout->name = MapLayout::getNameFromLabel(layout->label);
layout->width = "20";
layout->height = "20";
layout->border_label = QString("%1_MapBorder").arg(map->name);
layout->border_path = QString("data/layouts/%1/border.bin").arg(map->name);
layout->blockdata_label = QString("%1_MapBlockdata").arg(map->name);
layout->blockdata_path = QString("data/layouts/%1/map.bin").arg(map->name);
layout->tileset_primary_label = "gTileset_General";
layout->tileset_secondary_label = "gTileset_Petalburg";
map->layout = layout;
map->layout_label = layout->label;
// Insert new entry into the global map attributes.
QMap<QString, QString> attrs;
attrs.insert("border_label", QString("%1_MapBorder").arg(map->name));
attrs.insert("border_filepath", QString("data/maps/%1/border.bin").arg(map->name));
attrs.insert("blockdata_label", QString("%1_MapBlockdata").arg(map->name));
attrs.insert("blockdata_filepath", QString("data/maps/%1/map.bin").arg(map->name));
attrs.insert("attributes_label", QString("%1_MapAttributes").arg(map->name));
attrs.insert("width", map->width);
attrs.insert("height", map->height);
attrs.insert("tileset_primary", map->tileset_primary_label);
attrs.insert("tileset_secondary", map->tileset_secondary_label);
mapAttributes.insert(map->name, attrs);
// Insert new entry into the global map layouts.
mapLayouts.insert(layout->label, layout);
mapLayoutsTable.append(layout->label);
}
void Project::saveMapGroupsTable() {
@ -544,7 +455,7 @@ void Project::saveMapGroupsTable() {
text += QString("\t.4byte gMapGroup%1\n").arg(i);
}
saveTextFile(root + "/data/maps/_groups.inc", text);
saveTextFile(root + "/data/maps/groups.inc", text);
}
void Project::saveMapConstantsHeader() {
@ -585,8 +496,12 @@ void Project::saveMapConstantsHeader() {
}
void Project::getTilesets(Map* map) {
map->tileset_primary = getTileset(map->tileset_primary_label);
map->tileset_secondary = getTileset(map->tileset_secondary_label);
if (map->layout->has_unsaved_changes) {
return;
}
map->layout->tileset_primary = getTileset(map->layout->tileset_primary_label);
map->layout->tileset_secondary = getTileset(map->layout->tileset_secondary_label);
}
Tileset* Project::loadTileset(QString label) {
@ -611,37 +526,13 @@ Tileset* Project::loadTileset(QString label) {
return tileset;
}
QString Project::getBlockdataPath(Map* map) {
QString text = readTextFile(getMapAssetsFilepath());
QStringList *values = getLabelValues(parseAsm(text), map->blockdata_label);
QString path;
if (!values->isEmpty()) {
path = root + "/" + values->value(0).section('"', 1, 1);
} else {
path = root + "/data/maps/" + map->name + "/map.bin";
}
return path;
}
QString Project::getMapBorderPath(Map *map) {
QString text = readTextFile(getMapAssetsFilepath());
QStringList *values = getLabelValues(parseAsm(text), map->border_label);
QString path;
if (!values->isEmpty()) {
path = root + "/" + values->value(0).section('"', 1, 1);
} else {
path = root + "/data/maps/" + map->name + "/border.bin";
}
return path;
}
void Project::loadBlockdata(Map* map) {
if (!map->isPersistedToFile) {
if (!map->isPersistedToFile || map->layout->has_unsaved_changes) {
return;
}
QString path = getBlockdataPath(map);
map->blockdata = readBlockdata(path);
QString path = QString("%1/%2").arg(root).arg(map->layout->blockdata_path);
map->layout->blockdata = readBlockdata(path);
}
void Project::setNewMapBlockdata(Map* map) {
@ -649,16 +540,16 @@ void Project::setNewMapBlockdata(Map* map) {
for (int i = 0; i < map->getWidth() * map->getHeight(); i++) {
blockdata->addBlock(qint16(0x3001));
}
map->blockdata = blockdata;
map->layout->blockdata = blockdata;
}
void Project::loadMapBorder(Map *map) {
if (!map->isPersistedToFile) {
if (!map->isPersistedToFile || map->layout->has_unsaved_changes) {
return;
}
QString path = getMapBorderPath(map);
map->border = readBlockdata(path);
QString path = QString("%1/%2").arg(root).arg(map->layout->border_path);
map->layout->border = readBlockdata(path);
}
void Project::setNewMapBorder(Map *map) {
@ -667,17 +558,17 @@ void Project::setNewMapBorder(Map *map) {
blockdata->addBlock(qint16(0x01D5));
blockdata->addBlock(qint16(0x01DC));
blockdata->addBlock(qint16(0x01DD));
map->border = blockdata;
map->layout->border = blockdata;
}
void Project::saveMapBorder(Map *map) {
QString path = getMapBorderPath(map);
writeBlockdata(path, map->border);
QString path = QString("%1/%2").arg(root).arg(map->layout->border_path);
writeBlockdata(path, map->layout->border);
}
void Project::saveBlockdata(Map* map) {
QString path = getBlockdataPath(map);
writeBlockdata(path, map->blockdata);
QString path = QString("%1/%2").arg(root).arg(map->layout->blockdata_path);
writeBlockdata(path, map->layout->blockdata);
map->history.save();
}
@ -686,6 +577,8 @@ void Project::writeBlockdata(QString path, Blockdata *blockdata) {
if (file.open(QIODevice::WriteOnly)) {
QByteArray data = blockdata->serialize();
file.write(data);
} else {
qDebug() << "Failed to open blockdata file for writing: '" << path << "'";
}
}
@ -706,26 +599,35 @@ void Project::saveMap(Map *map) {
qDebug() << "Error: failed to create directory for new map. " << newMapDataDir;
}
// TODO: In the future, these files needs more structure to allow for proper parsing/saving.
// Create file data/scripts/maps/<map_name>.inc
QString text = QString("%1_MapScripts::\n\t.byte 0\n").arg(map->name);
saveTextFile(root + "/data/scripts/maps/" + map->name + ".inc", text);
QString newLayoutDir = QString(root + "/data/layouts/%1").arg(map->name);
if (!QDir::root().mkdir(newLayoutDir)) {
qDebug() << "Error: failed to create directory for new layout. " << newLayoutDir;
}
// Create file data/text/maps/<map_name>.inc
saveTextFile(root + "/data/text/maps/" + map->name + ".inc", "\n");
// TODO: In the future, these files needs more structure to allow for proper parsing/saving.
// Create file data/maps/<map_name>/scripts.inc
QString text = QString("%1_MapScripts::\n\t.byte 0\n").arg(map->name);
saveTextFile(root + "/data/maps/" + map->name + "/scripts.inc", text);
// Create file data/maps/<map_name>/text.inc
saveTextFile(root + "/data/maps/" + map->name + "/text.inc", "\n");
// Simply append to data/event_scripts.s.
text = QString("\n\t.include \"data/scripts/maps/%1.inc\"\n").arg(map->name);
text += QString("\t.include \"data/text/maps/%1.inc\"\n").arg(map->name);
text = QString("\n\t.include \"data/maps/%1/scripts.inc\"\n").arg(map->name);
text += QString("\t.include \"data/maps/%1/text.inc\"\n").arg(map->name);
appendTextFile(root + "/data/event_scripts.s", text);
// Simply append to data/map_events.s.
text = QString("\n\t.include \"data/maps/events/%1.inc\"\n").arg(map->name);
text = QString("\n\t.include \"data/maps/%1/events.inc\"\n").arg(map->name);
appendTextFile(root + "/data/map_events.s", text);
// Simply append to data/maps/headers.inc.
text = QString("\t.include \"data/maps/%1/header.inc\"\n").arg(map->name);
appendTextFile(root + "/data/maps/headers.inc", text);
// Simply append to data/layouts.inc.
text = QString("\t.include \"data/layouts/%1/layout.inc\"\n").arg(map->layout->name);
appendTextFile(root + "/data/layouts.inc", text);
}
saveMapBorder(map);
@ -735,25 +637,27 @@ void Project::saveMap(Map *map) {
saveMapEvents(map);
// Update global data structures with current map data.
updateMapAttributes(map);
updateMapLayout(map);
map->isPersistedToFile = true;
map->layout->has_unsaved_changes = false;
}
void Project::updateMapAttributes(Map* map) {
if (!mapAttributesTableMaster.contains(map->index.toInt())) {
mapAttributesTableMaster.insert(map->index.toInt(), map->name);
void Project::updateMapLayout(Map* map) {
if (!mapLayoutsTableMaster.contains(map->layout_label)) {
mapLayoutsTableMaster.append(map->layout_label);
}
// Deep copy
QMap<QString, QString> attrs = mapAttributes.value(map->name);
attrs.detach();
mapAttributesMaster.insert(map->name, attrs);
MapLayout *layout = mapLayouts.value(map->layout_label);
MapLayout *newLayout = new MapLayout();
*newLayout = *layout;
mapLayoutsMaster.insert(map->layout_label, newLayout);
}
void Project::saveAllDataStructures() {
saveMapAttributesTable();
saveAllMapAttributes();
saveMapLayoutsTable();
saveAllMapLayouts();
saveMapGroupsTable();
saveMapConstantsHeader();
saveMapsWithConnections();
@ -828,7 +732,6 @@ void Project::loadTilesetAssets(Tileset* tileset) {
tileset->tiles = tiles;
// metatiles
//qDebug() << metatiles_path;
QFile metatiles_file(metatiles_path);
if (metatiles_file.open(QIODevice::ReadOnly)) {
QByteArray data = metatiles_file.readAll();
@ -895,9 +798,9 @@ void Project::loadTilesetAssets(Tileset* tileset) {
for (int j = 0; j < 16; j++) {
palette.append(qRgb(j * 16, j * 16, j * 16));
}
qDebug() << QString("Could not open '%1'").arg(path);
qDebug() << QString("Could not open palette path '%1'").arg(path);
}
//qDebug() << path;
palettes->append(palette);
}
tileset->palettes = palettes;
@ -905,7 +808,6 @@ void Project::loadTilesetAssets(Tileset* tileset) {
Blockdata* Project::readBlockdata(QString path) {
Blockdata *blockdata = new Blockdata;
//qDebug() << path;
QFile file(path);
if (file.open(QIODevice::ReadOnly)) {
QByteArray data = file.readAll();
@ -913,7 +815,10 @@ Blockdata* Project::readBlockdata(QString path) {
uint16_t word = (data[i] & 0xff) + ((data[i + 1] & 0xff) << 8);
blockdata->addBlock(word);
}
} else {
qDebug() << "Failed to open blockdata path '" << path << "'";
}
return blockdata;
}
@ -976,7 +881,7 @@ void Project::deleteFile(QString path) {
}
void Project::readMapGroups() {
QString text = readTextFile(root + "/data/maps/_groups.inc");
QString text = readTextFile(root + "/data/maps/groups.inc");
if (text.isNull()) {
return;
}
@ -1039,9 +944,6 @@ void Project::readMapGroups() {
}
Map* Project::addNewMapToGroup(QString mapName, int groupNum) {
int mapIndex = mapAttributesTable.count() + 1;
mapAttributesTable.insert(mapIndex, mapName);
// Setup new map in memory, but don't write to file until map is actually saved later.
mapNames->append(mapName);
map_groups->insert(mapName, groupNum);
@ -1052,8 +954,8 @@ Map* Project::addNewMapToGroup(QString mapName, int groupNum) {
map->setName(mapName);
mapConstantsToMapNames->insert(map->constantName, map->name);
mapNamesToMapConstants->insert(map->name, map->constantName);
setNewMapHeader(map, mapIndex);
setNewMapAttributes(map);
setNewMapHeader(map, mapLayoutsTable.size() + 1);
setNewMapLayout(map);
getTilesets(map);
setNewMapBlockdata(map);
setNewMapBorder(map);
@ -1283,7 +1185,7 @@ void Project::loadEventPixmaps(QList<Event*> objects) {
}
void Project::saveMapEvents(Map *map) {
QString path = root + QString("/data/maps/events/%1.inc").arg(map->name);
QString path = root + QString("/data/maps/%1/events.inc").arg(map->name);
QString text = "";
if (map->events["object"].length() > 0) {
@ -1397,7 +1299,7 @@ void Project::readMapEvents(Map *map) {
}
// lazy
QString path = root + QString("/data/maps/events/%1.inc").arg(map->name);
QString path = root + QString("/data/maps/%1/events.inc").arg(map->name);
QString text = readTextFile(path);
if (text.isNull()) {
return;

View file

@ -19,10 +19,10 @@ public:
QStringList *mapNames = NULL;
QMap<QString, QString>* mapConstantsToMapNames;
QMap<QString, QString>* mapNamesToMapConstants;
QMap<int, QString> mapAttributesTable;
QMap<int, QString> mapAttributesTableMaster;
QMap<QString, QMap<QString, QString>> mapAttributes;
QMap<QString, QMap<QString, QString>> mapAttributesMaster;
QList<QString> mapLayoutsTable;
QList<QString> mapLayoutsTableMaster;
QMap<QString, MapLayout*> mapLayouts;
QMap<QString, MapLayout*> mapLayoutsMaster;
QStringList *itemNames = NULL;
QStringList *flagNames = NULL;
QStringList *varNames = NULL;
@ -52,21 +52,21 @@ public:
QList<QStringList>* getLabelMacros(QList<QStringList>*, QString);
QStringList* getLabelValues(QList<QStringList>*, QString);
void readMapHeader(Map*);
void readMapAttributesTable();
void readAllMapAttributes();
void readMapAttributes(Map*);
void readMapLayoutsTable();
void readAllMapLayouts();
QStringList* readLayoutValues(QString layoutName);
void readMapLayout(Map*);
void readMapsWithConnections();
void getTilesets(Map*);
void loadTilesetAssets(Tileset*);
QString getBlockdataPath(Map*);
void saveBlockdata(Map*);
void saveMapBorder(Map*);
void writeBlockdata(QString, Blockdata*);
void saveAllMaps();
void saveMap(Map*);
void saveAllDataStructures();
void saveAllMapAttributes();
void saveAllMapLayouts();
void saveMapGroupsTable();
void saveMapConstantsHeader();
@ -89,7 +89,6 @@ public:
void loadMapConnections(Map *map);
void loadMapBorder(Map *map);
QString getMapBorderPath(Map *map);
void saveMapEvents(Map *map);
@ -97,19 +96,19 @@ public:
QString readCIncbin(QString text, QString label);
QMap<QString, int> readCDefines(QString text, QStringList prefixes);
private:
QString getMapAttributesTableFilepath();
QString getMapAssetsFilepath();
QString getMapLayoutsTableFilepath();
QString getMapLayoutFilepath(QString);
void saveMapHeader(Map*);
void saveMapConnections(Map*);
void updateMapsWithConnections(Map*);
void saveMapsWithConnections();
void saveMapAttributesTable();
void updateMapAttributes(Map* map);
void saveMapLayoutsTable();
void updateMapLayout(Map*);
void readCDefinesSorted(QString, QStringList, QStringList*);
void readCDefinesSorted(QString, QStringList, QStringList*, QString, int);
void setNewMapHeader(Map* map, int mapIndex);
void setNewMapAttributes(Map* map);
void setNewMapLayout(Map* map);
void setNewMapBlockdata(Map* map);
void setNewMapBorder(Map *map);
void setNewMapEvents(Map *map);