mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-19 23:25:09 -05:00
resize region map tilemaps
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
void onRegionMapEntriesSelectedTileChanged(QString) {};
|
||||
void onRegionMapEntryDragged(int, int);
|
||||
|
||||
void resize(int width, int height);
|
||||
void resizeTilemap(int width, int height);
|
||||
|
||||
QObjectList shortcutableObjects() const;
|
||||
|
||||
@@ -87,6 +87,8 @@ private:
|
||||
RegionMapPixmapItem *region_map_item = nullptr;
|
||||
CityMapPixmapItem *city_map_item = nullptr;
|
||||
|
||||
bool saveRegionMap(RegionMap *map);
|
||||
void saveConfig();
|
||||
bool loadRegionMapEntries();
|
||||
bool saveRegionMapEntries();
|
||||
tsl::ordered_map<QString, MapSectionEntry> region_map_entries;
|
||||
@@ -122,6 +124,7 @@ private:
|
||||
|
||||
private slots:
|
||||
void on_action_RegionMap_Save_triggered();
|
||||
void on_actionSave_All_triggered();
|
||||
void on_action_RegionMap_Resize_triggered();
|
||||
void on_action_RegionMap_ClearImage_triggered();
|
||||
void on_action_RegionMap_ClearLayout_triggered();
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
this->tile_selector = tile_selector;
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
RegionMap *region_map;
|
||||
RegionMap *region_map = nullptr;
|
||||
TilemapTileSelector *tile_selector;
|
||||
|
||||
virtual void paint(QGraphicsSceneMouseEvent *);
|
||||
|
||||
Reference in New Issue
Block a user