mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-25 18:16:57 -05:00
Group AdvanceMap parsing together, fix its tileset defaults
This commit is contained in:
@@ -2931,7 +2931,7 @@
|
||||
<addaction name="actionTileset_Editor"/>
|
||||
<addaction name="actionRegion_Map_Editor"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionImport_Map_from_Advance_Map_1_92"/>
|
||||
<addaction name="actionImport_Layout_from_Advance_Map_1_92"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionOpen_Project_in_Text_Editor"/>
|
||||
</widget>
|
||||
@@ -3222,9 +3222,9 @@
|
||||
<string>Open Config Folder</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionImport_Map_from_Advance_Map_1_92">
|
||||
<action name="actionImport_Layout_from_Advance_Map_1_92">
|
||||
<property name="text">
|
||||
<string>Import Map from Advance Map 1.92...</string>
|
||||
<string>Import Layout from Advance Map 1.92...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionProject_Settings">
|
||||
|
||||
18
include/core/advancemapparser.h
Normal file
18
include/core/advancemapparser.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef ADVANCEMAPPARSER_H
|
||||
#define ADVANCEMAPPARSER_H
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QRgb>
|
||||
|
||||
class Project;
|
||||
class Layout;
|
||||
class Metatile;
|
||||
|
||||
namespace AdvanceMapParser {
|
||||
Layout *parseLayout(const QString &filepath, bool *error, const Project *project);
|
||||
QList<Metatile*> parseMetatiles(const QString &filepath, bool *error, bool primaryTileset);
|
||||
QList<QRgb> parsePalette(const QString &filepath, bool *error);
|
||||
};
|
||||
|
||||
#endif // ADVANCEMAPPARSER_H
|
||||
@@ -1,16 +0,0 @@
|
||||
#ifndef MAPPARSER_H
|
||||
#define MAPPARSER_H
|
||||
|
||||
#include "maplayout.h"
|
||||
#include "project.h"
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
class MapParser
|
||||
{
|
||||
public:
|
||||
MapParser();
|
||||
Layout *parse(QString filepath, bool *error, Project *project);
|
||||
};
|
||||
|
||||
#endif // MAPPARSER_H
|
||||
@@ -1,12 +0,0 @@
|
||||
#pragma once
|
||||
#ifndef METATILEPARSER_H
|
||||
#define METATILEPARSER_H
|
||||
|
||||
#include "metatile.h"
|
||||
#include <QList>
|
||||
|
||||
namespace MetatileParser {
|
||||
QList<Metatile*> parse(QString filepath, bool *error, bool primaryTileset);
|
||||
}
|
||||
|
||||
#endif // METATILEPARSER_H
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "heallocation.h"
|
||||
#include "log.h"
|
||||
#include "orderedjson.h"
|
||||
#include "orderedmap.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
@@ -57,7 +58,7 @@ public:
|
||||
QMap<QString, int> readCDefinesByRegex(const QString &filename, const QStringList ®exList);
|
||||
QMap<QString, int> readCDefinesByName(const QString &filename, const QStringList &names);
|
||||
QStringList readCDefineNames(const QString &filename, const QStringList ®exList);
|
||||
QMap<QString, QHash<QString, QString>> readCStructs(const QString &, const QString & = "", const QHash<int, QString> = { });
|
||||
tsl::ordered_map<QString, QHash<QString, QString>> readCStructs(const QString &, const QString & = "", const QHash<int, QString>& = {});
|
||||
QList<QStringList> getLabelMacros(const QList<QStringList>&, const QString&);
|
||||
QStringList getLabelValues(const QList<QStringList>&, const QString&);
|
||||
bool tryParseJsonFile(QJsonDocument *out, const QString &filepath);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "array_value.h"
|
||||
#include "define_statement.h"
|
||||
#include "lexer.h"
|
||||
#include "orderedmap.h"
|
||||
|
||||
namespace fex
|
||||
{
|
||||
@@ -19,9 +20,9 @@ namespace fex
|
||||
|
||||
std::vector<DefineStatement> Parse(std::vector<Token> tokens);
|
||||
std::vector<Array> ParseTopLevelArrays(std::vector<Token> tokens);
|
||||
std::map<std::string, ArrayValue> ParseTopLevelObjects(std::vector<Token> tokens);
|
||||
tsl::ordered_map<std::string, ArrayValue> ParseTopLevelObjects(std::vector<Token> tokens);
|
||||
|
||||
std::map<std::string, int> ReadDefines(const std::string &filename, std::vector<std::string> matching);
|
||||
tsl::ordered_map<std::string, int> ReadDefines(const std::string &filename, std::vector<std::string> matching);
|
||||
|
||||
private:
|
||||
int EvaluateExpression(std::vector<Token> tokens);
|
||||
|
||||
@@ -194,7 +194,6 @@ private slots:
|
||||
void onNewMapGroupCreated(const QString &groupName);
|
||||
void onNewLayoutCreated(Layout *layout);
|
||||
void onMapLoaded(Map *map);
|
||||
void importMapFromAdvanceMap1_92();
|
||||
void onMapRulerStatusChanged(const QString &);
|
||||
void applyUserShortcuts();
|
||||
void markMapEdited();
|
||||
@@ -238,7 +237,7 @@ private slots:
|
||||
void on_action_Export_Map_Image_triggered();
|
||||
void on_actionExport_Stitched_Map_Image_triggered();
|
||||
void on_actionExport_Map_Timelapse_Image_triggered();
|
||||
void on_actionImport_Map_from_Advance_Map_1_92_triggered();
|
||||
void on_actionImport_Layout_from_Advance_Map_1_92_triggered();
|
||||
|
||||
void on_pushButton_AddConnection_clicked();
|
||||
void on_button_OpenDiveMap_clicked();
|
||||
|
||||
@@ -189,7 +189,7 @@ public:
|
||||
void saveTilesetMetatiles(Tileset*);
|
||||
void saveTilesetTilesImage(Tileset*);
|
||||
void saveTilesetPalettes(Tileset*);
|
||||
void appendTilesetLabel(QString label, QString isSecondaryStr);
|
||||
void appendTilesetLabel(const QString &label, const QString &isSecondaryStr);
|
||||
bool readTilesetLabels();
|
||||
bool readTilesetMetatileLabels();
|
||||
bool readRegionMapSections();
|
||||
|
||||
@@ -20,7 +20,7 @@ class NewLayoutDialog : public QDialog
|
||||
public:
|
||||
explicit NewLayoutDialog(QWidget *parent = nullptr, Project *project = nullptr);
|
||||
~NewLayoutDialog();
|
||||
void init(Layout *);
|
||||
void copyFrom(const Layout &);
|
||||
void accept() override;
|
||||
|
||||
signals:
|
||||
@@ -39,7 +39,6 @@ private:
|
||||
|
||||
void saveSettings();
|
||||
bool isExistingLayout() const;
|
||||
void useLayoutSettings(Layout *mapLayout);
|
||||
|
||||
private slots:
|
||||
//void on_comboBox_Layout_currentTextChanged(const QString &text);//TODO
|
||||
|
||||
10
porymap.pro
10
porymap.pro
@@ -21,7 +21,8 @@ QMAKE_TARGET_BUNDLE_PREFIX = com.pret
|
||||
VERSION = 5.4.1
|
||||
DEFINES += PORYMAP_VERSION=\\\"$$VERSION\\\"
|
||||
|
||||
SOURCES += src/core/block.cpp \
|
||||
SOURCES += src/core/advancemapparser.cpp \
|
||||
src/core/block.cpp \
|
||||
src/core/bitpacker.cpp \
|
||||
src/core/blockdata.cpp \
|
||||
src/core/events.cpp \
|
||||
@@ -32,9 +33,7 @@ SOURCES += src/core/block.cpp \
|
||||
src/core/mapconnection.cpp \
|
||||
src/core/mapheader.cpp \
|
||||
src/core/maplayout.cpp \
|
||||
src/core/mapparser.cpp \
|
||||
src/core/metatile.cpp \
|
||||
src/core/metatileparser.cpp \
|
||||
src/core/network.cpp \
|
||||
src/core/paletteutil.cpp \
|
||||
src/core/parseutil.cpp \
|
||||
@@ -127,7 +126,8 @@ SOURCES += src/core/block.cpp \
|
||||
src/ui/updatepromoter.cpp \
|
||||
src/ui/wildmonchart.cpp
|
||||
|
||||
HEADERS += include/core/block.h \
|
||||
HEADERS += include/core/advancemapparser.h \
|
||||
include/core/block.h \
|
||||
include/core/bitpacker.h \
|
||||
include/core/blockdata.h \
|
||||
include/core/events.h \
|
||||
@@ -139,9 +139,7 @@ HEADERS += include/core/block.h \
|
||||
include/core/mapconnection.h \
|
||||
include/core/mapheader.h \
|
||||
include/core/maplayout.h \
|
||||
include/core/mapparser.h \
|
||||
include/core/metatile.h \
|
||||
include/core/metatileparser.h \
|
||||
include/core/network.h \
|
||||
include/core/paletteutil.h \
|
||||
include/core/parseutil.h \
|
||||
|
||||
217
src/core/advancemapparser.cpp
Normal file
217
src/core/advancemapparser.cpp
Normal file
@@ -0,0 +1,217 @@
|
||||
#include "advancemapparser.h"
|
||||
#include "log.h"
|
||||
#include "project.h"
|
||||
#include "maplayout.h"
|
||||
|
||||
Layout *AdvanceMapParser::parseLayout(const QString &filepath, bool *error, const Project *project)
|
||||
{
|
||||
QFile file(filepath);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
*error = true;
|
||||
logError(QString("Could not open Advance Map 1.92 Map .map file '%1': ").arg(filepath) + file.errorString());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QByteArray in = file.readAll();
|
||||
file.close();
|
||||
|
||||
if (in.length() < 20 || in.length() % 2 != 0) {
|
||||
*error = true;
|
||||
logError(QString("Advance Map 1.92 Map .map file '%1' is an unexpected size.").arg(filepath));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int borderWidth = static_cast<unsigned char>(in.at(16)); // 0 in RSE .map files
|
||||
int borderHeight = static_cast<unsigned char>(in.at(17)); // 0 in RSE .map files
|
||||
int numBorderTiles = borderWidth * borderHeight; // 0 if RSE
|
||||
|
||||
int mapDataOffset = 20 + (numBorderTiles * 2); // FRLG .map files store border metatile data after the header
|
||||
int mapWidth = static_cast<unsigned char>(in.at(0)) |
|
||||
(static_cast<unsigned char>(in.at(1)) << 8) |
|
||||
(static_cast<unsigned char>(in.at(2)) << 16) |
|
||||
(static_cast<unsigned char>(in.at(3)) << 24);
|
||||
int mapHeight = static_cast<unsigned char>(in.at(4)) |
|
||||
(static_cast<unsigned char>(in.at(5)) << 8) |
|
||||
(static_cast<unsigned char>(in.at(6)) << 16) |
|
||||
(static_cast<unsigned char>(in.at(7)) << 24);
|
||||
int mapPrimaryTilesetNum = static_cast<unsigned char>(in.at(8)) |
|
||||
(static_cast<unsigned char>(in.at(9)) << 8) |
|
||||
(static_cast<unsigned char>(in.at(10)) << 16) |
|
||||
(static_cast<unsigned char>(in.at(11)) << 24);
|
||||
int mapSecondaryTilesetNum = static_cast<unsigned char>(in.at(12)) |
|
||||
(static_cast<unsigned char>(in.at(13)) << 8) |
|
||||
(static_cast<unsigned char>(in.at(14)) << 16) |
|
||||
(static_cast<unsigned char>(in.at(15)) << 24);
|
||||
|
||||
int numMetatiles = mapWidth * mapHeight;
|
||||
int expectedFileSize = 20 + (numBorderTiles * 2) + (numMetatiles * 2);
|
||||
if (in.length() != expectedFileSize) {
|
||||
*error = true;
|
||||
logError(QString(".map file is an unexpected size. Expected %1 bytes, but it has %2 bytes.").arg(expectedFileSize).arg(in.length()));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Blockdata blockdata;
|
||||
for (int i = mapDataOffset; (i + 1) < in.length(); i += 2) {
|
||||
uint16_t word = static_cast<uint16_t>((in[i] & 0xff) + ((in[i + 1] & 0xff) << 8));
|
||||
blockdata.append(word);
|
||||
}
|
||||
|
||||
Blockdata border;
|
||||
if (numBorderTiles != 0) {
|
||||
for (int i = 20; (i + 1) < mapDataOffset; i += 2) {
|
||||
uint16_t word = static_cast<uint16_t>((in[i] & 0xff) + ((in[i + 1] & 0xff) << 8));
|
||||
border.append(word);
|
||||
}
|
||||
}
|
||||
|
||||
Layout *mapLayout = new Layout();
|
||||
mapLayout->width = mapWidth;
|
||||
mapLayout->height = mapHeight;
|
||||
mapLayout->border_width = (borderWidth == 0) ? DEFAULT_BORDER_WIDTH : borderWidth;
|
||||
mapLayout->border_height = (borderHeight == 0) ? DEFAULT_BORDER_HEIGHT : borderHeight;
|
||||
|
||||
const QList<QString> tilesets = project->tilesetLabelsOrdered;
|
||||
|
||||
if (mapPrimaryTilesetNum > tilesets.size())
|
||||
mapLayout->tileset_primary_label = project->getDefaultPrimaryTilesetLabel();
|
||||
else
|
||||
mapLayout->tileset_primary_label = tilesets.at(mapPrimaryTilesetNum);
|
||||
|
||||
if (mapSecondaryTilesetNum > tilesets.size())
|
||||
mapLayout->tileset_secondary_label = project->getDefaultSecondaryTilesetLabel();
|
||||
else
|
||||
mapLayout->tileset_secondary_label = tilesets.at(mapSecondaryTilesetNum);
|
||||
|
||||
mapLayout->blockdata = blockdata;
|
||||
|
||||
if (!border.isEmpty()) {
|
||||
mapLayout->border = border;
|
||||
}
|
||||
|
||||
return mapLayout;
|
||||
}
|
||||
|
||||
QList<Metatile*> AdvanceMapParser::parseMetatiles(const QString &filepath, bool *error, bool primaryTileset)
|
||||
{
|
||||
QFile file(filepath);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
*error = true;
|
||||
logError(QString("Could not open Advance Map 1.92 Metatile .bvd file '%1': ").arg(filepath) + file.errorString());
|
||||
return { };
|
||||
}
|
||||
|
||||
QByteArray in = file.readAll();
|
||||
file.close();
|
||||
|
||||
if (in.length() < 9 || in.length() % 2 != 0) {
|
||||
*error = true;
|
||||
logError(QString("Advance Map 1.92 Metatile .bvd file '%1' is an unexpected size.").arg(filepath));
|
||||
return { };
|
||||
}
|
||||
|
||||
int projIdOffset = in.length() - 4;
|
||||
int metatileSize = 16;
|
||||
BaseGameVersion version;
|
||||
if (in.at(projIdOffset + 0) == 'R'
|
||||
&& in.at(projIdOffset + 1) == 'S'
|
||||
&& in.at(projIdOffset + 2) == 'E'
|
||||
&& in.at(projIdOffset + 3) == ' ') {
|
||||
// ruby and emerald are handled equally here.
|
||||
version = BaseGameVersion::pokeemerald;
|
||||
} else if (in.at(projIdOffset + 0) == 'F'
|
||||
&& in.at(projIdOffset + 1) == 'R'
|
||||
&& in.at(projIdOffset + 2) == 'L'
|
||||
&& in.at(projIdOffset + 3) == 'G') {
|
||||
version = BaseGameVersion::pokefirered;
|
||||
} else {
|
||||
*error = true;
|
||||
logError(QString("Detected unsupported game type from .bvd file. Last 4 bytes of file must be 'RSE ' or 'FRLG'."));
|
||||
return { };
|
||||
}
|
||||
|
||||
int attrSize = Metatile::getDefaultAttributesSize(version);
|
||||
int maxMetatiles = primaryTileset ? Project::getNumMetatilesPrimary() : Project::getNumMetatilesTotal() - Project::getNumMetatilesPrimary();
|
||||
int numMetatiles = static_cast<unsigned char>(in.at(0)) |
|
||||
(static_cast<unsigned char>(in.at(1)) << 8) |
|
||||
(static_cast<unsigned char>(in.at(2)) << 16) |
|
||||
(static_cast<unsigned char>(in.at(3)) << 24);
|
||||
if (numMetatiles > maxMetatiles) {
|
||||
*error = true;
|
||||
logError(QString(".bvd file contains data for %1 metatiles, but the maximum number of metatiles is %2.").arg(numMetatiles).arg(maxMetatiles));
|
||||
return { };
|
||||
}
|
||||
if (numMetatiles < 1) {
|
||||
*error = true;
|
||||
logError(QString(".bvd file contains no data for metatiles."));
|
||||
return { };
|
||||
}
|
||||
|
||||
int expectedFileSize = 4 + (metatileSize * numMetatiles) + (attrSize * numMetatiles) + 4;
|
||||
if (in.length() != expectedFileSize) {
|
||||
*error = true;
|
||||
logError(QString(".bvd file is an unexpected size. Expected %1 bytes, but it has %2 bytes.").arg(expectedFileSize).arg(in.length()));
|
||||
return { };
|
||||
}
|
||||
|
||||
QList<Metatile*> metatiles;
|
||||
for (int i = 0; i < numMetatiles; i++) {
|
||||
Metatile *metatile = new Metatile();
|
||||
QList<Tile> tiles;
|
||||
for (int j = 0; j < 8; j++) {
|
||||
int metatileOffset = 4 + i * metatileSize + j * 2;
|
||||
Tile tile(static_cast<uint16_t>(
|
||||
static_cast<unsigned char>(in.at(metatileOffset)) |
|
||||
(static_cast<unsigned char>(in.at(metatileOffset + 1)) << 8)));
|
||||
tiles.append(tile);
|
||||
}
|
||||
|
||||
// AdvanceMap .bvd files only contain 8 tiles of data per metatile.
|
||||
// If the user has triple-layer metatiles enabled we need to fill the remaining 4 tiles ourselves.
|
||||
if (projectConfig.tripleLayerMetatilesEnabled) {
|
||||
Tile tile = Tile();
|
||||
for (int j = 0; j < 4; j++)
|
||||
tiles.append(tile);
|
||||
}
|
||||
|
||||
int attrOffset = 4 + (numMetatiles * metatileSize) + (i * attrSize);
|
||||
uint32_t attributes = 0;
|
||||
for (int j = 0; j < attrSize; j++)
|
||||
attributes |= static_cast<unsigned char>(in.at(attrOffset + j)) << (8 * j);
|
||||
metatile->setAttributes(attributes, version);
|
||||
metatile->tiles = tiles;
|
||||
metatiles.append(metatile);
|
||||
}
|
||||
|
||||
return metatiles;
|
||||
}
|
||||
|
||||
QList<QRgb> AdvanceMapParser::parsePalette(const QString &filepath, bool *error) {
|
||||
QFile file(filepath);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
*error = true;
|
||||
logError(QString("Could not open Advance Map 1.92 palette file '%1': ").arg(filepath) + file.errorString());
|
||||
return QList<QRgb>();
|
||||
}
|
||||
|
||||
QByteArray in = file.readAll();
|
||||
file.close();
|
||||
|
||||
if (in.length() % 4 != 0) {
|
||||
*error = true;
|
||||
logError(QString("Advance Map 1.92 palette file '%1' had an unexpected format. File's length must be a multiple of 4, but the length is %2.").arg(filepath).arg(in.length()));
|
||||
return QList<QRgb>();
|
||||
}
|
||||
|
||||
QList<QRgb> palette;
|
||||
int i = 0;
|
||||
while (i < in.length()) {
|
||||
unsigned char red = qMin(qMax(static_cast<unsigned char>(in.at(i + 0)), 0u), 255u);
|
||||
unsigned char green = qMin(qMax(static_cast<unsigned char>(in.at(i + 1)), 0u), 255u);
|
||||
unsigned char blue = qMin(qMax(static_cast<unsigned char>(in.at(i + 2)), 0u), 255u);
|
||||
palette.append(qRgb(red, green, blue));
|
||||
i += 4;
|
||||
}
|
||||
|
||||
return palette;
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
#include "mapparser.h"
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "project.h"
|
||||
|
||||
MapParser::MapParser()
|
||||
{
|
||||
}
|
||||
|
||||
Layout *MapParser::parse(QString filepath, bool *error, Project *project)
|
||||
{
|
||||
QFile file(filepath);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
*error = true;
|
||||
logError(QString("Could not open Advance Map 1.92 Map .map file '%1': ").arg(filepath) + file.errorString());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QByteArray in = file.readAll();
|
||||
file.close();
|
||||
|
||||
if (in.length() < 20 || in.length() % 2 != 0) {
|
||||
*error = true;
|
||||
logError(QString("Advance Map 1.92 Map .map file '%1' is an unexpected size.").arg(filepath));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int borderWidth = static_cast<unsigned char>(in.at(16)); // 0 in RSE .map files
|
||||
int borderHeight = static_cast<unsigned char>(in.at(17)); // 0 in RSE .map files
|
||||
int numBorderTiles = borderWidth * borderHeight; // 0 if RSE
|
||||
|
||||
int mapDataOffset = 20 + (numBorderTiles * 2); // FRLG .map files store border metatile data after the header
|
||||
int mapWidth = static_cast<unsigned char>(in.at(0)) |
|
||||
(static_cast<unsigned char>(in.at(1)) << 8) |
|
||||
(static_cast<unsigned char>(in.at(2)) << 16) |
|
||||
(static_cast<unsigned char>(in.at(3)) << 24);
|
||||
int mapHeight = static_cast<unsigned char>(in.at(4)) |
|
||||
(static_cast<unsigned char>(in.at(5)) << 8) |
|
||||
(static_cast<unsigned char>(in.at(6)) << 16) |
|
||||
(static_cast<unsigned char>(in.at(7)) << 24);
|
||||
int mapPrimaryTilesetNum = static_cast<unsigned char>(in.at(8)) |
|
||||
(static_cast<unsigned char>(in.at(9)) << 8) |
|
||||
(static_cast<unsigned char>(in.at(10)) << 16) |
|
||||
(static_cast<unsigned char>(in.at(11)) << 24);
|
||||
int mapSecondaryTilesetNum = static_cast<unsigned char>(in.at(12)) |
|
||||
(static_cast<unsigned char>(in.at(13)) << 8) |
|
||||
(static_cast<unsigned char>(in.at(14)) << 16) |
|
||||
(static_cast<unsigned char>(in.at(15)) << 24);
|
||||
|
||||
int numMetatiles = mapWidth * mapHeight;
|
||||
int expectedFileSize = 20 + (numBorderTiles * 2) + (numMetatiles * 2);
|
||||
if (in.length() != expectedFileSize) {
|
||||
*error = true;
|
||||
logError(QString(".map file is an unexpected size. Expected %1 bytes, but it has %2 bytes.").arg(expectedFileSize).arg(in.length()));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Blockdata blockdata;
|
||||
for (int i = mapDataOffset; (i + 1) < in.length(); i += 2) {
|
||||
uint16_t word = static_cast<uint16_t>((in[i] & 0xff) + ((in[i + 1] & 0xff) << 8));
|
||||
blockdata.append(word);
|
||||
}
|
||||
|
||||
Blockdata border;
|
||||
if (numBorderTiles != 0) {
|
||||
for (int i = 20; (i + 1) < mapDataOffset; i += 2) {
|
||||
uint16_t word = static_cast<uint16_t>((in[i] & 0xff) + ((in[i + 1] & 0xff) << 8));
|
||||
border.append(word);
|
||||
}
|
||||
}
|
||||
|
||||
Layout *mapLayout = new Layout();
|
||||
mapLayout->width = mapWidth;
|
||||
mapLayout->height = mapHeight;
|
||||
mapLayout->border_width = (borderWidth == 0) ? DEFAULT_BORDER_WIDTH : borderWidth;
|
||||
mapLayout->border_height = (borderHeight == 0) ? DEFAULT_BORDER_HEIGHT : borderHeight;
|
||||
|
||||
QList<QString> tilesets = project->tilesetLabelsOrdered;
|
||||
|
||||
if (mapPrimaryTilesetNum > tilesets.size())
|
||||
mapLayout->tileset_primary_label = tilesets.at(0);
|
||||
else
|
||||
mapLayout->tileset_primary_label = tilesets.at(mapPrimaryTilesetNum);
|
||||
|
||||
if (mapSecondaryTilesetNum > tilesets.size())
|
||||
mapLayout->tileset_secondary_label = tilesets.at(1);
|
||||
else
|
||||
mapLayout->tileset_secondary_label = tilesets.at(mapSecondaryTilesetNum);
|
||||
|
||||
mapLayout->blockdata = blockdata;
|
||||
|
||||
if (!border.isEmpty()) {
|
||||
mapLayout->border = border;
|
||||
}
|
||||
|
||||
return mapLayout;
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
#include "metatileparser.h"
|
||||
#include "config.h"
|
||||
#include "log.h"
|
||||
#include "project.h"
|
||||
#include <QString>
|
||||
|
||||
QList<Metatile*> MetatileParser::parse(QString filepath, bool *error, bool primaryTileset)
|
||||
{
|
||||
QFile file(filepath);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
*error = true;
|
||||
logError(QString("Could not open Advance Map 1.92 Metatile .bvd file '%1': ").arg(filepath) + file.errorString());
|
||||
return { };
|
||||
}
|
||||
|
||||
QByteArray in = file.readAll();
|
||||
file.close();
|
||||
|
||||
if (in.length() < 9 || in.length() % 2 != 0) {
|
||||
*error = true;
|
||||
logError(QString("Advance Map 1.92 Metatile .bvd file '%1' is an unexpected size.").arg(filepath));
|
||||
return { };
|
||||
}
|
||||
|
||||
int projIdOffset = in.length() - 4;
|
||||
int metatileSize = 16;
|
||||
BaseGameVersion version;
|
||||
if (in.at(projIdOffset + 0) == 'R'
|
||||
&& in.at(projIdOffset + 1) == 'S'
|
||||
&& in.at(projIdOffset + 2) == 'E'
|
||||
&& in.at(projIdOffset + 3) == ' ') {
|
||||
// ruby and emerald are handled equally here.
|
||||
version = BaseGameVersion::pokeemerald;
|
||||
} else if (in.at(projIdOffset + 0) == 'F'
|
||||
&& in.at(projIdOffset + 1) == 'R'
|
||||
&& in.at(projIdOffset + 2) == 'L'
|
||||
&& in.at(projIdOffset + 3) == 'G') {
|
||||
version = BaseGameVersion::pokefirered;
|
||||
} else {
|
||||
*error = true;
|
||||
logError(QString("Detected unsupported game type from .bvd file. Last 4 bytes of file must be 'RSE ' or 'FRLG'."));
|
||||
return { };
|
||||
}
|
||||
|
||||
int attrSize = Metatile::getDefaultAttributesSize(version);
|
||||
int maxMetatiles = primaryTileset ? Project::getNumMetatilesPrimary() : Project::getNumMetatilesTotal() - Project::getNumMetatilesPrimary();
|
||||
int numMetatiles = static_cast<unsigned char>(in.at(0)) |
|
||||
(static_cast<unsigned char>(in.at(1)) << 8) |
|
||||
(static_cast<unsigned char>(in.at(2)) << 16) |
|
||||
(static_cast<unsigned char>(in.at(3)) << 24);
|
||||
if (numMetatiles > maxMetatiles) {
|
||||
*error = true;
|
||||
logError(QString(".bvd file contains data for %1 metatiles, but the maximum number of metatiles is %2.").arg(numMetatiles).arg(maxMetatiles));
|
||||
return { };
|
||||
}
|
||||
if (numMetatiles < 1) {
|
||||
*error = true;
|
||||
logError(QString(".bvd file contains no data for metatiles."));
|
||||
return { };
|
||||
}
|
||||
|
||||
int expectedFileSize = 4 + (metatileSize * numMetatiles) + (attrSize * numMetatiles) + 4;
|
||||
if (in.length() != expectedFileSize) {
|
||||
*error = true;
|
||||
logError(QString(".bvd file is an unexpected size. Expected %1 bytes, but it has %2 bytes.").arg(expectedFileSize).arg(in.length()));
|
||||
return { };
|
||||
}
|
||||
|
||||
QList<Metatile*> metatiles;
|
||||
for (int i = 0; i < numMetatiles; i++) {
|
||||
Metatile *metatile = new Metatile();
|
||||
QList<Tile> tiles;
|
||||
for (int j = 0; j < 8; j++) {
|
||||
int metatileOffset = 4 + i * metatileSize + j * 2;
|
||||
Tile tile(static_cast<uint16_t>(
|
||||
static_cast<unsigned char>(in.at(metatileOffset)) |
|
||||
(static_cast<unsigned char>(in.at(metatileOffset + 1)) << 8)));
|
||||
tiles.append(tile);
|
||||
}
|
||||
|
||||
// AdvanceMap .bvd files only contain 8 tiles of data per metatile.
|
||||
// If the user has triple-layer metatiles enabled we need to fill the remaining 4 tiles ourselves.
|
||||
if (projectConfig.tripleLayerMetatilesEnabled) {
|
||||
Tile tile = Tile();
|
||||
for (int j = 0; j < 4; j++)
|
||||
tiles.append(tile);
|
||||
}
|
||||
|
||||
int attrOffset = 4 + (numMetatiles * metatileSize) + (i * attrSize);
|
||||
uint32_t attributes = 0;
|
||||
for (int j = 0; j < attrSize; j++)
|
||||
attributes |= static_cast<unsigned char>(in.at(attrOffset + j)) << (8 * j);
|
||||
metatile->setAttributes(attributes, version);
|
||||
metatile->tiles = tiles;
|
||||
metatiles.append(metatile);
|
||||
}
|
||||
|
||||
return metatiles;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "paletteutil.h"
|
||||
#include "advancemapparser.h"
|
||||
#include "log.h"
|
||||
#include <QFileInfo>
|
||||
#include <QRegularExpression>
|
||||
@@ -6,7 +7,6 @@
|
||||
|
||||
QList<QRgb> parsePal(QString filepath, bool *error);
|
||||
QList<QRgb> parseJASC(QString filepath, bool *error);
|
||||
QList<QRgb> parseAdvanceMapPal(QString filepath, bool *error);
|
||||
QList<QRgb> parseAdobeColorTable(QString filepath, bool *error);
|
||||
QList<QRgb> parseTileLayerPro(QString filepath, bool *error);
|
||||
QList<QRgb> parseAdvancePaletteEditor(QString filepath, bool *error);
|
||||
@@ -81,7 +81,7 @@ QList<QRgb> parsePal(QString filepath, bool *error) {
|
||||
return parseJASC(filepath, error);
|
||||
} else {
|
||||
file.close();
|
||||
return parseAdvanceMapPal(filepath, error);
|
||||
return AdvanceMapParser::parsePalette(filepath, error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,38 +152,6 @@ QList<QRgb> parseJASC(QString filepath, bool *error) {
|
||||
return palette;
|
||||
}
|
||||
|
||||
QList<QRgb> parseAdvanceMapPal(QString filepath, bool *error) {
|
||||
QFile file(filepath);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
*error = true;
|
||||
logError(QString("Could not open Advance Map 1.92 palette file '%1': ").arg(filepath) + file.errorString());
|
||||
return QList<QRgb>();
|
||||
}
|
||||
|
||||
QByteArray in = file.readAll();
|
||||
file.close();
|
||||
|
||||
if (in.length() % 4 != 0) {
|
||||
*error = true;
|
||||
logError(QString("Advance Map 1.92 palette file '%1' had an unexpected format. File's length must be a multiple of 4, but the length is %2.").arg(filepath).arg(in.length()));
|
||||
return QList<QRgb>();
|
||||
}
|
||||
|
||||
QList<QRgb> palette;
|
||||
int i = 0;
|
||||
while (i < in.length()) {
|
||||
unsigned char red = static_cast<unsigned char>(in.at(i));
|
||||
unsigned char green = static_cast<unsigned char>(in.at(i + 1));
|
||||
unsigned char blue = static_cast<unsigned char>(in.at(i + 2));
|
||||
palette.append(qRgb(clampColorValue(red),
|
||||
clampColorValue(green),
|
||||
clampColorValue(blue)));
|
||||
i += 4;
|
||||
}
|
||||
|
||||
return palette;
|
||||
}
|
||||
|
||||
QList<QRgb> parseAdobeColorTable(QString filepath, bool *error) {
|
||||
QFile file(filepath);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
|
||||
@@ -593,13 +593,13 @@ bool ParseUtil::gameStringToBool(QString gameString, bool * ok) {
|
||||
return gameStringToInt(gameString, ok) != 0;
|
||||
}
|
||||
|
||||
QMap<QString, QHash<QString, QString>> ParseUtil::readCStructs(const QString &filename, const QString &label, const QHash<int, QString> memberMap) {
|
||||
tsl::ordered_map<QString, QHash<QString, QString>> ParseUtil::readCStructs(const QString &filename, const QString &label, const QHash<int, QString> &memberMap) {
|
||||
QString filePath = this->root + "/" + filename;
|
||||
auto cParser = fex::Parser();
|
||||
auto tokens = fex::Lexer().LexFile(filePath.toStdString());
|
||||
auto structs = cParser.ParseTopLevelObjects(tokens);
|
||||
QMap<QString, QHash<QString, QString>> structMaps;
|
||||
for (auto it = structs.begin(); it != structs.end(); it++) {
|
||||
auto topLevelObjects = cParser.ParseTopLevelObjects(tokens);
|
||||
tsl::ordered_map<QString, QHash<QString, QString>> structs;
|
||||
for (auto it = topLevelObjects.begin(); it != topLevelObjects.end(); it++) {
|
||||
QString structLabel = QString::fromStdString(it->first);
|
||||
if (structLabel.isEmpty()) continue;
|
||||
if (!label.isEmpty() && label != structLabel) continue; // Speed up parsing if only looking for a particular symbol
|
||||
@@ -617,9 +617,9 @@ QMap<QString, QHash<QString, QString>> ParseUtil::readCStructs(const QString &fi
|
||||
}
|
||||
i++;
|
||||
}
|
||||
structMaps.insert(structLabel, values);
|
||||
structs[structLabel] = values;
|
||||
}
|
||||
return structMaps;
|
||||
return structs;
|
||||
}
|
||||
|
||||
QList<QStringList> ParseUtil::getLabelMacros(const QList<QStringList> &list, const QString &label) {
|
||||
|
||||
@@ -337,9 +337,9 @@ namespace fex
|
||||
return DefineStatement(identifer, value);
|
||||
}
|
||||
|
||||
std::map<std::string, int> Parser::ReadDefines(const std::string &filename, std::vector<std::string> matching)
|
||||
tsl::ordered_map<std::string, int> Parser::ReadDefines(const std::string &filename, std::vector<std::string> matching)
|
||||
{
|
||||
std::map<std::string, int> out;
|
||||
tsl::ordered_map<std::string, int> out;
|
||||
|
||||
Lexer lexer;
|
||||
auto tokens = lexer.LexFile(filename);
|
||||
@@ -488,12 +488,12 @@ namespace fex
|
||||
return items;
|
||||
}
|
||||
|
||||
std::map<std::string, ArrayValue> Parser::ParseTopLevelObjects(std::vector<Token> tokens)
|
||||
tsl::ordered_map<std::string, ArrayValue> Parser::ParseTopLevelObjects(std::vector<Token> tokens)
|
||||
{
|
||||
index_ = 0;
|
||||
tokens_ = std::move(tokens);
|
||||
|
||||
std::map<std::string, ArrayValue> items;
|
||||
tsl::ordered_map<std::string, ArrayValue> items;
|
||||
|
||||
while (index_ < tokens_.size())
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ QStringList ParserUtil::ReadDefines(QString filename, QString prefix)
|
||||
fex::Parser parser;
|
||||
|
||||
std::vector<std::string> match_list = { prefix.toStdString() + ".*" };
|
||||
std::map<std::string, int> defines = parser.ReadDefines(filepath.toStdString(), match_list);
|
||||
tsl::ordered_map<std::string, int> defines = parser.ReadDefines(filepath.toStdString(), match_list);
|
||||
|
||||
QStringList out;
|
||||
for(auto const& define : defines) {
|
||||
@@ -39,7 +39,7 @@ QStringList ParserUtil::ReadDefinesValueSort(QString filename, QString prefix)
|
||||
fex::Parser parser;
|
||||
|
||||
std::vector<std::string> match_list = { prefix.toStdString() + ".*" };
|
||||
std::map<std::string, int> defines = parser.ReadDefines(filepath.toStdString(), match_list);
|
||||
tsl::ordered_map<std::string, int> defines = parser.ReadDefines(filepath.toStdString(), match_list);
|
||||
|
||||
QMultiMap<int, QString> defines_keyed_by_value;
|
||||
for (const auto& pair : defines) {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "editcommands.h"
|
||||
#include "flowlayout.h"
|
||||
#include "shortcut.h"
|
||||
#include "mapparser.h"
|
||||
#include "advancemapparser.h"
|
||||
#include "prefab.h"
|
||||
#include "montabwidget.h"
|
||||
#include "imageexport.h"
|
||||
@@ -1634,7 +1634,7 @@ void MainWindow::on_actionNew_Tileset_triggered() {
|
||||
int index = insertTilesetLabel(&editor->project->secondaryTilesetLabels, createTilesetDialog->fullSymbolName);
|
||||
this->ui->comboBox_SecondaryTileset->insertItem(index, createTilesetDialog->fullSymbolName);
|
||||
}
|
||||
insertTilesetLabel(&editor->project->tilesetLabelsOrdered, createTilesetDialog->fullSymbolName);
|
||||
editor->project->tilesetLabelsOrdered.append(createTilesetDialog->fullSymbolName);
|
||||
|
||||
QMessageBox msgBox(this);
|
||||
msgBox.setText("Successfully created tileset.");
|
||||
@@ -2712,20 +2712,14 @@ void MainWindow::on_actionExport_Map_Timelapse_Image_triggered() {
|
||||
showExportMapImageWindow(ImageExporterMode::Timelapse);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionImport_Map_from_Advance_Map_1_92_triggered(){
|
||||
importMapFromAdvanceMap1_92();
|
||||
}
|
||||
|
||||
void MainWindow::importMapFromAdvanceMap1_92()
|
||||
{
|
||||
QString filepath = FileDialog::getOpenFileName(this, "Import Map from Advance Map 1.92", "", "Advance Map 1.92 Map Files (*.map)");
|
||||
void MainWindow::on_actionImport_Layout_from_Advance_Map_1_92_triggered() {
|
||||
QString filepath = FileDialog::getOpenFileName(this, "Import Layout from Advance Map 1.92", "", "Advance Map 1.92 Map Files (*.map)");
|
||||
if (filepath.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
MapParser parser;
|
||||
bool error = false;
|
||||
Layout *mapLayout = parser.parse(filepath, &error, editor->project);
|
||||
Layout *mapLayout = AdvanceMapParser::parseLayout(filepath, &error, editor->project);
|
||||
if (error) {
|
||||
QMessageBox msgBox(this);
|
||||
msgBox.setText("Failed to import map from Advance Map 1.92 .map file.");
|
||||
@@ -2734,11 +2728,13 @@ void MainWindow::importMapFromAdvanceMap1_92()
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
msgBox.setIcon(QMessageBox::Icon::Critical);
|
||||
msgBox.exec();
|
||||
delete mapLayout;
|
||||
return;
|
||||
}
|
||||
|
||||
openNewMapDialog();
|
||||
this->newMapDialog->init(mapLayout);
|
||||
openNewLayoutDialog();
|
||||
this->newLayoutDialog->copyFrom(*mapLayout);
|
||||
delete mapLayout;
|
||||
}
|
||||
|
||||
void MainWindow::showExportMapImageWindow(ImageExporterMode mode) {
|
||||
|
||||
@@ -1115,6 +1115,9 @@ bool Project::loadLayoutTilesets(Layout *layout) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: We are parsing the tileset headers file whenever we load a tileset for the first time.
|
||||
// At a minimum this means we're parsing the file three times per session (twice here for the first map's tilesets, once on launch in Project::readTilesetLabels).
|
||||
// We can cache the header data instead and only parse it once on launch.
|
||||
Tileset* Project::loadTileset(QString label, Tileset *tileset) {
|
||||
auto memberMap = Tileset::getHeaderMemberMap(this->usingAsmTilesets);
|
||||
if (this->usingAsmTilesets) {
|
||||
@@ -1134,14 +1137,14 @@ Tileset* Project::loadTileset(QString label, Tileset *tileset) {
|
||||
tileset->metatile_attrs_label = values.value(memberMap.key("metatileAttributes"));
|
||||
} else {
|
||||
// Read C tileset header
|
||||
const auto structs = parser.readCStructs(projectConfig.getFilePath(ProjectFilePath::tilesets_headers), label, memberMap);
|
||||
auto structs = parser.readCStructs(projectConfig.getFilePath(ProjectFilePath::tilesets_headers), label, memberMap);
|
||||
if (!structs.contains(label)) {
|
||||
return nullptr;
|
||||
}
|
||||
if (tileset == nullptr) {
|
||||
tileset = new Tileset;
|
||||
}
|
||||
const auto tilesetAttributes = structs[label];
|
||||
auto tilesetAttributes = structs[label];
|
||||
tileset->name = label;
|
||||
tileset->is_secondary = ParseUtil::gameStringToBool(tilesetAttributes.value("isSecondary"));
|
||||
tileset->tiles_label = tilesetAttributes.value("tiles");
|
||||
@@ -1579,7 +1582,7 @@ void Project::loadTilesetMetatiles(Tileset* tileset) {
|
||||
}
|
||||
|
||||
QString Project::findMetatileLabelsTileset(QString label) {
|
||||
for (QString tilesetName : this->tilesetLabelsOrdered) {
|
||||
for (const QString &tilesetName : this->tilesetLabelsOrdered) {
|
||||
QString metatileLabelPrefix = Tileset::getMetatileLabelPrefix(tilesetName);
|
||||
if (label.startsWith(metatileLabelPrefix))
|
||||
return tilesetName;
|
||||
@@ -2046,7 +2049,7 @@ QString Project::getDefaultSecondaryTilesetLabel() const {
|
||||
return defaultLabel;
|
||||
}
|
||||
|
||||
void Project::appendTilesetLabel(QString label, QString isSecondaryStr) {
|
||||
void Project::appendTilesetLabel(const QString &label, const QString &isSecondaryStr) {
|
||||
bool ok;
|
||||
bool isSecondary = ParseUtil::gameStringToBool(isSecondaryStr, &ok);
|
||||
if (!ok) {
|
||||
@@ -2080,20 +2083,18 @@ bool Project::readTilesetLabels() {
|
||||
QRegularExpressionMatch match = iter.next();
|
||||
appendTilesetLabel(match.captured("label"), match.captured("isSecondary"));
|
||||
}
|
||||
this->primaryTilesetLabels.sort();
|
||||
this->secondaryTilesetLabels.sort();
|
||||
this->tilesetLabelsOrdered.sort();
|
||||
filename = asm_filename; // For error reporting further down
|
||||
} else {
|
||||
this->usingAsmTilesets = false;
|
||||
const auto structs = parser.readCStructs(filename, "", Tileset::getHeaderMemberMap(this->usingAsmTilesets));
|
||||
const QStringList labels = structs.keys();
|
||||
// TODO: This is alphabetical, AdvanceMap import wants the vanilla order in tilesetLabelsOrdered
|
||||
for (const auto &tilesetLabel : labels){
|
||||
appendTilesetLabel(tilesetLabel, structs[tilesetLabel].value("isSecondary"));
|
||||
for (auto i = structs.cbegin(); i != structs.cend(); i++){
|
||||
appendTilesetLabel(i.key(), i.value().value("isSecondary"));
|
||||
}
|
||||
}
|
||||
|
||||
this->primaryTilesetLabels.sort();
|
||||
this->secondaryTilesetLabels.sort();
|
||||
|
||||
bool success = true;
|
||||
if (this->secondaryTilesetLabels.isEmpty()) {
|
||||
logError(QString("Failed to find any secondary tilesets in %1").arg(filename));
|
||||
@@ -2784,7 +2785,7 @@ bool Project::readEventGraphics() {
|
||||
};
|
||||
|
||||
QString filepath = projectConfig.getFilePath(ProjectFilePath::data_obj_event_gfx_info);
|
||||
const auto gfxInfos = parser.readCStructs(filepath, "", gfxInfoMemberMap);
|
||||
auto gfxInfos = parser.readCStructs(filepath, "", gfxInfoMemberMap);
|
||||
|
||||
QMap<QString, QStringList> picTables = parser.readCArrayMulti(projectConfig.getFilePath(ProjectFilePath::data_obj_event_pic_tables));
|
||||
QMap<QString, QString> graphicIncbins = parser.readCIncbinMulti(projectConfig.getFilePath(ProjectFilePath::data_obj_event_gfx));
|
||||
@@ -2794,7 +2795,7 @@ bool Project::readEventGraphics() {
|
||||
if (!gfxInfos.contains(info_label))
|
||||
continue;
|
||||
|
||||
const auto gfxInfoAttributes = gfxInfos[info_label];
|
||||
auto gfxInfoAttributes = gfxInfos[info_label];
|
||||
|
||||
auto eventGraphics = new EventGraphics;
|
||||
eventGraphics->inanimate = ParseUtil::gameStringToBool(gfxInfoAttributes.value("inanimate"));
|
||||
|
||||
@@ -41,18 +41,27 @@ NewLayoutDialog::~NewLayoutDialog()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
// Creating new map from AdvanceMap import
|
||||
// Creating new layout from AdvanceMap import
|
||||
// TODO: Re-use for a "Duplicate Layout" option?
|
||||
void NewLayoutDialog::init(Layout *layoutToCopy) {
|
||||
void NewLayoutDialog::copyFrom(const Layout &layoutToCopy) {
|
||||
if (this->importedLayout)
|
||||
delete this->importedLayout;
|
||||
|
||||
this->importedLayout = new Layout();
|
||||
this->importedLayout->blockdata = layoutToCopy->blockdata;
|
||||
if (!layoutToCopy->border.isEmpty())
|
||||
this->importedLayout->border = layoutToCopy->border;
|
||||
this->importedLayout->blockdata = layoutToCopy.blockdata;
|
||||
if (!layoutToCopy.border.isEmpty())
|
||||
this->importedLayout->border = layoutToCopy.border;
|
||||
|
||||
useLayoutSettings(this->importedLayout);
|
||||
this->settings->width = layoutToCopy.width;
|
||||
this->settings->height = layoutToCopy.height;
|
||||
this->settings->borderWidth = layoutToCopy.border_width;
|
||||
this->settings->borderHeight = layoutToCopy.border_height;
|
||||
this->settings->primaryTilesetLabel = layoutToCopy.tileset_primary_label;
|
||||
this->settings->secondaryTilesetLabel = layoutToCopy.tileset_secondary_label;
|
||||
|
||||
// Don't allow changes to the layout settings
|
||||
ui->newLayoutForm->setSettings(*this->settings);
|
||||
ui->newLayoutForm->setDisabled(true);
|
||||
}
|
||||
|
||||
void NewLayoutDialog::saveSettings() {
|
||||
@@ -61,20 +70,6 @@ void NewLayoutDialog::saveSettings() {
|
||||
this->settings->name = ui->lineEdit_Name->text();
|
||||
}
|
||||
|
||||
void NewLayoutDialog::useLayoutSettings(Layout *layout) {
|
||||
if (!layout) return;
|
||||
this->settings->width = layout->width;
|
||||
this->settings->height = layout->height;
|
||||
this->settings->borderWidth = layout->border_width;
|
||||
this->settings->borderHeight = layout->border_height;
|
||||
this->settings->primaryTilesetLabel = layout->tileset_primary_label;
|
||||
this->settings->secondaryTilesetLabel = layout->tileset_secondary_label;
|
||||
ui->newLayoutForm->setSettings(*this->settings);
|
||||
|
||||
// Don't allow changes to the layout settings
|
||||
ui->newLayoutForm->setDisabled(true);
|
||||
}
|
||||
|
||||
bool NewLayoutDialog::validateLayoutID(bool allowEmpty) {
|
||||
QString id = ui->lineEdit_LayoutID->text();
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "ui_tileseteditor.h"
|
||||
#include "log.h"
|
||||
#include "imageproviders.h"
|
||||
#include "metatileparser.h"
|
||||
#include "advancemapparser.h"
|
||||
#include "paletteutil.h"
|
||||
#include "imageexport.h"
|
||||
#include "config.h"
|
||||
@@ -978,7 +978,7 @@ void TilesetEditor::importTilesetMetatiles(Tileset *tileset, bool primary)
|
||||
}
|
||||
|
||||
bool error = false;
|
||||
QList<Metatile*> metatiles = MetatileParser::parse(filepath, &error, primary);
|
||||
QList<Metatile*> metatiles = AdvanceMapParser::parseMetatiles(filepath, &error, primary);
|
||||
if (error) {
|
||||
QMessageBox msgBox(this);
|
||||
msgBox.setText("Failed to import metatiles from Advance Map 1.92 .bvd file.");
|
||||
|
||||
Reference in New Issue
Block a user