mirror of
https://github.com/huderlem/porymap.git
synced 2026-10-01 04:16:37 -05:00
fix edit commands and ui things to use layout instead of map
This commit is contained in:
@@ -342,12 +342,12 @@ public:
|
||||
|
||||
|
||||
|
||||
// !TODO
|
||||
// !TODO: rename map vars to layout
|
||||
/// Implements a command to commit map edits from the scripting API.
|
||||
/// The scripting api can edit map/border blocks and dimensions.
|
||||
class ScriptEditMap : public QUndoCommand {
|
||||
public:
|
||||
ScriptEditMap(Map *map,
|
||||
ScriptEditMap(Layout *layout,
|
||||
QSize oldMapDimensions, QSize newMapDimensions,
|
||||
const Blockdata &oldMetatiles, const Blockdata &newMetatiles,
|
||||
QSize oldBorderDimensions, QSize newBorderDimensions,
|
||||
@@ -361,7 +361,7 @@ public:
|
||||
int id() const override { return CommandId::ID_ScriptEditMap; }
|
||||
|
||||
private:
|
||||
Map *map;
|
||||
Layout *layout = nullptr;
|
||||
|
||||
Blockdata newMetatiles;
|
||||
Blockdata oldMetatiles;
|
||||
|
||||
@@ -66,20 +66,11 @@ public:
|
||||
bool needsLayoutDir = true;
|
||||
bool needsHealLocation = false;
|
||||
|
||||
QImage collision_image;
|
||||
QPixmap collision_pixmap;
|
||||
QImage image;
|
||||
QPixmap pixmap;
|
||||
|
||||
QMap<Event::Group, QList<Event *>> events;
|
||||
QList<Event *> ownedEvents; // for memory management
|
||||
|
||||
QList<MapConnection*> connections;
|
||||
|
||||
// !TODO
|
||||
QList<int> metatileLayerOrder;
|
||||
QList<float> metatileLayerOpacity;
|
||||
|
||||
void setName(QString mapName);
|
||||
static QString mapConstantFromName(QString mapName);
|
||||
|
||||
@@ -89,68 +80,21 @@ public:
|
||||
int getBorderWidth();
|
||||
int getBorderHeight();
|
||||
|
||||
QUndoStack editHistory;
|
||||
void modify();
|
||||
void clean();
|
||||
|
||||
QPixmap render(bool ignoreCache = false, Layout *fromLayout = nullptr, QRect bounds = QRect(0, 0, -1, -1));
|
||||
QPixmap renderCollision(bool ignoreCache);
|
||||
QPixmap renderConnection(MapConnection, Layout *);
|
||||
QPixmap renderBorder(bool ignoreCache = false);
|
||||
|
||||
bool mapBlockChanged(int i, const Blockdata &cache);
|
||||
bool borderBlockChanged(int i, const Blockdata &cache);
|
||||
|
||||
// !TODO: remove
|
||||
void cacheBlockdata();
|
||||
void cacheCollision();
|
||||
|
||||
/// !TODO: remove this
|
||||
bool getBlock(int x, int y, Block *out);
|
||||
void setBlock(int x, int y, Block block, bool enableScriptCallback = false);
|
||||
void setBlockdata(Blockdata blockdata, bool enableScriptCallback = false);
|
||||
|
||||
uint16_t getBorderMetatileId(int x, int y);
|
||||
void setBorderMetatileId(int x, int y, uint16_t metatileId, bool enableScriptCallback = false);
|
||||
void setBorderBlockData(Blockdata blockdata, bool enableScriptCallback = false);
|
||||
|
||||
void floodFillCollisionElevation(int x, int y, uint16_t collision, uint16_t elevation);
|
||||
void _floodFillCollisionElevation(int x, int y, uint16_t collision, uint16_t elevation);
|
||||
void magicFillCollisionElevation(int x, int y, uint16_t collision, uint16_t elevation);
|
||||
|
||||
QList<Event *> getAllEvents() const;
|
||||
QStringList eventScriptLabels(Event::Group group = Event::Group::None) const;
|
||||
void removeEvent(Event *);
|
||||
void addEvent(Event *);
|
||||
|
||||
void setDimensions(int newWidth, int newHeight, bool setNewBlockdata = true, bool enableScriptCallback = false);
|
||||
void setBorderDimensions(int newWidth, int newHeight, bool setNewBlockdata = true, bool enableScriptCallback = false);
|
||||
|
||||
void clearBorderCache();
|
||||
void cacheBorder();
|
||||
|
||||
bool hasUnsavedChanges();
|
||||
|
||||
bool isWithinBounds(int x, int y);
|
||||
bool isWithinBorderBounds(int x, int y);
|
||||
|
||||
void openScript(QString label);
|
||||
|
||||
private:
|
||||
LayoutPixmapItem *mapItem = nullptr;
|
||||
QUndoStack editHistory;
|
||||
void modify();
|
||||
void clean();
|
||||
bool hasUnsavedChanges();
|
||||
|
||||
public:
|
||||
void setMapItem(LayoutPixmapItem *item) { mapItem = item; }
|
||||
QPixmap renderConnection(MapConnection, Layout *);
|
||||
|
||||
CollisionPixmapItem *collisionItem = nullptr;
|
||||
void setCollisionItem(CollisionPixmapItem *item) { collisionItem = item; }
|
||||
|
||||
BorderMetatilesPixmapItem *borderItem = nullptr;
|
||||
void setBorderItem(BorderMetatilesPixmapItem *item) { borderItem = item; }
|
||||
|
||||
private:
|
||||
void setNewDimensionsBlockdata(int newWidth, int newHeight);
|
||||
void setNewBorderDimensionsBlockdata(int newWidth, int newHeight);
|
||||
|
||||
signals:
|
||||
void mapChanged(Map *map);
|
||||
|
||||
@@ -77,9 +77,8 @@ public:
|
||||
int getBorderWidth();
|
||||
int getBorderHeight();
|
||||
|
||||
bool isWithinBounds(int x, int y) {
|
||||
return (x >= 0 && x < this->getWidth() && y >= 0 && y < this->getHeight());
|
||||
}
|
||||
bool isWithinBounds(int x, int y);
|
||||
bool isWithinBorderBounds(int x, int y);
|
||||
|
||||
bool getBlock(int x, int y, Block *out);
|
||||
void setBlock(int x, int y, Block block, bool enableScriptCallback = false);
|
||||
|
||||
Reference in New Issue
Block a user