mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-24 09:36:11 -05:00
Allow rendering individual metatile layers
This commit is contained in:
@@ -133,9 +133,6 @@ private:
|
||||
QMap<Event::Group, QList<Event *>> m_events;
|
||||
QSet<Event *> m_ownedEvents; // for memory management
|
||||
|
||||
QList<int> m_metatileLayerOrder;
|
||||
QList<float> m_metatileLayerOpacity;
|
||||
|
||||
void trackConnection(MapConnection*);
|
||||
|
||||
// MapConnections in 'ownedConnections' but not 'connections' persist in the edit history.
|
||||
|
||||
@@ -17,7 +17,7 @@ class BorderMetatilesPixmapItem;
|
||||
class Layout : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Layout() {}
|
||||
Layout() {};
|
||||
Layout(const Layout &other);
|
||||
|
||||
static QString layoutConstantFromName(const QString &name);
|
||||
@@ -64,8 +64,15 @@ public:
|
||||
QSize borderDimensions;
|
||||
} lastCommitBlocks; // to track map changes
|
||||
|
||||
QList<int> metatileLayerOrder;
|
||||
QList<float> metatileLayerOpacity;
|
||||
void setMetatileLayerOrder(const QList<int> &layerOrder) { m_metatileLayerOrder = layerOrder; }
|
||||
QList<int> metatileLayerOrder() const;
|
||||
static void setDefaultMetatileLayerOrder(const QList<int> &layerOrder) { s_defaultMetatileLayerOrder = layerOrder; }
|
||||
static QList<int> defaultMetatileLayerOrder();
|
||||
|
||||
void setMetatileLayerOpacity(const QList<float> &layerOpacity) { m_metatileLayerOpacity = layerOpacity; }
|
||||
QList<float> metatileLayerOpacity() const;
|
||||
static void setDefaultMetatileLayerOpacity(const QList<float> &layerOpacity) { s_defaultMetatileLayerOpacity = layerOpacity; }
|
||||
static QList<float> defaultMetatileLayerOpacity();
|
||||
|
||||
LayoutPixmapItem *layoutItem = nullptr;
|
||||
CollisionPixmapItem *collisionItem = nullptr;
|
||||
@@ -147,6 +154,8 @@ public:
|
||||
void setCollisionItem(CollisionPixmapItem *item) { collisionItem = item; }
|
||||
void setBorderItem(BorderMetatilesPixmapItem *item) { borderItem = item; }
|
||||
|
||||
bool metatileIsValid(uint16_t metatileId) { return Tileset::metatileIsValid(metatileId, this->tileset_primary, this->tileset_secondary); }
|
||||
|
||||
private:
|
||||
void setNewDimensionsBlockdata(int newWidth, int newHeight);
|
||||
void setNewBorderDimensionsBlockdata(int newWidth, int newHeight);
|
||||
@@ -155,6 +164,11 @@ private:
|
||||
|
||||
static int getBorderDrawDistance(int dimension, qreal minimum);
|
||||
|
||||
QList<int> m_metatileLayerOrder;
|
||||
QList<float> m_metatileLayerOpacity;
|
||||
static QList<int> s_defaultMetatileLayerOrder;
|
||||
static QList<float> s_defaultMetatileLayerOpacity;
|
||||
|
||||
signals:
|
||||
void dimensionsChanged(const QSize &size);
|
||||
void needsRedrawing();
|
||||
|
||||
@@ -284,7 +284,6 @@ signals:
|
||||
void wildMonTableEdited();
|
||||
void currentMetatilesSelectionChanged();
|
||||
void mapRulerStatusChanged(const QString &);
|
||||
void tilesetUpdated(QString);
|
||||
void gridToggled(bool);
|
||||
void editActionSet(EditAction newEditAction);
|
||||
};
|
||||
|
||||
@@ -145,6 +145,10 @@ public:
|
||||
Q_INVOKABLE void setMetatileTiles(int metatileId, QJSValue tilesObj, int tileStart = 0, int tileEnd = -1, bool forceRedraw = true);
|
||||
Q_INVOKABLE void setMetatileTiles(int metatileId, int tileId, bool xflip, bool yflip, int palette, int tileStart = 0, int tileEnd = -1, bool forceRedraw = true);
|
||||
Q_INVOKABLE QJSValue getTilePixels(int tileId);
|
||||
Q_INVOKABLE QList<int> getMetatileLayerOrder() const;
|
||||
Q_INVOKABLE void setMetatileLayerOrder(const QList<int> &order);
|
||||
Q_INVOKABLE QList<float> getMetatileLayerOpacity() const;
|
||||
Q_INVOKABLE void setMetatileLayerOpacity(const QList<float> &opacities);
|
||||
Q_INVOKABLE QString getSong();
|
||||
Q_INVOKABLE void setSong(QString song);
|
||||
Q_INVOKABLE QString getLocation();
|
||||
|
||||
@@ -23,7 +23,7 @@ enum CallbackType {
|
||||
OnMapResized,
|
||||
OnBorderResized,
|
||||
OnMapShifted,
|
||||
OnTilesetUpdated,
|
||||
OnTilesetsChanged,
|
||||
OnMainTabChanged,
|
||||
OnMapViewTabChanged,
|
||||
OnBorderVisibilityToggled,
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
static void cb_MapResized(int oldWidth, int oldHeight, const QMargins &delta);
|
||||
static void cb_BorderResized(int oldWidth, int oldHeight, int newWidth, int newHeight);
|
||||
static void cb_MapShifted(int xDelta, int yDelta);
|
||||
static void cb_TilesetUpdated(QString tilesetName);
|
||||
static void cb_TilesetsChanged(const QString &primaryTilesetName, const QString &secondaryTilesetName);
|
||||
static void cb_MainTabChanged(int oldTab, int newTab);
|
||||
static void cb_MapViewTabChanged(int oldTab, int newTab);
|
||||
static void cb_BorderVisibilityToggled(bool visible);
|
||||
|
||||
@@ -38,9 +38,9 @@ public:
|
||||
Q_INVOKABLE bool getSmartPathsEnabled();
|
||||
Q_INVOKABLE QList<QString> getCustomScripts();
|
||||
Q_INVOKABLE QList<int> getMetatileLayerOrder();
|
||||
Q_INVOKABLE void setMetatileLayerOrder(QList<int> order);
|
||||
Q_INVOKABLE void setMetatileLayerOrder(const QList<int> &order);
|
||||
Q_INVOKABLE QList<float> getMetatileLayerOpacity();
|
||||
Q_INVOKABLE void setMetatileLayerOpacity(QList<float> order);
|
||||
Q_INVOKABLE void setMetatileLayerOpacity(const QList<float> &order);
|
||||
Q_INVOKABLE QList<QString> getMapNames();
|
||||
Q_INVOKABLE QList<QString> getMapConstants();
|
||||
Q_INVOKABLE QList<QString> getLayoutNames();
|
||||
@@ -57,6 +57,8 @@ public:
|
||||
Q_INVOKABLE bool isPrimaryTileset(QString tilesetName);
|
||||
Q_INVOKABLE bool isSecondaryTileset(QString tilesetName);
|
||||
|
||||
static bool validateMetatileLayerOrder(const QList<int> &order);
|
||||
|
||||
private:
|
||||
void callTimeoutFunction(QJSValue callback);
|
||||
void runMessageBox(QString text, QString informativeText, QString detailedText, QMessageBox::Icon icon);
|
||||
|
||||
@@ -6,8 +6,12 @@
|
||||
#include <QImage>
|
||||
#include <QPixmap>
|
||||
|
||||
class Layout;
|
||||
|
||||
QImage getCollisionMetatileImage(Block);
|
||||
QImage getCollisionMetatileImage(int, int);
|
||||
QImage getMetatileImage(uint16_t, Layout*, bool useTruePalettes = false);
|
||||
QImage getMetatileImage(Metatile*, Layout*, bool useTruePalettes = false);
|
||||
QImage getMetatileImage(uint16_t, Tileset*, Tileset*, const QList<int>&, const QList<float>&, bool useTruePalettes = false);
|
||||
QImage getMetatileImage(Metatile*, Tileset*, Tileset*, const QList<int>&, const QList<float>&, bool useTruePalettes = false);
|
||||
QImage getTileImage(uint16_t, Tileset*, Tileset*);
|
||||
|
||||
@@ -36,8 +36,6 @@ public:
|
||||
this->prefabSelection = false;
|
||||
this->numMetatilesWide = numMetatilesWide;
|
||||
this->layout = layout;
|
||||
this->primaryTileset = layout->tileset_primary;
|
||||
this->secondaryTileset = layout->tileset_secondary;
|
||||
this->selection = MetatileSelection{};
|
||||
this->cellPos = QPoint(-1, -1);
|
||||
setAcceptHoverEvents(true);
|
||||
@@ -45,10 +43,10 @@ public:
|
||||
|
||||
QPoint getSelectionDimensions() override;
|
||||
void draw() override;
|
||||
void refresh();
|
||||
|
||||
bool select(uint16_t metatile);
|
||||
void selectFromMap(uint16_t metatileId, uint16_t collision, uint16_t elevation);
|
||||
void setTilesets(Tileset*, Tileset*);
|
||||
MetatileSelection getMetatileSelection();
|
||||
void setPrefabSelection(MetatileSelection selection);
|
||||
void setExternalSelection(int, int, QList<uint16_t>, QList<QPair<uint16_t, uint16_t>>);
|
||||
@@ -56,8 +54,9 @@ public:
|
||||
void setLayout(Layout *layout);
|
||||
bool isInternalSelection() const { return (!this->externalSelection && !this->prefabSelection); }
|
||||
|
||||
Tileset *primaryTileset;
|
||||
Tileset *secondaryTileset;
|
||||
Tileset *primaryTileset() const { return this->layout->tileset_primary; }
|
||||
Tileset *secondaryTileset() const { return this->layout->tileset_secondary; }
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent*) override;
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent*) override;
|
||||
|
||||
Reference in New Issue
Block a user