mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-26 10:35:55 -05:00
Bootstrap stamping
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#define COLLISIONPIXMAPITEM_H
|
||||
|
||||
#include "metatileselector.h"
|
||||
//#include "stampselector.h"
|
||||
#include "movementpermissionsselector.h"
|
||||
#include "mappixmapitem.h"
|
||||
#include "map.h"
|
||||
@@ -10,8 +11,14 @@
|
||||
class CollisionPixmapItem : public MapPixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
CollisionPixmapItem(Map *map, MovementPermissionsSelector *movementPermissionsSelector, MetatileSelector *metatileSelector, Settings *settings, qreal *opacity)
|
||||
: MapPixmapItem(map, metatileSelector, settings){
|
||||
CollisionPixmapItem(Map *map,
|
||||
MovementPermissionsSelector *movementPermissionsSelector,
|
||||
MetatileSelector *metatileSelector,
|
||||
StampSelector *stampSelector,
|
||||
Settings *settings,
|
||||
qreal *opacity,
|
||||
std::function<PaintType(void)> getActivePaintType)
|
||||
: MapPixmapItem(map, metatileSelector, stampSelector, settings, getActivePaintType){
|
||||
this->movementPermissionsSelector = movementPermissionsSelector;
|
||||
this->opacity = opacity;
|
||||
map->setCollisionItem(this);
|
||||
|
||||
@@ -4,8 +4,14 @@
|
||||
#include "map.h"
|
||||
#include "settings.h"
|
||||
#include "metatileselector.h"
|
||||
#include "stampselector.h"
|
||||
#include <QGraphicsPixmapItem>
|
||||
|
||||
enum PaintType {
|
||||
PaintTypeMetatile,
|
||||
PaintTypeStamp,
|
||||
};
|
||||
|
||||
class MapPixmapItem : public QObject, public QGraphicsPixmapItem {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -18,10 +24,12 @@ public:
|
||||
Metatiles,
|
||||
EventObjects
|
||||
};
|
||||
MapPixmapItem(Map *map_, MetatileSelector *metatileSelector, Settings *settings) {
|
||||
MapPixmapItem(Map *map_, MetatileSelector *metatileSelector, StampSelector *stampSelector, Settings *settings, std::function<PaintType(void)> getActivePaintType) {
|
||||
this->map = map_;
|
||||
this->map->setMapItem(this);
|
||||
this->metatileSelector = metatileSelector;
|
||||
this->stampSelector = stampSelector;
|
||||
this->getActivePaintType = getActivePaintType;
|
||||
this->settings = settings;
|
||||
this->paintingMode = PaintMode::Metatiles;
|
||||
this->lockedAxis = MapPixmapItem::Axis::None;
|
||||
@@ -31,6 +39,8 @@ public:
|
||||
MapPixmapItem::PaintMode paintingMode;
|
||||
Map *map;
|
||||
MetatileSelector *metatileSelector;
|
||||
StampSelector *stampSelector;
|
||||
std::function<PaintType(void)> getActivePaintType;
|
||||
Settings *settings;
|
||||
bool active;
|
||||
bool has_mouse = false;
|
||||
|
||||
@@ -6,27 +6,7 @@
|
||||
#include "map.h"
|
||||
#include "tileset.h"
|
||||
#include "maplayout.h"
|
||||
|
||||
struct MetatileSelectionItem
|
||||
{
|
||||
bool enabled;
|
||||
uint16_t metatileId;
|
||||
};
|
||||
|
||||
struct CollisionSelectionItem
|
||||
{
|
||||
bool enabled;
|
||||
uint16_t collision;
|
||||
uint16_t elevation;
|
||||
};
|
||||
|
||||
struct MetatileSelection
|
||||
{
|
||||
QPoint dimensions;
|
||||
bool hasCollision;
|
||||
QList<MetatileSelectionItem> metatileItems;
|
||||
QList<CollisionSelectionItem> collisionItems;
|
||||
};
|
||||
#include "paintselection.h"
|
||||
|
||||
class MetatileSelector: public SelectablePixmapItem {
|
||||
Q_OBJECT
|
||||
@@ -38,7 +18,7 @@ public:
|
||||
this->map = map;
|
||||
this->primaryTileset = map->layout->tileset_primary;
|
||||
this->secondaryTileset = map->layout->tileset_secondary;
|
||||
this->selection = MetatileSelection{};
|
||||
this->selection = MetatileSelection();
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
QPoint getSelectionDimensions();
|
||||
@@ -74,7 +54,6 @@ private:
|
||||
uint16_t getMetatileId(int x, int y);
|
||||
QPoint getMetatileIdCoords(uint16_t);
|
||||
bool shouldAcceptEvent(QGraphicsSceneMouseEvent*);
|
||||
bool selectionIsValid();
|
||||
|
||||
signals:
|
||||
void hoveredMetatileSelectionChanged(uint16_t);
|
||||
|
||||
48
include/ui/paintselection.h
Normal file
48
include/ui/paintselection.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
#ifndef PAINTSELECTION_H
|
||||
#define PAINTSELECTION_H
|
||||
|
||||
#include "block.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QPoint>
|
||||
|
||||
struct MetatileSelectionItem
|
||||
{
|
||||
bool enabled;
|
||||
uint16_t metatileId;
|
||||
};
|
||||
|
||||
struct CollisionSelectionItem
|
||||
{
|
||||
bool enabled;
|
||||
uint16_t collision;
|
||||
uint16_t elevation;
|
||||
};
|
||||
|
||||
class PaintSelection
|
||||
{
|
||||
public:
|
||||
QPoint dimensions;
|
||||
virtual bool paintNormal(int, Block*) = 0;
|
||||
};
|
||||
|
||||
class MetatileSelection: public PaintSelection
|
||||
{
|
||||
public:
|
||||
MetatileSelection() {}
|
||||
bool paintNormal(int index, Block *block) override;
|
||||
bool hasCollision = false;
|
||||
QList<MetatileSelectionItem> metatileItems;
|
||||
QList<CollisionSelectionItem> collisionItems;
|
||||
};
|
||||
|
||||
class StampSelection: public PaintSelection
|
||||
{
|
||||
public:
|
||||
StampSelection() {}
|
||||
bool paintNormal(int index, Block *block) override;
|
||||
QList<uint16_t> stampIds;
|
||||
};
|
||||
|
||||
#endif // PAINTSELECTION_H
|
||||
47
include/ui/stampselector.h
Normal file
47
include/ui/stampselector.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef STAMPSELECTOR_H
|
||||
#define STAMPSELECTOR_H
|
||||
|
||||
#include "selectablepixmapitem.h"
|
||||
#include "map.h"
|
||||
#include "tileset.h"
|
||||
#include "maplayout.h"
|
||||
#include "paintselection.h"
|
||||
|
||||
class StampSelector: public SelectablePixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
StampSelector(int numStampsWide, Map *map): SelectablePixmapItem(16, 16) {
|
||||
this->numStampsWide = numStampsWide;
|
||||
this->map = map;
|
||||
this->primaryTileset = map->layout->tileset_primary;
|
||||
this->secondaryTileset = map->layout->tileset_secondary;
|
||||
this->selection = StampSelection{};
|
||||
}
|
||||
QPoint getSelectionDimensions();
|
||||
void draw();
|
||||
bool select(uint16_t stampId);
|
||||
void setTilesets(Tileset*, Tileset*);
|
||||
StampSelection getStampSelection();
|
||||
QPoint getStampIdCoordsOnWidget(uint16_t);
|
||||
void setMap(Map*);
|
||||
Tileset *primaryTileset;
|
||||
Tileset *secondaryTileset;
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
|
||||
private:
|
||||
int numStampsWide;
|
||||
Map *map;
|
||||
StampSelection selection;
|
||||
|
||||
void updateSelectedStamps();
|
||||
uint16_t getStampId(int x, int y);
|
||||
QPoint getStampIdCoords(uint16_t);
|
||||
bool shouldAcceptEvent(QGraphicsSceneMouseEvent*);
|
||||
|
||||
signals:
|
||||
void selectedStampsChanged();
|
||||
};
|
||||
|
||||
#endif // STAMPSELECTOR_H
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "tileseteditortileselector.h"
|
||||
#include "metatilelayersitem.h"
|
||||
#include "map.h"
|
||||
#include "metatile.h"
|
||||
|
||||
namespace Ui {
|
||||
class TilesetEditor;
|
||||
|
||||
Reference in New Issue
Block a user