resize region map tilemaps

This commit is contained in:
garak
2022-04-28 13:21:36 -04:00
committed by garakmon
parent cff77ad58e
commit f7a0e02f95
13 changed files with 306 additions and 249 deletions

View File

@@ -38,8 +38,9 @@ struct MapSectionEntry
bool valid = false;
};
class RegionMap
class RegionMap : public QObject
{
Q_OBJECT
public:
RegionMap() = delete;
RegionMap(Project *);
@@ -64,7 +65,7 @@ public:
void saveConfig();// ? or do this in the editor only?
void saveOptions(int id, QString sec, QString name, int x, int y);
void resize(int width, int height);
void resizeTilemap(int width, int height, bool update = true);
void resetSquare(int index);
void clearLayout();
void clearImage();
@@ -86,6 +87,9 @@ public:
void setTile(int index, TilemapTile &tile);
void setTileData(int index, unsigned id, bool hFlip, bool vFlip, int palette);
int getMapSquareIndex(int x, int y);
QString getAlias() { return this->alias; }
poryjson::Json::object config();
QString palPath();
QString pngPath();
@@ -141,6 +145,11 @@ public:
void undo();
void redo();
void emitDisplay();
signals:
void mapNeedsDisplaying();
private:
// TODO: defaults needed?
tsl::ordered_map<QString, MapSectionEntry> *region_map_entries = nullptr;
@@ -150,9 +159,6 @@ private:
int tilemap_width;
int tilemap_height;
int region_width;
int region_height;
int layout_width;
int layout_height;

View File

@@ -14,6 +14,9 @@ enum RMCommandId {
ID_EditLayout,
ID_ResizeLayout,
ID_EditEntry,
ID_RemoveEntry,
ID_AddEntry,
ID_ResizeTilemap,
};
@@ -28,7 +31,7 @@ public:
bool mergeWith(const QUndoCommand *command) override;
int id() const override { return RMCommandId::ID_EditTilemap; }
private:
protected:
RegionMap *map;
QByteArray oldTilemap;
@@ -110,6 +113,8 @@ public:
void undo() override;
void redo() override;
int id() const override { return RMCommandId::ID_RemoveEntry; }
};
@@ -120,10 +125,28 @@ public:
void undo() override;
void redo() override;
int id() const override { return RMCommandId::ID_AddEntry; }
};
// ResizeTilemap
// ResizeMap
/// ResizeTilemap
class ResizeTilemap : public EditTilemap {
public:
ResizeTilemap(RegionMap *map, QByteArray oldTilemap, QByteArray newTilemap,
int oldWidth, int oldHeight, int newWidth, int newHeight, QUndoCommand *parent = nullptr);
void undo() override;
void redo() override;
int id() const override { return RMCommandId::ID_ResizeTilemap; }
private:
int oldWidth;
int oldHeight;
int newWidth;
int newHeight;
};
#endif // REGIONMAPEDITCOMMANDS_H