mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-20 07:36:31 -05:00
Restructure source tree
This commit is contained in:
20
include/core/block.h
Normal file
20
include/core/block.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef BLOCK_H
|
||||
#define BLOCK_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class Block
|
||||
{
|
||||
public:
|
||||
Block();
|
||||
Block(uint16_t);
|
||||
Block(const Block&);
|
||||
bool operator ==(Block);
|
||||
bool operator !=(Block);
|
||||
uint16_t tile:10;
|
||||
uint16_t collision:2;
|
||||
uint16_t elevation:4;
|
||||
uint16_t rawValue();
|
||||
};
|
||||
|
||||
#endif // BLOCK_H
|
||||
32
include/core/blockdata.h
Normal file
32
include/core/blockdata.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef BLOCKDATA_H
|
||||
#define BLOCKDATA_H
|
||||
|
||||
#include "block.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
|
||||
class Blockdata : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Blockdata(QObject *parent = nullptr);
|
||||
~Blockdata() {
|
||||
if (blocks) delete blocks;
|
||||
}
|
||||
|
||||
public:
|
||||
QList<Block> *blocks = nullptr;
|
||||
void addBlock(uint16_t);
|
||||
void addBlock(Block);
|
||||
QByteArray serialize();
|
||||
void copyFrom(Blockdata*);
|
||||
Blockdata* copy();
|
||||
bool equals(Blockdata *);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
#endif // BLOCKDATA_H
|
||||
85
include/core/event.h
Normal file
85
include/core/event.h
Normal file
@@ -0,0 +1,85 @@
|
||||
#ifndef EVENT_H
|
||||
#define EVENT_H
|
||||
|
||||
#include <QString>
|
||||
#include <QPixmap>
|
||||
#include <QMap>
|
||||
#include <QDebug>
|
||||
|
||||
class EventType
|
||||
{
|
||||
public:
|
||||
static QString Object;
|
||||
static QString Warp;
|
||||
static QString CoordScript;
|
||||
static QString CoordWeather;
|
||||
static QString Sign;
|
||||
static QString HiddenItem;
|
||||
static QString SecretBase;
|
||||
static QString HealLocation;
|
||||
};
|
||||
|
||||
class Event
|
||||
{
|
||||
public:
|
||||
Event();
|
||||
public:
|
||||
int x() {
|
||||
return getInt("x");
|
||||
}
|
||||
int y() {
|
||||
return getInt("y");
|
||||
}
|
||||
int elevation() {
|
||||
return getInt("elevation");
|
||||
}
|
||||
void setX(int x) {
|
||||
put("x", x);
|
||||
}
|
||||
void setY(int y) {
|
||||
put("y", y);
|
||||
}
|
||||
QString get(QString key) {
|
||||
return values.value(key);
|
||||
}
|
||||
int getInt(QString key) {
|
||||
return values.value(key).toInt(nullptr, 0);
|
||||
}
|
||||
uint16_t getU16(QString key) {
|
||||
return values.value(key).toUShort(nullptr, 0);
|
||||
}
|
||||
void put(QString key, int value) {
|
||||
put(key, QString("%1").arg(value));
|
||||
}
|
||||
void put(QString key, QString value) {
|
||||
values.insert(key, value);
|
||||
}
|
||||
|
||||
static Event* createNewEvent(QString, QString);
|
||||
static Event* createNewObjectEvent();
|
||||
static Event* createNewWarpEvent(QString);
|
||||
static Event* createNewHealLocationEvent(QString);
|
||||
static Event* createNewCoordScriptEvent();
|
||||
static Event* createNewCoordWeatherEvent();
|
||||
static Event* createNewSignEvent();
|
||||
static Event* createNewHiddenItemEvent();
|
||||
static Event* createNewSecretBaseEvent();
|
||||
|
||||
QString buildObjectEventMacro(int);
|
||||
QString buildWarpEventMacro(QMap<QString, QString>*);
|
||||
QString buildCoordScriptEventMacro();
|
||||
QString buildCoordWeatherEventMacro();
|
||||
QString buildSignEventMacro();
|
||||
QString buildHiddenItemEventMacro();
|
||||
QString buildSecretBaseEventMacro();
|
||||
void setPixmapFromSpritesheet(QImage, int, int);
|
||||
int getPixelX();
|
||||
int getPixelY();
|
||||
|
||||
QMap<QString, QString> values;
|
||||
QPixmap pixmap;
|
||||
int spriteWidth;
|
||||
int spriteHeight;
|
||||
};
|
||||
|
||||
#endif // EVENT_H
|
||||
24
include/core/heallocation.h
Normal file
24
include/core/heallocation.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef HEALLOCATION_H
|
||||
#define HEALLOCATION_H
|
||||
|
||||
#include "event.h"
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
|
||||
class HealLocation {
|
||||
|
||||
public:
|
||||
HealLocation()=default;
|
||||
HealLocation(QString, int, uint16_t, uint16_t);
|
||||
friend QDebug operator<<(QDebug debug, const HealLocation &hl);
|
||||
|
||||
public:
|
||||
//QString group;
|
||||
QString name;
|
||||
int index;
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
static HealLocation fromEvent(Event*);
|
||||
};
|
||||
|
||||
#endif // HEALLOCATION_H
|
||||
58
include/core/history.h
Normal file
58
include/core/history.h
Normal file
@@ -0,0 +1,58 @@
|
||||
#ifndef HISTORY_H
|
||||
#define HISTORY_H
|
||||
|
||||
#include <QList>
|
||||
|
||||
template <typename T>
|
||||
class History {
|
||||
public:
|
||||
History() { }
|
||||
T back() {
|
||||
if (head > 0) {
|
||||
return history.at(--head);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
T next() {
|
||||
if (head + 1 < history.length()) {
|
||||
return history.at(++head);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void push(T commit) {
|
||||
while (head + 1 < history.length()) {
|
||||
T item = history.last();
|
||||
history.removeLast();
|
||||
delete item;
|
||||
}
|
||||
if (saved > head) {
|
||||
saved = -1;
|
||||
}
|
||||
history.append(commit);
|
||||
head++;
|
||||
}
|
||||
|
||||
T current() {
|
||||
if (head < 0 || history.length() == 0) {
|
||||
return NULL;
|
||||
}
|
||||
return history.at(head);
|
||||
}
|
||||
|
||||
void save() {
|
||||
saved = head;
|
||||
}
|
||||
|
||||
bool isSaved() {
|
||||
return saved == head;
|
||||
}
|
||||
|
||||
private:
|
||||
QList<T> history;
|
||||
int head = -1;
|
||||
int saved = -1;
|
||||
};
|
||||
|
||||
#endif // HISTORY_H
|
||||
15
include/core/historyitem.h
Normal file
15
include/core/historyitem.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef HISTORYITEM_H
|
||||
#define HISTORYITEM_H
|
||||
|
||||
#include "blockdata.h"
|
||||
|
||||
class HistoryItem {
|
||||
public:
|
||||
Blockdata *metatiles;
|
||||
int layoutWidth;
|
||||
int layoutHeight;
|
||||
HistoryItem(Blockdata *metatiles, int layoutWidth, int layoutHeight);
|
||||
~HistoryItem();
|
||||
};
|
||||
|
||||
#endif // HISTORYITEM_H
|
||||
89
include/core/map.h
Normal file
89
include/core/map.h
Normal file
@@ -0,0 +1,89 @@
|
||||
#ifndef MAP_H
|
||||
#define MAP_H
|
||||
|
||||
#include "blockdata.h"
|
||||
#include "history.h"
|
||||
#include "historyitem.h"
|
||||
#include "mapconnection.h"
|
||||
#include "maplayout.h"
|
||||
#include "tileset.h"
|
||||
#include "event.h"
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <math.h>
|
||||
|
||||
class Map : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Map(QObject *parent = nullptr);
|
||||
|
||||
public:
|
||||
QString name;
|
||||
QString constantName;
|
||||
QString group_num;
|
||||
QString layout_label;
|
||||
QString events_label;
|
||||
QString scripts_label;
|
||||
QString connections_label;
|
||||
QString song;
|
||||
QString layout_id;
|
||||
QString location;
|
||||
QString requiresFlash;
|
||||
QString isFlyable; // TODO: implement this
|
||||
QString weather;
|
||||
QString type;
|
||||
QString unknown;
|
||||
QString show_location;
|
||||
QString battle_scene;
|
||||
MapLayout *layout;
|
||||
bool isPersistedToFile = true;
|
||||
QImage collision_image;
|
||||
QPixmap collision_pixmap;
|
||||
QImage image;
|
||||
QPixmap pixmap;
|
||||
History<HistoryItem*> metatileHistory;
|
||||
QMap<QString, QList<Event*>> events;
|
||||
QList<MapConnection*> connections;
|
||||
void setName(QString mapName);
|
||||
static QString mapConstantFromName(QString mapName);
|
||||
static QString objectEventsLabelFromName(QString mapName);
|
||||
static QString warpEventsLabelFromName(QString mapName);
|
||||
static QString coordEventsLabelFromName(QString mapName);
|
||||
static QString bgEventsLabelFromName(QString mapName);
|
||||
int getWidth();
|
||||
int getHeight();
|
||||
QPixmap render(bool ignoreCache);
|
||||
QPixmap renderCollision(bool ignoreCache);
|
||||
bool blockChanged(int, Blockdata*);
|
||||
void cacheBlockdata();
|
||||
void cacheCollision();
|
||||
Block *getBlock(int x, int y);
|
||||
void setBlock(int x, int y, Block block);
|
||||
void _setBlock(int x, int y, Block block);
|
||||
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 undo();
|
||||
void redo();
|
||||
void commit();
|
||||
QList<Event*> getAllEvents();
|
||||
void removeEvent(Event*);
|
||||
void addEvent(Event*);
|
||||
QPixmap renderConnection(MapConnection);
|
||||
QPixmap renderBorder();
|
||||
void setDimensions(int newWidth, int newHeight, bool setNewBlockData = true);
|
||||
void cacheBorder();
|
||||
bool hasUnsavedChanges();
|
||||
|
||||
private:
|
||||
void setNewDimensionsBlockdata(int newWidth, int newHeight);
|
||||
|
||||
signals:
|
||||
void mapChanged(Map *map);
|
||||
void mapNeedsRedrawing();
|
||||
};
|
||||
|
||||
#endif // MAP_H
|
||||
14
include/core/mapconnection.h
Normal file
14
include/core/mapconnection.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef MAPCONNECTION_H
|
||||
#define MAPCONNECTION_H
|
||||
|
||||
#include <QString>
|
||||
#include <QDebug>
|
||||
|
||||
class MapConnection {
|
||||
public:
|
||||
QString direction;
|
||||
QString offset;
|
||||
QString map_name;
|
||||
};
|
||||
|
||||
#endif // MAPCONNECTION_H
|
||||
41
include/core/maplayout.h
Normal file
41
include/core/maplayout.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef MAPLAYOUT_H
|
||||
#define MAPLAYOUT_H
|
||||
|
||||
#include "blockdata.h"
|
||||
#include "tileset.h"
|
||||
#include <QImage>
|
||||
#include <QPixmap>
|
||||
#include <QString>
|
||||
|
||||
class MapLayout {
|
||||
public:
|
||||
MapLayout() {}
|
||||
int index;
|
||||
QString name;
|
||||
QString label;
|
||||
QString width;
|
||||
QString height;
|
||||
QString border_label;
|
||||
QString border_path;
|
||||
QString blockdata_label;
|
||||
QString blockdata_path;
|
||||
QString tileset_primary_label;
|
||||
QString tileset_secondary_label;
|
||||
Tileset *tileset_primary = nullptr;
|
||||
Tileset *tileset_secondary = nullptr;
|
||||
Blockdata* blockdata = nullptr;
|
||||
QImage border_image;
|
||||
QPixmap border_pixmap;
|
||||
Blockdata *border = nullptr;
|
||||
Blockdata *cached_blockdata = nullptr;
|
||||
Blockdata *cached_collision = nullptr;
|
||||
Blockdata *cached_border = nullptr;
|
||||
bool has_unsaved_changes = false;
|
||||
public:
|
||||
static QString getNameFromLabel(QString label) {
|
||||
// ASSUMPTION: strip off "_Layout" from layout label. Directories in 'data/layouts/' must be well-formed.
|
||||
return label.replace(label.lastIndexOf("_Layout"), label.length(), "");
|
||||
}
|
||||
};
|
||||
|
||||
#endif // MAPLAYOUT_H
|
||||
17
include/core/metatile.h
Normal file
17
include/core/metatile.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef METATILE_H
|
||||
#define METATILE_H
|
||||
|
||||
#include "tile.h"
|
||||
#include <QImage>
|
||||
|
||||
class Metatile
|
||||
{
|
||||
public:
|
||||
Metatile();
|
||||
public:
|
||||
QList<Tile> *tiles = nullptr;
|
||||
|
||||
static int getBlockIndex(int);
|
||||
};
|
||||
|
||||
#endif // METATILE_H
|
||||
47
include/core/parseutil.h
Normal file
47
include/core/parseutil.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef PARSEUTIL_H
|
||||
#define PARSEUTIL_H
|
||||
|
||||
#include "heallocation.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
|
||||
enum TokenType {
|
||||
Number,
|
||||
Operator,
|
||||
};
|
||||
|
||||
class Token {
|
||||
public:
|
||||
Token(QString value = "", QString type = "") {
|
||||
this->value = value;
|
||||
this->type = TokenType::Operator;
|
||||
if (type == "decimal" || type == "hex") {
|
||||
this->type = TokenType::Number;
|
||||
this->operatorPrecedence = -1;
|
||||
} else if (type == "operator") {
|
||||
this->operatorPrecedence = precedenceMap[value];
|
||||
}
|
||||
}
|
||||
static QMap<QString, int> precedenceMap;
|
||||
QString value;
|
||||
TokenType type;
|
||||
int operatorPrecedence; // only relevant for operator tokens
|
||||
};
|
||||
|
||||
class ParseUtil
|
||||
{
|
||||
public:
|
||||
ParseUtil();
|
||||
void strip_comment(QString*);
|
||||
QList<QStringList>* parseAsm(QString);
|
||||
int evaluateDefine(QString, QMap<QString, int>*);
|
||||
QList<HealLocation>* parseHealLocs(QString);
|
||||
private:
|
||||
QList<Token> tokenizeExpression(QString expression, QMap<QString, int>* knownIdentifiers);
|
||||
QList<Token> generatePostfix(QList<Token> tokens);
|
||||
int evaluatePostfix(QList<Token> postfix);
|
||||
};
|
||||
|
||||
#endif // PARSEUTIL_H
|
||||
16
include/core/tile.h
Normal file
16
include/core/tile.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef TILE_H
|
||||
#define TILE_H
|
||||
|
||||
|
||||
class Tile
|
||||
{
|
||||
public:
|
||||
Tile();
|
||||
public:
|
||||
int tile;
|
||||
int xflip;
|
||||
int yflip;
|
||||
int palette;
|
||||
};
|
||||
|
||||
#endif // TILE_H
|
||||
32
include/core/tileset.h
Normal file
32
include/core/tileset.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef TILESET_H
|
||||
#define TILESET_H
|
||||
|
||||
#include "metatile.h"
|
||||
#include "tile.h"
|
||||
#include <QImage>
|
||||
|
||||
class Tileset
|
||||
{
|
||||
public:
|
||||
Tileset();
|
||||
public:
|
||||
QString name;
|
||||
QString is_compressed;
|
||||
QString is_secondary;
|
||||
QString padding;
|
||||
QString tiles_label;
|
||||
QString palettes_label;
|
||||
QString metatiles_label;
|
||||
QString callback_label;
|
||||
QString metatile_attrs_label;
|
||||
|
||||
QList<QImage> *tiles = nullptr;
|
||||
QList<Metatile*> *metatiles = nullptr;
|
||||
QList<QList<QRgb>> *palettes = nullptr;
|
||||
|
||||
static Tileset* getBlockTileset(int, Tileset*, Tileset*);
|
||||
static Metatile* getMetatile(int, Tileset*, Tileset*);
|
||||
static QList<QList<QRgb>> getBlockPalettes(Tileset*, Tileset*);
|
||||
};
|
||||
|
||||
#endif // TILESET_H
|
||||
263
include/editor.h
Normal file
263
include/editor.h
Normal file
@@ -0,0 +1,263 @@
|
||||
#ifndef EDITOR_H
|
||||
#define EDITOR_H
|
||||
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsItemGroup>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QGraphicsItemAnimation>
|
||||
#include <QComboBox>
|
||||
#include <QCheckBox>
|
||||
#include <QCursor>
|
||||
|
||||
#include "mapconnection.h"
|
||||
#include "metatileselector.h"
|
||||
#include "movementpermissionsselector.h"
|
||||
#include "project.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "bordermetatilespixmapitem.h"
|
||||
#include "connectionpixmapitem.h"
|
||||
#include "currentselectedmetatilespixmapitem.h"
|
||||
#include "collisionpixmapitem.h"
|
||||
#include "mappixmapitem.h"
|
||||
#include "settings.h"
|
||||
|
||||
class DraggablePixmapItem;
|
||||
class MetatilesPixmapItem;
|
||||
|
||||
class Editor : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Editor(Ui::MainWindow* ui);
|
||||
public:
|
||||
Ui::MainWindow* ui;
|
||||
QObject *parent = nullptr;
|
||||
Project *project = nullptr;
|
||||
Map *map = nullptr;
|
||||
Settings *settings;
|
||||
void saveProject();
|
||||
void save();
|
||||
void undo();
|
||||
void redo();
|
||||
void setMap(QString map_name);
|
||||
void displayMap();
|
||||
void displayMetatileSelector();
|
||||
void displayMapMetatiles();
|
||||
void displayMapMovementPermissions();
|
||||
void displayBorderMetatiles();
|
||||
void displayCurrentMetatilesSelection();
|
||||
void redrawCurrentMetatilesSelection();
|
||||
void displayMovementPermissionSelector();
|
||||
void displayElevationMetatiles();
|
||||
void displayMapEvents();
|
||||
void displayMapConnections();
|
||||
void displayMapBorder();
|
||||
void displayMapGrid();
|
||||
|
||||
void setEditingMap();
|
||||
void setEditingCollision();
|
||||
void setEditingObjects();
|
||||
void setEditingConnections();
|
||||
void setCurrentConnectionDirection(QString curDirection);
|
||||
void updateCurrentConnectionDirection(QString curDirection);
|
||||
void setConnectionsVisibility(bool visible);
|
||||
void updateConnectionOffset(int offset);
|
||||
void setConnectionMap(QString mapName);
|
||||
void addNewConnection();
|
||||
void removeCurrentConnection();
|
||||
void updateDiveMap(QString mapName);
|
||||
void updateEmergeMap(QString mapName);
|
||||
void setSelectedConnectionFromMap(QString mapName);
|
||||
void updatePrimaryTileset(QString tilesetLabel);
|
||||
void updateSecondaryTileset(QString tilesetLabel);
|
||||
void toggleBorderVisibility(bool visible);
|
||||
|
||||
DraggablePixmapItem *addMapEvent(Event *event);
|
||||
void selectMapEvent(DraggablePixmapItem *object);
|
||||
void selectMapEvent(DraggablePixmapItem *object, bool toggle);
|
||||
DraggablePixmapItem *addNewEvent(QString event_type);
|
||||
Event* createNewEvent(QString event_type);
|
||||
void deleteEvent(Event *);
|
||||
void updateSelectedEvents();
|
||||
void redrawObject(DraggablePixmapItem *item);
|
||||
QList<DraggablePixmapItem *> *getObjects();
|
||||
|
||||
QGraphicsScene *scene = nullptr;
|
||||
QGraphicsPixmapItem *current_view = nullptr;
|
||||
MapPixmapItem *map_item = nullptr;
|
||||
ConnectionPixmapItem* selected_connection_item = nullptr;
|
||||
QList<QGraphicsPixmapItem*> connection_items;
|
||||
QList<ConnectionPixmapItem*> connection_edit_items;
|
||||
CollisionPixmapItem *collision_item = nullptr;
|
||||
QGraphicsItemGroup *events_group = nullptr;
|
||||
QList<QGraphicsPixmapItem*> borderItems;
|
||||
QList<QGraphicsLineItem*> gridLines;
|
||||
|
||||
QGraphicsScene *scene_metatiles = nullptr;
|
||||
QGraphicsScene *scene_current_metatile_selection = nullptr;
|
||||
QGraphicsScene *scene_selected_border_metatiles = nullptr;
|
||||
QGraphicsScene *scene_collision_metatiles = nullptr;
|
||||
QGraphicsScene *scene_elevation_metatiles = nullptr;
|
||||
MetatileSelector *metatile_selector_item = nullptr;
|
||||
|
||||
BorderMetatilesPixmapItem *selected_border_metatiles_item = nullptr;
|
||||
CurrentSelectedMetatilesPixmapItem *scene_current_metatile_selection_item = nullptr;
|
||||
MovementPermissionsSelector *movement_permissions_selector_item = nullptr;
|
||||
|
||||
QList<DraggablePixmapItem*> *events = nullptr;
|
||||
QList<DraggablePixmapItem*> *selected_events = nullptr;
|
||||
|
||||
QString map_edit_mode;
|
||||
QString prev_edit_mode;
|
||||
|
||||
int scale_exp = 0;
|
||||
double scale_base = sqrt(2); // adjust scale factor with this
|
||||
|
||||
void objectsView_onMousePress(QMouseEvent *event);
|
||||
void objectsView_onMouseMove(QMouseEvent *event);
|
||||
void objectsView_onMouseRelease(QMouseEvent *event);
|
||||
|
||||
private:
|
||||
void setConnectionItemsVisible(bool);
|
||||
void setBorderItemsVisible(bool, qreal = 1);
|
||||
void setConnectionEditControlValues(MapConnection*);
|
||||
void setConnectionEditControlsEnabled(bool);
|
||||
void createConnectionItem(MapConnection* connection, bool hide);
|
||||
void populateConnectionMapPickers();
|
||||
void setDiveEmergeControls();
|
||||
void updateDiveEmergeMap(QString mapName, QString direction);
|
||||
void onConnectionOffsetChanged(int newOffset);
|
||||
void removeMirroredConnection(MapConnection*);
|
||||
void updateMirroredConnectionOffset(MapConnection*);
|
||||
void updateMirroredConnectionDirection(MapConnection*, QString);
|
||||
void updateMirroredConnectionMap(MapConnection*, QString);
|
||||
void updateMirroredConnection(MapConnection*, QString, QString, bool isDelete = false);
|
||||
Event* createNewObjectEvent();
|
||||
Event* createNewWarpEvent();
|
||||
Event* createNewHealLocationEvent();
|
||||
Event* createNewCoordScriptEvent();
|
||||
Event* createNewCoordWeatherEvent();
|
||||
Event* createNewSignEvent();
|
||||
Event* createNewHiddenItemEvent();
|
||||
Event* createNewSecretBaseEvent();
|
||||
QString getMovementPermissionText(uint16_t collision, uint16_t elevation);
|
||||
|
||||
private slots:
|
||||
void mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item);
|
||||
void mouseEvent_collision(QGraphicsSceneMouseEvent *event, CollisionPixmapItem *item);
|
||||
void onConnectionMoved(MapConnection*);
|
||||
void onConnectionItemSelected(ConnectionPixmapItem* connectionItem);
|
||||
void onConnectionItemDoubleClicked(ConnectionPixmapItem* connectionItem);
|
||||
void onConnectionDirectionChanged(QString newDirection);
|
||||
void onBorderMetatilesChanged();
|
||||
void onHoveredMovementPermissionChanged(uint16_t, uint16_t);
|
||||
void onHoveredMovementPermissionCleared();
|
||||
void onHoveredMetatileSelectionChanged(uint16_t);
|
||||
void onHoveredMetatileSelectionCleared();
|
||||
void onHoveredMapMetatileChanged(int, int);
|
||||
void onHoveredMapMetatileCleared();
|
||||
void onHoveredMapMovementPermissionChanged(int, int);
|
||||
void onHoveredMapMovementPermissionCleared();
|
||||
void onSelectedMetatilesChanged();
|
||||
|
||||
signals:
|
||||
void objectsChanged();
|
||||
void selectedObjectsChanged();
|
||||
void loadMapRequested(QString, QString);
|
||||
void tilesetChanged(QString);
|
||||
void warpEventDoubleClicked(QString mapName, QString warpNum);
|
||||
void currentMetatilesSelectionChanged();
|
||||
void wheelZoom(int delta);
|
||||
};
|
||||
|
||||
|
||||
|
||||
class DraggablePixmapItem : public QObject, public QGraphicsPixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DraggablePixmapItem(QPixmap pixmap): QGraphicsPixmapItem(pixmap) {
|
||||
}
|
||||
Editor *editor = nullptr;
|
||||
Event *event = nullptr;
|
||||
QGraphicsItemAnimation *pos_anim = nullptr;
|
||||
DraggablePixmapItem(Event *event_, Editor *editor_) : QGraphicsPixmapItem(event_->pixmap) {
|
||||
event = event_;
|
||||
editor = editor_;
|
||||
updatePosition();
|
||||
}
|
||||
bool active;
|
||||
int last_x;
|
||||
int last_y;
|
||||
void updatePosition() {
|
||||
int x = event->getPixelX();
|
||||
int y = event->getPixelY();
|
||||
setX(x);
|
||||
setY(y);
|
||||
setZValue(event->y());
|
||||
}
|
||||
void move(int x, int y);
|
||||
void emitPositionChanged() {
|
||||
emit xChanged(event->x());
|
||||
emit yChanged(event->y());
|
||||
emit elevationChanged(event->elevation());
|
||||
}
|
||||
void updatePixmap() {
|
||||
QList<Event*> objects;
|
||||
objects.append(event);
|
||||
event->pixmap = QPixmap();
|
||||
editor->project->loadEventPixmaps(objects);
|
||||
this->updatePosition();
|
||||
editor->redrawObject(this);
|
||||
emit spriteChanged(event->pixmap);
|
||||
}
|
||||
void bind(QComboBox *combo, QString key) {
|
||||
connect(combo, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentTextChanged),
|
||||
this, [this, key](QString value){
|
||||
this->event->put(key, value);
|
||||
});
|
||||
connect(this, &DraggablePixmapItem::onPropertyChanged,
|
||||
this, [combo, key](QString key2, QString value){
|
||||
if (key2 == key) {
|
||||
combo->addItem(value);
|
||||
combo->setCurrentText(value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
signals:
|
||||
void positionChanged(Event *event);
|
||||
void xChanged(int);
|
||||
void yChanged(int);
|
||||
void elevationChanged(int);
|
||||
void spriteChanged(QPixmap pixmap);
|
||||
void onPropertyChanged(QString key, QString value);
|
||||
|
||||
public slots:
|
||||
void set_x(const QString &text) {
|
||||
event->put("x", text);
|
||||
updatePosition();
|
||||
}
|
||||
void set_y(const QString &text) {
|
||||
event->put("y", text);
|
||||
updatePosition();
|
||||
}
|
||||
void set_elevation(const QString &text) {
|
||||
event->put("elevation", text);
|
||||
updatePosition();
|
||||
}
|
||||
void set_sprite(const QString &text) {
|
||||
event->put("sprite", text);
|
||||
updatePixmap();
|
||||
}
|
||||
void set_script(const QString &text) {
|
||||
event->put("script_label", text);
|
||||
}
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*);
|
||||
};
|
||||
|
||||
#endif // EDITOR_H
|
||||
161
include/mainwindow.h
Normal file
161
include/mainwindow.h
Normal file
@@ -0,0 +1,161 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QString>
|
||||
#include <QModelIndex>
|
||||
#include <QMainWindow>
|
||||
#include <QStandardItemModel>
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <QGraphicsItemGroup>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QAbstractItemModel>
|
||||
#include "project.h"
|
||||
#include "map.h"
|
||||
#include "editor.h"
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
public slots:
|
||||
void scaleMapView(int);
|
||||
|
||||
private slots:
|
||||
void on_action_Open_Project_triggered();
|
||||
void on_mapList_activated(const QModelIndex &index);
|
||||
void on_action_Save_Project_triggered();
|
||||
void openWarpMap(QString map_name, QString warp_num);
|
||||
|
||||
void undo();
|
||||
void redo();
|
||||
|
||||
void openInTextEditor();
|
||||
|
||||
void onLoadMapRequested(QString, QString);
|
||||
void onMapChanged(Map *map);
|
||||
void onMapNeedsRedrawing();
|
||||
|
||||
void on_action_Save_triggered();
|
||||
void on_tabWidget_2_currentChanged(int index);
|
||||
void on_action_Exit_triggered();
|
||||
void on_comboBox_Song_activated(const QString &arg1);
|
||||
void on_comboBox_Location_activated(const QString &arg1);
|
||||
void on_comboBox_Visibility_activated(const QString &arg1);
|
||||
void on_comboBox_Weather_activated(const QString &arg1);
|
||||
void on_comboBox_Type_activated(const QString &arg1);
|
||||
void on_comboBox_BattleScene_activated(const QString &arg1);
|
||||
void on_checkBox_ShowLocation_clicked(bool checked);
|
||||
|
||||
void on_tabWidget_currentChanged(int index);
|
||||
|
||||
void on_actionUndo_triggered();
|
||||
|
||||
void on_actionRedo_triggered();
|
||||
|
||||
void on_actionZoom_In_triggered();
|
||||
void on_actionZoom_Out_triggered();
|
||||
void on_actionBetter_Cursors_triggered();
|
||||
void on_actionPencil_triggered();
|
||||
void on_actionPointer_triggered();
|
||||
void on_actionFlood_Fill_triggered();
|
||||
void on_actionEyedropper_triggered();
|
||||
void on_actionMove_triggered();
|
||||
void on_actionMap_Shift_triggered();
|
||||
|
||||
void on_toolButton_deleteObject_clicked();
|
||||
void on_toolButton_Open_Scripts_clicked();
|
||||
|
||||
void addNewEvent(QString);
|
||||
void updateSelectedObjects();
|
||||
|
||||
void on_toolButton_Paint_clicked();
|
||||
|
||||
void on_toolButton_Select_clicked();
|
||||
|
||||
void on_toolButton_Fill_clicked();
|
||||
|
||||
void on_toolButton_Dropper_clicked();
|
||||
|
||||
void on_toolButton_Move_clicked();
|
||||
|
||||
void on_toolButton_Shift_clicked();
|
||||
|
||||
void onOpenMapListContextMenu(const QPoint &point);
|
||||
void onAddNewMapToGroupClick(QAction* triggeredAction);
|
||||
void onTilesetChanged(QString);
|
||||
void currentMetatilesSelectionChanged();
|
||||
|
||||
void on_action_Export_Map_Image_triggered();
|
||||
|
||||
void on_comboBox_ConnectionDirection_currentIndexChanged(const QString &arg1);
|
||||
|
||||
void on_spinBox_ConnectionOffset_valueChanged(int offset);
|
||||
|
||||
void on_comboBox_ConnectedMap_currentTextChanged(const QString &mapName);
|
||||
|
||||
void on_pushButton_AddConnection_clicked();
|
||||
|
||||
void on_pushButton_RemoveConnection_clicked();
|
||||
|
||||
void on_comboBox_DiveMap_currentTextChanged(const QString &mapName);
|
||||
|
||||
void on_comboBox_EmergeMap_currentTextChanged(const QString &mapName);
|
||||
|
||||
void on_comboBox_PrimaryTileset_activated(const QString &arg1);
|
||||
|
||||
void on_comboBox_SecondaryTileset_activated(const QString &arg1);
|
||||
|
||||
void on_pushButton_clicked();
|
||||
|
||||
void on_checkBox_smartPaths_stateChanged(int selected);
|
||||
|
||||
void on_checkBox_Visibility_clicked(bool checked);
|
||||
|
||||
void on_checkBox_ToggleBorder_stateChanged(int arg1);
|
||||
|
||||
void resetMapViewScale();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
QStandardItemModel *mapListModel;
|
||||
QList<QStandardItem*> *mapGroupsModel;
|
||||
Editor *editor = nullptr;
|
||||
QIcon* mapIcon;
|
||||
void setMap(QString);
|
||||
void redrawMapScene();
|
||||
void loadDataStructures();
|
||||
void populateMapList();
|
||||
QString getExistingDirectory(QString);
|
||||
void openProject(QString dir);
|
||||
QString getDefaultMap();
|
||||
void setRecentMap(QString map_name);
|
||||
QStandardItem* createMapItem(QString mapName, int groupNum, int inGroupNum);
|
||||
|
||||
void markAllEdited(QAbstractItemModel *model);
|
||||
void markEdited(QModelIndex index);
|
||||
void updateMapList();
|
||||
|
||||
void displayMapProperties();
|
||||
void checkToolButtons();
|
||||
|
||||
void initExtraShortcuts();
|
||||
void initExtraSignals();
|
||||
void initEditor();
|
||||
void loadUserSettings();
|
||||
void openRecentProject();
|
||||
};
|
||||
|
||||
enum MapListUserRoles {
|
||||
GroupRole = Qt::UserRole + 1, // Used to hold the map group number.
|
||||
TypeRole = Qt::UserRole + 2, // Used to differentiate between the different layers of the map list tree view.
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
152
include/project.h
Normal file
152
include/project.h
Normal file
@@ -0,0 +1,152 @@
|
||||
#ifndef PROJECT_H
|
||||
#define PROJECT_H
|
||||
|
||||
#include "map.h"
|
||||
#include "blockdata.h"
|
||||
#include "heallocation.h"
|
||||
|
||||
#include <QStringList>
|
||||
#include <QList>
|
||||
#include <QStandardItem>
|
||||
|
||||
static QString NONE_MAP_CONSTANT = "MAP_NONE";
|
||||
static QString NONE_MAP_NAME = "None";
|
||||
|
||||
class Project
|
||||
{
|
||||
public:
|
||||
Project();
|
||||
QString root;
|
||||
QStringList *groupNames = nullptr;
|
||||
QMap<QString, int> *map_groups;
|
||||
QList<QStringList> groupedMapNames;
|
||||
QStringList *mapNames = nullptr;
|
||||
QList<HealLocation> flyableMaps;
|
||||
QMap<QString, QString>* mapConstantsToMapNames;
|
||||
QMap<QString, QString>* mapNamesToMapConstants;
|
||||
QList<QString> mapLayoutsTable;
|
||||
QList<QString> mapLayoutsTableMaster;
|
||||
QMap<QString, MapLayout*> mapLayouts;
|
||||
QMap<QString, MapLayout*> mapLayoutsMaster;
|
||||
QStringList *regionMapSections = nullptr;
|
||||
QStringList *itemNames = nullptr;
|
||||
QStringList *flagNames = nullptr;
|
||||
QStringList *varNames = nullptr;
|
||||
QStringList *movementTypes = nullptr;
|
||||
QStringList *mapTypes = nullptr;
|
||||
QStringList *mapBattleScenes = nullptr;
|
||||
QStringList *weatherNames = nullptr;
|
||||
QStringList *coordEventWeatherNames = nullptr;
|
||||
QStringList *secretBaseIds = nullptr;
|
||||
QStringList *bgEventFacingDirections = nullptr;
|
||||
QStringList mapsWithConnections;
|
||||
|
||||
QMap<QString, Map*> *map_cache;
|
||||
Map* loadMap(QString);
|
||||
Map* getMap(QString);
|
||||
|
||||
QMap<QString, Tileset*> *tileset_cache = nullptr;
|
||||
Tileset* loadTileset(QString);
|
||||
Tileset* getTileset(QString);
|
||||
|
||||
Blockdata* readBlockdata(QString);
|
||||
void loadBlockdata(Map*);
|
||||
|
||||
QString readTextFile(QString path);
|
||||
void saveTextFile(QString path, QString text);
|
||||
void appendTextFile(QString path, QString text);
|
||||
void deleteFile(QString path);
|
||||
|
||||
void readMapGroups();
|
||||
Map* addNewMapToGroup(QString mapName, int groupNum);
|
||||
QString getNewMapName();
|
||||
QString getProjectTitle();
|
||||
|
||||
QList<QStringList>* getLabelMacros(QList<QStringList>*, QString);
|
||||
QStringList* getLabelValues(QList<QStringList>*, QString);
|
||||
void readMapHeader(Map*);
|
||||
void readMapLayoutsTable();
|
||||
void readAllMapLayouts();
|
||||
QStringList* readLayoutValues(QString layoutName);
|
||||
void readMapLayout(Map*);
|
||||
void readMapsWithConnections();
|
||||
void loadMapTilesets(Map*);
|
||||
void loadTilesetAssets(Tileset*);
|
||||
|
||||
void saveBlockdata(Map*);
|
||||
void saveMapBorder(Map*);
|
||||
void writeBlockdata(QString, Blockdata*);
|
||||
void saveAllMaps();
|
||||
void saveMap(Map*);
|
||||
void saveAllDataStructures();
|
||||
void saveAllMapLayouts();
|
||||
void saveMapGroupsTable();
|
||||
void saveMapConstantsHeader();
|
||||
void saveHealLocationStruct(Map*);
|
||||
|
||||
QList<QStringList>* parseAsm(QString text);
|
||||
QStringList getSongNames();
|
||||
QStringList getVisibilities();
|
||||
QMap<QString, QStringList> getTilesets();
|
||||
void readTilesetProperties();
|
||||
void readRegionMapSections();
|
||||
void readItemNames();
|
||||
void readFlagNames();
|
||||
void readVarNames();
|
||||
void readMovementTypes();
|
||||
void readMapTypes();
|
||||
void readMapBattleScenes();
|
||||
void readWeatherNames();
|
||||
void readCoordEventWeatherNames();
|
||||
void readSecretBaseIds();
|
||||
void readBgEventFacingDirections();
|
||||
|
||||
void loadEventPixmaps(QList<Event*> objects);
|
||||
QMap<QString, int> getEventObjGfxConstants();
|
||||
QString fixGraphicPath(QString path);
|
||||
|
||||
void readMapEvents(Map *map);
|
||||
void loadMapConnections(Map *map);
|
||||
|
||||
void loadMapBorder(Map *map);
|
||||
|
||||
void saveMapEvents(Map *map);
|
||||
|
||||
QStringList readCArray(QString text, QString label);
|
||||
QString readCIncbin(QString text, QString label);
|
||||
QMap<QString, int> readCDefines(QString text, QStringList prefixes);
|
||||
|
||||
static int getNumTilesPrimary();
|
||||
static int getNumTilesTotal();
|
||||
static int getNumMetatilesPrimary();
|
||||
static int getNumMetatilesTotal();
|
||||
static int getNumPalettesPrimary();
|
||||
static int getNumPalettesTotal();
|
||||
private:
|
||||
QString getMapLayoutsTableFilepath();
|
||||
QString getMapLayoutFilepath(QString);
|
||||
void saveMapHeader(Map*);
|
||||
void saveMapConnections(Map*);
|
||||
void updateMapsWithConnections(Map*);
|
||||
void saveMapsWithConnections();
|
||||
void saveMapLayoutsTable();
|
||||
void updateMapLayout(Map*);
|
||||
void readCDefinesSorted(QString, QStringList, QStringList*);
|
||||
void readCDefinesSorted(QString, QStringList, QStringList*, QString, int);
|
||||
|
||||
void setNewMapHeader(Map* map, int mapIndex);
|
||||
void setNewMapLayout(Map* map);
|
||||
void setNewMapBlockdata(Map* map);
|
||||
void setNewMapBorder(Map *map);
|
||||
void setNewMapEvents(Map *map);
|
||||
void setNewMapConnections(Map *map);
|
||||
|
||||
static int num_tiles_primary;
|
||||
static int num_tiles_total;
|
||||
static int num_metatiles_primary;
|
||||
static int num_metatiles_total;
|
||||
static int num_pals_primary;
|
||||
static int num_pals_total;
|
||||
};
|
||||
|
||||
#endif // PROJECT_H
|
||||
15
include/settings.h
Normal file
15
include/settings.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef SETTINGS_H
|
||||
#define SETTINGS_H
|
||||
|
||||
#include <QCursor>
|
||||
|
||||
class Settings
|
||||
{
|
||||
public:
|
||||
Settings();
|
||||
bool smartPathsEnabled;
|
||||
bool betterCursors;
|
||||
QCursor mapCursor;
|
||||
};
|
||||
|
||||
#endif // SETTINGS_H
|
||||
25
include/ui/bordermetatilespixmapitem.h
Normal file
25
include/ui/bordermetatilespixmapitem.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef BORDERMETATILESPIXMAPITEM_H
|
||||
#define BORDERMETATILESPIXMAPITEM_H
|
||||
|
||||
#include "map.h"
|
||||
#include "metatileselector.h"
|
||||
#include <QGraphicsPixmapItem>
|
||||
|
||||
class BorderMetatilesPixmapItem : public QObject, public QGraphicsPixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
BorderMetatilesPixmapItem(Map *map_, MetatileSelector *metatileSelector) {
|
||||
this->map = map_;
|
||||
this->metatileSelector = metatileSelector;
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
MetatileSelector *metatileSelector;
|
||||
Map* map;
|
||||
void draw();
|
||||
signals:
|
||||
void borderMetatilesChanged();
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
||||
};
|
||||
|
||||
#endif // BORDERMETATILESPIXMAPITEM_H
|
||||
37
include/ui/collisionpixmapitem.h
Normal file
37
include/ui/collisionpixmapitem.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef COLLISIONPIXMAPITEM_H
|
||||
#define COLLISIONPIXMAPITEM_H
|
||||
|
||||
#include "metatileselector.h"
|
||||
#include "movementpermissionsselector.h"
|
||||
#include "mappixmapitem.h"
|
||||
#include "map.h"
|
||||
#include "settings.h"
|
||||
|
||||
class CollisionPixmapItem : public MapPixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
CollisionPixmapItem(Map *map, MovementPermissionsSelector *movementPermissionsSelector, MetatileSelector *metatileSelector, Settings *settings)
|
||||
: MapPixmapItem(map, metatileSelector, settings){
|
||||
this->movementPermissionsSelector = movementPermissionsSelector;
|
||||
}
|
||||
MovementPermissionsSelector *movementPermissionsSelector;
|
||||
void updateMovementPermissionSelection(QGraphicsSceneMouseEvent *event);
|
||||
virtual void paint(QGraphicsSceneMouseEvent*);
|
||||
virtual void floodFill(QGraphicsSceneMouseEvent*);
|
||||
virtual void pick(QGraphicsSceneMouseEvent*);
|
||||
virtual void draw(bool ignoreCache = false);
|
||||
|
||||
signals:
|
||||
void mouseEvent(QGraphicsSceneMouseEvent *, CollisionPixmapItem *);
|
||||
void hoveredMapMovementPermissionChanged(int, int);
|
||||
void hoveredMapMovementPermissionCleared();
|
||||
|
||||
protected:
|
||||
void hoverMoveEvent(QGraphicsSceneHoverEvent*);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent*);
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
|
||||
};
|
||||
|
||||
#endif // COLLISIONPIXMAPITEM_H
|
||||
44
include/ui/connectionpixmapitem.h
Normal file
44
include/ui/connectionpixmapitem.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef CONNECTIONPIXMAPITEM_H
|
||||
#define CONNECTIONPIXMAPITEM_H
|
||||
|
||||
#include "mapconnection.h"
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <QPainter>
|
||||
|
||||
class ConnectionPixmapItem : public QObject, public QGraphicsPixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConnectionPixmapItem(QPixmap pixmap, MapConnection* connection, int x, int y, int baseMapWidth, int baseMapHeight): QGraphicsPixmapItem(pixmap) {
|
||||
this->basePixmap = pixmap;
|
||||
this->connection = connection;
|
||||
setFlag(ItemIsMovable);
|
||||
setFlag(ItemSendsGeometryChanges);
|
||||
this->initialX = x;
|
||||
this->initialY = y;
|
||||
this->initialOffset = connection->offset.toInt();
|
||||
this->baseMapWidth = baseMapWidth;
|
||||
this->baseMapHeight = baseMapHeight;
|
||||
}
|
||||
QPixmap basePixmap;
|
||||
MapConnection* connection;
|
||||
int initialX;
|
||||
int initialY;
|
||||
int initialOffset;
|
||||
int baseMapWidth;
|
||||
int baseMapHeight;
|
||||
void render(qreal opacity = 1);
|
||||
int getMinOffset();
|
||||
int getMaxOffset();
|
||||
|
||||
protected:
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*);
|
||||
|
||||
signals:
|
||||
void connectionItemSelected(ConnectionPixmapItem* connectionItem);
|
||||
void connectionItemDoubleClicked(ConnectionPixmapItem* connectionItem);
|
||||
void connectionMoved(MapConnection*);
|
||||
};
|
||||
|
||||
#endif // CONNECTIONPIXMAPITEM_H
|
||||
20
include/ui/currentselectedmetatilespixmapitem.h
Normal file
20
include/ui/currentselectedmetatilespixmapitem.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef CURRENTSELECTEDMETATILESPIXMAPITEM_H
|
||||
#define CURRENTSELECTEDMETATILESPIXMAPITEM_H
|
||||
|
||||
#include "map.h"
|
||||
#include "metatileselector.h"
|
||||
#include <QGraphicsPixmapItem>
|
||||
|
||||
class CurrentSelectedMetatilesPixmapItem : public QObject, public QGraphicsPixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
CurrentSelectedMetatilesPixmapItem(Map *map, MetatileSelector *metatileSelector) {
|
||||
this->map = map;
|
||||
this->metatileSelector = metatileSelector;
|
||||
}
|
||||
Map* map = nullptr;
|
||||
MetatileSelector *metatileSelector;
|
||||
void draw();
|
||||
};
|
||||
|
||||
#endif // CURRENTSELECTEDMETATILESPIXMAPITEM_H
|
||||
22
include/ui/eventpropertiesframe.h
Normal file
22
include/ui/eventpropertiesframe.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef EVENTPROPERTIESFRAME_H
|
||||
#define EVENTPROPERTIESFRAME_H
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
namespace Ui {
|
||||
class EventPropertiesFrame;
|
||||
}
|
||||
|
||||
class EventPropertiesFrame : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EventPropertiesFrame(QWidget *parent = nullptr);
|
||||
~EventPropertiesFrame();
|
||||
|
||||
public:
|
||||
Ui::EventPropertiesFrame *ui;
|
||||
};
|
||||
|
||||
#endif // EVENTPROPERTIESFRAME_H
|
||||
26
include/ui/graphicsview.h
Normal file
26
include/ui/graphicsview.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef GRAPHICSVIEW_H
|
||||
#define GRAPHICSVIEW_H
|
||||
|
||||
#include <QGraphicsView>
|
||||
#include <QMouseEvent>
|
||||
|
||||
class Editor;
|
||||
|
||||
class GraphicsView : public QGraphicsView
|
||||
{
|
||||
public:
|
||||
GraphicsView() : QGraphicsView() {}
|
||||
GraphicsView(QWidget *parent) : QGraphicsView(parent) {}
|
||||
|
||||
public:
|
||||
// GraphicsView_Object object;
|
||||
Editor *editor;
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
};
|
||||
|
||||
//Q_DECLARE_METATYPE(GraphicsView)
|
||||
|
||||
#endif // GRAPHICSVIEW_H
|
||||
14
include/ui/imageproviders.h
Normal file
14
include/ui/imageproviders.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef IMAGEPROVIDERS_H
|
||||
#define IMAGEPROVIDERS_H
|
||||
|
||||
#include "block.h"
|
||||
#include "tileset.h"
|
||||
#include <QImage>
|
||||
#include <QPixmap>
|
||||
|
||||
QImage getCollisionMetatileImage(Block);
|
||||
QImage getCollisionMetatileImage(int, int);
|
||||
QImage getMetatileImage(int, Tileset*, Tileset*);
|
||||
QImage getTileImage(int, Tileset*, Tileset*);
|
||||
|
||||
#endif // IMAGEPROVIDERS_H
|
||||
55
include/ui/mappixmapitem.h
Normal file
55
include/ui/mappixmapitem.h
Normal file
@@ -0,0 +1,55 @@
|
||||
#ifndef MAPPIXMAPITEM_H
|
||||
#define MAPPIXMAPITEM_H
|
||||
|
||||
#include "map.h"
|
||||
#include "settings.h"
|
||||
#include "metatileselector.h"
|
||||
#include <QGraphicsPixmapItem>
|
||||
|
||||
class MapPixmapItem : public QObject, public QGraphicsPixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MapPixmapItem(Map *map_, MetatileSelector *metatileSelector, Settings *settings) {
|
||||
this->map = map_;
|
||||
this->metatileSelector = metatileSelector;
|
||||
this->settings = settings;
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
Map *map;
|
||||
MetatileSelector *metatileSelector;
|
||||
Settings *settings;
|
||||
bool active;
|
||||
bool right_click;
|
||||
int paint_tile_initial_x;
|
||||
int paint_tile_initial_y;
|
||||
QPoint selection_origin;
|
||||
QList<QPoint> selection;
|
||||
virtual void paint(QGraphicsSceneMouseEvent*);
|
||||
virtual void floodFill(QGraphicsSceneMouseEvent*);
|
||||
void _floodFill(int x, int y);
|
||||
void _floodFillSmartPath(int initialX, int initialY);
|
||||
virtual void pick(QGraphicsSceneMouseEvent*);
|
||||
virtual void select(QGraphicsSceneMouseEvent*);
|
||||
virtual void shift(QGraphicsSceneMouseEvent*);
|
||||
virtual void draw(bool ignoreCache = false);
|
||||
void updateMetatileSelection(QGraphicsSceneMouseEvent *event);
|
||||
|
||||
private:
|
||||
void paintNormal(int x, int y);
|
||||
void paintSmartPath(int x, int y);
|
||||
static QList<int> smartPathTable;
|
||||
|
||||
signals:
|
||||
void mouseEvent(QGraphicsSceneMouseEvent *, MapPixmapItem *);
|
||||
void hoveredMapMetatileChanged(int x, int y);
|
||||
void hoveredMapMetatileCleared();
|
||||
|
||||
protected:
|
||||
void hoverMoveEvent(QGraphicsSceneHoverEvent*);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent*);
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
|
||||
};
|
||||
|
||||
#endif // MAPPIXMAPITEM_H
|
||||
19
include/ui/mapsceneeventfilter.h
Normal file
19
include/ui/mapsceneeventfilter.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef MAPSCENEEVENTFILTER_H
|
||||
#define MAPSCENEEVENTFILTER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class MapSceneEventFilter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
public:
|
||||
explicit MapSceneEventFilter(QObject *parent = nullptr);
|
||||
|
||||
signals:
|
||||
void wheelZoom(int delta);
|
||||
public slots:
|
||||
};
|
||||
|
||||
#endif // MAPSCENEEVENTFILTER_H
|
||||
51
include/ui/metatileselector.h
Normal file
51
include/ui/metatileselector.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef METATILESELECTOR_H
|
||||
#define METATILESELECTOR_H
|
||||
|
||||
#include "selectablepixmapitem.h"
|
||||
#include "tileset.h"
|
||||
|
||||
class MetatileSelector: public SelectablePixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MetatileSelector(int numMetatilesWide, Tileset *primaryTileset, Tileset *secondaryTileset): SelectablePixmapItem(16, 16) {
|
||||
this->externalSelection = false;
|
||||
this->numMetatilesWide = numMetatilesWide;
|
||||
this->primaryTileset = primaryTileset;
|
||||
this->secondaryTileset = secondaryTileset;
|
||||
this->selectedMetatiles = new QList<uint16_t>();
|
||||
this->externalSelectedMetatiles = new QList<uint16_t>();
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
QPoint getSelectionDimensions();
|
||||
void draw();
|
||||
void select(uint16_t metatile);
|
||||
void setTilesets(Tileset*, Tileset*);
|
||||
QList<uint16_t>* getSelectedMetatiles();
|
||||
void setExternalSelection(int, int, QList<uint16_t>*);
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
|
||||
void hoverMoveEvent(QGraphicsSceneHoverEvent*);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent*);
|
||||
private:
|
||||
bool externalSelection;
|
||||
int numMetatilesWide;
|
||||
Tileset *primaryTileset;
|
||||
Tileset *secondaryTileset;
|
||||
QList<uint16_t> *selectedMetatiles;
|
||||
int externalSelectionWidth;
|
||||
int externalSelectionHeight;
|
||||
QList<uint16_t> *externalSelectedMetatiles;
|
||||
|
||||
void updateSelectedMetatiles();
|
||||
uint16_t getMetatileId(int x, int y);
|
||||
QPoint getMetatileIdCoords(uint16_t);
|
||||
|
||||
signals:
|
||||
void hoveredMetatileSelectionChanged(uint16_t);
|
||||
void hoveredMetatileSelectionCleared();
|
||||
void selectedMetatilesChanged();
|
||||
};
|
||||
|
||||
#endif // METATILESELECTOR_H
|
||||
29
include/ui/movementpermissionsselector.h
Normal file
29
include/ui/movementpermissionsselector.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef MOVEMENTPERMISSIONSSELECTOR_H
|
||||
#define MOVEMENTPERMISSIONSSELECTOR_H
|
||||
|
||||
#include "selectablepixmapitem.h"
|
||||
|
||||
class MovementPermissionsSelector: public SelectablePixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MovementPermissionsSelector(): SelectablePixmapItem(32, 32, 1, 1) {
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
void draw();
|
||||
uint16_t getSelectedCollision();
|
||||
uint16_t getSelectedElevation();
|
||||
void select(uint16_t collision, uint16_t elevation);
|
||||
|
||||
protected:
|
||||
void hoverMoveEvent(QGraphicsSceneHoverEvent*);
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent*);
|
||||
|
||||
private:
|
||||
void setSelectedMovementPermissions(QPointF);
|
||||
|
||||
signals:
|
||||
void hoveredMovementPermissionChanged(uint16_t, uint16_t);
|
||||
void hoveredMovementPermissionCleared();
|
||||
};
|
||||
|
||||
#endif // MOVEMENTPERMISSIONSSELECTOR_H
|
||||
37
include/ui/neweventtoolbutton.h
Normal file
37
include/ui/neweventtoolbutton.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef NEWEVENTTOOLBUTTON_H
|
||||
#define NEWEVENTTOOLBUTTON_H
|
||||
|
||||
#include "event.h"
|
||||
#include <QToolButton>
|
||||
|
||||
class NewEventToolButton : public QToolButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit NewEventToolButton(QWidget *parent = nullptr);
|
||||
QString getSelectedEventType();
|
||||
public slots:
|
||||
void newObject();
|
||||
void newWarp();
|
||||
void newHealLocation();
|
||||
void newCoordScript();
|
||||
void newCoordWeather();
|
||||
void newSign();
|
||||
void newHiddenItem();
|
||||
void newSecretBase();
|
||||
signals:
|
||||
void newEventAdded(QString);
|
||||
private:
|
||||
QString selectedEventType;
|
||||
QAction *newObjectAction;
|
||||
QAction *newWarpAction;
|
||||
QAction *newHealLocationAction;
|
||||
QAction *newCoordScriptAction;
|
||||
QAction *newCoordWeatherAction;
|
||||
QAction *newSignAction;
|
||||
QAction *newHiddenItemAction;
|
||||
QAction *newSecretBaseAction;
|
||||
void init();
|
||||
};
|
||||
|
||||
#endif // NEWEVENTTOOLBUTTON_H
|
||||
17
include/ui/noscrollcombobox.h
Normal file
17
include/ui/noscrollcombobox.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef NOSCROLLCOMBOBOX_H
|
||||
#define NOSCROLLCOMBOBOX_H
|
||||
|
||||
#include <QComboBox>
|
||||
|
||||
class NoScrollComboBox : public QComboBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NoScrollComboBox(QWidget *parent = nullptr);
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif // NOSCROLLCOMBOBOX_H
|
||||
17
include/ui/noscrollspinbox.h
Normal file
17
include/ui/noscrollspinbox.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef NOSCROLLSPINBOX_H
|
||||
#define NOSCROLLSPINBOX_H
|
||||
|
||||
#include <QSpinBox>
|
||||
|
||||
class NoScrollSpinBox : public QSpinBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NoScrollSpinBox(QWidget *parent = nullptr);
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
#endif // NOSCROLLSPINBOX_H
|
||||
40
include/ui/selectablepixmapitem.h
Normal file
40
include/ui/selectablepixmapitem.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef SELECTABLEPIXMAPITEM_H
|
||||
#define SELECTABLEPIXMAPITEM_H
|
||||
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
|
||||
class SelectablePixmapItem : public QObject, public QGraphicsPixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
SelectablePixmapItem(int cellWidth, int cellHeight): SelectablePixmapItem(cellWidth, cellHeight, INT_MAX, INT_MAX) {}
|
||||
SelectablePixmapItem(int cellWidth, int cellHeight, int maxSelectionWidth, int maxSelectionHeight) {
|
||||
this->cellWidth = cellWidth;
|
||||
this->cellHeight = cellHeight;
|
||||
this->maxSelectionWidth = maxSelectionWidth;
|
||||
this->maxSelectionHeight = maxSelectionHeight;
|
||||
}
|
||||
virtual QPoint getSelectionDimensions();
|
||||
virtual void draw() = 0;
|
||||
|
||||
protected:
|
||||
int cellWidth;
|
||||
int cellHeight;
|
||||
int maxSelectionWidth;
|
||||
int maxSelectionHeight;
|
||||
int selectionInitialX;
|
||||
int selectionInitialY;
|
||||
int selectionOffsetX;
|
||||
int selectionOffsetY;
|
||||
|
||||
QPoint getSelectionStart();
|
||||
void select(int, int, int, int);
|
||||
void updateSelection(int, int);
|
||||
QPoint getCellPos(QPointF);
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent*);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
|
||||
virtual void drawSelection();
|
||||
};
|
||||
|
||||
#endif // SELECTABLEPIXMAPITEM_H
|
||||
Reference in New Issue
Block a user