Merge remote-tracking branch 'origin/master' into metatile-leaks
This commit is contained in:
commit
c351f069ff
26 changed files with 534 additions and 841 deletions
|
@ -12,12 +12,12 @@ public:
|
|||
Block(uint16_t tile, uint16_t collision, uint16_t elevation);
|
||||
Block(const Block &);
|
||||
Block &operator=(const Block &);
|
||||
bool operator ==(Block);
|
||||
bool operator !=(Block);
|
||||
bool operator ==(Block) const;
|
||||
bool operator !=(Block) const;
|
||||
uint16_t tile:10;
|
||||
uint16_t collision:2;
|
||||
uint16_t elevation:4;
|
||||
uint16_t rawValue();
|
||||
uint16_t rawValue() const;
|
||||
};
|
||||
|
||||
#endif // BLOCK_H
|
||||
|
|
|
@ -4,31 +4,13 @@
|
|||
|
||||
#include "block.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
#include <QVector>
|
||||
|
||||
class Blockdata : public QObject
|
||||
class Blockdata : public QVector<Block>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Blockdata(QObject *parent = nullptr);
|
||||
~Blockdata() {
|
||||
if (blocks) delete blocks;
|
||||
}
|
||||
|
||||
public:
|
||||
QVector<Block> *blocks = nullptr;
|
||||
void addBlock(uint16_t);
|
||||
void addBlock(Block);
|
||||
QByteArray serialize();
|
||||
void copyFrom(Blockdata*);
|
||||
Blockdata* copy();
|
||||
bool equals(Blockdata *);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
QByteArray serialize() const;
|
||||
};
|
||||
|
||||
#endif // BLOCKDATA_H
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#ifndef EDITCOMMANDS_H
|
||||
#define EDITCOMMANDS_H
|
||||
|
||||
#include "blockdata.h"
|
||||
|
||||
#include <QUndoCommand>
|
||||
#include <QList>
|
||||
|
||||
|
@ -41,9 +43,8 @@ enum CommandId {
|
|||
class PaintMetatile : public QUndoCommand {
|
||||
public:
|
||||
PaintMetatile(Map *map,
|
||||
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
||||
const Blockdata &oldMetatiles, const Blockdata &newMetatiles,
|
||||
unsigned actionId, QUndoCommand *parent = nullptr);
|
||||
virtual ~PaintMetatile();
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
@ -54,8 +55,8 @@ public:
|
|||
private:
|
||||
Map *map;
|
||||
|
||||
Blockdata *newMetatiles;
|
||||
Blockdata *oldMetatiles;
|
||||
Blockdata newMetatiles;
|
||||
Blockdata oldMetatiles;
|
||||
|
||||
unsigned actionId;
|
||||
};
|
||||
|
@ -67,7 +68,7 @@ private:
|
|||
class PaintCollision : public PaintMetatile {
|
||||
public:
|
||||
PaintCollision(Map *map,
|
||||
Blockdata *oldCollision, Blockdata *newCollision,
|
||||
const Blockdata &oldCollision, const Blockdata &newCollision,
|
||||
unsigned actionId, QUndoCommand *parent = nullptr)
|
||||
: PaintMetatile(map, oldCollision, newCollision, actionId, parent) {
|
||||
setText("Paint Collision");
|
||||
|
@ -82,9 +83,8 @@ public:
|
|||
class PaintBorder : public QUndoCommand {
|
||||
public:
|
||||
PaintBorder(Map *map,
|
||||
Blockdata *oldBorder, Blockdata *newBorder,
|
||||
const Blockdata &oldBorder, const Blockdata &newBorder,
|
||||
unsigned actionId, QUndoCommand *parent = nullptr);
|
||||
~PaintBorder();
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
@ -95,8 +95,8 @@ public:
|
|||
private:
|
||||
Map *map;
|
||||
|
||||
Blockdata *newBorder;
|
||||
Blockdata *oldBorder;
|
||||
Blockdata newBorder;
|
||||
Blockdata oldBorder;
|
||||
|
||||
unsigned actionId;
|
||||
};
|
||||
|
@ -108,7 +108,7 @@ private:
|
|||
class BucketFillMetatile : public PaintMetatile {
|
||||
public:
|
||||
BucketFillMetatile(Map *map,
|
||||
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
||||
const Blockdata &oldMetatiles, const Blockdata &newMetatiles,
|
||||
unsigned actionId, QUndoCommand *parent = nullptr)
|
||||
: PaintMetatile(map, oldMetatiles, newMetatiles, actionId, parent) {
|
||||
setText("Bucket Fill Metatiles");
|
||||
|
@ -124,7 +124,7 @@ public:
|
|||
class BucketFillCollision : public PaintCollision {
|
||||
public:
|
||||
BucketFillCollision(Map *map,
|
||||
Blockdata *oldCollision, Blockdata *newCollision,
|
||||
const Blockdata &oldCollision, const Blockdata &newCollision,
|
||||
QUndoCommand *parent = nullptr)
|
||||
: PaintCollision(map, oldCollision, newCollision, -1, parent) {
|
||||
setText("Flood Fill Collision");
|
||||
|
@ -141,7 +141,7 @@ public:
|
|||
class MagicFillMetatile : public PaintMetatile {
|
||||
public:
|
||||
MagicFillMetatile(Map *map,
|
||||
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
||||
const Blockdata &oldMetatiles, const Blockdata &newMetatiles,
|
||||
unsigned actionId, QUndoCommand *parent = nullptr)
|
||||
: PaintMetatile(map, oldMetatiles, newMetatiles, actionId, parent) {
|
||||
setText("Magic Fill Metatiles");
|
||||
|
@ -156,7 +156,7 @@ public:
|
|||
class MagicFillCollision : public PaintCollision {
|
||||
public:
|
||||
MagicFillCollision(Map *map,
|
||||
Blockdata *oldCollision, Blockdata *newCollision,
|
||||
const Blockdata &oldCollision, const Blockdata &newCollision,
|
||||
QUndoCommand *parent = nullptr)
|
||||
: PaintCollision(map, oldCollision, newCollision, -1, parent) {
|
||||
setText("Magic Fill Collision");
|
||||
|
@ -172,9 +172,8 @@ public:
|
|||
class ShiftMetatiles : public QUndoCommand {
|
||||
public:
|
||||
ShiftMetatiles(Map *map,
|
||||
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
||||
const Blockdata &oldMetatiles, const Blockdata &newMetatiles,
|
||||
unsigned actionId, QUndoCommand *parent = nullptr);
|
||||
~ShiftMetatiles();
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
@ -185,8 +184,8 @@ public:
|
|||
private:
|
||||
Map *map;
|
||||
|
||||
Blockdata *newMetatiles;
|
||||
Blockdata *oldMetatiles;
|
||||
Blockdata newMetatiles;
|
||||
Blockdata oldMetatiles;
|
||||
|
||||
unsigned actionId;
|
||||
};
|
||||
|
@ -197,11 +196,10 @@ private:
|
|||
class ResizeMap : public QUndoCommand {
|
||||
public:
|
||||
ResizeMap(Map *map, QSize oldMapDimensions, QSize newMapDimensions,
|
||||
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
||||
const Blockdata &oldMetatiles, const Blockdata &newMetatiles,
|
||||
QSize oldBorderDimensions, QSize newBorderDimensions,
|
||||
Blockdata *oldBorder, Blockdata *newBorder,
|
||||
const Blockdata &oldBorder, const Blockdata &newBorder,
|
||||
QUndoCommand *parent = nullptr);
|
||||
~ResizeMap();
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
@ -222,11 +220,11 @@ private:
|
|||
int newBorderWidth;
|
||||
int newBorderHeight;
|
||||
|
||||
Blockdata *newMetatiles;
|
||||
Blockdata *oldMetatiles;
|
||||
Blockdata newMetatiles;
|
||||
Blockdata oldMetatiles;
|
||||
|
||||
Blockdata *newBorder;
|
||||
Blockdata *oldBorder;
|
||||
Blockdata newBorder;
|
||||
Blockdata oldBorder;
|
||||
};
|
||||
|
||||
|
||||
|
@ -238,7 +236,6 @@ public:
|
|||
EventMove(QList<Event *> events,
|
||||
int deltaX, int deltaY, unsigned actionId,
|
||||
QUndoCommand *parent = nullptr);
|
||||
~EventMove();
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
@ -262,7 +259,6 @@ public:
|
|||
EventShift(QList<Event *> events,
|
||||
int deltaX, int deltaY, unsigned actionId,
|
||||
QUndoCommand *parent = nullptr);
|
||||
~EventShift();
|
||||
int id() const override;
|
||||
private:
|
||||
QList<Event *> events;
|
||||
|
@ -276,7 +272,6 @@ class EventCreate : public QUndoCommand {
|
|||
public:
|
||||
EventCreate(Editor *editor, Map *map, Event *event,
|
||||
QUndoCommand *parent = nullptr);
|
||||
~EventCreate();
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
@ -299,7 +294,6 @@ public:
|
|||
EventDelete(Editor *editor, Map *map,
|
||||
QList<Event *> selectedEvents, Event *nextSelectedEvent,
|
||||
QUndoCommand *parent = nullptr);
|
||||
~EventDelete();
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
@ -321,7 +315,6 @@ class EventDuplicate : public QUndoCommand {
|
|||
public:
|
||||
EventDuplicate(Editor *editor, Map *map, QList<Event *> selectedEvents,
|
||||
QUndoCommand *parent = nullptr);
|
||||
~EventDuplicate();
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
@ -343,9 +336,8 @@ class ScriptEditMap : public QUndoCommand {
|
|||
public:
|
||||
ScriptEditMap(Map *map,
|
||||
QSize oldMapDimensions, QSize newMapDimensions,
|
||||
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
||||
const Blockdata &oldMetatiles, const Blockdata &newMetatiles,
|
||||
QUndoCommand *parent = nullptr);
|
||||
~ScriptEditMap();
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
@ -356,8 +348,8 @@ public:
|
|||
private:
|
||||
Map *map;
|
||||
|
||||
Blockdata *newMetatiles;
|
||||
Blockdata *oldMetatiles;
|
||||
Blockdata newMetatiles;
|
||||
Blockdata oldMetatiles;
|
||||
|
||||
int oldMapWidth;
|
||||
int oldMapHeight;
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
static Event* createNewSecretBaseEvent(Project*);
|
||||
|
||||
OrderedJson::object buildObjectEventJSON();
|
||||
OrderedJson::object buildWarpEventJSON(QMap<QString, QString>*);
|
||||
OrderedJson::object buildWarpEventJSON(const QMap<QString, QString> &);
|
||||
OrderedJson::object buildTriggerEventJSON();
|
||||
OrderedJson::object buildWeatherTriggerEventJSON();
|
||||
OrderedJson::object buildSignEventJSON();
|
||||
|
|
|
@ -75,8 +75,8 @@ public:
|
|||
int getBorderHeight();
|
||||
QPixmap render(bool ignoreCache, MapLayout * fromLayout = nullptr);
|
||||
QPixmap renderCollision(qreal opacity, bool ignoreCache);
|
||||
bool mapBlockChanged(int i, Blockdata * cache);
|
||||
bool borderBlockChanged(int i, Blockdata * cache);
|
||||
bool mapBlockChanged(int i, const Blockdata &cache);
|
||||
bool borderBlockChanged(int i, const Blockdata &cache);
|
||||
void cacheBlockdata();
|
||||
void cacheCollision();
|
||||
bool getBlock(int x, int y, Block *out);
|
||||
|
|
|
@ -24,15 +24,15 @@ public:
|
|||
QString tileset_secondary_label;
|
||||
Tileset *tileset_primary = nullptr;
|
||||
Tileset *tileset_secondary = nullptr;
|
||||
Blockdata *blockdata = nullptr;
|
||||
Blockdata blockdata;
|
||||
QImage border_image;
|
||||
QPixmap border_pixmap;
|
||||
Blockdata *border = nullptr;
|
||||
Blockdata *cached_blockdata = nullptr;
|
||||
Blockdata *cached_collision = nullptr;
|
||||
Blockdata *cached_border = nullptr;
|
||||
Blockdata border;
|
||||
Blockdata cached_blockdata;
|
||||
Blockdata cached_collision;
|
||||
Blockdata cached_border;
|
||||
struct {
|
||||
Blockdata *blocks = nullptr;
|
||||
Blockdata blocks;
|
||||
QSize dimensions;
|
||||
} lastCommitMapBlocks; // to track map changes
|
||||
};
|
||||
|
|
|
@ -39,31 +39,30 @@ public:
|
|||
class ParseUtil
|
||||
{
|
||||
public:
|
||||
ParseUtil();
|
||||
void set_root(QString);
|
||||
static QString readTextFile(QString);
|
||||
ParseUtil() { };
|
||||
void set_root(const QString &dir);
|
||||
static QString readTextFile(const QString &path);
|
||||
static int textFileLineCount(const QString &path);
|
||||
void strip_comment(QString*);
|
||||
QList<QStringList>* parseAsm(QString);
|
||||
int evaluateDefine(QString, QMap<QString, int>*);
|
||||
QStringList readCArray(QString text, QString label);
|
||||
QMap<QString, QString> readNamedIndexCArray(QString text, QString label);
|
||||
QString readCIncbin(QString text, QString label);
|
||||
QMap<QString, int> readCDefines(QString filename, QStringList prefixes, QMap<QString, int> = QMap<QString, int>());
|
||||
void readCDefinesSorted(QString, QStringList, QStringList*, QMap<QString, int> = QMap<QString, int>());
|
||||
QList<QStringList>* getLabelMacros(QList<QStringList>*, QString);
|
||||
QStringList* getLabelValues(QList<QStringList>*, QString);
|
||||
bool tryParseJsonFile(QJsonDocument *out, QString filepath);
|
||||
bool ensureFieldsExist(QJsonObject obj, QList<QString> fields);
|
||||
QList<QStringList> parseAsm(const QString &filename);
|
||||
int evaluateDefine(const QString&, const QMap<QString, int>&);
|
||||
QStringList readCArray(const QString &text, const QString &label);
|
||||
QMap<QString, QString> readNamedIndexCArray(const QString &text, const QString &label);
|
||||
QString readCIncbin(const QString &text, const QString &label);
|
||||
QMap<QString, int> readCDefines(const QString &filename, const QStringList &prefixes, QMap<QString, int> = { });
|
||||
QStringList readCDefinesSorted(const QString&, const QStringList&, const QMap<QString, int>& = { });
|
||||
QList<QStringList> getLabelMacros(const QList<QStringList>&, const QString&);
|
||||
QStringList getLabelValues(const QList<QStringList>&, const QString&);
|
||||
bool tryParseJsonFile(QJsonDocument *out, const QString &filepath);
|
||||
bool ensureFieldsExist(const QJsonObject &obj, const QList<QString> &fields);
|
||||
|
||||
// Returns the 1-indexed line number for the definition of scriptLabel in the scripts file at filePath.
|
||||
// Returns 0 if a definition for scriptLabel cannot be found.
|
||||
static int getScriptLineNumber(const QString &filePath, const QString &scriptLabel);
|
||||
static int getRawScriptLineNumber(QString text, const QString &scriptLabel);
|
||||
static int getPoryScriptLineNumber(QString text, const QString &scriptLabel);
|
||||
static QString &removeStringLiterals(QString &text);
|
||||
static QString &removeLineComments(QString &text, const QString &commentSymbol);
|
||||
static QString &removeLineComments(QString &text, const QStringList &commentSymbols);
|
||||
static QString removeStringLiterals(QString text);
|
||||
static QString removeLineComments(QString text, const QString &commentSymbol);
|
||||
static QString removeLineComments(QString text, const QStringList &commentSymbols);
|
||||
|
||||
static QStringList splitShellCommand(QStringView command);
|
||||
|
||||
|
@ -71,10 +70,10 @@ private:
|
|||
QString root;
|
||||
QString text;
|
||||
QString file;
|
||||
QList<Token> tokenizeExpression(QString expression, QMap<QString, int>* knownIdentifiers);
|
||||
QList<Token> generatePostfix(QList<Token> tokens);
|
||||
int evaluatePostfix(QList<Token> postfix);
|
||||
void error(QString message, QString expression);
|
||||
QList<Token> tokenizeExpression(QString expression, const QMap<QString, int> &knownIdentifiers);
|
||||
QList<Token> generatePostfix(const QList<Token> &tokens);
|
||||
int evaluatePostfix(const QList<Token> &postfix);
|
||||
void error(const QString &message, const QString &expression);
|
||||
};
|
||||
|
||||
#endif // PARSEUTIL_H
|
||||
|
|
|
@ -31,35 +31,37 @@ public:
|
|||
Project(const Project &) = delete;
|
||||
Project & operator = (const Project &) = delete;
|
||||
|
||||
inline QWidget *parentWidget() const { return static_cast<QWidget *>(parent()); }
|
||||
|
||||
public:
|
||||
QString root;
|
||||
QStringList *groupNames = nullptr;
|
||||
QMap<QString, int> *mapGroups;
|
||||
QStringList groupNames;
|
||||
QMap<QString, int> mapGroups;
|
||||
QList<QStringList> groupedMapNames;
|
||||
QStringList *mapNames = nullptr;
|
||||
QStringList mapNames;
|
||||
QMap<QString, QVariant> miscConstants;
|
||||
QList<HealLocation> healLocations;
|
||||
QMap<QString, QString>* mapConstantsToMapNames;
|
||||
QMap<QString, QString>* mapNamesToMapConstants;
|
||||
QList<QString> mapLayoutsTable;
|
||||
QList<QString> mapLayoutsTableMaster;
|
||||
QMap<QString, QString> mapConstantsToMapNames;
|
||||
QMap<QString, QString> mapNamesToMapConstants;
|
||||
QStringList mapLayoutsTable;
|
||||
QStringList mapLayoutsTableMaster;
|
||||
QString layoutsLabel;
|
||||
QMap<QString, MapLayout*> mapLayouts;
|
||||
QMap<QString, MapLayout*> mapLayoutsMaster;
|
||||
QMap<QString, QString> *mapSecToMapHoverName;
|
||||
QMap<QString, QString> mapSecToMapHoverName;
|
||||
QMap<QString, int> mapSectionNameToValue;
|
||||
QMap<int, QString> mapSectionValueToName;
|
||||
QStringList *itemNames = nullptr;
|
||||
QStringList *flagNames = nullptr;
|
||||
QStringList *varNames = nullptr;
|
||||
QStringList *movementTypes = nullptr;
|
||||
QStringList *mapTypes = nullptr;
|
||||
QStringList *mapBattleScenes = nullptr;
|
||||
QStringList *weatherNames = nullptr;
|
||||
QStringList *coordEventWeatherNames = nullptr;
|
||||
QStringList *secretBaseIds = nullptr;
|
||||
QStringList *bgEventFacingDirections = nullptr;
|
||||
QStringList *trainerTypes = nullptr;
|
||||
QStringList itemNames;
|
||||
QStringList flagNames;
|
||||
QStringList varNames;
|
||||
QStringList movementTypes;
|
||||
QStringList mapTypes;
|
||||
QStringList mapBattleScenes;
|
||||
QStringList weatherNames;
|
||||
QStringList coordEventWeatherNames;
|
||||
QStringList secretBaseIds;
|
||||
QStringList bgEventFacingDirections;
|
||||
QStringList trainerTypes;
|
||||
QMap<QString, int> metatileBehaviorMap;
|
||||
QMap<int, QString> metatileBehaviorMapInverse;
|
||||
QMap<QString, QString> facingDirections;
|
||||
|
@ -82,16 +84,16 @@ public:
|
|||
DataQualifiers getDataQualifiers(QString, QString);
|
||||
QMap<QString, DataQualifiers> dataQualifiers;
|
||||
|
||||
QMap<QString, Map*> *mapCache;
|
||||
QMap<QString, Map*> mapCache;
|
||||
Map* loadMap(QString);
|
||||
Map* getMap(QString);
|
||||
|
||||
QMap<QString, Tileset*> *tilesetCache = nullptr;
|
||||
QMap<QString, Tileset*> tilesetCache;
|
||||
Tileset* loadTileset(QString, Tileset *tileset = nullptr);
|
||||
Tileset* getTileset(QString, bool forceLoad = false);
|
||||
QMap<QString, QStringList> tilesetLabels;
|
||||
|
||||
Blockdata* readBlockdata(QString);
|
||||
Blockdata readBlockdata(QString);
|
||||
bool loadBlockdata(Map*);
|
||||
|
||||
void saveTextFile(QString path, QString text);
|
||||
|
@ -129,7 +131,7 @@ public:
|
|||
|
||||
void saveLayoutBlockdata(Map*);
|
||||
void saveLayoutBorder(Map*);
|
||||
void writeBlockdata(QString, Blockdata*);
|
||||
void writeBlockdata(QString, const Blockdata &);
|
||||
void saveAllMaps();
|
||||
void saveMap(Map*);
|
||||
void saveAllDataStructures();
|
||||
|
@ -219,8 +221,6 @@ private:
|
|||
static int default_map_size;
|
||||
static int max_object_events;
|
||||
|
||||
QWidget *parent;
|
||||
|
||||
signals:
|
||||
void reloadProject();
|
||||
void uncheckMonitorFilesAction();
|
||||
|
|
|
@ -27,17 +27,17 @@ Block &Block::operator=(const Block &other) {
|
|||
return *this;
|
||||
}
|
||||
|
||||
uint16_t Block::rawValue() {
|
||||
uint16_t Block::rawValue() const {
|
||||
return static_cast<uint16_t>(
|
||||
(tile & 0x3ff) +
|
||||
((collision & 0x3) << 10) +
|
||||
((elevation & 0xf) << 12));
|
||||
}
|
||||
|
||||
bool Block::operator ==(Block other) {
|
||||
bool Block::operator ==(Block other) const {
|
||||
return (tile == other.tile) && (collision == other.collision) && (elevation == other.elevation);
|
||||
}
|
||||
|
||||
bool Block::operator !=(Block other) {
|
||||
bool Block::operator !=(Block other) const {
|
||||
return !(operator ==(other));
|
||||
}
|
||||
|
|
|
@ -1,54 +1,11 @@
|
|||
#include "blockdata.h"
|
||||
|
||||
Blockdata::Blockdata(QObject *parent) : QObject(parent)
|
||||
{
|
||||
blocks = new QVector<Block>;
|
||||
}
|
||||
|
||||
void Blockdata::addBlock(uint16_t word) {
|
||||
Block block(word);
|
||||
blocks->append(block);
|
||||
}
|
||||
|
||||
void Blockdata::addBlock(Block block) {
|
||||
blocks->append(block);
|
||||
}
|
||||
|
||||
QByteArray Blockdata::serialize() {
|
||||
QByteArray Blockdata::serialize() const {
|
||||
QByteArray data;
|
||||
for (int i = 0; i < blocks->length(); i++) {
|
||||
Block block = blocks->value(i);
|
||||
for (const auto &block : *this) {
|
||||
uint16_t word = block.rawValue();
|
||||
data.append(static_cast<char>(word & 0xff));
|
||||
data.append(static_cast<char>((word >> 8) & 0xff));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
void Blockdata::copyFrom(Blockdata* other) {
|
||||
blocks->clear();
|
||||
for (int i = 0; i < other->blocks->length(); i++) {
|
||||
addBlock(other->blocks->value(i));
|
||||
}
|
||||
}
|
||||
|
||||
Blockdata* Blockdata::copy() {
|
||||
Blockdata* blockdata = new Blockdata;
|
||||
blockdata->copyFrom(this);
|
||||
return blockdata;
|
||||
}
|
||||
|
||||
bool Blockdata::equals(Blockdata *other) {
|
||||
if (!other) {
|
||||
return false;
|
||||
}
|
||||
if (blocks->length() != other->blocks->length()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < blocks->length(); i++) {
|
||||
if (blocks->value(i) != other->blocks->value(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -31,8 +31,9 @@ void renderMapBlocks(Map *map, bool ignoreCache = false) {
|
|||
map->mapItem->draw(ignoreCache);
|
||||
map->collisionItem->draw(ignoreCache);
|
||||
}
|
||||
|
||||
PaintMetatile::PaintMetatile(Map *map,
|
||||
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
||||
const Blockdata &oldMetatiles, const Blockdata &newMetatiles,
|
||||
unsigned actionId, QUndoCommand *parent) : QUndoCommand(parent) {
|
||||
setText("Paint Metatiles");
|
||||
|
||||
|
@ -43,21 +44,14 @@ PaintMetatile::PaintMetatile(Map *map,
|
|||
this->actionId = actionId;
|
||||
}
|
||||
|
||||
PaintMetatile::~PaintMetatile() {
|
||||
if (newMetatiles) delete newMetatiles;
|
||||
if (oldMetatiles) delete oldMetatiles;
|
||||
}
|
||||
|
||||
void PaintMetatile::redo() {
|
||||
QUndoCommand::redo();
|
||||
|
||||
if (!map) return;
|
||||
|
||||
if (map->layout->blockdata) {
|
||||
map->layout->blockdata->copyFrom(newMetatiles);
|
||||
}
|
||||
map->layout->blockdata = newMetatiles;
|
||||
|
||||
map->layout->lastCommitMapBlocks.blocks->copyFrom(map->layout->blockdata);
|
||||
map->layout->lastCommitMapBlocks.blocks = map->layout->blockdata;
|
||||
|
||||
renderMapBlocks(map);
|
||||
}
|
||||
|
@ -65,11 +59,9 @@ void PaintMetatile::redo() {
|
|||
void PaintMetatile::undo() {
|
||||
if (!map) return;
|
||||
|
||||
if (map->layout->blockdata) {
|
||||
map->layout->blockdata->copyFrom(oldMetatiles);
|
||||
}
|
||||
map->layout->blockdata = oldMetatiles;
|
||||
|
||||
map->layout->lastCommitMapBlocks.blocks->copyFrom(map->layout->blockdata);
|
||||
map->layout->lastCommitMapBlocks.blocks = map->layout->blockdata;
|
||||
|
||||
renderMapBlocks(map);
|
||||
|
||||
|
@ -79,13 +71,13 @@ void PaintMetatile::undo() {
|
|||
bool PaintMetatile::mergeWith(const QUndoCommand *command) {
|
||||
const PaintMetatile *other = static_cast<const PaintMetatile *>(command);
|
||||
|
||||
if (this->map != other->map)
|
||||
if (map != other->map)
|
||||
return false;
|
||||
|
||||
if (actionId != other->actionId)
|
||||
return false;
|
||||
|
||||
this->newMetatiles->copyFrom(other->newMetatiles);
|
||||
newMetatiles = other->newMetatiles;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -95,7 +87,7 @@ bool PaintMetatile::mergeWith(const QUndoCommand *command) {
|
|||
******************************************************************************/
|
||||
|
||||
PaintBorder::PaintBorder(Map *map,
|
||||
Blockdata *oldBorder, Blockdata *newBorder,
|
||||
const Blockdata &oldBorder, const Blockdata &newBorder,
|
||||
unsigned actionId, QUndoCommand *parent) : QUndoCommand(parent) {
|
||||
setText("Paint Border");
|
||||
|
||||
|
@ -106,19 +98,12 @@ PaintBorder::PaintBorder(Map *map,
|
|||
this->actionId = actionId;
|
||||
}
|
||||
|
||||
PaintBorder::~PaintBorder() {
|
||||
if (newBorder) delete newBorder;
|
||||
if (oldBorder) delete oldBorder;
|
||||
}
|
||||
|
||||
void PaintBorder::redo() {
|
||||
QUndoCommand::redo();
|
||||
|
||||
if (!map) return;
|
||||
|
||||
if (map->layout->border) {
|
||||
map->layout->border->copyFrom(newBorder);
|
||||
}
|
||||
map->layout->border = newBorder;
|
||||
|
||||
map->borderItem->draw();
|
||||
}
|
||||
|
@ -126,9 +111,7 @@ void PaintBorder::redo() {
|
|||
void PaintBorder::undo() {
|
||||
if (!map) return;
|
||||
|
||||
if (map->layout->border) {
|
||||
map->layout->border->copyFrom(oldBorder);
|
||||
}
|
||||
map->layout->border = oldBorder;
|
||||
|
||||
map->borderItem->draw();
|
||||
|
||||
|
@ -140,7 +123,7 @@ void PaintBorder::undo() {
|
|||
******************************************************************************/
|
||||
|
||||
ShiftMetatiles::ShiftMetatiles(Map *map,
|
||||
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
||||
const Blockdata &oldMetatiles, const Blockdata &newMetatiles,
|
||||
unsigned actionId, QUndoCommand *parent) : QUndoCommand(parent) {
|
||||
setText("Shift Metatiles");
|
||||
|
||||
|
@ -151,21 +134,14 @@ ShiftMetatiles::ShiftMetatiles(Map *map,
|
|||
this->actionId = actionId;
|
||||
}
|
||||
|
||||
ShiftMetatiles::~ShiftMetatiles() {
|
||||
if (newMetatiles) delete newMetatiles;
|
||||
if (oldMetatiles) delete oldMetatiles;
|
||||
}
|
||||
|
||||
void ShiftMetatiles::redo() {
|
||||
QUndoCommand::redo();
|
||||
|
||||
if (!map) return;
|
||||
|
||||
if (map->layout->blockdata) {
|
||||
map->layout->blockdata->copyFrom(newMetatiles);
|
||||
}
|
||||
map->layout->blockdata = newMetatiles;
|
||||
|
||||
map->layout->lastCommitMapBlocks.blocks->copyFrom(map->layout->blockdata);
|
||||
map->layout->lastCommitMapBlocks.blocks = map->layout->blockdata;
|
||||
|
||||
renderMapBlocks(map, true);
|
||||
}
|
||||
|
@ -173,11 +149,9 @@ void ShiftMetatiles::redo() {
|
|||
void ShiftMetatiles::undo() {
|
||||
if (!map) return;
|
||||
|
||||
if (map->layout->blockdata) {
|
||||
map->layout->blockdata->copyFrom(oldMetatiles);
|
||||
}
|
||||
map->layout->blockdata = oldMetatiles;
|
||||
|
||||
map->layout->lastCommitMapBlocks.blocks->copyFrom(map->layout->blockdata);
|
||||
map->layout->lastCommitMapBlocks.blocks = map->layout->blockdata;
|
||||
|
||||
renderMapBlocks(map, true);
|
||||
|
||||
|
@ -193,7 +167,7 @@ bool ShiftMetatiles::mergeWith(const QUndoCommand *command) {
|
|||
if (actionId != other->actionId)
|
||||
return false;
|
||||
|
||||
this->newMetatiles->copyFrom(other->newMetatiles);
|
||||
this->newMetatiles = other->newMetatiles;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -203,9 +177,9 @@ bool ShiftMetatiles::mergeWith(const QUndoCommand *command) {
|
|||
******************************************************************************/
|
||||
|
||||
ResizeMap::ResizeMap(Map *map, QSize oldMapDimensions, QSize newMapDimensions,
|
||||
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
||||
const Blockdata &oldMetatiles, const Blockdata &newMetatiles,
|
||||
QSize oldBorderDimensions, QSize newBorderDimensions,
|
||||
Blockdata *oldBorder, Blockdata *newBorder,
|
||||
const Blockdata &oldBorder, const Blockdata &newBorder,
|
||||
QUndoCommand *parent) : QUndoCommand(parent) {
|
||||
setText("Resize Map");
|
||||
|
||||
|
@ -230,25 +204,16 @@ ResizeMap::ResizeMap(Map *map, QSize oldMapDimensions, QSize newMapDimensions,
|
|||
this->newBorder = newBorder;
|
||||
}
|
||||
|
||||
ResizeMap::~ResizeMap() {
|
||||
if (newMetatiles) delete newMetatiles;
|
||||
if (oldMetatiles) delete oldMetatiles;
|
||||
}
|
||||
|
||||
void ResizeMap::redo() {
|
||||
QUndoCommand::redo();
|
||||
|
||||
if (!map) return;
|
||||
|
||||
if (map->layout->blockdata) {
|
||||
map->layout->blockdata->copyFrom(newMetatiles);
|
||||
map->setDimensions(newMapWidth, newMapHeight, false);
|
||||
}
|
||||
map->layout->blockdata = newMetatiles;
|
||||
map->setDimensions(newMapWidth, newMapHeight, false);
|
||||
|
||||
if (map->layout->border) {
|
||||
map->layout->border->copyFrom(newBorder);
|
||||
map->setBorderDimensions(newBorderWidth, newBorderHeight, false);
|
||||
}
|
||||
map->layout->border = newBorder;
|
||||
map->setBorderDimensions(newBorderWidth, newBorderHeight, false);
|
||||
|
||||
map->layout->lastCommitMapBlocks.dimensions = QSize(map->getWidth(), map->getHeight());
|
||||
|
||||
|
@ -258,15 +223,11 @@ void ResizeMap::redo() {
|
|||
void ResizeMap::undo() {
|
||||
if (!map) return;
|
||||
|
||||
if (map->layout->blockdata) {
|
||||
map->layout->blockdata->copyFrom(oldMetatiles);
|
||||
map->setDimensions(oldMapWidth, oldMapHeight, false);
|
||||
}
|
||||
map->layout->blockdata = oldMetatiles;
|
||||
map->setDimensions(oldMapWidth, oldMapHeight, false);
|
||||
|
||||
if (map->layout->border) {
|
||||
map->layout->border->copyFrom(oldBorder);
|
||||
map->setBorderDimensions(oldBorderWidth, oldBorderHeight, false);
|
||||
}
|
||||
map->layout->border = oldBorder;
|
||||
map->setBorderDimensions(oldBorderWidth, oldBorderHeight, false);
|
||||
|
||||
map->layout->lastCommitMapBlocks.dimensions = QSize(map->getWidth(), map->getHeight());
|
||||
|
||||
|
@ -292,8 +253,6 @@ EventMove::EventMove(QList<Event *> events,
|
|||
this->actionId = actionId;
|
||||
}
|
||||
|
||||
EventMove::~EventMove() {}
|
||||
|
||||
void EventMove::redo() {
|
||||
QUndoCommand::redo();
|
||||
|
||||
|
@ -340,8 +299,6 @@ EventShift::EventShift(QList<Event *> events,
|
|||
setText("Shift Events");
|
||||
}
|
||||
|
||||
EventShift::~EventShift() {}
|
||||
|
||||
int EventShift::id() const {
|
||||
return CommandId::ID_EventShift | getEventTypeMask(events);
|
||||
}
|
||||
|
@ -360,13 +317,11 @@ EventCreate::EventCreate(Editor *editor, Map *map, Event *event,
|
|||
this->event = event;
|
||||
}
|
||||
|
||||
EventCreate::~EventCreate() {}
|
||||
|
||||
void EventCreate::redo() {
|
||||
QUndoCommand::redo();
|
||||
|
||||
map->addEvent(event);
|
||||
|
||||
|
||||
editor->project->loadEventPixmaps(map->getAllEvents());
|
||||
editor->addMapEvent(event);
|
||||
|
||||
|
@ -412,8 +367,6 @@ EventDelete::EventDelete(Editor *editor, Map *map,
|
|||
this->nextSelectedEvent = nextSelectedEvent;
|
||||
}
|
||||
|
||||
EventDelete::~EventDelete() {}
|
||||
|
||||
void EventDelete::redo() {
|
||||
QUndoCommand::redo();
|
||||
|
||||
|
@ -435,7 +388,7 @@ void EventDelete::redo() {
|
|||
void EventDelete::undo() {
|
||||
for (Event *event : selectedEvents) {
|
||||
map->addEvent(event);
|
||||
|
||||
|
||||
editor->project->loadEventPixmaps(map->getAllEvents());
|
||||
editor->addMapEvent(event);
|
||||
}
|
||||
|
@ -469,8 +422,6 @@ EventDuplicate::EventDuplicate(Editor *editor, Map *map,
|
|||
this->selectedEvents = selectedEvents;
|
||||
}
|
||||
|
||||
EventDuplicate::~EventDuplicate() {}
|
||||
|
||||
void EventDuplicate::redo() {
|
||||
QUndoCommand::redo();
|
||||
|
||||
|
@ -517,7 +468,7 @@ int EventDuplicate::id() const {
|
|||
|
||||
ScriptEditMap::ScriptEditMap(Map *map,
|
||||
QSize oldMapDimensions, QSize newMapDimensions,
|
||||
Blockdata *oldMetatiles, Blockdata *newMetatiles,
|
||||
const Blockdata &oldMetatiles, const Blockdata &newMetatiles,
|
||||
QUndoCommand *parent) : QUndoCommand(parent) {
|
||||
setText("Script Edit Map");
|
||||
|
||||
|
@ -532,24 +483,17 @@ ScriptEditMap::ScriptEditMap(Map *map,
|
|||
this->newMapHeight = newMapDimensions.height();
|
||||
}
|
||||
|
||||
ScriptEditMap::~ScriptEditMap() {
|
||||
if (newMetatiles) delete newMetatiles;
|
||||
if (oldMetatiles) delete oldMetatiles;
|
||||
}
|
||||
|
||||
void ScriptEditMap::redo() {
|
||||
QUndoCommand::redo();
|
||||
|
||||
if (!map) return;
|
||||
|
||||
if (map->layout->blockdata) {
|
||||
map->layout->blockdata->copyFrom(newMetatiles);
|
||||
if (newMapWidth != map->getWidth() || newMapHeight != map->getHeight()) {
|
||||
map->setDimensions(newMapWidth, newMapHeight, false);
|
||||
}
|
||||
map->layout->blockdata = newMetatiles;
|
||||
if (newMapWidth != map->getWidth() || newMapHeight != map->getHeight()) {
|
||||
map->setDimensions(newMapWidth, newMapHeight, false);
|
||||
}
|
||||
|
||||
map->layout->lastCommitMapBlocks.blocks->copyFrom(newMetatiles);
|
||||
map->layout->lastCommitMapBlocks.blocks = newMetatiles;
|
||||
map->layout->lastCommitMapBlocks.dimensions = QSize(newMapWidth, newMapHeight);
|
||||
|
||||
renderMapBlocks(map);
|
||||
|
@ -558,14 +502,12 @@ void ScriptEditMap::redo() {
|
|||
void ScriptEditMap::undo() {
|
||||
if (!map) return;
|
||||
|
||||
if (map->layout->blockdata) {
|
||||
map->layout->blockdata->copyFrom(oldMetatiles);
|
||||
if (oldMapWidth != map->getWidth() || oldMapHeight != map->getHeight()) {
|
||||
map->setDimensions(oldMapWidth, oldMapHeight, false);
|
||||
}
|
||||
map->layout->blockdata = oldMetatiles;
|
||||
if (oldMapWidth != map->getWidth() || oldMapHeight != map->getHeight()) {
|
||||
map->setDimensions(oldMapWidth, oldMapHeight, false);
|
||||
}
|
||||
|
||||
map->layout->lastCommitMapBlocks.blocks->copyFrom(oldMetatiles);
|
||||
map->layout->lastCommitMapBlocks.blocks = oldMetatiles;
|
||||
map->layout->lastCommitMapBlocks.dimensions = QSize(oldMapWidth, oldMapHeight);
|
||||
|
||||
renderMapBlocks(map);
|
||||
|
|
|
@ -71,7 +71,7 @@ Event* Event::createNewObjectEvent(Project *project)
|
|||
event->put("event_group_type", "object_event_group");
|
||||
event->put("event_type", EventType::Object);
|
||||
event->put("sprite", project->getEventObjGfxConstants().keys().first());
|
||||
event->put("movement_type", project->movementTypes->first());
|
||||
event->put("movement_type", project->movementTypes.first());
|
||||
if (projectConfig.getObjectEventInConnectionEnabled()) {
|
||||
event->put("in_connection", false);
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ Event* Event::createNewObjectEvent(Project *project)
|
|||
event->put("script_label", "NULL");
|
||||
event->put("event_flag", "0");
|
||||
event->put("replacement", "0");
|
||||
event->put("trainer_type", project->trainerTypes->value(0, "0"));
|
||||
event->put("trainer_type", project->trainerTypes.value(0, "0"));
|
||||
event->put("sight_radius_tree_id", 0);
|
||||
event->put("elevation", 3);
|
||||
return event;
|
||||
|
@ -118,7 +118,7 @@ Event* Event::createNewTriggerEvent(Project *project)
|
|||
event->put("event_group_type", "coord_event_group");
|
||||
event->put("event_type", EventType::Trigger);
|
||||
event->put("script_label", "NULL");
|
||||
event->put("script_var", project->varNames->first());
|
||||
event->put("script_var", project->varNames.first());
|
||||
event->put("script_var_value", "0");
|
||||
event->put("elevation", 0);
|
||||
return event;
|
||||
|
@ -129,7 +129,7 @@ Event* Event::createNewWeatherTriggerEvent(Project *project)
|
|||
Event *event = new Event;
|
||||
event->put("event_group_type", "coord_event_group");
|
||||
event->put("event_type", EventType::WeatherTrigger);
|
||||
event->put("weather", project->coordEventWeatherNames->first());
|
||||
event->put("weather", project->coordEventWeatherNames.first());
|
||||
event->put("elevation", 0);
|
||||
return event;
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ Event* Event::createNewSignEvent(Project *project)
|
|||
Event *event = new Event;
|
||||
event->put("event_group_type", "bg_event_group");
|
||||
event->put("event_type", EventType::Sign);
|
||||
event->put("player_facing_direction", project->bgEventFacingDirections->first());
|
||||
event->put("player_facing_direction", project->bgEventFacingDirections.first());
|
||||
event->put("script_label", "NULL");
|
||||
event->put("elevation", 0);
|
||||
return event;
|
||||
|
@ -150,8 +150,8 @@ Event* Event::createNewHiddenItemEvent(Project *project)
|
|||
Event *event = new Event;
|
||||
event->put("event_group_type", "bg_event_group");
|
||||
event->put("event_type", EventType::HiddenItem);
|
||||
event->put("item", project->itemNames->first());
|
||||
event->put("flag", project->flagNames->first());
|
||||
event->put("item", project->itemNames.first());
|
||||
event->put("flag", project->flagNames.first());
|
||||
event->put("elevation", 3);
|
||||
if (projectConfig.getHiddenItemQuantityEnabled()) {
|
||||
event->put("quantity", 1);
|
||||
|
@ -167,7 +167,7 @@ Event* Event::createNewSecretBaseEvent(Project *project)
|
|||
Event *event = new Event;
|
||||
event->put("event_group_type", "bg_event_group");
|
||||
event->put("event_type", EventType::SecretBase);
|
||||
event->put("secret_base_id", project->secretBaseIds->first());
|
||||
event->put("secret_base_id", project->secretBaseIds.first());
|
||||
event->put("elevation", 0);
|
||||
return event;
|
||||
}
|
||||
|
@ -321,13 +321,13 @@ OrderedJson::object Event::buildObjectEventJSON()
|
|||
return eventObj;
|
||||
}
|
||||
|
||||
OrderedJson::object Event::buildWarpEventJSON(QMap<QString, QString> *mapNamesToMapConstants)
|
||||
OrderedJson::object Event::buildWarpEventJSON(const QMap<QString, QString> &mapNamesToMapConstants)
|
||||
{
|
||||
OrderedJson::object warpObj;
|
||||
warpObj["x"] = this->getU16("x");
|
||||
warpObj["y"] = this->getU16("y");
|
||||
warpObj["elevation"] = this->getInt("elevation");
|
||||
warpObj["dest_map"] = mapNamesToMapConstants->value(this->get("destination_map_name"));
|
||||
warpObj["dest_map"] = mapNamesToMapConstants.value(this->get("destination_map_name"));
|
||||
warpObj["dest_warp_id"] = this->getInt("destination_warp");
|
||||
this->addCustomValuesTo(&warpObj);
|
||||
|
||||
|
|
185
src/core/map.cpp
185
src/core/map.cpp
|
@ -78,96 +78,61 @@ int Map::getBorderHeight() {
|
|||
return layout->border_height.toInt(nullptr, 0);
|
||||
}
|
||||
|
||||
bool Map::mapBlockChanged(int i, Blockdata * cache) {
|
||||
if (!cache)
|
||||
bool Map::mapBlockChanged(int i, const Blockdata &cache) {
|
||||
if (cache.length() <= i)
|
||||
return true;
|
||||
if (!layout->blockdata)
|
||||
return true;
|
||||
if (!cache->blocks)
|
||||
return true;
|
||||
if (!layout->blockdata->blocks)
|
||||
return true;
|
||||
if (cache->blocks->length() <= i)
|
||||
return true;
|
||||
if (layout->blockdata->blocks->length() <= i)
|
||||
if (layout->blockdata.length() <= i)
|
||||
return true;
|
||||
|
||||
return layout->blockdata->blocks->value(i) != cache->blocks->value(i);
|
||||
return layout->blockdata.at(i) != cache.at(i);
|
||||
}
|
||||
|
||||
bool Map::borderBlockChanged(int i, Blockdata * cache) {
|
||||
if (!cache)
|
||||
bool Map::borderBlockChanged(int i, const Blockdata &cache) {
|
||||
if (cache.length() <= i)
|
||||
return true;
|
||||
if (!layout->border)
|
||||
return true;
|
||||
if (!cache->blocks)
|
||||
return true;
|
||||
if (!layout->border->blocks)
|
||||
return true;
|
||||
if (cache->blocks->length() <= i)
|
||||
return true;
|
||||
if (layout->border->blocks->length() <= i)
|
||||
if (layout->border.length() <= i)
|
||||
return true;
|
||||
|
||||
return layout->border->blocks->value(i) != cache->blocks->value(i);
|
||||
return layout->border.at(i) != cache.at(i);
|
||||
}
|
||||
|
||||
void Map::cacheBorder() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
layout->cached_border.clear();
|
||||
for (const auto &block : layout->border)
|
||||
layout->cached_border.append(block);
|
||||
}
|
||||
|
||||
void Map::cacheBlockdata() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
layout->cached_blockdata.clear();
|
||||
for (const auto &block : layout->blockdata)
|
||||
layout->cached_blockdata.append(block);
|
||||
}
|
||||
|
||||
void Map::cacheCollision() {
|
||||
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);
|
||||
}
|
||||
}
|
||||
layout->cached_collision.clear();
|
||||
for (const auto &block : layout->blockdata)
|
||||
layout->cached_collision.append(block);
|
||||
}
|
||||
|
||||
QPixmap Map::renderCollision(qreal opacity, bool ignoreCache) {
|
||||
bool changed_any = false;
|
||||
int width_ = getWidth();
|
||||
int height_ = getHeight();
|
||||
if (
|
||||
collision_image.isNull()
|
||||
|| collision_image.width() != width_ * 16
|
||||
|| collision_image.height() != height_ * 16
|
||||
) {
|
||||
if (collision_image.isNull() || collision_image.width() != width_ * 16 || collision_image.height() != height_ * 16) {
|
||||
collision_image = QImage(width_ * 16, height_ * 16, QImage::Format_RGBA8888);
|
||||
changed_any = true;
|
||||
}
|
||||
if (!(layout->blockdata && layout->blockdata->blocks && width_ && height_)) {
|
||||
if (layout->blockdata.isEmpty() || !width_ || !height_) {
|
||||
collision_pixmap = collision_pixmap.fromImage(collision_image);
|
||||
return collision_pixmap;
|
||||
}
|
||||
QPainter painter(&collision_image);
|
||||
for (int i = 0; i < layout->blockdata->blocks->length(); i++) {
|
||||
if (!ignoreCache && layout->cached_collision && !mapBlockChanged(i, layout->cached_collision)) {
|
||||
for (int i = 0; i < layout->blockdata.length(); i++) {
|
||||
if (!ignoreCache && !mapBlockChanged(i, layout->cached_collision)) {
|
||||
continue;
|
||||
}
|
||||
changed_any = true;
|
||||
Block block = layout->blockdata->blocks->value(i);
|
||||
Block block = layout->blockdata.at(i);
|
||||
QImage metatile_image = getMetatileImage(block.tile, layout->tileset_primary, layout->tileset_secondary, metatileLayerOrder, metatileLayerOpacity);
|
||||
QImage collision_metatile_image = getCollisionMetatileImage(block);
|
||||
int map_y = width_ ? i / width_ : 0;
|
||||
|
@ -192,26 +157,22 @@ QPixmap Map::render(bool ignoreCache = false, MapLayout * fromLayout) {
|
|||
bool changed_any = false;
|
||||
int width_ = getWidth();
|
||||
int height_ = getHeight();
|
||||
if (
|
||||
image.isNull()
|
||||
|| image.width() != width_ * 16
|
||||
|| image.height() != height_ * 16
|
||||
) {
|
||||
if (image.isNull() || image.width() != width_ * 16 || image.height() != height_ * 16) {
|
||||
image = QImage(width_ * 16, height_ * 16, QImage::Format_RGBA8888);
|
||||
changed_any = true;
|
||||
}
|
||||
if (!(layout->blockdata && layout->blockdata->blocks && width_ && height_)) {
|
||||
if (layout->blockdata.isEmpty() || !width_ || !height_) {
|
||||
pixmap = pixmap.fromImage(image);
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
QPainter painter(&image);
|
||||
for (int i = 0; i < layout->blockdata->blocks->length(); i++) {
|
||||
for (int i = 0; i < layout->blockdata.length(); i++) {
|
||||
if (!ignoreCache && !mapBlockChanged(i, layout->cached_blockdata)) {
|
||||
continue;
|
||||
}
|
||||
changed_any = true;
|
||||
Block block = layout->blockdata->blocks->value(i);
|
||||
Block block = layout->blockdata.at(i);
|
||||
QImage metatile_image = getMetatileImage(
|
||||
block.tile,
|
||||
fromLayout ? fromLayout->tileset_primary : layout->tileset_primary,
|
||||
|
@ -245,18 +206,18 @@ QPixmap Map::renderBorder(bool ignoreCache) {
|
|||
layout->border_image = QImage(width_ * 16, height_ * 16, QImage::Format_RGBA8888);
|
||||
border_resized = true;
|
||||
}
|
||||
if (!(layout->border && layout->border->blocks)) {
|
||||
if (layout->border.isEmpty()) {
|
||||
layout->border_pixmap = layout->border_pixmap.fromImage(layout->border_image);
|
||||
return layout->border_pixmap;
|
||||
}
|
||||
QPainter painter(&layout->border_image);
|
||||
for (int i = 0; i < layout->border->blocks->length(); i++) {
|
||||
for (int i = 0; i < layout->border.length(); i++) {
|
||||
if (!ignoreCache && (!border_resized && !borderBlockChanged(i, layout->cached_border))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
changed_any = true;
|
||||
Block block = layout->border->blocks->value(i);
|
||||
Block block = layout->border.at(i);
|
||||
uint16_t tile = block.tile;
|
||||
QImage metatile_image = getMetatileImage(tile, layout->tileset_primary, layout->tileset_secondary, metatileLayerOrder, metatileLayerOpacity);
|
||||
int map_y = width_ ? i / width_ : 0;
|
||||
|
@ -310,38 +271,38 @@ void Map::setNewDimensionsBlockdata(int newWidth, int newHeight) {
|
|||
int oldWidth = getWidth();
|
||||
int oldHeight = getHeight();
|
||||
|
||||
Blockdata* newBlockData = new Blockdata;
|
||||
Blockdata newBlockdata;
|
||||
|
||||
for (int y = 0; y < newHeight; y++)
|
||||
for (int x = 0; x < newWidth; x++) {
|
||||
if (x < oldWidth && y < oldHeight) {
|
||||
int index = y * oldWidth + x;
|
||||
newBlockData->addBlock(layout->blockdata->blocks->value(index));
|
||||
newBlockdata.append(layout->blockdata.value(index));
|
||||
} else {
|
||||
newBlockData->addBlock(0);
|
||||
newBlockdata.append(0);
|
||||
}
|
||||
}
|
||||
|
||||
layout->blockdata->copyFrom(newBlockData);
|
||||
layout->blockdata = newBlockdata;
|
||||
}
|
||||
|
||||
void Map::setNewBorderDimensionsBlockdata(int newWidth, int newHeight) {
|
||||
int oldWidth = getBorderWidth();
|
||||
int oldHeight = getBorderHeight();
|
||||
|
||||
Blockdata* newBlockData = new Blockdata;
|
||||
Blockdata newBlockdata;
|
||||
|
||||
for (int y = 0; y < newHeight; y++)
|
||||
for (int x = 0; x < newWidth; x++) {
|
||||
if (x < oldWidth && y < oldHeight) {
|
||||
int index = y * oldWidth + x;
|
||||
newBlockData->addBlock(layout->border->blocks->value(index));
|
||||
newBlockdata.append(layout->border.value(index));
|
||||
} else {
|
||||
newBlockData->addBlock(0);
|
||||
newBlockdata.append(0);
|
||||
}
|
||||
}
|
||||
|
||||
layout->border->copyFrom(newBlockData);
|
||||
layout->border = newBlockdata;
|
||||
}
|
||||
|
||||
void Map::setDimensions(int newWidth, int newHeight, bool setNewBlockdata) {
|
||||
|
@ -368,21 +329,19 @@ void Map::setBorderDimensions(int newWidth, int newHeight, bool setNewBlockdata)
|
|||
}
|
||||
|
||||
bool Map::getBlock(int x, int y, Block *out) {
|
||||
if (layout->blockdata && layout->blockdata->blocks) {
|
||||
if (x >= 0 && x < getWidth() && y >= 0 && y < getHeight()) {
|
||||
int i = y * getWidth() + x;
|
||||
*out = layout->blockdata->blocks->value(i);
|
||||
return true;
|
||||
}
|
||||
if (x >= 0 && x < getWidth() && y >= 0 && y < getHeight()) {
|
||||
int i = y * getWidth() + x;
|
||||
*out = layout->blockdata.value(i);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Map::setBlock(int x, int y, Block block, bool enableScriptCallback) {
|
||||
int i = y * getWidth() + x;
|
||||
if (layout->blockdata && layout->blockdata->blocks && i < layout->blockdata->blocks->size()) {
|
||||
Block prevBlock = layout->blockdata->blocks->value(i);
|
||||
layout->blockdata->blocks->replace(i, block);
|
||||
if (i < layout->blockdata.size()) {
|
||||
Block prevBlock = layout->blockdata.at(i);
|
||||
layout->blockdata.replace(i, block);
|
||||
if (enableScriptCallback) {
|
||||
Scripting::cb_MetatileChanged(x, y, prevBlock, block);
|
||||
}
|
||||
|
@ -393,40 +352,40 @@ void Map::_floodFillCollisionElevation(int x, int y, uint16_t collision, uint16_
|
|||
QList<QPoint> todo;
|
||||
todo.append(QPoint(x, y));
|
||||
while (todo.length()) {
|
||||
QPoint point = todo.takeAt(0);
|
||||
x = point.x();
|
||||
y = point.y();
|
||||
Block block;
|
||||
if (!getBlock(x, y, &block)) {
|
||||
continue;
|
||||
}
|
||||
QPoint point = todo.takeAt(0);
|
||||
x = point.x();
|
||||
y = point.y();
|
||||
Block block;
|
||||
if (!getBlock(x, y, &block)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
uint old_coll = block.collision;
|
||||
uint old_elev = block.elevation;
|
||||
if (old_coll == collision && old_elev == elevation) {
|
||||
continue;
|
||||
}
|
||||
uint old_coll = block.collision;
|
||||
uint old_elev = block.elevation;
|
||||
if (old_coll == collision && old_elev == elevation) {
|
||||
continue;
|
||||
}
|
||||
|
||||
block.collision = collision;
|
||||
block.elevation = elevation;
|
||||
setBlock(x, y, block, true);
|
||||
if (getBlock(x + 1, y, &block) && block.collision == old_coll && block.elevation == old_elev) {
|
||||
todo.append(QPoint(x + 1, y));
|
||||
}
|
||||
if (getBlock(x - 1, y, &block) && block.collision == old_coll && block.elevation == old_elev) {
|
||||
todo.append(QPoint(x - 1, y));
|
||||
}
|
||||
if (getBlock(x, y + 1, &block) && block.collision == old_coll && block.elevation == old_elev) {
|
||||
todo.append(QPoint(x, y + 1));
|
||||
}
|
||||
if (getBlock(x, y - 1, &block) && block.collision == old_coll && block.elevation == old_elev) {
|
||||
todo.append(QPoint(x, y - 1));
|
||||
}
|
||||
block.collision = collision;
|
||||
block.elevation = elevation;
|
||||
setBlock(x, y, block, true);
|
||||
if (getBlock(x + 1, y, &block) && block.collision == old_coll && block.elevation == old_elev) {
|
||||
todo.append(QPoint(x + 1, y));
|
||||
}
|
||||
if (getBlock(x - 1, y, &block) && block.collision == old_coll && block.elevation == old_elev) {
|
||||
todo.append(QPoint(x - 1, y));
|
||||
}
|
||||
if (getBlock(x, y + 1, &block) && block.collision == old_coll && block.elevation == old_elev) {
|
||||
todo.append(QPoint(x, y + 1));
|
||||
}
|
||||
if (getBlock(x, y - 1, &block) && block.collision == old_coll && block.elevation == old_elev) {
|
||||
todo.append(QPoint(x, y - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Map::floodFillCollisionElevation(int x, int y, uint16_t collision, uint16_t elevation) {
|
||||
Block block;;
|
||||
Block block;
|
||||
if (getBlock(x, y, &block) && (block.collision != collision || block.elevation != elevation)) {
|
||||
_floodFillCollisionElevation(x, y, collision, elevation);
|
||||
}
|
||||
|
|
|
@ -6,15 +6,12 @@
|
|||
#include <QJsonObject>
|
||||
#include <QStack>
|
||||
|
||||
ParseUtil::ParseUtil()
|
||||
{
|
||||
}
|
||||
|
||||
void ParseUtil::set_root(QString dir) {
|
||||
void ParseUtil::set_root(const QString &dir) {
|
||||
this->root = dir;
|
||||
}
|
||||
|
||||
void ParseUtil::error(QString message, QString expression) {
|
||||
void ParseUtil::error(const QString &message, const QString &expression) {
|
||||
QStringList lines = text.split(QRegularExpression("[\r\n]"));
|
||||
int lineNum = 0, colNum = 0;
|
||||
for (QString line : lines) {
|
||||
|
@ -25,21 +22,7 @@ void ParseUtil::error(QString message, QString expression) {
|
|||
logError(QString("%1:%2:%3: %4").arg(file).arg(lineNum).arg(colNum).arg(message));
|
||||
}
|
||||
|
||||
void ParseUtil::strip_comment(QString *line) {
|
||||
bool in_string = false;
|
||||
for (int i = 0; i < line->length(); i++) {
|
||||
if (line->at(i) == '"') {
|
||||
in_string = !in_string;
|
||||
} else if (line->at(i) == '@') {
|
||||
if (!in_string) {
|
||||
line->truncate(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString ParseUtil::readTextFile(QString path) {
|
||||
QString ParseUtil::readTextFile(const QString &path) {
|
||||
QFile file(path);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
logError(QString("Could not open '%1': ").arg(path) + file.errorString());
|
||||
|
@ -59,45 +42,41 @@ int ParseUtil::textFileLineCount(const QString &path) {
|
|||
return text.split('\n').count() + 1;
|
||||
}
|
||||
|
||||
QList<QStringList>* ParseUtil::parseAsm(QString filename) {
|
||||
QList<QStringList> *parsed = new QList<QStringList>;
|
||||
QList<QStringList> ParseUtil::parseAsm(const QString &filename) {
|
||||
QList<QStringList> parsed;
|
||||
|
||||
text = readTextFile(root + "/" + filename);
|
||||
QStringList lines = text.split('\n');
|
||||
for (QString line : lines) {
|
||||
QString label;
|
||||
strip_comment(&line);
|
||||
if (line.trimmed().isEmpty()) {
|
||||
} else if (line.contains(':')) {
|
||||
label = line.left(line.indexOf(':'));
|
||||
QStringList *list = new QStringList;
|
||||
list->append(".label"); // This is not a real keyword. It's used only to make the output more regular.
|
||||
list->append(label);
|
||||
parsed->append(*list);
|
||||
text = readTextFile(root + '/' + filename);
|
||||
const QStringList lines = removeLineComments(text, "@").split('\n');
|
||||
for (const auto &line : lines) {
|
||||
const QString trimmedLine = line.trimmed();
|
||||
if (trimmedLine.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line.contains(':')) {
|
||||
const QString label = line.left(line.indexOf(':'));
|
||||
const QStringList list{ ".label", label }; // .label is not a real keyword. It's used only to make the output more regular.
|
||||
parsed.append(list);
|
||||
// There should not be anything else on the line.
|
||||
// gas will raise a syntax error if there is.
|
||||
} else {
|
||||
line = line.trimmed();
|
||||
//parsed->append(line.split(QRegExp("\\s*,\\s*")));
|
||||
QString macro;
|
||||
QStringList params;
|
||||
int index = line.indexOf(QRegExp("\\s+"));
|
||||
macro = line.left(index);
|
||||
params = line.right(line.length() - index).trimmed().split(QRegExp("\\s*,\\s*"));
|
||||
int index = trimmedLine.indexOf(QRegExp("\\s+"));
|
||||
const QString macro = trimmedLine.left(index);
|
||||
QStringList params(trimmedLine.right(trimmedLine.length() - index).trimmed().split(QRegExp("\\s*,\\s*")));
|
||||
params.prepend(macro);
|
||||
parsed->append(params);
|
||||
parsed.append(params);
|
||||
}
|
||||
}
|
||||
return parsed;
|
||||
}
|
||||
|
||||
int ParseUtil::evaluateDefine(QString define, QMap<QString, int>* knownDefines) {
|
||||
int ParseUtil::evaluateDefine(const QString &define, const QMap<QString, int> &knownDefines) {
|
||||
QList<Token> tokens = tokenizeExpression(define, knownDefines);
|
||||
QList<Token> postfixExpression = generatePostfix(tokens);
|
||||
return evaluatePostfix(postfixExpression);
|
||||
}
|
||||
|
||||
QList<Token> ParseUtil::tokenizeExpression(QString expression, QMap<QString, int>* knownIdentifiers) {
|
||||
QList<Token> ParseUtil::tokenizeExpression(QString expression, const QMap<QString, int> &knownIdentifiers) {
|
||||
QList<Token> tokens;
|
||||
|
||||
QStringList tokenTypes = (QStringList() << "hex" << "decimal" << "identifier" << "operator" << "leftparen" << "rightparen");
|
||||
|
@ -114,8 +93,8 @@ QList<Token> ParseUtil::tokenizeExpression(QString expression, QMap<QString, int
|
|||
QString token = match.captured(tokenType);
|
||||
if (!token.isEmpty()) {
|
||||
if (tokenType == "identifier") {
|
||||
if (knownIdentifiers->contains(token)) {
|
||||
QString actualToken = QString("%1").arg(knownIdentifiers->value(token));
|
||||
if (knownIdentifiers.contains(token)) {
|
||||
QString actualToken = QString("%1").arg(knownIdentifiers.value(token));
|
||||
expression = expression.replace(0, token.length(), actualToken);
|
||||
token = actualToken;
|
||||
tokenType = "decimal";
|
||||
|
@ -158,7 +137,7 @@ QMap<QString, int> Token::precedenceMap = QMap<QString, int>(
|
|||
|
||||
// Shunting-yard algorithm for generating postfix notation.
|
||||
// https://en.wikipedia.org/wiki/Shunting-yard_algorithm
|
||||
QList<Token> ParseUtil::generatePostfix(QList<Token> tokens) {
|
||||
QList<Token> ParseUtil::generatePostfix(const QList<Token> &tokens) {
|
||||
QList<Token> output;
|
||||
QStack<Token> operatorStack;
|
||||
for (Token token : tokens) {
|
||||
|
@ -200,7 +179,7 @@ QList<Token> ParseUtil::generatePostfix(QList<Token> tokens) {
|
|||
|
||||
// Evaluate postfix expression.
|
||||
// https://en.wikipedia.org/wiki/Reverse_Polish_notation#Postfix_evaluation_algorithm
|
||||
int ParseUtil::evaluatePostfix(QList<Token> postfix) {
|
||||
int ParseUtil::evaluatePostfix(const QList<Token> &postfix) {
|
||||
QStack<Token> stack;
|
||||
for (Token token : postfix) {
|
||||
if (token.type == TokenClass::Operator && stack.size() > 1) {
|
||||
|
@ -234,7 +213,7 @@ int ParseUtil::evaluatePostfix(QList<Token> postfix) {
|
|||
return stack.size() ? stack.pop().value.toInt(nullptr, 0) : 0;
|
||||
}
|
||||
|
||||
QString ParseUtil::readCIncbin(QString filename, QString label) {
|
||||
QString ParseUtil::readCIncbin(const QString &filename, const QString &label) {
|
||||
QString path;
|
||||
|
||||
if (label.isNull()) {
|
||||
|
@ -257,7 +236,10 @@ QString ParseUtil::readCIncbin(QString filename, QString label) {
|
|||
return path;
|
||||
}
|
||||
|
||||
QMap<QString, int> ParseUtil::readCDefines(QString filename, QStringList prefixes, QMap<QString, int> allDefines) {
|
||||
QMap<QString, int> ParseUtil::readCDefines(const QString &filename,
|
||||
const QStringList &prefixes,
|
||||
QMap<QString, int> allDefines)
|
||||
{
|
||||
QMap<QString, int> filteredDefines;
|
||||
|
||||
file = filename;
|
||||
|
@ -286,7 +268,7 @@ QMap<QString, int> ParseUtil::readCDefines(QString filename, QStringList prefixe
|
|||
QString name = match.captured("defineName");
|
||||
QString expression = match.captured("defineValue");
|
||||
if (expression == " ") continue;
|
||||
int value = evaluateDefine(expression, &allDefines);
|
||||
int value = evaluateDefine(expression, allDefines);
|
||||
allDefines.insert(name, value);
|
||||
for (QString prefix : prefixes) {
|
||||
if (name.startsWith(prefix) || QRegularExpression(prefix).match(name).hasMatch()) {
|
||||
|
@ -297,7 +279,10 @@ QMap<QString, int> ParseUtil::readCDefines(QString filename, QStringList prefixe
|
|||
return filteredDefines;
|
||||
}
|
||||
|
||||
void ParseUtil::readCDefinesSorted(QString filename, QStringList prefixes, QStringList* definesToSet, QMap<QString, int> knownDefines) {
|
||||
QStringList ParseUtil::readCDefinesSorted(const QString &filename,
|
||||
const QStringList &prefixes,
|
||||
const QMap<QString, int> &knownDefines)
|
||||
{
|
||||
QMap<QString, int> defines = readCDefines(filename, prefixes, knownDefines);
|
||||
|
||||
// The defines should to be sorted by their underlying value, not alphabetically.
|
||||
|
@ -306,10 +291,10 @@ void ParseUtil::readCDefinesSorted(QString filename, QStringList prefixes, QStri
|
|||
for (QString defineName : defines.keys()) {
|
||||
definesInverse.insert(defines[defineName], defineName);
|
||||
}
|
||||
*definesToSet = definesInverse.values();
|
||||
return definesInverse.values();
|
||||
}
|
||||
|
||||
QStringList ParseUtil::readCArray(QString filename, QString label) {
|
||||
QStringList ParseUtil::readCArray(const QString &filename, const QString &label) {
|
||||
QStringList list;
|
||||
|
||||
if (label.isNull()) {
|
||||
|
@ -335,13 +320,13 @@ QStringList ParseUtil::readCArray(QString filename, QString label) {
|
|||
return list;
|
||||
}
|
||||
|
||||
QMap<QString, QString> ParseUtil::readNamedIndexCArray(QString filename, QString label) {
|
||||
QMap<QString, QString> ParseUtil::readNamedIndexCArray(const QString &filename, const QString &label) {
|
||||
text = readTextFile(root + "/" + filename);
|
||||
QMap<QString, QString> map;
|
||||
|
||||
QRegularExpression re_text(QString(R"(\b%1\b\s*(\[?[^\]]*\])?\s*=\s*\{([^\}]*)\})").arg(label));
|
||||
QString body = re_text.match(text).captured(2).replace(QRegularExpression("\\s*"), "");
|
||||
|
||||
|
||||
QRegularExpression re("\\[(?<index>[A-Za-z0-9_]*)\\]=(?<value>&?[A-Za-z0-9_]*)");
|
||||
QRegularExpressionMatchIterator iter = re.globalMatch(body);
|
||||
|
||||
|
@ -355,24 +340,23 @@ QMap<QString, QString> ParseUtil::readNamedIndexCArray(QString filename, QString
|
|||
return map;
|
||||
}
|
||||
|
||||
QList<QStringList>* ParseUtil::getLabelMacros(QList<QStringList> *list, QString label) {
|
||||
QList<QStringList> ParseUtil::getLabelMacros(const QList<QStringList> &list, const QString &label) {
|
||||
bool in_label = false;
|
||||
QList<QStringList> *new_list = new QList<QStringList>;
|
||||
for (int i = 0; i < list->length(); i++) {
|
||||
QStringList params = list->value(i);
|
||||
QString macro = params.value(0);
|
||||
QList<QStringList> new_list;
|
||||
for (const auto ¶ms : list) {
|
||||
const QString macro = params.value(0);
|
||||
if (macro == ".label") {
|
||||
if (params.value(1) == label) {
|
||||
in_label = true;
|
||||
} else if (in_label) {
|
||||
// If nothing has been read yet, assume the label
|
||||
// we're looking for is in a stack of labels.
|
||||
if (new_list->length() > 0) {
|
||||
if (new_list.length() > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (in_label) {
|
||||
new_list->append(params);
|
||||
new_list.append(params);
|
||||
}
|
||||
}
|
||||
return new_list;
|
||||
|
@ -380,32 +364,31 @@ QList<QStringList>* ParseUtil::getLabelMacros(QList<QStringList> *list, QString
|
|||
|
||||
// For if you don't care about filtering by macro,
|
||||
// and just want all values associated with some label.
|
||||
QStringList* ParseUtil::getLabelValues(QList<QStringList> *list, QString label) {
|
||||
list = getLabelMacros(list, label);
|
||||
QStringList *values = new QStringList;
|
||||
for (int i = 0; i < list->length(); i++) {
|
||||
QStringList params = list->value(i);
|
||||
QString macro = params.value(0);
|
||||
QStringList ParseUtil::getLabelValues(const QList<QStringList> &list, const QString &label) {
|
||||
const QList<QStringList> labelMacros = getLabelMacros(list, label);
|
||||
QStringList values;
|
||||
for (const auto ¶ms : labelMacros) {
|
||||
const QString macro = params.value(0);
|
||||
if (macro == ".align" || macro == ".ifdef" || macro == ".ifndef") {
|
||||
continue;
|
||||
}
|
||||
for (int j = 1; j < params.length(); j++) {
|
||||
values->append(params.value(j));
|
||||
for (int i = 1; i < params.length(); i++) {
|
||||
values.append(params.value(i));
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
bool ParseUtil::tryParseJsonFile(QJsonDocument *out, QString filepath) {
|
||||
bool ParseUtil::tryParseJsonFile(QJsonDocument *out, const QString &filepath) {
|
||||
QFile file(filepath);
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
logError(QString("Error: Could not open %1 for reading").arg(filepath));
|
||||
return false;
|
||||
}
|
||||
|
||||
QByteArray data = file.readAll();
|
||||
const QByteArray data = file.readAll();
|
||||
QJsonParseError parseError;
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &parseError);
|
||||
const QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &parseError);
|
||||
file.close();
|
||||
if (parseError.error != QJsonParseError::NoError) {
|
||||
logError(QString("Error: Failed to parse json file %1: %2").arg(filepath).arg(parseError.errorString()));
|
||||
|
@ -416,7 +399,7 @@ bool ParseUtil::tryParseJsonFile(QJsonDocument *out, QString filepath) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ParseUtil::ensureFieldsExist(QJsonObject obj, QList<QString> fields) {
|
||||
bool ParseUtil::ensureFieldsExist(const QJsonObject &obj, const QList<QString> &fields) {
|
||||
for (QString field : fields) {
|
||||
if (!obj.contains(field)) {
|
||||
logError(QString("JSON object is missing field '%1'.").arg(field));
|
||||
|
@ -439,8 +422,8 @@ int ParseUtil::getScriptLineNumber(const QString &filePath, const QString &scrip
|
|||
}
|
||||
|
||||
int ParseUtil::getRawScriptLineNumber(QString text, const QString &scriptLabel) {
|
||||
removeStringLiterals(text);
|
||||
removeLineComments(text, "@");
|
||||
text = removeStringLiterals(text);
|
||||
text = removeLineComments(text, "@");
|
||||
|
||||
static const QRegularExpression re_incScriptLabel("\\b(?<label>[\\w_][\\w\\d_]*):{1,2}");
|
||||
QRegularExpressionMatchIterator it = re_incScriptLabel.globalMatch(text);
|
||||
|
@ -454,8 +437,8 @@ int ParseUtil::getRawScriptLineNumber(QString text, const QString &scriptLabel)
|
|||
}
|
||||
|
||||
int ParseUtil::getPoryScriptLineNumber(QString text, const QString &scriptLabel) {
|
||||
removeStringLiterals(text);
|
||||
removeLineComments(text, {"//", "#"});
|
||||
text = removeStringLiterals(text);
|
||||
text = removeLineComments(text, {"//", "#"});
|
||||
|
||||
static const QRegularExpression re_poryScriptLabel("\\b(script)(\\((global|local)\\))?\\s*\\b(?<label>[\\w_][\\w\\d_]*)");
|
||||
QRegularExpressionMatchIterator it = re_poryScriptLabel.globalMatch(text);
|
||||
|
@ -477,19 +460,19 @@ int ParseUtil::getPoryScriptLineNumber(QString text, const QString &scriptLabel)
|
|||
return 0;
|
||||
}
|
||||
|
||||
QString &ParseUtil::removeStringLiterals(QString &text) {
|
||||
QString ParseUtil::removeStringLiterals(QString text) {
|
||||
static const QRegularExpression re_string("\".*\"");
|
||||
return text.remove(re_string);
|
||||
}
|
||||
|
||||
QString &ParseUtil::removeLineComments(QString &text, const QString &commentSymbol) {
|
||||
QString ParseUtil::removeLineComments(QString text, const QString &commentSymbol) {
|
||||
const QRegularExpression re_lineComment(commentSymbol + "+.*");
|
||||
return text.remove(re_lineComment);
|
||||
}
|
||||
|
||||
QString &ParseUtil::removeLineComments(QString &text, const QStringList &commentSymbols) {
|
||||
QString ParseUtil::removeLineComments(QString text, const QStringList &commentSymbols) {
|
||||
for (const auto &commentSymbol : commentSymbols)
|
||||
removeLineComments(text, commentSymbol);
|
||||
text = removeLineComments(text, commentSymbol);
|
||||
return text;
|
||||
}
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ bool RegionMap::readLayout() {
|
|||
return false;
|
||||
}
|
||||
|
||||
QMap<QString, QString> *qmap = new QMap<QString, QString>;
|
||||
QMap<QString, QString> qmap;
|
||||
|
||||
bool mapNamesQualified = false, mapEntriesQualified = false;
|
||||
|
||||
|
@ -155,7 +155,7 @@ bool RegionMap::readLayout() {
|
|||
QStringList entry = reAfter.match(line).captured(1).remove(" ").split(",");
|
||||
QString mapsec = reBefore.match(line).captured(1);
|
||||
QString insertion = entry[4].remove("sMapName_");
|
||||
qmap->insert(mapsec, sMapNamesMap.value(insertion));
|
||||
qmap.insert(mapsec, sMapNamesMap.value(insertion));
|
||||
mapSecToMapEntry[mapsec] = {
|
||||
// x y width height name
|
||||
entry[0].toInt(), entry[1].toInt(), entry[2].toInt(), entry[3].toInt(), insertion
|
||||
|
@ -265,7 +265,7 @@ void RegionMap::saveOptions(int id, QString sec, QString name, int x, int y) {
|
|||
this->map_squares[index].mapsec = sec;
|
||||
if (!name.isEmpty()) {
|
||||
this->map_squares[index].map_name = name;
|
||||
this->project->mapSecToMapHoverName->insert(sec, name);
|
||||
this->project->mapSecToMapHoverName.insert(sec, name);
|
||||
QString sName = fixCase(sec);
|
||||
sMapNamesMap.insert(sName, name);
|
||||
if (!mapSecToMapEntry.keys().contains(sec)) {
|
||||
|
|
|
@ -726,11 +726,11 @@ void Editor::populateConnectionMapPickers() {
|
|||
ui->comboBox_EmergeMap->blockSignals(true);
|
||||
|
||||
ui->comboBox_ConnectedMap->clear();
|
||||
ui->comboBox_ConnectedMap->addItems(*project->mapNames);
|
||||
ui->comboBox_ConnectedMap->addItems(project->mapNames);
|
||||
ui->comboBox_DiveMap->clear();
|
||||
ui->comboBox_DiveMap->addItems(*project->mapNames);
|
||||
ui->comboBox_DiveMap->addItems(project->mapNames);
|
||||
ui->comboBox_EmergeMap->clear();
|
||||
ui->comboBox_EmergeMap->addItems(*project->mapNames);
|
||||
ui->comboBox_EmergeMap->addItems(project->mapNames);
|
||||
|
||||
ui->comboBox_ConnectedMap->blockSignals(false);
|
||||
ui->comboBox_DiveMap->blockSignals(true);
|
||||
|
@ -959,7 +959,7 @@ void Editor::onHoveredMapMetatileChanged(const QPoint &pos) {
|
|||
if (map_item->paintingMode == MapPixmapItem::PaintMode::Metatiles
|
||||
&& pos.x() >= 0 && pos.x() < map->getWidth() && pos.y() >= 0 && pos.y() < map->getHeight()) {
|
||||
int blockIndex = pos.y() * map->getWidth() + pos.x();
|
||||
int metatileId = map->layout->blockdata->blocks->at(blockIndex).tile;
|
||||
int metatileId = map->layout->blockdata.at(blockIndex).tile;
|
||||
this->ui->statusBar->showMessage(QString("X: %1, Y: %2, %3, Scale = %4x")
|
||||
.arg(pos.x())
|
||||
.arg(pos.y())
|
||||
|
@ -989,8 +989,8 @@ void Editor::onHoveredMapMovementPermissionChanged(int x, int y) {
|
|||
if (map_item->paintingMode == MapPixmapItem::PaintMode::Metatiles
|
||||
&& x >= 0 && x < map->getWidth() && y >= 0 && y < map->getHeight()) {
|
||||
int blockIndex = y * map->getWidth() + x;
|
||||
uint16_t collision = map->layout->blockdata->blocks->at(blockIndex).collision;
|
||||
uint16_t elevation = map->layout->blockdata->blocks->at(blockIndex).elevation;
|
||||
uint16_t collision = map->layout->blockdata.at(blockIndex).collision;
|
||||
uint16_t elevation = map->layout->blockdata.at(blockIndex).elevation;
|
||||
QString message = QString("X: %1, Y: %2, %3")
|
||||
.arg(x)
|
||||
.arg(y)
|
||||
|
@ -1678,7 +1678,7 @@ void Editor::updateConnectionOffset(int offset) {
|
|||
}
|
||||
|
||||
void Editor::setConnectionMap(QString mapName) {
|
||||
if (!mapName.isEmpty() && !project->mapNames->contains(mapName)) {
|
||||
if (!mapName.isEmpty() && !project->mapNames.contains(mapName)) {
|
||||
logError(QString("Invalid map name '%1' specified for connection.").arg(mapName));
|
||||
return;
|
||||
}
|
||||
|
@ -1714,9 +1714,9 @@ void Editor::addNewConnection() {
|
|||
}
|
||||
|
||||
// Don't connect the map to itself.
|
||||
QString defaultMapName = project->mapNames->first();
|
||||
QString defaultMapName = project->mapNames.first();
|
||||
if (defaultMapName == map->name) {
|
||||
defaultMapName = project->mapNames->value(1);
|
||||
defaultMapName = project->mapNames.value(1);
|
||||
}
|
||||
|
||||
MapConnection* newConnection = new MapConnection;
|
||||
|
@ -1824,7 +1824,7 @@ void Editor::updateEmergeMap(QString mapName) {
|
|||
}
|
||||
|
||||
void Editor::updateDiveEmergeMap(QString mapName, QString direction) {
|
||||
if (!mapName.isEmpty() && !project->mapNamesToMapConstants->contains(mapName)) {
|
||||
if (!mapName.isEmpty() && !project->mapNamesToMapConstants.contains(mapName)) {
|
||||
logError(QString("Invalid %1 connection map name: '%2'").arg(direction).arg(mapName));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -672,7 +672,7 @@ void MainWindow::refreshMapScene()
|
|||
|
||||
void MainWindow::openWarpMap(QString map_name, QString warp_num) {
|
||||
// Ensure valid destination map name.
|
||||
if (!editor->project->mapNames->contains(map_name)) {
|
||||
if (!editor->project->mapNames.contains(map_name)) {
|
||||
logError(QString("Invalid warp destination map name '%1'").arg(map_name));
|
||||
return;
|
||||
}
|
||||
|
@ -910,11 +910,11 @@ bool MainWindow::loadProjectCombos() {
|
|||
ui->comboBox_SecondaryTileset->clear();
|
||||
ui->comboBox_SecondaryTileset->addItems(tilesets.value("secondary"));
|
||||
ui->comboBox_Weather->clear();
|
||||
ui->comboBox_Weather->addItems(*project->weatherNames);
|
||||
ui->comboBox_Weather->addItems(project->weatherNames);
|
||||
ui->comboBox_BattleScene->clear();
|
||||
ui->comboBox_BattleScene->addItems(*project->mapBattleScenes);
|
||||
ui->comboBox_BattleScene->addItems(project->mapBattleScenes);
|
||||
ui->comboBox_Type->clear();
|
||||
ui->comboBox_Type->addItems(*project->mapTypes);
|
||||
ui->comboBox_Type->addItems(project->mapTypes);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -946,8 +946,8 @@ void MainWindow::sortMapList() {
|
|||
switch (mapSortOrder)
|
||||
{
|
||||
case MapSortOrder::Group:
|
||||
for (int i = 0; i < project->groupNames->length(); i++) {
|
||||
QString group_name = project->groupNames->value(i);
|
||||
for (int i = 0; i < project->groupNames.length(); i++) {
|
||||
QString group_name = project->groupNames.value(i);
|
||||
QStandardItem *group = new QStandardItem;
|
||||
group->setText(group_name);
|
||||
group->setIcon(mapFolderIcon);
|
||||
|
@ -982,7 +982,7 @@ void MainWindow::sortMapList() {
|
|||
mapGroupItemsList->append(mapsec);
|
||||
mapsecToGroupNum.insert(mapsec_name, i);
|
||||
}
|
||||
for (int i = 0; i < project->groupNames->length(); i++) {
|
||||
for (int i = 0; i < project->groupNames.length(); i++) {
|
||||
QStringList names = project->groupedMapNames.value(i);
|
||||
for (int j = 0; j < names.length(); j++) {
|
||||
QString map_name = names.value(j);
|
||||
|
@ -1014,7 +1014,7 @@ void MainWindow::sortMapList() {
|
|||
mapGroupItemsList->append(layoutItem);
|
||||
layoutIndices[layoutId] = i;
|
||||
}
|
||||
for (int i = 0; i < project->groupNames->length(); i++) {
|
||||
for (int i = 0; i < project->groupNames.length(); i++) {
|
||||
QStringList names = project->groupedMapNames.value(i);
|
||||
for (int j = 0; j < names.length(); j++) {
|
||||
QString map_name = names.value(j);
|
||||
|
@ -1340,10 +1340,10 @@ void MainWindow::drawMapListIcons(QAbstractItemModel *model) {
|
|||
QVariant data = index.data(Qt::UserRole);
|
||||
if (!data.isNull()) {
|
||||
QString map_name = data.toString();
|
||||
if (editor->project && editor->project->mapCache->contains(map_name)) {
|
||||
if (editor->project && editor->project->mapCache.contains(map_name)) {
|
||||
QStandardItem *map = mapListModel->itemFromIndex(mapListIndexes.value(map_name));
|
||||
map->setIcon(*mapIcon);
|
||||
if (editor->project->mapCache->value(map_name)->hasUnsavedChanges()) {
|
||||
if (editor->project->mapCache.value(map_name)->hasUnsavedChanges()) {
|
||||
map->setIcon(*mapEditedIcon);
|
||||
projectHasUnsavedChanges = true;
|
||||
}
|
||||
|
@ -1821,19 +1821,19 @@ void MainWindow::updateSelectedObjects() {
|
|||
}
|
||||
|
||||
if (key == "destination_map_name") {
|
||||
if (!editor->project->mapNames->contains(value)) {
|
||||
if (!editor->project->mapNames.contains(value)) {
|
||||
combo->addItem(value);
|
||||
}
|
||||
combo->addItems(*editor->project->mapNames);
|
||||
combo->addItems(editor->project->mapNames);
|
||||
combo->setCurrentIndex(combo->findText(value));
|
||||
combo->setToolTip("The destination map name of the warp.");
|
||||
} else if (key == "destination_warp") {
|
||||
combo->setToolTip("The warp id on the destination map.");
|
||||
} else if (key == "item") {
|
||||
if (!editor->project->itemNames->contains(value)) {
|
||||
if (!editor->project->itemNames.contains(value)) {
|
||||
combo->addItem(value);
|
||||
}
|
||||
combo->addItems(*editor->project->itemNames);
|
||||
combo->addItems(editor->project->itemNames);
|
||||
combo->setCurrentIndex(combo->findText(value));
|
||||
} else if (key == "quantity") {
|
||||
spin->setToolTip("The number of items received when the hidden item is picked up.");
|
||||
|
@ -1842,27 +1842,27 @@ void MainWindow::updateSelectedObjects() {
|
|||
} else if (key == "underfoot") {
|
||||
check->setToolTip("If checked, hidden item can only be picked up using the Itemfinder");
|
||||
} else if (key == "flag" || key == "event_flag") {
|
||||
if (!editor->project->flagNames->contains(value)) {
|
||||
if (!editor->project->flagNames.contains(value)) {
|
||||
combo->addItem(value);
|
||||
}
|
||||
combo->addItems(*editor->project->flagNames);
|
||||
combo->addItems(editor->project->flagNames);
|
||||
combo->setCurrentIndex(combo->findText(value));
|
||||
if (key == "flag")
|
||||
combo->setToolTip("The flag which is set when the hidden item is picked up.");
|
||||
else if (key == "event_flag")
|
||||
combo->setToolTip("The flag which hides the object when set.");
|
||||
} else if (key == "script_var") {
|
||||
if (!editor->project->varNames->contains(value)) {
|
||||
if (!editor->project->varNames.contains(value)) {
|
||||
combo->addItem(value);
|
||||
}
|
||||
combo->addItems(*editor->project->varNames);
|
||||
combo->addItems(editor->project->varNames);
|
||||
combo->setCurrentIndex(combo->findText(value));
|
||||
combo->setToolTip("The variable by which the script is triggered.\n"
|
||||
"The script is triggered when this variable's value matches 'Var Value'.");
|
||||
} else if (key == "script_var_value") {
|
||||
combo->setToolTip("The variable's value which triggers the script.");
|
||||
} else if (key == "movement_type") {
|
||||
if (!editor->project->movementTypes->contains(value)) {
|
||||
if (!editor->project->movementTypes.contains(value)) {
|
||||
combo->addItem(value);
|
||||
}
|
||||
connect(combo, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
||||
|
@ -1870,31 +1870,31 @@ void MainWindow::updateSelectedObjects() {
|
|||
item->event->setFrameFromMovement(editor->project->facingDirections.value(value));
|
||||
item->updatePixmap();
|
||||
});
|
||||
combo->addItems(*editor->project->movementTypes);
|
||||
combo->addItems(editor->project->movementTypes);
|
||||
combo->setCurrentIndex(combo->findText(value));
|
||||
combo->setToolTip("The object's natural movement behavior when\n"
|
||||
"the player is not interacting with it.");
|
||||
} else if (key == "weather") {
|
||||
if (!editor->project->coordEventWeatherNames->contains(value)) {
|
||||
if (!editor->project->coordEventWeatherNames.contains(value)) {
|
||||
combo->addItem(value);
|
||||
}
|
||||
combo->addItems(*editor->project->coordEventWeatherNames);
|
||||
combo->addItems(editor->project->coordEventWeatherNames);
|
||||
combo->setCurrentIndex(combo->findText(value));
|
||||
combo->setToolTip("The weather that starts when the player steps on this spot.");
|
||||
} else if (key == "secret_base_id") {
|
||||
if (!editor->project->secretBaseIds->contains(value)) {
|
||||
if (!editor->project->secretBaseIds.contains(value)) {
|
||||
combo->addItem(value);
|
||||
}
|
||||
combo->addItems(*editor->project->secretBaseIds);
|
||||
combo->addItems(editor->project->secretBaseIds);
|
||||
combo->setCurrentIndex(combo->findText(value));
|
||||
combo->setToolTip("The secret base id which is inside this secret\n"
|
||||
"base entrance. Secret base ids are meant to be\n"
|
||||
"unique to each and every secret base entrance.");
|
||||
} else if (key == "player_facing_direction") {
|
||||
if (!editor->project->bgEventFacingDirections->contains(value)) {
|
||||
if (!editor->project->bgEventFacingDirections.contains(value)) {
|
||||
combo->addItem(value);
|
||||
}
|
||||
combo->addItems(*editor->project->bgEventFacingDirections);
|
||||
combo->addItems(editor->project->bgEventFacingDirections);
|
||||
combo->setCurrentIndex(combo->findText(value));
|
||||
combo->setToolTip("The direction which the player must be facing\n"
|
||||
"to be able to interact with this event.");
|
||||
|
@ -1912,7 +1912,7 @@ void MainWindow::updateSelectedObjects() {
|
|||
combo->addItems(editor->map->eventScriptLabels());
|
||||
combo->setToolTip("The script which is executed with this event.");
|
||||
} else if (key == "trainer_type") {
|
||||
combo->addItems(*editor->project->trainerTypes);
|
||||
combo->addItems(editor->project->trainerTypes);
|
||||
combo->setCurrentIndex(combo->findText(value));
|
||||
combo->setToolTip("The trainer type of this object event.\n"
|
||||
"If it is not a trainer, use NONE. SEE ALL DIRECTIONS\n"
|
||||
|
@ -1924,10 +1924,10 @@ void MainWindow::updateSelectedObjects() {
|
|||
} else if (key == "in_connection") {
|
||||
check->setToolTip("Check if object is positioned in the connection to another map.");
|
||||
} else if (key == "respawn_map") {
|
||||
if (!editor->project->mapNames->contains(value)) {
|
||||
if (!editor->project->mapNames.contains(value)) {
|
||||
combo->addItem(value);
|
||||
}
|
||||
combo->addItems(*editor->project->mapNames);
|
||||
combo->addItems(editor->project->mapNames);
|
||||
combo->setToolTip("The map where the player will respawn after whiteout.");
|
||||
} else if (key == "respawn_npc") {
|
||||
spin->setToolTip("event_object ID of the NPC the player interacts with\n"
|
||||
|
@ -2475,7 +2475,7 @@ void MainWindow::on_spinBox_ConnectionOffset_valueChanged(int offset)
|
|||
|
||||
void MainWindow::on_comboBox_ConnectedMap_currentTextChanged(const QString &mapName)
|
||||
{
|
||||
if (editor->project->mapNames->contains(mapName))
|
||||
if (editor->project->mapNames.contains(mapName))
|
||||
editor->setConnectionMap(mapName);
|
||||
}
|
||||
|
||||
|
@ -2503,13 +2503,13 @@ void MainWindow::on_pushButton_ConfigureEncountersJSON_clicked() {
|
|||
|
||||
void MainWindow::on_comboBox_DiveMap_currentTextChanged(const QString &mapName)
|
||||
{
|
||||
if (editor->project->mapNames->contains(mapName))
|
||||
if (editor->project->mapNames.contains(mapName))
|
||||
editor->updateDiveMap(mapName);
|
||||
}
|
||||
|
||||
void MainWindow::on_comboBox_EmergeMap_currentTextChanged(const QString &mapName)
|
||||
{
|
||||
if (editor->project->mapNames->contains(mapName))
|
||||
if (editor->project->mapNames.contains(mapName))
|
||||
editor->updateEmergeMap(mapName);
|
||||
}
|
||||
|
||||
|
@ -2603,8 +2603,8 @@ void MainWindow::on_pushButton_ChangeDimensions_clicked()
|
|||
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
Map *map = editor->map;
|
||||
Blockdata *oldMetatiles = map->layout->blockdata->copy();
|
||||
Blockdata *oldBorder = map->layout->border->copy();
|
||||
Blockdata oldMetatiles = map->layout->blockdata;
|
||||
Blockdata oldBorder = map->layout->border;
|
||||
QSize oldMapDimensions(map->getWidth(), map->getHeight());
|
||||
QSize oldBorderDimensions(map->getBorderWidth(), map->getBorderHeight());
|
||||
QSize newMapDimensions(widthSpinBox->value(), heightSpinBox->value());
|
||||
|
@ -2612,11 +2612,11 @@ void MainWindow::on_pushButton_ChangeDimensions_clicked()
|
|||
if (oldMapDimensions != newMapDimensions || oldBorderDimensions != newBorderDimensions) {
|
||||
editor->map->setDimensions(newMapDimensions.width(), newMapDimensions.height());
|
||||
editor->map->setBorderDimensions(newBorderDimensions.width(), newBorderDimensions.height());
|
||||
editor->map->editHistory.push(new ResizeMap(map,
|
||||
editor->map->editHistory.push(new ResizeMap(map,
|
||||
oldMapDimensions, newMapDimensions,
|
||||
oldMetatiles, map->layout->blockdata->copy(),
|
||||
oldMetatiles, map->layout->blockdata,
|
||||
oldBorderDimensions, newBorderDimensions,
|
||||
oldBorder, map->layout->border->copy()
|
||||
oldBorder, map->layout->border
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ void MainWindow::tryCommitMapChanges(bool commitChanges) {
|
|||
if (map) {
|
||||
map->editHistory.push(new ScriptEditMap(map,
|
||||
map->layout->lastCommitMapBlocks.dimensions, QSize(map->getWidth(), map->getHeight()),
|
||||
map->layout->lastCommitMapBlocks.blocks->copy(), map->layout->blockdata->copy()
|
||||
map->layout->lastCommitMapBlocks.blocks, map->layout->blockdata
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ void MainWindow::magicFillFromSelection(int x, int y, bool forceRedraw, bool com
|
|||
void MainWindow::shift(int xDelta, int yDelta, bool forceRedraw, bool commitChanges) {
|
||||
if (!this->editor || !this->editor->map)
|
||||
return;
|
||||
this->editor->map_item->shift(xDelta, yDelta);
|
||||
this->editor->map_item->shift(xDelta, yDelta, true);
|
||||
this->tryCommitMapChanges(commitChanges);
|
||||
this->tryRedrawMapArea(forceRedraw);
|
||||
}
|
||||
|
|
372
src/project.cpp
372
src/project.cpp
|
@ -36,55 +36,15 @@ int Project::max_map_data_size = 10240; // 0x2800
|
|||
int Project::default_map_size = 20;
|
||||
int Project::max_object_events = 64;
|
||||
|
||||
Project::Project(QWidget *parent) : parent(parent)
|
||||
Project::Project(QWidget *parent) : QObject(parent)
|
||||
{
|
||||
groupNames = new QStringList;
|
||||
mapGroups = new QMap<QString, int>;
|
||||
mapNames = new QStringList;
|
||||
itemNames = new QStringList;
|
||||
flagNames = new QStringList;
|
||||
varNames = new QStringList;
|
||||
movementTypes = new QStringList;
|
||||
mapTypes = new QStringList;
|
||||
mapBattleScenes = new QStringList;
|
||||
weatherNames = new QStringList;
|
||||
coordEventWeatherNames = new QStringList;
|
||||
secretBaseIds = new QStringList;
|
||||
bgEventFacingDirections = new QStringList;
|
||||
trainerTypes = new QStringList;
|
||||
mapCache = new QMap<QString, Map*>;
|
||||
mapConstantsToMapNames = new QMap<QString, QString>;
|
||||
mapNamesToMapConstants = new QMap<QString, QString>;
|
||||
tilesetCache = new QMap<QString, Tileset*>;
|
||||
|
||||
initSignals();
|
||||
}
|
||||
|
||||
Project::~Project()
|
||||
{
|
||||
delete this->groupNames;
|
||||
delete this->mapGroups;
|
||||
delete this->mapNames;
|
||||
delete this->itemNames;
|
||||
delete this->flagNames;
|
||||
delete this->varNames;
|
||||
delete this->weatherNames;
|
||||
delete this->coordEventWeatherNames;
|
||||
|
||||
delete this->secretBaseIds;
|
||||
delete this->movementTypes;
|
||||
delete this->bgEventFacingDirections;
|
||||
delete this->mapBattleScenes;
|
||||
delete this->trainerTypes;
|
||||
delete this->mapTypes;
|
||||
|
||||
delete this->mapConstantsToMapNames;
|
||||
delete this->mapNamesToMapConstants;
|
||||
|
||||
clearMapCache();
|
||||
delete this->mapCache;
|
||||
clearTilesetCache();
|
||||
delete this->tilesetCache;
|
||||
}
|
||||
|
||||
void Project::initSignals() {
|
||||
|
@ -101,7 +61,7 @@ void Project::initSignals() {
|
|||
static bool showing = false;
|
||||
if (showing) return;
|
||||
|
||||
QMessageBox notice(this->parent);
|
||||
QMessageBox notice(this->parentWidget());
|
||||
notice.setText("File Changed");
|
||||
notice.setInformativeText(QString("The file %1 has changed on disk. Would you like to reload the project?")
|
||||
.arg(changed.remove(this->root + "/")));
|
||||
|
@ -139,24 +99,24 @@ QString Project::getProjectTitle() {
|
|||
}
|
||||
|
||||
void Project::clearMapCache() {
|
||||
for (QString mapName : mapCache->keys()) {
|
||||
Map *map = mapCache->take(mapName);
|
||||
for (QString mapName : mapCache.keys()) {
|
||||
Map *map = mapCache.take(mapName);
|
||||
if (map) delete map;
|
||||
}
|
||||
emit mapCacheCleared();
|
||||
}
|
||||
|
||||
void Project::clearTilesetCache() {
|
||||
for (QString tilesetName : tilesetCache->keys()) {
|
||||
Tileset *tileset = tilesetCache->take(tilesetName);
|
||||
for (QString tilesetName : tilesetCache.keys()) {
|
||||
Tileset *tileset = tilesetCache.take(tilesetName);
|
||||
if (tileset) delete tileset;
|
||||
}
|
||||
}
|
||||
|
||||
Map* Project::loadMap(QString map_name) {
|
||||
Map *map;
|
||||
if (mapCache->contains(map_name)) {
|
||||
map = mapCache->value(map_name);
|
||||
if (mapCache.contains(map_name)) {
|
||||
map = mapCache.value(map_name);
|
||||
// TODO: uncomment when undo/redo history is fully implemented for all actions.
|
||||
if (true/*map->hasUnsavedChanges()*/) {
|
||||
return map;
|
||||
|
@ -169,7 +129,7 @@ Map* Project::loadMap(QString map_name) {
|
|||
if (!(loadMapData(map) && loadMapLayout(map)))
|
||||
return nullptr;
|
||||
|
||||
mapCache->insert(map_name, map);
|
||||
mapCache.insert(map_name, map);
|
||||
return map;
|
||||
}
|
||||
|
||||
|
@ -204,7 +164,7 @@ QMap<QString, bool> Project::getTopLevelMapFields() {
|
|||
topLevelMapFields.insert("allow_escaping", true);
|
||||
topLevelMapFields.insert("allow_running", true);
|
||||
}
|
||||
|
||||
|
||||
if (projectConfig.getFloorNumberEnabled()) {
|
||||
topLevelMapFields.insert("floor_number", true);
|
||||
}
|
||||
|
@ -283,8 +243,8 @@ bool Project::loadMapData(Map* map) {
|
|||
|
||||
// Ensure the warp destination map constant is valid before adding it to the warps.
|
||||
QString mapConstant = event["dest_map"].toString();
|
||||
if (mapConstantsToMapNames->contains(mapConstant)) {
|
||||
warp->put("destination_map_name", mapConstantsToMapNames->value(mapConstant));
|
||||
if (mapConstantsToMapNames.contains(mapConstant)) {
|
||||
warp->put("destination_map_name", mapConstantsToMapNames.value(mapConstant));
|
||||
warp->put("event_group_type", "warp_event_group");
|
||||
map->events["warp_event_group"].append(warp);
|
||||
} else if (mapConstant == NONE_MAP_CONSTANT) {
|
||||
|
@ -302,7 +262,7 @@ bool Project::loadMapData(Map* map) {
|
|||
HealLocation loc = *it;
|
||||
|
||||
//if TRUE map is flyable / has healing location
|
||||
if (loc.mapName == QString(mapNamesToMapConstants->value(map->name)).remove(0,4)) {
|
||||
if (loc.mapName == QString(mapNamesToMapConstants.value(map->name)).remove(0,4)) {
|
||||
Event *heal = new Event;
|
||||
heal->put("map_name", map->name);
|
||||
heal->put("x", loc.x);
|
||||
|
@ -311,11 +271,11 @@ bool Project::loadMapData(Map* map) {
|
|||
heal->put("id_name", loc.idName);
|
||||
heal->put("index", loc.index);
|
||||
heal->put("elevation", 3); // TODO: change this?
|
||||
heal->put("destination_map_name", mapConstantsToMapNames->value(map->name));
|
||||
heal->put("destination_map_name", mapConstantsToMapNames.value(map->name));
|
||||
heal->put("event_group_type", "heal_event_group");
|
||||
heal->put("event_type", EventType::HealLocation);
|
||||
if (projectConfig.getHealLocationRespawnDataEnabled()) {
|
||||
heal->put("respawn_map", mapConstantsToMapNames->value(QString("MAP_" + loc.respawnMap)));
|
||||
heal->put("respawn_map", mapConstantsToMapNames.value(QString("MAP_" + loc.respawnMap)));
|
||||
heal->put("respawn_npc", loc.respawnNPC);
|
||||
}
|
||||
map->events["heal_event_group"].append(heal);
|
||||
|
@ -408,8 +368,8 @@ bool Project::loadMapData(Map* map) {
|
|||
connection->direction = connectionObj["direction"].toString();
|
||||
connection->offset = QString::number(connectionObj["offset"].toInt());
|
||||
QString mapConstant = connectionObj["map"].toString();
|
||||
if (mapConstantsToMapNames->contains(mapConstant)) {
|
||||
connection->map_name = mapConstantsToMapNames->value(mapConstant);
|
||||
if (mapConstantsToMapNames.contains(mapConstant)) {
|
||||
connection->map_name = mapConstantsToMapNames.value(mapConstant);
|
||||
map->connections.append(connection);
|
||||
} else {
|
||||
logError(QString("Failed to find connected map for map constant '%1'").arg(mapConstant));
|
||||
|
@ -429,8 +389,8 @@ bool Project::loadMapData(Map* map) {
|
|||
}
|
||||
|
||||
QString Project::readMapLayoutId(QString map_name) {
|
||||
if (mapCache->contains(map_name)) {
|
||||
return mapCache->value(map_name)->layoutId;
|
||||
if (mapCache.contains(map_name)) {
|
||||
return mapCache.value(map_name)->layoutId;
|
||||
}
|
||||
|
||||
QString mapFilepath = QString("%1/data/maps/%2/map.json").arg(root).arg(map_name);
|
||||
|
@ -445,8 +405,8 @@ QString Project::readMapLayoutId(QString map_name) {
|
|||
}
|
||||
|
||||
QString Project::readMapLocation(QString map_name) {
|
||||
if (mapCache->contains(map_name)) {
|
||||
return mapCache->value(map_name)->location;
|
||||
if (mapCache.contains(map_name)) {
|
||||
return mapCache.value(map_name)->location;
|
||||
}
|
||||
|
||||
QString mapFilepath = QString("%1/data/maps/%2/map.json").arg(root).arg(map_name);
|
||||
|
@ -464,8 +424,8 @@ void Project::setNewMapHeader(Map* map, int mapIndex) {
|
|||
map->layoutId = QString("%1").arg(mapIndex);
|
||||
map->location = mapSectionValueToName.value(0);
|
||||
map->requiresFlash = "FALSE";
|
||||
map->weather = weatherNames->value(0, "WEATHER_NONE");
|
||||
map->type = mapTypes->value(0, "MAP_TYPE_NONE");
|
||||
map->weather = weatherNames.value(0, "WEATHER_NONE");
|
||||
map->type = mapTypes.value(0, "MAP_TYPE_NONE");
|
||||
map->song = defaultSong;
|
||||
if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokeruby) {
|
||||
map->show_location = "TRUE";
|
||||
|
@ -479,7 +439,7 @@ void Project::setNewMapHeader(Map* map, int mapIndex) {
|
|||
map->floorNumber = 0;
|
||||
}
|
||||
|
||||
map->battle_scene = mapBattleScenes->value(0, "MAP_BATTLE_SCENE_NORMAL");
|
||||
map->battle_scene = mapBattleScenes.value(0, "MAP_BATTLE_SCENE_NORMAL");
|
||||
}
|
||||
|
||||
bool Project::loadMapLayout(Map* map) {
|
||||
|
@ -703,7 +663,7 @@ void Project::saveMapGroups() {
|
|||
mapGroupsObj["layouts_table_label"] = layoutsLabel;
|
||||
|
||||
OrderedJson::array groupNamesArr;
|
||||
for (QString groupName : *this->groupNames) {
|
||||
for (QString groupName : this->groupNames) {
|
||||
groupNamesArr.push_back(groupName);
|
||||
}
|
||||
mapGroupsObj["group_order"] = groupNamesArr;
|
||||
|
@ -714,7 +674,7 @@ void Project::saveMapGroups() {
|
|||
for (QString mapName : mapNames) {
|
||||
groupArr.push_back(mapName);
|
||||
}
|
||||
mapGroupsObj[this->groupNames->at(groupNum)] = groupArr;
|
||||
mapGroupsObj[this->groupNames.at(groupNum)] = groupArr;
|
||||
groupNum++;
|
||||
}
|
||||
|
||||
|
@ -826,13 +786,13 @@ void Project::saveMapConstantsHeader() {
|
|||
text += QString("// Map Group %1\n").arg(groupNum);
|
||||
int maxLength = 0;
|
||||
for (QString mapName : mapNames) {
|
||||
QString mapConstantName = mapNamesToMapConstants->value(mapName);
|
||||
QString mapConstantName = mapNamesToMapConstants.value(mapName);
|
||||
if (mapConstantName.length() > maxLength)
|
||||
maxLength = mapConstantName.length();
|
||||
}
|
||||
int groupIndex = 0;
|
||||
for (QString mapName : mapNames) {
|
||||
QString mapConstantName = mapNamesToMapConstants->value(mapName);
|
||||
QString mapConstantName = mapNamesToMapConstants.value(mapName);
|
||||
text += QString("#define %1%2(%3 | (%4 << 8))\n")
|
||||
.arg(mapConstantName)
|
||||
.arg(QString(" ").repeated(maxLength - mapConstantName.length() + 1))
|
||||
|
@ -1148,31 +1108,31 @@ bool Project::loadMapTilesets(Map* map) {
|
|||
}
|
||||
|
||||
Tileset* Project::loadTileset(QString label, Tileset *tileset) {
|
||||
QStringList *values = parser.getLabelValues(parser.parseAsm("data/tilesets/headers.inc"), label);
|
||||
if (values->isEmpty()) {
|
||||
const QStringList values = parser.getLabelValues(parser.parseAsm("data/tilesets/headers.inc"), label);
|
||||
if (values.isEmpty()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (tileset == nullptr) {
|
||||
tileset = new Tileset;
|
||||
}
|
||||
tileset->name = label;
|
||||
tileset->is_compressed = values->value(0);
|
||||
tileset->is_secondary = values->value(1);
|
||||
tileset->padding = values->value(2);
|
||||
tileset->tiles_label = values->value(3);
|
||||
tileset->palettes_label = values->value(4);
|
||||
tileset->metatiles_label = values->value(5);
|
||||
tileset->is_compressed = values.value(0);
|
||||
tileset->is_secondary = values.value(1);
|
||||
tileset->padding = values.value(2);
|
||||
tileset->tiles_label = values.value(3);
|
||||
tileset->palettes_label = values.value(4);
|
||||
tileset->metatiles_label = values.value(5);
|
||||
if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered) {
|
||||
tileset->callback_label = values->value(6);
|
||||
tileset->metatile_attrs_label = values->value(7);
|
||||
tileset->callback_label = values.value(6);
|
||||
tileset->metatile_attrs_label = values.value(7);
|
||||
} else {
|
||||
tileset->metatile_attrs_label = values->value(6);
|
||||
tileset->callback_label = values->value(7);
|
||||
tileset->metatile_attrs_label = values.value(6);
|
||||
tileset->callback_label = values.value(7);
|
||||
}
|
||||
|
||||
loadTilesetAssets(tileset);
|
||||
|
||||
tilesetCache->insert(label, tileset);
|
||||
tilesetCache.insert(label, tileset);
|
||||
return tileset;
|
||||
}
|
||||
|
||||
|
@ -1183,32 +1143,26 @@ bool Project::loadBlockdata(Map *map) {
|
|||
|
||||
QString path = QString("%1/%2").arg(root).arg(map->layout->blockdata_path);
|
||||
map->layout->blockdata = readBlockdata(path);
|
||||
if (map->layout->lastCommitMapBlocks.blocks) {
|
||||
delete map->layout->lastCommitMapBlocks.blocks;
|
||||
}
|
||||
map->layout->lastCommitMapBlocks.blocks = new Blockdata;
|
||||
map->layout->lastCommitMapBlocks.blocks->copyFrom(map->layout->blockdata);
|
||||
map->layout->lastCommitMapBlocks.blocks = map->layout->blockdata;
|
||||
map->layout->lastCommitMapBlocks.dimensions = QSize(map->getWidth(), map->getHeight());
|
||||
|
||||
if (map->layout->blockdata->blocks->count() != map->getWidth() * map->getHeight()) {
|
||||
if (map->layout->blockdata.count() != map->getWidth() * map->getHeight()) {
|
||||
logWarn(QString("Layout blockdata length %1 does not match dimensions %2x%3 (should be %4). Resizing blockdata.")
|
||||
.arg(map->layout->blockdata->blocks->count())
|
||||
.arg(map->layout->blockdata.count())
|
||||
.arg(map->getWidth())
|
||||
.arg(map->getHeight())
|
||||
.arg(map->getWidth() * map->getHeight()));
|
||||
map->layout->blockdata->blocks->resize(map->getWidth() * map->getHeight());
|
||||
map->layout->blockdata.resize(map->getWidth() * map->getHeight());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Project::setNewMapBlockdata(Map *map) {
|
||||
Blockdata *blockdata = new Blockdata;
|
||||
map->layout->blockdata.clear();
|
||||
for (int i = 0; i < map->getWidth() * map->getHeight(); i++) {
|
||||
blockdata->addBlock(qint16(0x3001));
|
||||
map->layout->blockdata.append(qint16(0x3001));
|
||||
}
|
||||
map->layout->blockdata = blockdata;
|
||||
map->layout->lastCommitMapBlocks.blocks = new Blockdata;
|
||||
map->layout->lastCommitMapBlocks.blocks->copyFrom(map->layout->blockdata);
|
||||
map->layout->lastCommitMapBlocks.blocks = map->layout->blockdata;
|
||||
map->layout->lastCommitMapBlocks.dimensions = QSize(map->getWidth(), map->getHeight());
|
||||
}
|
||||
|
||||
|
@ -1220,33 +1174,32 @@ bool Project::loadMapBorder(Map *map) {
|
|||
QString path = QString("%1/%2").arg(root).arg(map->layout->border_path);
|
||||
map->layout->border = readBlockdata(path);
|
||||
int borderLength = map->getBorderWidth() * map->getBorderHeight();
|
||||
if (map->layout->border->blocks->count() != borderLength) {
|
||||
if (map->layout->border.count() != borderLength) {
|
||||
logWarn(QString("Layout border blockdata length %1 must be %2. Resizing border blockdata.")
|
||||
.arg(map->layout->border->blocks->count())
|
||||
.arg(map->layout->border.count())
|
||||
.arg(borderLength));
|
||||
map->layout->border->blocks->resize(borderLength);
|
||||
map->layout->border.resize(borderLength);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Project::setNewMapBorder(Map *map) {
|
||||
Blockdata *blockdata = new Blockdata;
|
||||
map->layout->border.clear();
|
||||
if (map->getBorderWidth() != DEFAULT_BORDER_WIDTH || map->getBorderHeight() != DEFAULT_BORDER_HEIGHT) {
|
||||
for (int i = 0; i < map->getBorderWidth() * map->getBorderHeight(); i++) {
|
||||
blockdata->addBlock(0);
|
||||
map->layout->border.append(0);
|
||||
}
|
||||
} else if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered) {
|
||||
blockdata->addBlock(qint16(0x0014));
|
||||
blockdata->addBlock(qint16(0x0015));
|
||||
blockdata->addBlock(qint16(0x001C));
|
||||
blockdata->addBlock(qint16(0x001D));
|
||||
map->layout->border.append(qint16(0x0014));
|
||||
map->layout->border.append(qint16(0x0015));
|
||||
map->layout->border.append(qint16(0x001C));
|
||||
map->layout->border.append(qint16(0x001D));
|
||||
} else {
|
||||
blockdata->addBlock(qint16(0x01D4));
|
||||
blockdata->addBlock(qint16(0x01D5));
|
||||
blockdata->addBlock(qint16(0x01DC));
|
||||
blockdata->addBlock(qint16(0x01DD));
|
||||
map->layout->border.append(qint16(0x01D4));
|
||||
map->layout->border.append(qint16(0x01D5));
|
||||
map->layout->border.append(qint16(0x01DC));
|
||||
map->layout->border.append(qint16(0x01DD));
|
||||
}
|
||||
map->layout->border = blockdata;
|
||||
}
|
||||
|
||||
void Project::saveLayoutBorder(Map *map) {
|
||||
|
@ -1259,10 +1212,10 @@ void Project::saveLayoutBlockdata(Map* map) {
|
|||
writeBlockdata(path, map->layout->blockdata);
|
||||
}
|
||||
|
||||
void Project::writeBlockdata(QString path, Blockdata *blockdata) {
|
||||
void Project::writeBlockdata(QString path, const Blockdata &blockdata) {
|
||||
QFile file(path);
|
||||
if (file.open(QIODevice::WriteOnly)) {
|
||||
QByteArray data = blockdata->serialize();
|
||||
QByteArray data = blockdata.serialize();
|
||||
file.write(data);
|
||||
} else {
|
||||
logError(QString("Failed to open blockdata file for writing: '%1'").arg(path));
|
||||
|
@ -1270,10 +1223,10 @@ void Project::writeBlockdata(QString path, Blockdata *blockdata) {
|
|||
}
|
||||
|
||||
void Project::saveAllMaps() {
|
||||
QList<QString> keys = mapCache->keys();
|
||||
QList<QString> keys = mapCache.keys();
|
||||
for (int i = 0; i < keys.length(); i++) {
|
||||
QString key = keys.value(i);
|
||||
Map* map = mapCache->value(key);
|
||||
Map* map = mapCache.value(key);
|
||||
saveMap(map);
|
||||
}
|
||||
}
|
||||
|
@ -1376,11 +1329,11 @@ void Project::saveMap(Map *map) {
|
|||
if (map->connections.length() > 0) {
|
||||
OrderedJson::array connectionsArr;
|
||||
for (MapConnection* connection : map->connections) {
|
||||
if (mapNamesToMapConstants->contains(connection->map_name)) {
|
||||
if (mapNamesToMapConstants.contains(connection->map_name)) {
|
||||
OrderedJson::object connectionObj;
|
||||
connectionObj["direction"] = connection->direction;
|
||||
connectionObj["offset"] = connection->offset.toInt();
|
||||
connectionObj["map"] = this->mapNamesToMapConstants->value(connection->map_name);
|
||||
connectionObj["map"] = this->mapNamesToMapConstants.value(connection->map_name);
|
||||
connectionsArr.append(connectionObj);
|
||||
} else {
|
||||
logError(QString("Failed to write map connection. '%1' is not a valid map name").arg(connection->map_name));
|
||||
|
@ -1497,15 +1450,15 @@ void Project::loadTilesetAssets(Tileset* tileset) {
|
|||
}
|
||||
QRegularExpression re("([a-z])([A-Z0-9])");
|
||||
QString tilesetName = tileset->name;
|
||||
QString dir_path = root + "/data/tilesets/" + category + "/" + tilesetName.replace("gTileset_", "").replace(re, "\\1_\\2").toLower();
|
||||
QString dir_path = root + "/data/tilesets/" + category + '/' + tilesetName.replace("gTileset_", "").replace(re, "\\1_\\2").toLower();
|
||||
|
||||
QList<QStringList> *graphics = parser.parseAsm("data/tilesets/graphics.inc");
|
||||
QStringList *tiles_values = parser.getLabelValues(graphics, tileset->tiles_label);
|
||||
QStringList *palettes_values = parser.getLabelValues(graphics, tileset->palettes_label);
|
||||
const QList<QStringList> graphics = parser.parseAsm("data/tilesets/graphics.inc");
|
||||
const QStringList tiles_values = parser.getLabelValues(graphics, tileset->tiles_label);
|
||||
const QStringList palettes_values = parser.getLabelValues(graphics, tileset->palettes_label);
|
||||
|
||||
QString tiles_path;
|
||||
if (!tiles_values->isEmpty()) {
|
||||
tiles_path = root + "/" + tiles_values->value(0).section('"', 1, 1);
|
||||
if (!tiles_values.isEmpty()) {
|
||||
tiles_path = root + '/' + tiles_values.value(0).section('"', 1, 1);
|
||||
} else {
|
||||
tiles_path = dir_path + "/tiles.4bpp";
|
||||
if (tileset->is_compressed == "TRUE") {
|
||||
|
@ -1513,28 +1466,27 @@ void Project::loadTilesetAssets(Tileset* tileset) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!palettes_values->isEmpty()) {
|
||||
for (int i = 0; i < palettes_values->length(); i++) {
|
||||
QString value = palettes_values->value(i);
|
||||
tileset->palettePaths.append(this->fixPalettePath(root + "/" + value.section('"', 1, 1)));
|
||||
if (!palettes_values.isEmpty()) {
|
||||
for (const auto &value : palettes_values) {
|
||||
tileset->palettePaths.append(this->fixPalettePath(root + '/' + value.section('"', 1, 1)));
|
||||
}
|
||||
} else {
|
||||
QString palettes_dir_path = dir_path + "/palettes";
|
||||
for (int i = 0; i < 16; i++) {
|
||||
tileset->palettePaths.append(palettes_dir_path + "/" + QString("%1").arg(i, 2, 10, QLatin1Char('0')) + ".pal");
|
||||
tileset->palettePaths.append(palettes_dir_path + '/' + QString("%1").arg(i, 2, 10, QLatin1Char('0')) + ".pal");
|
||||
}
|
||||
}
|
||||
|
||||
QList<QStringList> *metatiles_macros = parser.parseAsm("data/tilesets/metatiles.inc");
|
||||
QStringList *metatiles_values = parser.getLabelValues(metatiles_macros, tileset->metatiles_label);
|
||||
if (!metatiles_values->isEmpty()) {
|
||||
tileset->metatiles_path = root + "/" + metatiles_values->value(0).section('"', 1, 1);
|
||||
const QList<QStringList> metatiles_macros = parser.parseAsm("data/tilesets/metatiles.inc");
|
||||
const QStringList metatiles_values = parser.getLabelValues(metatiles_macros, tileset->metatiles_label);
|
||||
if (!metatiles_values.isEmpty()) {
|
||||
tileset->metatiles_path = root + '/' + metatiles_values.value(0).section('"', 1, 1);
|
||||
} else {
|
||||
tileset->metatiles_path = dir_path + "/metatiles.bin";
|
||||
}
|
||||
QStringList *metatile_attrs_values = parser.getLabelValues(metatiles_macros, tileset->metatile_attrs_label);
|
||||
if (!metatile_attrs_values->isEmpty()) {
|
||||
tileset->metatile_attrs_path = root + "/" + metatile_attrs_values->value(0).section('"', 1, 1);
|
||||
const QStringList metatile_attrs_values = parser.getLabelValues(metatiles_macros, tileset->metatile_attrs_label);
|
||||
if (!metatile_attrs_values.isEmpty()) {
|
||||
tileset->metatile_attrs_path = root + '/' + metatile_attrs_values.value(0).section('"', 1, 1);
|
||||
} else {
|
||||
tileset->metatile_attrs_path = dir_path + "/metatile_attributes.bin";
|
||||
}
|
||||
|
@ -1702,14 +1654,14 @@ void Project::loadTilesetMetatileLabels(Tileset* tileset) {
|
|||
}
|
||||
}
|
||||
|
||||
Blockdata* Project::readBlockdata(QString path) {
|
||||
Blockdata *blockdata = new Blockdata;
|
||||
Blockdata Project::readBlockdata(QString path) {
|
||||
Blockdata blockdata;
|
||||
QFile file(path);
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
QByteArray data = file.readAll();
|
||||
for (int i = 0; (i + 1) < data.length(); i += 2) {
|
||||
uint16_t word = static_cast<uint16_t>((data[i] & 0xff) + ((data[i + 1] & 0xff) << 8));
|
||||
blockdata->addBlock(word);
|
||||
blockdata.append(word);
|
||||
}
|
||||
} else {
|
||||
logError(QString("Failed to open blockdata path '%1'").arg(path));
|
||||
|
@ -1719,8 +1671,8 @@ Blockdata* Project::readBlockdata(QString path) {
|
|||
}
|
||||
|
||||
Map* Project::getMap(QString map_name) {
|
||||
if (mapCache->contains(map_name)) {
|
||||
return mapCache->value(map_name);
|
||||
if (mapCache.contains(map_name)) {
|
||||
return mapCache.value(map_name);
|
||||
} else {
|
||||
Map *map = loadMap(map_name);
|
||||
return map;
|
||||
|
@ -1729,8 +1681,8 @@ Map* Project::getMap(QString map_name) {
|
|||
|
||||
Tileset* Project::getTileset(QString label, bool forceLoad) {
|
||||
Tileset *existingTileset = nullptr;
|
||||
if (tilesetCache->contains(label)) {
|
||||
existingTileset = tilesetCache->value(label);
|
||||
if (tilesetCache.contains(label)) {
|
||||
existingTileset = tilesetCache.value(label);
|
||||
}
|
||||
|
||||
if (existingTileset && !forceLoad) {
|
||||
|
@ -1840,9 +1792,9 @@ bool Project::readWildMonData() {
|
|||
}
|
||||
|
||||
bool Project::readMapGroups() {
|
||||
mapConstantsToMapNames->clear();
|
||||
mapNamesToMapConstants->clear();
|
||||
mapGroups->clear();
|
||||
mapConstantsToMapNames.clear();
|
||||
mapNamesToMapConstants.clear();
|
||||
mapGroups.clear();
|
||||
|
||||
QString mapGroupsFilepath = QString("%1/data/maps/map_groups.json").arg(root);
|
||||
fileWatcher.addPath(mapGroupsFilepath);
|
||||
|
@ -1856,29 +1808,29 @@ bool Project::readMapGroups() {
|
|||
QJsonArray mapGroupOrder = mapGroupsObj["group_order"].toArray();
|
||||
|
||||
QList<QStringList> groupedMaps;
|
||||
QStringList *maps = new QStringList;
|
||||
QStringList *groups = new QStringList;
|
||||
QStringList maps;
|
||||
QStringList groups;
|
||||
for (int groupIndex = 0; groupIndex < mapGroupOrder.size(); groupIndex++) {
|
||||
QString groupName = mapGroupOrder.at(groupIndex).toString();
|
||||
QJsonArray mapNames = mapGroupsObj.value(groupName).toArray();
|
||||
groupedMaps.append(QStringList());
|
||||
groups->append(groupName);
|
||||
groups.append(groupName);
|
||||
for (int j = 0; j < mapNames.size(); j++) {
|
||||
QString mapName = mapNames.at(j).toString();
|
||||
mapGroups->insert(mapName, groupIndex);
|
||||
mapGroups.insert(mapName, groupIndex);
|
||||
groupedMaps[groupIndex].append(mapName);
|
||||
maps->append(mapName);
|
||||
maps.append(mapName);
|
||||
|
||||
// Build the mapping and reverse mapping between map constants and map names.
|
||||
QString mapConstant = Map::mapConstantFromName(mapName);
|
||||
mapConstantsToMapNames->insert(mapConstant, mapName);
|
||||
mapNamesToMapConstants->insert(mapName, mapConstant);
|
||||
mapConstantsToMapNames.insert(mapConstant, mapName);
|
||||
mapNamesToMapConstants.insert(mapName, mapConstant);
|
||||
}
|
||||
}
|
||||
|
||||
mapConstantsToMapNames->insert(NONE_MAP_CONSTANT, NONE_MAP_NAME);
|
||||
mapNamesToMapConstants->insert(NONE_MAP_NAME, NONE_MAP_CONSTANT);
|
||||
maps->append(NONE_MAP_NAME);
|
||||
mapConstantsToMapNames.insert(NONE_MAP_CONSTANT, NONE_MAP_NAME);
|
||||
mapNamesToMapConstants.insert(NONE_MAP_NAME, NONE_MAP_CONSTANT);
|
||||
maps.append(NONE_MAP_NAME);
|
||||
|
||||
groupNames = groups;
|
||||
groupedMapNames = groupedMaps;
|
||||
|
@ -1888,15 +1840,15 @@ bool Project::readMapGroups() {
|
|||
|
||||
Map* Project::addNewMapToGroup(QString mapName, int groupNum) {
|
||||
// Setup new map in memory, but don't write to file until map is actually saved later.
|
||||
mapNames->append(mapName);
|
||||
mapGroups->insert(mapName, groupNum);
|
||||
mapNames.append(mapName);
|
||||
mapGroups.insert(mapName, groupNum);
|
||||
groupedMapNames[groupNum].append(mapName);
|
||||
|
||||
Map *map = new Map;
|
||||
map->isPersistedToFile = false;
|
||||
map->setName(mapName);
|
||||
mapConstantsToMapNames->insert(map->constantName, map->name);
|
||||
mapNamesToMapConstants->insert(map->name, map->constantName);
|
||||
mapConstantsToMapNames.insert(map->constantName, map->name);
|
||||
mapNamesToMapConstants.insert(map->name, map->constantName);
|
||||
setNewMapHeader(map, mapLayoutsTable.size() + 1);
|
||||
setNewMapLayout(map);
|
||||
loadMapTilesets(map);
|
||||
|
@ -1904,14 +1856,14 @@ Map* Project::addNewMapToGroup(QString mapName, int groupNum) {
|
|||
setNewMapBorder(map);
|
||||
setNewMapEvents(map);
|
||||
setNewMapConnections(map);
|
||||
mapCache->insert(mapName, map);
|
||||
mapCache.insert(mapName, map);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
Map* Project::addNewMapToGroup(QString mapName, int groupNum, Map *newMap, bool existingLayout) {
|
||||
mapNames->append(mapName);
|
||||
mapGroups->insert(mapName, groupNum);
|
||||
mapNames.append(mapName);
|
||||
mapGroups.insert(mapName, groupNum);
|
||||
groupedMapNames[groupNum].append(mapName);
|
||||
|
||||
Map *map = new Map;
|
||||
|
@ -1920,8 +1872,8 @@ Map* Project::addNewMapToGroup(QString mapName, int groupNum, Map *newMap, bool
|
|||
map->isPersistedToFile = false;
|
||||
map->setName(mapName);
|
||||
|
||||
mapConstantsToMapNames->insert(map->constantName, map->name);
|
||||
mapNamesToMapConstants->insert(map->name, map->constantName);
|
||||
mapConstantsToMapNames.insert(map->constantName, map->name);
|
||||
mapNamesToMapConstants.insert(map->name, map->constantName);
|
||||
if (!existingLayout) {
|
||||
mapLayouts.insert(map->layoutId, map->layout);
|
||||
mapLayoutsTable.append(map->layoutId);
|
||||
|
@ -1942,7 +1894,7 @@ QString Project::getNewMapName() {
|
|||
QString newMapName;
|
||||
do {
|
||||
newMapName = QString("NewMap%1").arg(++i);
|
||||
} while (mapNames->contains(newMapName));
|
||||
} while (mapNames.contains(newMapName));
|
||||
|
||||
return newMapName;
|
||||
}
|
||||
|
@ -2160,12 +2112,11 @@ bool Project::readHealLocations() {
|
|||
}
|
||||
|
||||
bool Project::readItemNames() {
|
||||
itemNames->clear();
|
||||
QStringList prefixes = (QStringList() << "\\bITEM_(?!(B_)?USE_)"); // Exclude ITEM_USE_ and ITEM_B_USE_ constants
|
||||
QStringList prefixes("\\bITEM_(?!(B_)?USE_)"); // Exclude ITEM_USE_ and ITEM_B_USE_ constants
|
||||
QString filename = "include/constants/items.h";
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
parser.readCDefinesSorted(filename, prefixes, itemNames);
|
||||
if (itemNames->isEmpty()) {
|
||||
itemNames = parser.readCDefinesSorted(filename, prefixes);
|
||||
if (itemNames.isEmpty()) {
|
||||
logError(QString("Failed to read item constants from %1").arg(filename));
|
||||
return false;
|
||||
}
|
||||
|
@ -2179,12 +2130,11 @@ bool Project::readFlagNames() {
|
|||
fileWatcher.addPath(root + "/" + opponentsFilename);
|
||||
QMap<QString, int> maxTrainers = parser.readCDefines(opponentsFilename, QStringList() << "\\bMAX_");
|
||||
// Parse flags
|
||||
flagNames->clear();
|
||||
QStringList prefixes = (QStringList() << "\\bFLAG_");
|
||||
QStringList prefixes("\\bFLAG_");
|
||||
QString flagsFilename = "include/constants/flags.h";
|
||||
fileWatcher.addPath(root + "/" + flagsFilename);
|
||||
parser.readCDefinesSorted(flagsFilename, prefixes, flagNames, maxTrainers);
|
||||
if (flagNames->isEmpty()) {
|
||||
flagNames = parser.readCDefinesSorted(flagsFilename, prefixes, maxTrainers);
|
||||
if (flagNames.isEmpty()) {
|
||||
logError(QString("Failed to read flag constants from %1").arg(flagsFilename));
|
||||
return false;
|
||||
}
|
||||
|
@ -2192,12 +2142,11 @@ bool Project::readFlagNames() {
|
|||
}
|
||||
|
||||
bool Project::readVarNames() {
|
||||
varNames->clear();
|
||||
QStringList prefixes = (QStringList() << "\\bVAR_");
|
||||
QStringList prefixes("\\bVAR_");
|
||||
QString filename = "include/constants/vars.h";
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
parser.readCDefinesSorted(filename, prefixes, varNames);
|
||||
if (varNames->isEmpty()) {
|
||||
varNames = parser.readCDefinesSorted(filename, prefixes);
|
||||
if (varNames.isEmpty()) {
|
||||
logError(QString("Failed to read var constants from %1").arg(filename));
|
||||
return false;
|
||||
}
|
||||
|
@ -2205,12 +2154,11 @@ bool Project::readVarNames() {
|
|||
}
|
||||
|
||||
bool Project::readMovementTypes() {
|
||||
movementTypes->clear();
|
||||
QStringList prefixes = (QStringList() << "\\bMOVEMENT_TYPE_");
|
||||
QStringList prefixes("\\bMOVEMENT_TYPE_");
|
||||
QString filename = "include/constants/event_object_movement.h";
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
parser.readCDefinesSorted(filename, prefixes, movementTypes);
|
||||
if (movementTypes->isEmpty()) {
|
||||
movementTypes = parser.readCDefinesSorted(filename, prefixes);
|
||||
if (movementTypes.isEmpty()) {
|
||||
logError(QString("Failed to read movement type constants from %1").arg(filename));
|
||||
return false;
|
||||
}
|
||||
|
@ -2229,12 +2177,11 @@ bool Project::readInitialFacingDirections() {
|
|||
}
|
||||
|
||||
bool Project::readMapTypes() {
|
||||
mapTypes->clear();
|
||||
QStringList prefixes = (QStringList() << "\\bMAP_TYPE_");
|
||||
QStringList prefixes("\\bMAP_TYPE_");
|
||||
QString filename = "include/constants/map_types.h";
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
parser.readCDefinesSorted(filename, prefixes, mapTypes);
|
||||
if (mapTypes->isEmpty()) {
|
||||
mapTypes = parser.readCDefinesSorted(filename, prefixes);
|
||||
if (mapTypes.isEmpty()) {
|
||||
logError(QString("Failed to read map type constants from %1").arg(filename));
|
||||
return false;
|
||||
}
|
||||
|
@ -2242,12 +2189,11 @@ bool Project::readMapTypes() {
|
|||
}
|
||||
|
||||
bool Project::readMapBattleScenes() {
|
||||
mapBattleScenes->clear();
|
||||
QStringList prefixes = (QStringList() << "\\bMAP_BATTLE_SCENE_");
|
||||
QStringList prefixes("\\bMAP_BATTLE_SCENE_");
|
||||
QString filename = "include/constants/map_types.h";
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
parser.readCDefinesSorted("include/constants/map_types.h", prefixes, mapBattleScenes);
|
||||
if (mapBattleScenes->isEmpty()) {
|
||||
mapBattleScenes = parser.readCDefinesSorted("include/constants/map_types.h", prefixes);
|
||||
if (mapBattleScenes.isEmpty()) {
|
||||
logError(QString("Failed to read map battle scene constants from %1").arg(filename));
|
||||
return false;
|
||||
}
|
||||
|
@ -2255,12 +2201,11 @@ bool Project::readMapBattleScenes() {
|
|||
}
|
||||
|
||||
bool Project::readWeatherNames() {
|
||||
weatherNames->clear();
|
||||
QStringList prefixes = (QStringList() << "\\bWEATHER_");
|
||||
QStringList prefixes("\\bWEATHER_");
|
||||
QString filename = "include/constants/weather.h";
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
parser.readCDefinesSorted(filename, prefixes, weatherNames);
|
||||
if (weatherNames->isEmpty()) {
|
||||
weatherNames = parser.readCDefinesSorted(filename, prefixes);
|
||||
if (weatherNames.isEmpty()) {
|
||||
logError(QString("Failed to read weather constants from %1").arg(filename));
|
||||
return false;
|
||||
}
|
||||
|
@ -2268,14 +2213,14 @@ bool Project::readWeatherNames() {
|
|||
}
|
||||
|
||||
bool Project::readCoordEventWeatherNames() {
|
||||
if (!projectConfig.getEventWeatherTriggerEnabled()) return true;
|
||||
if (!projectConfig.getEventWeatherTriggerEnabled())
|
||||
return true;
|
||||
|
||||
coordEventWeatherNames->clear();
|
||||
QStringList prefixes = (QStringList() << "\\bCOORD_EVENT_WEATHER_");
|
||||
QStringList prefixes("\\bCOORD_EVENT_WEATHER_");
|
||||
QString filename = "include/constants/weather.h";
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
parser.readCDefinesSorted(filename, prefixes, coordEventWeatherNames);
|
||||
if (coordEventWeatherNames->isEmpty()) {
|
||||
coordEventWeatherNames = parser.readCDefinesSorted(filename, prefixes);
|
||||
if (coordEventWeatherNames.isEmpty()) {
|
||||
logError(QString("Failed to read coord event weather constants from %1").arg(filename));
|
||||
return false;
|
||||
}
|
||||
|
@ -2283,14 +2228,14 @@ bool Project::readCoordEventWeatherNames() {
|
|||
}
|
||||
|
||||
bool Project::readSecretBaseIds() {
|
||||
if (!projectConfig.getEventSecretBaseEnabled()) return true;
|
||||
if (!projectConfig.getEventSecretBaseEnabled())
|
||||
return true;
|
||||
|
||||
secretBaseIds->clear();
|
||||
QStringList prefixes = (QStringList() << "\\bSECRET_BASE_[A-Za-z0-9_]*_[0-9]+");
|
||||
QStringList prefixes("\\bSECRET_BASE_[A-Za-z0-9_]*_[0-9]+");
|
||||
QString filename = "include/constants/secret_bases.h";
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
parser.readCDefinesSorted(filename, prefixes, secretBaseIds);
|
||||
if (secretBaseIds->isEmpty()) {
|
||||
secretBaseIds = parser.readCDefinesSorted(filename, prefixes);
|
||||
if (secretBaseIds.isEmpty()) {
|
||||
logError(QString("Failed to read secret base id constants from %1").arg(filename));
|
||||
return false;
|
||||
}
|
||||
|
@ -2298,12 +2243,11 @@ bool Project::readSecretBaseIds() {
|
|||
}
|
||||
|
||||
bool Project::readBgEventFacingDirections() {
|
||||
bgEventFacingDirections->clear();
|
||||
QStringList prefixes = (QStringList() << "\\bBG_EVENT_PLAYER_FACING_");
|
||||
QStringList prefixes("\\bBG_EVENT_PLAYER_FACING_");
|
||||
QString filename = "include/constants/event_bg.h";
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
parser.readCDefinesSorted(filename, prefixes, bgEventFacingDirections);
|
||||
if (bgEventFacingDirections->isEmpty()) {
|
||||
bgEventFacingDirections = parser.readCDefinesSorted(filename, prefixes);
|
||||
if (bgEventFacingDirections.isEmpty()) {
|
||||
logError(QString("Failed to read bg event facing direction constants from %1").arg(filename));
|
||||
return false;
|
||||
}
|
||||
|
@ -2311,12 +2255,11 @@ bool Project::readBgEventFacingDirections() {
|
|||
}
|
||||
|
||||
bool Project::readTrainerTypes() {
|
||||
trainerTypes->clear();
|
||||
QStringList prefixes = (QStringList() << "\\bTRAINER_TYPE_");
|
||||
QStringList prefixes("\\bTRAINER_TYPE_");
|
||||
QString filename = "include/constants/trainer_types.h";
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
parser.readCDefinesSorted(filename, prefixes, trainerTypes);
|
||||
if (trainerTypes->isEmpty()) {
|
||||
trainerTypes = parser.readCDefinesSorted(filename, prefixes);
|
||||
if (trainerTypes.isEmpty()) {
|
||||
logError(QString("Failed to read trainer type constants from %1").arg(filename));
|
||||
return false;
|
||||
}
|
||||
|
@ -2327,7 +2270,7 @@ bool Project::readMetatileBehaviors() {
|
|||
this->metatileBehaviorMap.clear();
|
||||
this->metatileBehaviorMapInverse.clear();
|
||||
|
||||
QStringList prefixes = (QStringList() << "\\bMB_");
|
||||
QStringList prefixes("\\bMB_");
|
||||
QString filename = "include/constants/metatile_behaviors.h";
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
this->metatileBehaviorMap = parser.readCDefines(filename, prefixes);
|
||||
|
@ -2343,8 +2286,7 @@ bool Project::readMetatileBehaviors() {
|
|||
}
|
||||
|
||||
QStringList Project::getSongNames() {
|
||||
QStringList songDefinePrefixes;
|
||||
songDefinePrefixes << "\\bSE_" << "\\bMUS_";
|
||||
QStringList songDefinePrefixes{ "\\bSE_", "\\bMUS_" };
|
||||
QString filename = "include/constants/songs.h";
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
QMap<QString, int> songDefines = parser.readCDefines(filename, songDefinePrefixes);
|
||||
|
@ -2355,8 +2297,7 @@ QStringList Project::getSongNames() {
|
|||
}
|
||||
|
||||
QMap<QString, int> Project::getEventObjGfxConstants() {
|
||||
QStringList eventObjGfxPrefixes;
|
||||
eventObjGfxPrefixes << "\\bOBJ_EVENT_GFX_";
|
||||
QStringList eventObjGfxPrefixes("\\bOBJ_EVENT_GFX_");
|
||||
|
||||
QString filename = "include/constants/event_objects.h";
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
|
@ -2370,15 +2311,14 @@ bool Project::readMiscellaneousConstants() {
|
|||
if (projectConfig.getEncounterJsonActive()) {
|
||||
QString filename = "include/constants/pokemon.h";
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
QMap<QString, int> pokemonDefines = parser.readCDefines(filename, QStringList() << "MIN_" << "MAX_");
|
||||
QMap<QString, int> pokemonDefines = parser.readCDefines(filename, { "MIN_", "MAX_" });
|
||||
miscConstants.insert("max_level_define", pokemonDefines.value("MAX_LEVEL") > pokemonDefines.value("MIN_LEVEL") ? pokemonDefines.value("MAX_LEVEL") : 100);
|
||||
miscConstants.insert("min_level_define", pokemonDefines.value("MIN_LEVEL") < pokemonDefines.value("MAX_LEVEL") ? pokemonDefines.value("MIN_LEVEL") : 1);
|
||||
}
|
||||
|
||||
QString filename = "include/constants/global.h";
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
QStringList definePrefixes;
|
||||
definePrefixes << "\\bOBJECT_";
|
||||
QStringList definePrefixes("\\bOBJECT_");
|
||||
QMap<QString, int> defines = parser.readCDefines(filename, definePrefixes);
|
||||
|
||||
auto it = defines.find("OBJECT_EVENT_TEMPLATES_COUNT");
|
||||
|
|
|
@ -11,22 +11,18 @@ void BorderMetatilesPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
int width = map->getBorderWidth();
|
||||
int height = map->getBorderHeight();
|
||||
|
||||
Blockdata *oldBorder = map->layout->border->copy();
|
||||
Blockdata oldBorder = map->layout->border;
|
||||
|
||||
for (int i = 0; i < selectionDimensions.x() && (i + pos.x()) < width; i++) {
|
||||
for (int j = 0; j < selectionDimensions.y() && (j + pos.y()) < height; j++) {
|
||||
int blockIndex = (j + pos.y()) * width + (i + pos.x());
|
||||
uint16_t tile = selectedMetatiles->at(j * selectionDimensions.x() + i);
|
||||
(*map->layout->border->blocks)[blockIndex].tile = tile;
|
||||
map->layout->border[blockIndex].tile = tile;
|
||||
}
|
||||
}
|
||||
|
||||
Blockdata *newBorder = map->layout->border->copy();
|
||||
if (newBorder->equals(oldBorder)) {
|
||||
delete newBorder;
|
||||
delete oldBorder;
|
||||
} else {
|
||||
map->editHistory.push(new PaintBorder(map, oldBorder, newBorder, 0));
|
||||
if (map->layout->border != oldBorder) {
|
||||
map->editHistory.push(new PaintBorder(map, oldBorder, map->layout->border, 0));
|
||||
}
|
||||
|
||||
emit borderMetatilesChanged();
|
||||
|
@ -39,7 +35,6 @@ void BorderMetatilesPixmapItem::draw() {
|
|||
int height = map->getBorderHeight();
|
||||
QImage image(16 * width, 16 * height, QImage::Format_RGBA8888);
|
||||
QPainter painter(&image);
|
||||
QVector<Block> *blocks = map->layout->border->blocks;
|
||||
|
||||
for (int i = 0; i < width; i++) {
|
||||
for (int j = 0; j < height; j++) {
|
||||
|
@ -47,7 +42,7 @@ void BorderMetatilesPixmapItem::draw() {
|
|||
int y = j * 16;
|
||||
int index = j * width + i;
|
||||
QImage metatile_image = getMetatileImage(
|
||||
blocks->value(index).tile,
|
||||
map->layout->border.value(index).tile,
|
||||
map->layout->tileset_primary,
|
||||
map->layout->tileset_secondary,
|
||||
map->metatileLayerOrder,
|
||||
|
|
|
@ -45,7 +45,7 @@ void CollisionPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
|
|||
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
|
||||
actionId_++;
|
||||
} else if (map) {
|
||||
Blockdata *oldCollision = map->layout->blockdata->copy();
|
||||
Blockdata oldCollision = map->layout->blockdata;
|
||||
|
||||
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
|
||||
|
||||
|
@ -65,12 +65,8 @@ void CollisionPixmapItem::paint(QGraphicsSceneMouseEvent *event) {
|
|||
map->setBlock(pos.x(), pos.y(), block, true);
|
||||
}
|
||||
|
||||
Blockdata *newCollision = map->layout->blockdata->copy();
|
||||
if (newCollision->equals(oldCollision)) {
|
||||
delete newCollision;
|
||||
delete oldCollision;
|
||||
} else {
|
||||
map->editHistory.push(new PaintCollision(map, oldCollision, newCollision, actionId_));
|
||||
if (map->layout->blockdata != oldCollision) {
|
||||
map->editHistory.push(new PaintCollision(map, oldCollision, map->layout->blockdata, actionId_));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,19 +75,15 @@ void CollisionPixmapItem::floodFill(QGraphicsSceneMouseEvent *event) {
|
|||
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
|
||||
this->actionId_++;
|
||||
} else if (map) {
|
||||
Blockdata *oldCollision = map->layout->blockdata->copy();
|
||||
Blockdata oldCollision = map->layout->blockdata;
|
||||
|
||||
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
|
||||
uint16_t collision = this->movementPermissionsSelector->getSelectedCollision();
|
||||
uint16_t elevation = this->movementPermissionsSelector->getSelectedElevation();
|
||||
map->floodFillCollisionElevation(pos.x(), pos.y(), collision, elevation);
|
||||
|
||||
Blockdata *newCollision = map->layout->blockdata->copy();
|
||||
if (newCollision->equals(oldCollision)) {
|
||||
delete newCollision;
|
||||
delete oldCollision;
|
||||
} else {
|
||||
map->editHistory.push(new BucketFillCollision(map, oldCollision, newCollision));
|
||||
if (map->layout->blockdata != oldCollision) {
|
||||
map->editHistory.push(new BucketFillCollision(map, oldCollision, map->layout->blockdata));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -100,18 +92,14 @@ void CollisionPixmapItem::magicFill(QGraphicsSceneMouseEvent *event) {
|
|||
if (event->type() == QEvent::GraphicsSceneMouseRelease) {
|
||||
this->actionId_++;
|
||||
} else if (map) {
|
||||
Blockdata *oldCollision = map->layout->blockdata->copy();
|
||||
Blockdata oldCollision = map->layout->blockdata;
|
||||
QPoint pos = Metatile::coordFromPixmapCoord(event->pos());
|
||||
uint16_t collision = this->movementPermissionsSelector->getSelectedCollision();
|
||||
uint16_t elevation = this->movementPermissionsSelector->getSelectedElevation();
|
||||
map->magicFillCollisionElevation(pos.x(), pos.y(), collision, elevation);
|
||||
|
||||
Blockdata *newCollision = map->layout->blockdata->copy();
|
||||
if (newCollision->equals(oldCollision)) {
|
||||
delete newCollision;
|
||||
delete oldCollision;
|
||||
} else {
|
||||
map->editHistory.push(new MagicFillCollision(map, oldCollision, newCollision));
|
||||
if (map->layout->blockdata != oldCollision) {
|
||||
map->editHistory.push(new MagicFillCollision(map, oldCollision, map->layout->blockdata));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ void DraggablePixmapItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *) {
|
|||
}
|
||||
else if (this->event->get("event_type") == EventType::SecretBase) {
|
||||
QString baseId = this->event->get("secret_base_id");
|
||||
QString destMap = editor->project->mapConstantsToMapNames->value("MAP_" + baseId.left(baseId.lastIndexOf("_")));
|
||||
QString destMap = editor->project->mapConstantsToMapNames.value("MAP_" + baseId.left(baseId.lastIndexOf("_")));
|
||||
if (destMap != NONE_MAP_NAME) {
|
||||
emit editor->warpEventDoubleClicked(destMap, "0");
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ MapImageExporter::MapImageExporter(QWidget *parent_, Editor *editor_, ImageExpor
|
|||
this->ui->groupBox_Connections->setVisible(this->mode == ImageExporterMode::Normal);
|
||||
this->ui->groupBox_Timelapse->setVisible(this->mode == ImageExporterMode::Timelapse);
|
||||
|
||||
this->ui->comboBox_MapSelection->addItems(*editor->project->mapNames);
|
||||
this->ui->comboBox_MapSelection->addItems(editor->project->mapNames);
|
||||
this->ui->comboBox_MapSelection->setCurrentText(map->name);
|
||||
this->ui->comboBox_MapSelection->setEnabled(false);// TODO: allow selecting map from drop-down
|
||||
|
||||
|
|
|
@ -76,7 +76,8 @@ void MapPixmapItem::shift(QGraphicsSceneMouseEvent *event) {
|
|||
}
|
||||
|
||||
void MapPixmapItem::shift(int xDelta, int yDelta, bool fromScriptCall) {
|
||||
Blockdata *backupBlockdata = map->layout->blockdata->copy();
|
||||
Blockdata oldMetatiles = map->layout->blockdata;
|
||||
|
||||
for (int i = 0; i < map->getWidth(); i++)
|
||||
for (int j = 0; j < map->getHeight(); j++) {
|
||||
int destX = i + xDelta;
|
||||
|
@ -89,20 +90,12 @@ void MapPixmapItem::shift(int xDelta, int yDelta, bool fromScriptCall) {
|
|||
destY %= map->getHeight();
|
||||
|
||||
int blockIndex = j * map->getWidth() + i;
|
||||
Block srcBlock = backupBlockdata->blocks->at(blockIndex);
|
||||
Block srcBlock = oldMetatiles.at(blockIndex);
|
||||
map->setBlock(destX, destY, srcBlock);
|
||||
}
|
||||
|
||||
if (!fromScriptCall) {
|
||||
Blockdata *newMetatiles = map->layout->blockdata->copy();
|
||||
if (newMetatiles->equals(backupBlockdata)) {
|
||||
delete newMetatiles;
|
||||
delete backupBlockdata;
|
||||
} else {
|
||||
map->editHistory.push(new ShiftMetatiles(map, backupBlockdata, newMetatiles, actionId_));
|
||||
}
|
||||
} else {
|
||||
delete backupBlockdata;
|
||||
if (!fromScriptCall && map->layout->blockdata != oldMetatiles) {
|
||||
map->editHistory.push(new ShiftMetatiles(map, oldMetatiles, map->layout->blockdata, actionId_));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,8 +117,7 @@ void MapPixmapItem::paintNormal(int x, int y, bool fromScriptCall) {
|
|||
y = initialY + (yDiff / selectionDimensions.y()) * selectionDimensions.y();
|
||||
|
||||
// for edit history
|
||||
Blockdata *oldMetatiles = nullptr;
|
||||
if (!fromScriptCall) oldMetatiles = map->layout->blockdata->copy();
|
||||
Blockdata oldMetatiles = !fromScriptCall ? map->layout->blockdata : Blockdata();
|
||||
|
||||
for (int i = 0; i < selectionDimensions.x() && i + x < map->getWidth(); i++)
|
||||
for (int j = 0; j < selectionDimensions.y() && j + y < map->getHeight(); j++) {
|
||||
|
@ -143,14 +135,8 @@ void MapPixmapItem::paintNormal(int x, int y, bool fromScriptCall) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!fromScriptCall) {
|
||||
Blockdata *newMetatiles = map->layout->blockdata->copy();
|
||||
if (newMetatiles->equals(oldMetatiles)) {
|
||||
delete newMetatiles;
|
||||
delete oldMetatiles;
|
||||
} else {
|
||||
map->editHistory.push(new PaintMetatile(map, oldMetatiles, newMetatiles, actionId_));
|
||||
}
|
||||
if (!fromScriptCall && map->layout->blockdata != oldMetatiles) {
|
||||
map->editHistory.push(new PaintMetatile(map, oldMetatiles, map->layout->blockdata, actionId_));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -198,8 +184,7 @@ void MapPixmapItem::paintSmartPath(int x, int y, bool fromScriptCall) {
|
|||
}
|
||||
|
||||
// for edit history
|
||||
Blockdata *oldMetatiles = nullptr;
|
||||
if (!fromScriptCall) oldMetatiles = map->layout->blockdata->copy();
|
||||
Blockdata oldMetatiles = !fromScriptCall ? map->layout->blockdata : Blockdata();
|
||||
|
||||
// Fill the region with the open tile.
|
||||
for (int i = 0; i <= 1; i++)
|
||||
|
@ -263,14 +248,8 @@ void MapPixmapItem::paintSmartPath(int x, int y, bool fromScriptCall) {
|
|||
map->setBlock(actualX, actualY, block, !fromScriptCall);
|
||||
}
|
||||
|
||||
if (!fromScriptCall) {
|
||||
Blockdata *newMetatiles = map->layout->blockdata->copy();
|
||||
if (newMetatiles->equals(oldMetatiles)) {
|
||||
delete newMetatiles;
|
||||
delete oldMetatiles;
|
||||
} else {
|
||||
map->editHistory.push(new PaintMetatile(map, oldMetatiles, newMetatiles, actionId_));
|
||||
}
|
||||
if (!fromScriptCall && map->layout->blockdata != oldMetatiles) {
|
||||
map->editHistory.push(new PaintMetatile(map, oldMetatiles, map->layout->blockdata, actionId_));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,7 +266,7 @@ void MapPixmapItem::lockNondominantAxis(QGraphicsSceneMouseEvent *event) {
|
|||
this->straight_path_initial_x = pos.x();
|
||||
this->straight_path_initial_y = pos.y();
|
||||
}
|
||||
|
||||
|
||||
// Only lock an axis when the current position != initial
|
||||
int xDiff = pos.x() - this->straight_path_initial_x;
|
||||
int yDiff = pos.y() - this->straight_path_initial_y;
|
||||
|
@ -352,7 +331,7 @@ void MapPixmapItem::updateMetatileSelection(QGraphicsSceneMouseEvent *event) {
|
|||
metatiles.append(block.tile);
|
||||
}
|
||||
int blockIndex = y * map->getWidth() + x;
|
||||
block = map->layout->blockdata->blocks->at(blockIndex);
|
||||
block = map->layout->blockdata.at(blockIndex);
|
||||
auto collision = block.collision;
|
||||
auto elevation = block.elevation;
|
||||
collisions.append(QPair<uint16_t, uint16_t>(collision, elevation));
|
||||
|
@ -421,8 +400,7 @@ void MapPixmapItem::magicFill(
|
|||
return;
|
||||
}
|
||||
|
||||
Blockdata *oldMetatiles = nullptr;
|
||||
if (!fromScriptCall) oldMetatiles = map->layout->blockdata->copy();
|
||||
Blockdata oldMetatiles = !fromScriptCall ? map->layout->blockdata : Blockdata();
|
||||
|
||||
bool setCollisions = selectedCollisions && selectedCollisions->length() == selectedMetatiles->length();
|
||||
uint16_t tile = block.tile;
|
||||
|
@ -446,14 +424,8 @@ void MapPixmapItem::magicFill(
|
|||
}
|
||||
}
|
||||
|
||||
if (!fromScriptCall) {
|
||||
Blockdata *newMetatiles = map->layout->blockdata->copy();
|
||||
if (newMetatiles->equals(oldMetatiles)) {
|
||||
delete newMetatiles;
|
||||
delete oldMetatiles;
|
||||
} else {
|
||||
map->editHistory.push(new MagicFillMetatile(map, oldMetatiles, newMetatiles, actionId_));
|
||||
}
|
||||
if (!fromScriptCall && map->layout->blockdata != oldMetatiles) {
|
||||
map->editHistory.push(new MagicFillMetatile(map, oldMetatiles, map->layout->blockdata, actionId_));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -480,10 +452,7 @@ void MapPixmapItem::floodFill(
|
|||
QList<QPair<uint16_t, uint16_t>> *selectedCollisions,
|
||||
bool fromScriptCall) {
|
||||
bool setCollisions = selectedCollisions && selectedCollisions->length() == selectedMetatiles->length();
|
||||
Blockdata *oldMetatiles = nullptr;
|
||||
if (!fromScriptCall) {
|
||||
oldMetatiles = map->layout->blockdata->copy();
|
||||
}
|
||||
Blockdata oldMetatiles = !fromScriptCall ? map->layout->blockdata : Blockdata();
|
||||
|
||||
QSet<int> visited;
|
||||
QList<QPoint> todo;
|
||||
|
@ -533,14 +502,8 @@ void MapPixmapItem::floodFill(
|
|||
}
|
||||
}
|
||||
|
||||
if (!fromScriptCall) {
|
||||
Blockdata *newMetatiles = map->layout->blockdata->copy();
|
||||
if (newMetatiles->equals(oldMetatiles)) {
|
||||
delete newMetatiles;
|
||||
delete oldMetatiles;
|
||||
} else {
|
||||
map->editHistory.push(new BucketFillMetatile(map, oldMetatiles, newMetatiles, actionId_));
|
||||
}
|
||||
if (!fromScriptCall && map->layout->blockdata != oldMetatiles) {
|
||||
map->editHistory.push(new BucketFillMetatile(map, oldMetatiles, map->layout->blockdata, actionId_));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -563,8 +526,7 @@ void MapPixmapItem::floodFillSmartPath(int initialX, int initialY, bool fromScri
|
|||
setCollisions = true;
|
||||
}
|
||||
|
||||
Blockdata *oldMetatiles = nullptr;
|
||||
if (!fromScriptCall) oldMetatiles = map->layout->blockdata->copy();
|
||||
Blockdata oldMetatiles = !fromScriptCall ? map->layout->blockdata : Blockdata();
|
||||
|
||||
// Flood fill the region with the open tile.
|
||||
QList<QPoint> todo;
|
||||
|
@ -659,14 +621,8 @@ void MapPixmapItem::floodFillSmartPath(int initialX, int initialY, bool fromScri
|
|||
}
|
||||
}
|
||||
|
||||
if (!fromScriptCall) {
|
||||
Blockdata *newMetatiles = map->layout->blockdata->copy();
|
||||
if (newMetatiles->equals(oldMetatiles)) {
|
||||
delete newMetatiles;
|
||||
delete oldMetatiles;
|
||||
} else {
|
||||
map->editHistory.push(new BucketFillMetatile(map, oldMetatiles, newMetatiles, actionId_));
|
||||
}
|
||||
if (!fromScriptCall && map->layout->blockdata != oldMetatiles) {
|
||||
map->editHistory.push(new BucketFillMetatile(map, oldMetatiles, map->layout->blockdata, actionId_));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -89,8 +89,8 @@ void NewMapPopup::setDefaultValues(int groupNum, QString mapSec) {
|
|||
ui->comboBox_NewMap_Primary_Tileset->addItems(tilesets.value("primary"));
|
||||
ui->comboBox_NewMap_Secondary_Tileset->addItems(tilesets.value("secondary"));
|
||||
|
||||
ui->comboBox_NewMap_Group->addItems(*project->groupNames);
|
||||
ui->comboBox_NewMap_Group->setCurrentText(project->groupNames->at(groupNum));
|
||||
ui->comboBox_NewMap_Group->addItems(project->groupNames);
|
||||
ui->comboBox_NewMap_Group->setCurrentText(project->groupNames.at(groupNum));
|
||||
|
||||
if (existingLayout) {
|
||||
ui->spinBox_NewMap_Width->setValue(project->mapLayouts.value(layoutId)->width.toInt(nullptr, 0));
|
||||
|
@ -110,7 +110,7 @@ void NewMapPopup::setDefaultValues(int groupNum, QString mapSec) {
|
|||
ui->spinBox_NewMap_BorderHeight->setValue(DEFAULT_BORDER_HEIGHT);
|
||||
}
|
||||
|
||||
ui->comboBox_NewMap_Type->addItems(*project->mapTypes);
|
||||
ui->comboBox_NewMap_Type->addItems(project->mapTypes);
|
||||
ui->comboBox_NewMap_Location->addItems(project->mapSectionValueToName.values());
|
||||
if (!mapSec.isEmpty()) ui->comboBox_NewMap_Location->setCurrentText(mapSec);
|
||||
ui->checkBox_NewMap_Show_Location->setChecked(true);
|
||||
|
@ -165,7 +165,7 @@ void NewMapPopup::setDefaultValues(int groupNum, QString mapSec) {
|
|||
}
|
||||
|
||||
void NewMapPopup::on_lineEdit_NewMap_Name_textChanged(const QString &text) {
|
||||
if (project->mapNames->contains(text)) {
|
||||
if (project->mapNames.contains(text)) {
|
||||
QPalette palette = this->ui->lineEdit_NewMap_Name->palette();
|
||||
QColor color = Qt::red;
|
||||
color.setAlpha(25);
|
||||
|
@ -188,7 +188,7 @@ void NewMapPopup::on_pushButton_NewMap_Accept_clicked() {
|
|||
// After stripping invalid characters, strip any leading digits.
|
||||
QString newMapName = this->ui->lineEdit_NewMap_Name->text().remove(QRegularExpression("[^a-zA-Z0-9_]+"));
|
||||
newMapName.remove(QRegularExpression("^[0-9]*"));
|
||||
if (project->mapNames->contains(newMapName) || newMapName.isEmpty()) {
|
||||
if (project->mapNames.contains(newMapName) || newMapName.isEmpty()) {
|
||||
newMapName = project->getNewMapName();
|
||||
}
|
||||
|
||||
|
@ -197,9 +197,9 @@ void NewMapPopup::on_pushButton_NewMap_Accept_clicked() {
|
|||
newMap->location = this->ui->comboBox_NewMap_Location->currentText();
|
||||
newMap->song = this->project->defaultSong;
|
||||
newMap->requiresFlash = "0";
|
||||
newMap->weather = this->project->weatherNames->value(0, "WEATHER_NONE");
|
||||
newMap->weather = this->project->weatherNames.value(0, "WEATHER_NONE");
|
||||
newMap->show_location = this->ui->checkBox_NewMap_Show_Location->isChecked() ? "1" : "0";
|
||||
newMap->battle_scene = this->project->mapBattleScenes->value(0, "MAP_BATTLE_SCENE_NORMAL");
|
||||
newMap->battle_scene = this->project->mapBattleScenes.value(0, "MAP_BATTLE_SCENE_NORMAL");
|
||||
|
||||
if (this->existingLayout) {
|
||||
layout = this->project->mapLayouts.value(this->layoutId);
|
||||
|
@ -236,7 +236,7 @@ void NewMapPopup::on_pushButton_NewMap_Accept_clicked() {
|
|||
newMap->floorNumber = this->ui->spinBox_NewMap_Floor_Number->value();
|
||||
}
|
||||
|
||||
group = project->groupNames->indexOf(this->ui->comboBox_NewMap_Group->currentText());
|
||||
group = project->groupNames.indexOf(this->ui->comboBox_NewMap_Group->currentText());
|
||||
newMap->layout = layout;
|
||||
newMap->layoutId = layout->id;
|
||||
if (this->existingLayout) {
|
||||
|
|
|
@ -215,7 +215,7 @@ void RegionMapEditor::displayRegionMapLayoutOptions() {
|
|||
|
||||
void RegionMapEditor::updateRegionMapLayoutOptions(int index) {
|
||||
this->ui->comboBox_RM_ConnectedMap->blockSignals(true);
|
||||
this->ui->lineEdit_RM_MapName->setText(this->project->mapSecToMapHoverName->value(this->region_map->map_squares[index].mapsec));
|
||||
this->ui->lineEdit_RM_MapName->setText(this->project->mapSecToMapHoverName.value(this->region_map->map_squares[index].mapsec));
|
||||
this->ui->comboBox_RM_ConnectedMap->setCurrentText(this->region_map->map_squares[index].mapsec);
|
||||
this->ui->comboBox_RM_ConnectedMap->blockSignals(false);
|
||||
}
|
||||
|
@ -438,7 +438,7 @@ void RegionMapEditor::onRegionMapLayoutSelectedTileChanged(int index) {
|
|||
this->currIndex = index;
|
||||
this->region_map_layout_item->highlightedTile = index;
|
||||
if (this->region_map->map_squares[index].has_map) {
|
||||
message = QString("\t %1").arg(this->project->mapSecToMapHoverName->value(
|
||||
message = QString("\t %1").arg(this->project->mapSecToMapHoverName.value(
|
||||
this->region_map->map_squares[index].mapsec)).remove("{NAME_END}");
|
||||
}
|
||||
this->ui->statusbar->showMessage(message);
|
||||
|
@ -454,7 +454,7 @@ void RegionMapEditor::onRegionMapLayoutHoveredTileChanged(int index) {
|
|||
if (x >= 0 && y >= 0) {
|
||||
message = QString("(%1, %2)").arg(x).arg(y);
|
||||
if (this->region_map->map_squares[index].has_map) {
|
||||
message += QString("\t %1").arg(this->project->mapSecToMapHoverName->value(
|
||||
message += QString("\t %1").arg(this->project->mapSecToMapHoverName.value(
|
||||
this->region_map->map_squares[index].mapsec)).remove("{NAME_END}");
|
||||
}
|
||||
}
|
||||
|
@ -551,7 +551,7 @@ void RegionMapEditor::on_tabWidget_Region_Map_currentChanged(int index) {
|
|||
}
|
||||
|
||||
void RegionMapEditor::on_comboBox_RM_ConnectedMap_activated(const QString &mapsec) {
|
||||
this->ui->lineEdit_RM_MapName->setText(this->project->mapSecToMapHoverName->value(mapsec));
|
||||
this->ui->lineEdit_RM_MapName->setText(this->project->mapSecToMapHoverName.value(mapsec));
|
||||
onRegionMapLayoutSelectedTileChanged(this->currIndex);// re-draw layout image
|
||||
this->hasUnsavedChanges = true;// sometimes this is called for unknown reasons
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue