mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-19 23:25:09 -05:00
Merge branch 'master' into api-redesign
This commit is contained in:
@@ -18,4 +18,6 @@ public:
|
||||
void setMap(Map *map) { this->map = map; }
|
||||
};
|
||||
|
||||
QPixmap drawMetatileSelection(MetatileSelection selection, Map *map);
|
||||
|
||||
#endif // CURRENTSELECTEDMETATILESPIXMAPITEM_H
|
||||
|
||||
@@ -4,6 +4,27 @@
|
||||
#include <QGraphicsView>
|
||||
#include <QMouseEvent>
|
||||
|
||||
class ClickableGraphicsView : public QGraphicsView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ClickableGraphicsView() : QGraphicsView() {}
|
||||
ClickableGraphicsView(QWidget *parent) : QGraphicsView(parent) {}
|
||||
|
||||
public:
|
||||
void mousePressEvent(QMouseEvent *event) {
|
||||
QGraphicsView::mousePressEvent(event);
|
||||
emit this->clicked(event);
|
||||
}
|
||||
void mouseDoubleClickEvent(QMouseEvent *event) {
|
||||
QGraphicsView::mouseDoubleClickEvent(event);
|
||||
emit this->clicked(event);
|
||||
}
|
||||
|
||||
signals:
|
||||
void clicked(QMouseEvent *event);
|
||||
};
|
||||
|
||||
class Editor;
|
||||
|
||||
class GraphicsView : public QGraphicsView
|
||||
|
||||
@@ -58,16 +58,16 @@ public:
|
||||
int initialX,
|
||||
int initialY,
|
||||
QPoint selectionDimensions,
|
||||
QList<uint16_t> *selectedMetatiles,
|
||||
QList<QPair<uint16_t, uint16_t>> *selectedCollisions,
|
||||
QList<MetatileSelectionItem> selectedMetatiles,
|
||||
QList<CollisionSelectionItem> selectedCollisions,
|
||||
bool fromScriptCall = false);
|
||||
void floodFill(int x, int y, bool fromScriptCall = false);
|
||||
void floodFill(int x, int y, uint16_t metatileId, bool fromScriptCall = false);
|
||||
void floodFill(int initialX,
|
||||
int initialY,
|
||||
QPoint selectionDimensions,
|
||||
QList<uint16_t> *selectedMetatiles,
|
||||
QList<QPair<uint16_t, uint16_t>> *selectedCollisions,
|
||||
QList<MetatileSelectionItem> selectedMetatiles,
|
||||
QList<CollisionSelectionItem> selectedCollisions,
|
||||
bool fromScriptCall = false);
|
||||
void floodFillSmartPath(int initialX, int initialY, bool fromScriptCall = false);
|
||||
virtual void pick(QGraphicsSceneMouseEvent*);
|
||||
|
||||
@@ -7,6 +7,27 @@
|
||||
#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;
|
||||
};
|
||||
|
||||
class MetatileSelector: public SelectablePixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -16,9 +37,7 @@ public:
|
||||
this->map = map;
|
||||
this->primaryTileset = map->layout->tileset_primary;
|
||||
this->secondaryTileset = map->layout->tileset_secondary;
|
||||
this->selectedMetatiles = new QList<uint16_t>();
|
||||
this->selectedCollisions = new QList<QPair<uint16_t, uint16_t>>();
|
||||
this->externalSelectedMetatiles = new QList<uint16_t>();
|
||||
this->selection = MetatileSelection{};
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
QPoint getSelectionDimensions();
|
||||
@@ -26,8 +45,8 @@ public:
|
||||
bool select(uint16_t metatile);
|
||||
bool selectFromMap(uint16_t metatileId, uint16_t collision, uint16_t elevation);
|
||||
void setTilesets(Tileset*, Tileset*);
|
||||
QList<uint16_t>* getSelectedMetatiles();
|
||||
QList<QPair<uint16_t, uint16_t>>* getSelectedCollisions();
|
||||
MetatileSelection getMetatileSelection();
|
||||
void setDirectSelection(MetatileSelection selection);
|
||||
void setExternalSelection(int, int, QList<uint16_t>, QList<QPair<uint16_t, uint16_t>>);
|
||||
QPoint getMetatileIdCoordsOnWidget(uint16_t);
|
||||
void setMap(Map*);
|
||||
@@ -43,11 +62,10 @@ private:
|
||||
bool externalSelection;
|
||||
int numMetatilesWide;
|
||||
Map *map;
|
||||
QList<uint16_t> *selectedMetatiles;
|
||||
QList<QPair<uint16_t, uint16_t>> *selectedCollisions;
|
||||
int externalSelectionWidth;
|
||||
int externalSelectionHeight;
|
||||
QList<uint16_t> *externalSelectedMetatiles;
|
||||
QList<uint16_t> externalSelectedMetatiles;
|
||||
MetatileSelection selection;
|
||||
|
||||
void updateSelectedMetatiles();
|
||||
void updateExternalSelectedMetatiles();
|
||||
|
||||
39
include/ui/prefab.h
Normal file
39
include/ui/prefab.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef PREFAB_H
|
||||
#define PREFAB_H
|
||||
|
||||
#include "ui/metatileselector.h"
|
||||
#include "map.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QLabel>
|
||||
#include <QUuid>
|
||||
|
||||
struct PrefabItem
|
||||
{
|
||||
QUuid id;
|
||||
QString name;
|
||||
QString primaryTileset;
|
||||
QString secondaryTileset;
|
||||
MetatileSelection selection;
|
||||
};
|
||||
|
||||
class Prefab
|
||||
{
|
||||
public:
|
||||
void initPrefabUI(MetatileSelector *selector, QWidget *prefabWidget, QLabel *emptyPrefabLabel, Map *map);
|
||||
void addPrefab(MetatileSelection selection, Map *map, QString name);
|
||||
void updatePrefabUi(Map *map);
|
||||
|
||||
private:
|
||||
MetatileSelector *selector;
|
||||
QWidget *prefabWidget;
|
||||
QLabel *emptyPrefabLabel;
|
||||
QList<PrefabItem> items;
|
||||
void loadPrefabs();
|
||||
void savePrefabs();
|
||||
QList<PrefabItem> getPrefabsForTilesets(QString primaryTileset, QString secondaryTileset);
|
||||
};
|
||||
|
||||
extern Prefab prefab;
|
||||
|
||||
#endif // PREFAB_H
|
||||
28
include/ui/prefabcreationdialog.h
Normal file
28
include/ui/prefabcreationdialog.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef PREFABCREATIONDIALOG_H
|
||||
#define PREFABCREATIONDIALOG_H
|
||||
|
||||
#include "metatileselector.h"
|
||||
#include "map.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class PrefabCreationDialog;
|
||||
}
|
||||
|
||||
class PrefabCreationDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PrefabCreationDialog(QWidget *parent, MetatileSelector *metatileSelector, Map *map);
|
||||
~PrefabCreationDialog();
|
||||
void savePrefab();
|
||||
|
||||
private:
|
||||
Map *map;
|
||||
Ui::PrefabCreationDialog *ui;
|
||||
MetatileSelection selection;
|
||||
};
|
||||
|
||||
#endif // PREFABCREATIONDIALOG_H
|
||||
22
include/ui/prefabframe.h
Normal file
22
include/ui/prefabframe.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef PREFABFRAME_H
|
||||
#define PREFABFRAME_H
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
namespace Ui {
|
||||
class PrefabFrame;
|
||||
}
|
||||
|
||||
class PrefabFrame : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PrefabFrame(QWidget *parent = nullptr);
|
||||
~PrefabFrame();
|
||||
|
||||
public:
|
||||
Ui::PrefabFrame *ui;
|
||||
};
|
||||
|
||||
#endif // PREFABFRAME_H
|
||||
Reference in New Issue
Block a user