mirror of
https://github.com/huderlem/porymap.git
synced 2026-09-30 20:06:56 -05:00
@@ -22,12 +22,6 @@ static const QVersionNumber porymapVersion = QVersionNumber::fromString(PORYMAP_
|
||||
|
||||
#define CONFIG_BACKWARDS_COMPATABILITY
|
||||
|
||||
enum MapSortOrder {
|
||||
Group = 0,
|
||||
Area = 1,
|
||||
Layout = 2,
|
||||
};
|
||||
|
||||
class KeyValueConfigBase
|
||||
{
|
||||
public:
|
||||
@@ -56,7 +50,7 @@ public:
|
||||
this->recentProjects.clear();
|
||||
this->projectManuallyClosed = false;
|
||||
this->reopenOnLaunch = true;
|
||||
this->mapSortOrder = MapSortOrder::Group;
|
||||
this->mapListTab = 0;
|
||||
this->prettyCursors = true;
|
||||
this->mirrorConnectingMaps = true;
|
||||
this->showDiveEmergeMaps = false;
|
||||
@@ -107,7 +101,7 @@ public:
|
||||
|
||||
bool reopenOnLaunch;
|
||||
bool projectManuallyClosed;
|
||||
MapSortOrder mapSortOrder;
|
||||
int mapListTab;
|
||||
bool prettyCursors;
|
||||
bool mirrorConnectingMaps;
|
||||
bool showDiveEmergeMaps;
|
||||
@@ -219,7 +213,6 @@ enum ProjectIdentifier {
|
||||
define_map_empty,
|
||||
define_map_section_prefix,
|
||||
define_map_section_empty,
|
||||
define_map_section_count,
|
||||
define_species_prefix,
|
||||
regex_behaviors,
|
||||
regex_obj_event_gfx,
|
||||
@@ -275,7 +268,6 @@ enum ProjectFilePath {
|
||||
constants_obj_event_movement,
|
||||
constants_obj_events,
|
||||
constants_event_bg,
|
||||
constants_region_map_sections,
|
||||
constants_metatile_labels,
|
||||
constants_metatile_behaviors,
|
||||
constants_species,
|
||||
@@ -406,7 +398,7 @@ public:
|
||||
reset();
|
||||
}
|
||||
virtual void reset() override {
|
||||
this->recentMap = QString();
|
||||
this->recentMapOrLayout = QString();
|
||||
this->useEncounterJson = true;
|
||||
this->customScripts.clear();
|
||||
this->readKeys.clear();
|
||||
@@ -418,7 +410,7 @@ public:
|
||||
QList<bool> getCustomScriptsEnabled();
|
||||
|
||||
QString projectDir;
|
||||
QString recentMap;
|
||||
QString recentMapOrLayout;
|
||||
bool useEncounterJson;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#include <QList>
|
||||
#include <QPointer>
|
||||
|
||||
class MapPixmapItem;
|
||||
class Map;
|
||||
class Layout;
|
||||
class Blockdata;
|
||||
class Event;
|
||||
class DraggablePixmapItem;
|
||||
@@ -24,9 +24,9 @@ enum CommandId {
|
||||
ID_PaintCollision,
|
||||
ID_BucketFillCollision,
|
||||
ID_MagicFillCollision,
|
||||
ID_ResizeMap,
|
||||
ID_ResizeLayout,
|
||||
ID_PaintBorder,
|
||||
ID_ScriptEditMap,
|
||||
ID_ScriptEditLayout,
|
||||
ID_EventMove,
|
||||
ID_EventShift,
|
||||
ID_EventCreate,
|
||||
@@ -50,7 +50,7 @@ enum CommandId {
|
||||
/// onto the map using the pencil tool.
|
||||
class PaintMetatile : public QUndoCommand {
|
||||
public:
|
||||
PaintMetatile(Map *map,
|
||||
PaintMetatile(Layout *layout,
|
||||
const Blockdata &oldMetatiles, const Blockdata &newMetatiles,
|
||||
unsigned actionId, QUndoCommand *parent = nullptr);
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
int id() const override { return CommandId::ID_PaintMetatile; }
|
||||
|
||||
private:
|
||||
Map *map;
|
||||
Layout *layout;
|
||||
|
||||
Blockdata newMetatiles;
|
||||
Blockdata oldMetatiles;
|
||||
@@ -75,10 +75,10 @@ private:
|
||||
/// on the metatile collision and elevation.
|
||||
class PaintCollision : public PaintMetatile {
|
||||
public:
|
||||
PaintCollision(Map *map,
|
||||
PaintCollision(Layout *layout,
|
||||
const Blockdata &oldCollision, const Blockdata &newCollision,
|
||||
unsigned actionId, QUndoCommand *parent = nullptr)
|
||||
: PaintMetatile(map, oldCollision, newCollision, actionId, parent) {
|
||||
: PaintMetatile(layout, oldCollision, newCollision, actionId, parent) {
|
||||
setText("Paint Collision");
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public:
|
||||
/// Implements a command to commit paint actions on the map border.
|
||||
class PaintBorder : public QUndoCommand {
|
||||
public:
|
||||
PaintBorder(Map *map,
|
||||
PaintBorder(Layout *layout,
|
||||
const Blockdata &oldBorder, const Blockdata &newBorder,
|
||||
unsigned actionId, QUndoCommand *parent = nullptr);
|
||||
|
||||
@@ -101,7 +101,7 @@ public:
|
||||
int id() const override { return CommandId::ID_PaintBorder; }
|
||||
|
||||
private:
|
||||
Map *map;
|
||||
Layout *layout;
|
||||
|
||||
Blockdata newBorder;
|
||||
Blockdata oldBorder;
|
||||
@@ -115,10 +115,10 @@ private:
|
||||
/// with the bucket tool onto the map.
|
||||
class BucketFillMetatile : public PaintMetatile {
|
||||
public:
|
||||
BucketFillMetatile(Map *map,
|
||||
BucketFillMetatile(Layout *layout,
|
||||
const Blockdata &oldMetatiles, const Blockdata &newMetatiles,
|
||||
unsigned actionId, QUndoCommand *parent = nullptr)
|
||||
: PaintMetatile(map, oldMetatiles, newMetatiles, actionId, parent) {
|
||||
: PaintMetatile(layout, oldMetatiles, newMetatiles, actionId, parent) {
|
||||
setText("Bucket Fill Metatiles");
|
||||
}
|
||||
|
||||
@@ -131,10 +131,10 @@ public:
|
||||
/// on the metatile collision and elevation.
|
||||
class BucketFillCollision : public PaintCollision {
|
||||
public:
|
||||
BucketFillCollision(Map *map,
|
||||
BucketFillCollision(Layout *layout,
|
||||
const Blockdata &oldCollision, const Blockdata &newCollision,
|
||||
QUndoCommand *parent = nullptr)
|
||||
: PaintCollision(map, oldCollision, newCollision, -1, parent) {
|
||||
: PaintCollision(layout, oldCollision, newCollision, -1, parent) {
|
||||
setText("Flood Fill Collision");
|
||||
}
|
||||
|
||||
@@ -148,10 +148,10 @@ public:
|
||||
/// with the bucket or paint tool onto the map.
|
||||
class MagicFillMetatile : public PaintMetatile {
|
||||
public:
|
||||
MagicFillMetatile(Map *map,
|
||||
MagicFillMetatile(Layout *layout,
|
||||
const Blockdata &oldMetatiles, const Blockdata &newMetatiles,
|
||||
unsigned actionId, QUndoCommand *parent = nullptr)
|
||||
: PaintMetatile(map, oldMetatiles, newMetatiles, actionId, parent) {
|
||||
: PaintMetatile(layout, oldMetatiles, newMetatiles, actionId, parent) {
|
||||
setText("Magic Fill Metatiles");
|
||||
}
|
||||
|
||||
@@ -163,10 +163,10 @@ public:
|
||||
/// Implements a command to commit magic fill collision actions.
|
||||
class MagicFillCollision : public PaintCollision {
|
||||
public:
|
||||
MagicFillCollision(Map *map,
|
||||
MagicFillCollision(Layout *layout,
|
||||
const Blockdata &oldCollision, const Blockdata &newCollision,
|
||||
QUndoCommand *parent = nullptr)
|
||||
: PaintCollision(map, oldCollision, newCollision, -1, parent) {
|
||||
: PaintCollision(layout, oldCollision, newCollision, -1, parent) {
|
||||
setText("Magic Fill Collision");
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ public:
|
||||
/// Implements a command to commit metatile shift actions.
|
||||
class ShiftMetatiles : public QUndoCommand {
|
||||
public:
|
||||
ShiftMetatiles(Map *map,
|
||||
ShiftMetatiles(Layout *layout,
|
||||
const Blockdata &oldMetatiles, const Blockdata &newMetatiles,
|
||||
unsigned actionId, QUndoCommand *parent = nullptr);
|
||||
|
||||
@@ -190,7 +190,7 @@ public:
|
||||
int id() const override { return CommandId::ID_ShiftMetatiles; }
|
||||
|
||||
private:
|
||||
Map *map;
|
||||
Layout *layout= nullptr;
|
||||
|
||||
Blockdata newMetatiles;
|
||||
Blockdata oldMetatiles;
|
||||
@@ -201,9 +201,9 @@ private:
|
||||
|
||||
|
||||
/// Implements a command to commit a map or border resize action.
|
||||
class ResizeMap : public QUndoCommand {
|
||||
class ResizeLayout : public QUndoCommand {
|
||||
public:
|
||||
ResizeMap(Map *map, QSize oldMapDimensions, QSize newMapDimensions,
|
||||
ResizeLayout(Layout *layout, QSize oldLayoutDimensions, QSize newLayoutDimensions,
|
||||
const Blockdata &oldMetatiles, const Blockdata &newMetatiles,
|
||||
QSize oldBorderDimensions, QSize newBorderDimensions,
|
||||
const Blockdata &oldBorder, const Blockdata &newBorder,
|
||||
@@ -213,15 +213,15 @@ public:
|
||||
void redo() override;
|
||||
|
||||
bool mergeWith(const QUndoCommand *) override { return false; }
|
||||
int id() const override { return CommandId::ID_ResizeMap; }
|
||||
int id() const override { return CommandId::ID_ResizeLayout; }
|
||||
|
||||
private:
|
||||
Map *map;
|
||||
Layout *layout = nullptr;
|
||||
|
||||
int oldMapWidth;
|
||||
int oldMapHeight;
|
||||
int newMapWidth;
|
||||
int newMapHeight;
|
||||
int oldLayoutWidth;
|
||||
int oldLayoutHeight;
|
||||
int newLayoutWidth;
|
||||
int newLayoutHeight;
|
||||
|
||||
int oldBorderWidth;
|
||||
int oldBorderHeight;
|
||||
@@ -351,10 +351,10 @@ public:
|
||||
|
||||
/// 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 {
|
||||
class ScriptEditLayout : public QUndoCommand {
|
||||
public:
|
||||
ScriptEditMap(Map *map,
|
||||
QSize oldMapDimensions, QSize newMapDimensions,
|
||||
ScriptEditLayout(Layout *layout,
|
||||
QSize oldLayoutDimensions, QSize newLayoutDimensions,
|
||||
const Blockdata &oldMetatiles, const Blockdata &newMetatiles,
|
||||
QSize oldBorderDimensions, QSize newBorderDimensions,
|
||||
const Blockdata &oldBorder, const Blockdata &newBorder,
|
||||
@@ -364,10 +364,10 @@ public:
|
||||
void redo() override;
|
||||
|
||||
bool mergeWith(const QUndoCommand *) override { return false; }
|
||||
int id() const override { return CommandId::ID_ScriptEditMap; }
|
||||
int id() const override { return CommandId::ID_ScriptEditLayout; }
|
||||
|
||||
private:
|
||||
Map *map;
|
||||
Layout *layout = nullptr;
|
||||
|
||||
Blockdata newMetatiles;
|
||||
Blockdata oldMetatiles;
|
||||
@@ -375,10 +375,10 @@ private:
|
||||
Blockdata newBorder;
|
||||
Blockdata oldBorder;
|
||||
|
||||
int oldMapWidth;
|
||||
int oldMapHeight;
|
||||
int newMapWidth;
|
||||
int newMapHeight;
|
||||
int oldLayoutWidth;
|
||||
int oldLayoutHeight;
|
||||
int newLayoutWidth;
|
||||
int newLayoutHeight;
|
||||
|
||||
int oldBorderWidth;
|
||||
int oldBorderHeight;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
// porymap will reflect changes to it, but the value is hard-coded in the projects at the moment
|
||||
#define BORDER_DISTANCE 7
|
||||
|
||||
class MapPixmapItem;
|
||||
class LayoutPixmapItem;
|
||||
class CollisionPixmapItem;
|
||||
class BorderMetatilesPixmapItem;
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
public:
|
||||
QString name;
|
||||
QString constantName;
|
||||
|
||||
QString song;
|
||||
QString layoutId;
|
||||
QString location;
|
||||
@@ -51,20 +52,22 @@ public:
|
||||
bool allowEscaping;
|
||||
int floorNumber = 0;
|
||||
QString battle_scene;
|
||||
|
||||
QString sharedEventsMap = "";
|
||||
QString sharedScriptsMap = "";
|
||||
|
||||
QStringList scriptsFileLabels;
|
||||
QMap<QString, QJsonValue> customHeaders;
|
||||
MapLayout *layout;
|
||||
|
||||
Layout *layout = nullptr;
|
||||
void setLayout(Layout *layout);
|
||||
|
||||
bool isPersistedToFile = true;
|
||||
bool hasUnsavedDataChanges = false;
|
||||
|
||||
bool needsLayoutDir = true;
|
||||
bool needsHealLocation = false;
|
||||
bool scriptsLoaded = false;
|
||||
QImage collision_image;
|
||||
QPixmap collision_pixmap;
|
||||
QImage image;
|
||||
QPixmap pixmap;
|
||||
|
||||
QMap<Event::Group, QList<Event *>> events;
|
||||
QList<Event *> ownedEvents; // for memory management
|
||||
@@ -74,64 +77,34 @@ public:
|
||||
|
||||
void setName(QString mapName);
|
||||
static QString mapConstantFromName(QString mapName, bool includePrefix = true);
|
||||
|
||||
int getWidth();
|
||||
int getHeight();
|
||||
int getBorderWidth();
|
||||
int getBorderHeight();
|
||||
QPixmap render(bool ignoreCache = false, MapLayout *fromLayout = nullptr, QRect bounds = QRect(0, 0, -1, -1));
|
||||
QPixmap renderCollision(bool ignoreCache);
|
||||
bool mapBlockChanged(int i, const Blockdata &cache);
|
||||
bool borderBlockChanged(int i, const Blockdata &cache);
|
||||
void cacheBlockdata();
|
||||
void cacheCollision();
|
||||
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 getScriptLabels(Event::Group group = Event::Group::None);
|
||||
QString getScriptsFilePath() const;
|
||||
void openScript(QString label);
|
||||
void removeEvent(Event *);
|
||||
void addEvent(Event *);
|
||||
|
||||
void deleteConnections();
|
||||
QList<MapConnection*> getConnections() const;
|
||||
void removeConnection(MapConnection *);
|
||||
void addConnection(MapConnection *);
|
||||
void loadConnection(MapConnection *);
|
||||
QRect getConnectionRect(const QString &direction, MapLayout *fromLayout = nullptr);
|
||||
QPixmap renderConnection(const QString &direction, MapLayout *fromLayout = nullptr);
|
||||
QPixmap renderBorder(bool ignoreCache = false);
|
||||
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);
|
||||
QString getScriptsFilePath() const;
|
||||
|
||||
MapPixmapItem *mapItem = nullptr;
|
||||
void setMapItem(MapPixmapItem *item) { mapItem = item; }
|
||||
|
||||
CollisionPixmapItem *collisionItem = nullptr;
|
||||
void setCollisionItem(CollisionPixmapItem *item) { collisionItem = item; }
|
||||
|
||||
BorderMetatilesPixmapItem *borderItem = nullptr;
|
||||
void setBorderItem(BorderMetatilesPixmapItem *item) { borderItem = item; }
|
||||
QRect getConnectionRect(const QString &direction, Layout *fromLayout = nullptr);
|
||||
QPixmap renderConnection(const QString &direction, Layout *fromLayout = nullptr);
|
||||
|
||||
QUndoStack editHistory;
|
||||
void modify();
|
||||
void clean();
|
||||
bool hasUnsavedChanges() const;
|
||||
void pruneEditHistory();
|
||||
|
||||
private:
|
||||
void setNewDimensionsBlockdata(int newWidth, int newHeight);
|
||||
void setNewBorderDimensionsBlockdata(int newWidth, int newHeight);
|
||||
void trackConnection(MapConnection*);
|
||||
|
||||
// MapConnections in 'ownedConnections' but not 'connections' persist in the edit history.
|
||||
@@ -141,7 +114,6 @@ private:
|
||||
signals:
|
||||
void modified();
|
||||
void mapDimensionsChanged(const QSize &size);
|
||||
void mapNeedsRedrawing();
|
||||
void openScriptRequested(QString label);
|
||||
void connectionAdded(MapConnection*);
|
||||
void connectionRemoved(MapConnection*);
|
||||
|
||||
@@ -7,41 +7,135 @@
|
||||
#include <QImage>
|
||||
#include <QPixmap>
|
||||
#include <QString>
|
||||
#include <QUndoStack>
|
||||
|
||||
class MapLayout {
|
||||
class Map;
|
||||
class LayoutPixmapItem;
|
||||
class CollisionPixmapItem;
|
||||
class BorderMetatilesPixmapItem;
|
||||
|
||||
class Layout : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MapLayout() {}
|
||||
Layout() {}
|
||||
|
||||
static QString layoutConstantFromName(QString mapName);
|
||||
|
||||
bool loaded = false;
|
||||
|
||||
QString id;
|
||||
QString name;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
int border_width;
|
||||
int border_height;
|
||||
|
||||
QString border_path;
|
||||
QString blockdata_path;
|
||||
|
||||
QString tileset_primary_label;
|
||||
QString tileset_secondary_label;
|
||||
|
||||
Tileset *tileset_primary = nullptr;
|
||||
Tileset *tileset_secondary = nullptr;
|
||||
|
||||
Blockdata blockdata;
|
||||
|
||||
QImage image;
|
||||
QPixmap pixmap;
|
||||
QImage border_image;
|
||||
QPixmap border_pixmap;
|
||||
QImage collision_image;
|
||||
QPixmap collision_pixmap;
|
||||
|
||||
Blockdata border;
|
||||
Blockdata cached_blockdata;
|
||||
Blockdata cached_collision;
|
||||
Blockdata cached_border;
|
||||
struct {
|
||||
Blockdata blocks;
|
||||
QSize mapDimensions;
|
||||
QSize layoutDimensions;
|
||||
Blockdata border;
|
||||
QSize borderDimensions;
|
||||
} lastCommitBlocks; // to track map changes
|
||||
|
||||
QList<int> metatileLayerOrder;
|
||||
QList<float> metatileLayerOpacity;
|
||||
|
||||
LayoutPixmapItem *layoutItem = nullptr;
|
||||
CollisionPixmapItem *collisionItem = nullptr;
|
||||
BorderMetatilesPixmapItem *borderItem = nullptr;
|
||||
|
||||
QUndoStack editHistory;
|
||||
|
||||
// to simplify new layout settings transfer between functions
|
||||
struct SimpleSettings {
|
||||
QString id;
|
||||
QString name;
|
||||
int width;
|
||||
int height;
|
||||
QString tileset_primary_label;
|
||||
QString tileset_secondary_label;
|
||||
QString from_id = QString();
|
||||
};
|
||||
|
||||
public:
|
||||
Layout *copy();
|
||||
void copyFrom(Layout *other);
|
||||
|
||||
int getWidth();
|
||||
int getHeight();
|
||||
int getBorderWidth();
|
||||
int getBorderHeight();
|
||||
|
||||
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);
|
||||
void setBlockdata(Blockdata blockdata, bool enableScriptCallback = false);
|
||||
|
||||
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 cacheBlockdata();
|
||||
void cacheCollision();
|
||||
void clearBorderCache();
|
||||
void cacheBorder();
|
||||
|
||||
bool hasUnsavedChanges() const;
|
||||
|
||||
bool layoutBlockChanged(int i, const Blockdata &cache);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
QPixmap getLayoutItemPixmap();
|
||||
|
||||
void setLayoutItem(LayoutPixmapItem *item) { layoutItem = item; }
|
||||
void setCollisionItem(CollisionPixmapItem *item) { collisionItem = item; }
|
||||
void setBorderItem(BorderMetatilesPixmapItem *item) { borderItem = item; }
|
||||
|
||||
private:
|
||||
void setNewDimensionsBlockdata(int newWidth, int newHeight);
|
||||
void setNewBorderDimensionsBlockdata(int newWidth, int newHeight);
|
||||
|
||||
signals:
|
||||
void layoutChanged(Layout *layout);
|
||||
//void modified();
|
||||
void layoutDimensionsChanged(const QSize &size);
|
||||
void needsRedrawing();
|
||||
};
|
||||
|
||||
#endif // MAPLAYOUT_H
|
||||
|
||||
@@ -10,7 +10,7 @@ class MapParser
|
||||
{
|
||||
public:
|
||||
MapParser();
|
||||
MapLayout *parse(QString filepath, bool *error, Project *project);
|
||||
Layout *parse(QString filepath, bool *error, Project *project);
|
||||
};
|
||||
|
||||
#endif // MAPPARSER_H
|
||||
|
||||
@@ -57,8 +57,8 @@ public:
|
||||
bool loadLayout(poryjson::Json);
|
||||
bool loadEntries();
|
||||
|
||||
void setEntries(tsl::ordered_map<QString, MapSectionEntry> *entries) { this->region_map_entries = entries; }
|
||||
void setEntries(tsl::ordered_map<QString, MapSectionEntry> entries) { *(this->region_map_entries) = entries; }
|
||||
void setEntries(QMap<QString, MapSectionEntry> *entries) { this->region_map_entries = entries; }
|
||||
void setEntries(const QMap<QString, MapSectionEntry> &entries) { *(this->region_map_entries) = entries; }
|
||||
void clearEntries() { this->region_map_entries->clear(); }
|
||||
MapSectionEntry getEntry(QString section);
|
||||
void setEntry(QString section, MapSectionEntry entry);
|
||||
@@ -114,8 +114,6 @@ public:
|
||||
void setLayer(QString layer) { this->current_layer = layer; }
|
||||
QString getLayer() { return this->current_layer; }
|
||||
|
||||
QString fixCase(QString);
|
||||
|
||||
int padLeft() { return this->offset_left; }
|
||||
int padTop() { return this->offset_top; }
|
||||
int padRight() { return this->tilemap_width - this->layout_width - this->offset_left; }
|
||||
@@ -149,14 +147,12 @@ public:
|
||||
|
||||
const QString section_prefix;
|
||||
const QString default_map_section;
|
||||
const QString count_map_section;
|
||||
|
||||
signals:
|
||||
void mapNeedsDisplaying();
|
||||
|
||||
private:
|
||||
// TODO: defaults needed?
|
||||
tsl::ordered_map<QString, MapSectionEntry> *region_map_entries = nullptr;
|
||||
QMap<QString, MapSectionEntry> *region_map_entries = nullptr;
|
||||
|
||||
QString alias = "";
|
||||
|
||||
|
||||
@@ -64,9 +64,9 @@ private:
|
||||
|
||||
|
||||
/// Edit Layout Dimensions
|
||||
class ResizeLayout : public QUndoCommand {
|
||||
class ResizeRMLayout : public QUndoCommand {
|
||||
public:
|
||||
ResizeLayout(RegionMap *map, int oldWidth, int oldHeight, int newWidth, int newHeight,
|
||||
ResizeRMLayout(RegionMap *map, int oldWidth, int oldHeight, int newWidth, int newHeight,
|
||||
QMap<QString, QList<LayoutSquare>> oldLayouts, QMap<QString, QList<LayoutSquare>> newLayouts, QUndoCommand *parent = nullptr);
|
||||
|
||||
void undo() override;
|
||||
@@ -153,7 +153,7 @@ private:
|
||||
/// ClearEntries
|
||||
class ClearEntries : public QUndoCommand {
|
||||
public:
|
||||
ClearEntries(RegionMap *map, tsl::ordered_map<QString, MapSectionEntry>, QUndoCommand *parent = nullptr);
|
||||
ClearEntries(RegionMap *map, QMap<QString, MapSectionEntry>, QUndoCommand *parent = nullptr);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
@@ -163,7 +163,7 @@ public:
|
||||
|
||||
private:
|
||||
RegionMap *map;
|
||||
tsl::ordered_map<QString, MapSectionEntry> entries;
|
||||
QMap<QString, MapSectionEntry> entries;
|
||||
};
|
||||
|
||||
#endif // REGIONMAPEDITCOMMANDS_H
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
struct WildPokemon {
|
||||
int minLevel = 5;
|
||||
int maxLevel = 5;
|
||||
QString species = "SPECIES_NONE";
|
||||
QString species = "SPECIES_NONE"; // TODO: Use define_species_prefix
|
||||
};
|
||||
|
||||
struct WildMonInfo {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <QCheckBox>
|
||||
#include <QCursor>
|
||||
#include <QUndoGroup>
|
||||
#include <QPointer>
|
||||
|
||||
#include "mapconnection.h"
|
||||
#include "metatileselector.h"
|
||||
@@ -21,7 +22,7 @@
|
||||
#include "divingmappixmapitem.h"
|
||||
#include "currentselectedmetatilespixmapitem.h"
|
||||
#include "collisionpixmapitem.h"
|
||||
#include "mappixmapitem.h"
|
||||
#include "layoutpixmapitem.h"
|
||||
#include "settings.h"
|
||||
#include "gridsettings.h"
|
||||
#include "movablerect.h"
|
||||
@@ -46,18 +47,33 @@ public:
|
||||
public:
|
||||
Ui::MainWindow* ui;
|
||||
QObject *parent = nullptr;
|
||||
|
||||
QPointer<Project> project = nullptr;
|
||||
Map *map = nullptr;
|
||||
QPointer<Map> map = nullptr;
|
||||
QPointer<Layout> layout = nullptr;
|
||||
|
||||
QUndoGroup editGroup; // Manages the undo history for each map
|
||||
|
||||
Settings *settings;
|
||||
GridSettings gridSettings;
|
||||
|
||||
void setProject(Project * project);
|
||||
void saveProject();
|
||||
void save();
|
||||
void closeProject();
|
||||
bool setMap(QString map_name);
|
||||
void saveProject();
|
||||
void saveUiFields();
|
||||
void saveEncounterTabData();
|
||||
|
||||
void closeProject();
|
||||
|
||||
bool setMap(QString map_name);
|
||||
bool setLayout(QString layoutName);
|
||||
void unsetMap();
|
||||
|
||||
Tileset *getCurrentMapPrimaryTileset();
|
||||
|
||||
bool displayMap();
|
||||
bool displayLayout();
|
||||
|
||||
void displayMetatileSelector();
|
||||
void displayMapMetatiles();
|
||||
void displayMapMovementPermissions();
|
||||
@@ -75,56 +91,54 @@ public:
|
||||
void updateMapBorder();
|
||||
void updateMapConnections();
|
||||
|
||||
void setEditingMap();
|
||||
void setEditingCollision();
|
||||
void setEditingObjects();
|
||||
void setEditingConnections();
|
||||
void setMapEditingButtonsEnabled(bool enabled);
|
||||
void setConnectionsVisibility(bool visible);
|
||||
void updateDivingMapsVisibility();
|
||||
void renderDivingConnections();
|
||||
void addConnection(MapConnection* connection);
|
||||
void removeConnection(MapConnection* connection);
|
||||
void removeSelectedConnection();
|
||||
void addNewWildMonGroup(QWidget *window);
|
||||
void deleteWildMonGroup();
|
||||
void configureEncounterJSON(QWidget *);
|
||||
EncounterTableModel* getCurrentWildMonTable();
|
||||
void updateDiveMap(QString mapName);
|
||||
void updateEmergeMap(QString mapName);
|
||||
void setSelectedConnection(MapConnection *connection);
|
||||
|
||||
void updatePrimaryTileset(QString tilesetLabel, bool forceLoad = false);
|
||||
void updateSecondaryTileset(QString tilesetLabel, bool forceLoad = false);
|
||||
void toggleBorderVisibility(bool visible, bool enableScriptCallback = true);
|
||||
void updateCustomMapHeaderValues(QTableWidget *);
|
||||
void configureEncounterJSON(QWidget *);
|
||||
Tileset *getCurrentMapPrimaryTileset();
|
||||
|
||||
DraggablePixmapItem *addMapEvent(Event *event);
|
||||
bool eventLimitReached(Map *, Event::Type);
|
||||
void selectMapEvent(DraggablePixmapItem *object, bool toggle = false);
|
||||
DraggablePixmapItem *addNewEvent(Event::Type type);
|
||||
void updateSelectedEvents();
|
||||
void duplicateSelectedEvents();
|
||||
void redrawObject(DraggablePixmapItem *item);
|
||||
QList<DraggablePixmapItem *> getObjects();
|
||||
|
||||
void updateCursorRectPos(int x, int y);
|
||||
void setCursorRectVisible(bool visible);
|
||||
|
||||
void updateWarpEventWarning(Event *event);
|
||||
void updateWarpEventWarnings();
|
||||
bool eventLimitReached(Map *, Event::Type);
|
||||
|
||||
QPointer<QGraphicsScene> scene = nullptr;
|
||||
QGraphicsPixmapItem *current_view = nullptr;
|
||||
QPointer<MapPixmapItem> map_item = nullptr;
|
||||
QPointer<LayoutPixmapItem> map_item = nullptr;
|
||||
QList<QPointer<ConnectionPixmapItem>> connection_items;
|
||||
QMap<QString, QPointer<DivingMapPixmapItem>> diving_map_items;
|
||||
QGraphicsPathItem *connection_mask = nullptr;
|
||||
QPointer<CollisionPixmapItem> collision_item = nullptr;
|
||||
QGraphicsItemGroup *events_group = nullptr;
|
||||
|
||||
QList<QGraphicsPixmapItem*> borderItems;
|
||||
QGraphicsItemGroup *mapGrid = nullptr;
|
||||
MapRuler *map_ruler = nullptr;
|
||||
|
||||
MovableRect *playerViewRect = nullptr;
|
||||
CursorTileRect *cursorMapTileRect = nullptr;
|
||||
MapRuler *map_ruler = nullptr;
|
||||
|
||||
QPointer<QGraphicsScene> scene_metatiles = nullptr;
|
||||
QPointer<QGraphicsScene> scene_current_metatile_selection = nullptr;
|
||||
@@ -140,8 +154,27 @@ public:
|
||||
QPointer<ConnectionPixmapItem> selected_connection_item = nullptr;
|
||||
QPointer<MapConnection> connection_to_select = nullptr;
|
||||
|
||||
QString map_edit_mode = "paint";
|
||||
QString obj_edit_mode = "select";
|
||||
enum class EditAction { None, Paint, Select, Fill, Shift, Pick, Move };
|
||||
EditAction mapEditAction = EditAction::Paint;
|
||||
EditAction objectEditAction = EditAction::Select;
|
||||
|
||||
enum class EditMode { None, Disabled, Metatiles, Collision, Header, Events, Connections, Encounters };
|
||||
EditMode editMode = EditMode::None;
|
||||
void setEditMode(EditMode mode) { this->editMode = mode; }
|
||||
EditMode getEditMode() { return this->editMode; }
|
||||
|
||||
bool getEditingLayout();
|
||||
|
||||
void setEditorView();
|
||||
|
||||
void setEditingMetatiles();
|
||||
void setEditingCollision();
|
||||
void setEditingHeader();
|
||||
void setEditingObjects();
|
||||
void setEditingConnections();
|
||||
void setEditingEncounters();
|
||||
|
||||
void setMapEditingButtonsEnabled(bool enabled);
|
||||
|
||||
int scaleIndex = 2;
|
||||
qreal collisionOpacity = 0.5;
|
||||
@@ -151,10 +184,9 @@ public:
|
||||
|
||||
int getBorderDrawDistance(int dimension);
|
||||
|
||||
QUndoGroup editGroup; // Manages the undo history for each map
|
||||
|
||||
bool selectingEvent = false;
|
||||
|
||||
void deleteSelectedEvents();
|
||||
void shouldReselectEvents();
|
||||
void scaleMapView(int);
|
||||
static void openInTextEditor(const QString &path, int lineNum = 0);
|
||||
@@ -206,11 +238,11 @@ private:
|
||||
qint64 *pid = nullptr);
|
||||
|
||||
private slots:
|
||||
void onMapStartPaint(QGraphicsSceneMouseEvent *event, MapPixmapItem *item);
|
||||
void onMapEndPaint(QGraphicsSceneMouseEvent *event, MapPixmapItem *item);
|
||||
void onMapStartPaint(QGraphicsSceneMouseEvent *event, LayoutPixmapItem *item);
|
||||
void onMapEndPaint(QGraphicsSceneMouseEvent *event, LayoutPixmapItem *item);
|
||||
void setSmartPathCursorMode(QGraphicsSceneMouseEvent *event);
|
||||
void setStraightPathCursorMode(QGraphicsSceneMouseEvent *event);
|
||||
void mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item);
|
||||
void mouseEvent_map(QGraphicsSceneMouseEvent *event, LayoutPixmapItem *item);
|
||||
void mouseEvent_collision(QGraphicsSceneMouseEvent *event, CollisionPixmapItem *item);
|
||||
void setSelectedConnectionItem(ConnectionPixmapItem *connectionItem);
|
||||
void onHoveredMovementPermissionChanged(uint16_t, uint16_t);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "regionmapeditor.h"
|
||||
#include "mapimageexporter.h"
|
||||
#include "filterchildrenproxymodel.h"
|
||||
#include "maplistmodels.h"
|
||||
#include "newmappopup.h"
|
||||
#include "newtilesetdialog.h"
|
||||
#include "shortcutseditor.h"
|
||||
@@ -172,8 +173,8 @@ private slots:
|
||||
void on_action_Open_Project_triggered();
|
||||
void on_action_Reload_Project_triggered();
|
||||
void on_action_Close_Project_triggered();
|
||||
void on_mapList_activated(const QModelIndex &index);
|
||||
void on_action_Save_Project_triggered();
|
||||
|
||||
void openWarpMap(QString map_name, int event_id, Event::Group event_group);
|
||||
|
||||
void duplicate();
|
||||
@@ -182,16 +183,17 @@ private slots:
|
||||
void copy();
|
||||
void paste();
|
||||
|
||||
void onLayoutChanged(Layout *layout);
|
||||
void onOpenConnectedMap(MapConnection*);
|
||||
void onMapNeedsRedrawing();
|
||||
void onTilesetsSaved(QString, QString);
|
||||
void openNewMapPopupWindow();
|
||||
void onNewMapCreated();
|
||||
void onMapCacheCleared();
|
||||
void onMapLoaded(Map *map);
|
||||
void importMapFromAdvanceMap1_92();
|
||||
void onMapRulerStatusChanged(const QString &);
|
||||
void applyUserShortcuts();
|
||||
void markMapEdited();
|
||||
void markSpecificMapEdited(Map*);
|
||||
|
||||
void on_action_NewMap_triggered();
|
||||
void on_actionNew_Tileset_triggered();
|
||||
@@ -202,6 +204,7 @@ private slots:
|
||||
void on_comboBox_Weather_currentTextChanged(const QString &arg1);
|
||||
void on_comboBox_Type_currentTextChanged(const QString &arg1);
|
||||
void on_comboBox_BattleScene_currentTextChanged(const QString &arg1);
|
||||
void on_comboBox_LayoutSelector_currentTextChanged(const QString &arg1);
|
||||
void on_checkBox_ShowLocation_stateChanged(int selected);
|
||||
void on_checkBox_AllowRunning_stateChanged(int selected);
|
||||
void on_checkBox_AllowBiking_stateChanged(int selected);
|
||||
@@ -221,9 +224,6 @@ private slots:
|
||||
void on_actionMove_triggered();
|
||||
void on_actionMap_Shift_triggered();
|
||||
|
||||
void onDeleteKeyPressed();
|
||||
void on_toolButton_deleteObject_clicked();
|
||||
|
||||
void addNewEvent(Event::Type type);
|
||||
void tryAddEventTab(QWidget * tab);
|
||||
void displayEventTabs();
|
||||
@@ -238,9 +238,6 @@ private slots:
|
||||
void on_toolButton_Shift_clicked();
|
||||
|
||||
void onOpenMapListContextMenu(const QPoint &point);
|
||||
void onAddNewMapToGroupClick(QAction* triggeredAction);
|
||||
void onAddNewMapToAreaClick(QAction* triggeredAction);
|
||||
void onAddNewMapToLayoutClick(QAction* triggeredAction);
|
||||
void currentMetatilesSelectionChanged();
|
||||
|
||||
void on_action_Export_Map_Image_triggered();
|
||||
@@ -264,10 +261,6 @@ private slots:
|
||||
|
||||
void on_actionTileset_Editor_triggered();
|
||||
|
||||
void mapSortOrder_changed(QAction *action);
|
||||
|
||||
void on_lineEdit_filterBox_textChanged(const QString &arg1);
|
||||
|
||||
void moveEvent(QMoveEvent *event);
|
||||
void closeEvent(QCloseEvent *);
|
||||
|
||||
@@ -280,8 +273,11 @@ private slots:
|
||||
void on_slider_DiveMapOpacity_valueChanged(int value);
|
||||
void on_slider_EmergeMapOpacity_valueChanged(int value);
|
||||
void on_horizontalSlider_CollisionTransparency_valueChanged(int value);
|
||||
void on_toolButton_ExpandAll_clicked();
|
||||
void on_toolButton_CollapseAll_clicked();
|
||||
|
||||
void mapListShortcut_ToggleEmptyFolders();
|
||||
void mapListShortcut_ExpandAll();
|
||||
void mapListShortcut_CollapseAll();
|
||||
|
||||
void on_actionAbout_Porymap_triggered();
|
||||
void on_actionOpen_Log_File_triggered();
|
||||
void on_actionOpen_Config_Folder_triggered();
|
||||
@@ -322,15 +318,18 @@ private:
|
||||
QPointer<ProjectSettingsEditor> projectSettingsEditor = nullptr;
|
||||
QPointer<GridSettingsDialog> gridSettingsDialog = nullptr;
|
||||
QPointer<CustomScriptsEditor> customScriptsEditor = nullptr;
|
||||
|
||||
QPointer<FilterChildrenProxyModel> groupListProxyModel = nullptr;
|
||||
QPointer<MapGroupModel> mapGroupModel = nullptr;
|
||||
QPointer<FilterChildrenProxyModel> areaListProxyModel = nullptr;
|
||||
QPointer<MapAreaModel> mapAreaModel = nullptr;
|
||||
QPointer<FilterChildrenProxyModel> layoutListProxyModel = nullptr;
|
||||
QPointer<LayoutTreeModel> layoutTreeModel = nullptr;
|
||||
|
||||
QPointer<UpdatePromoter> updatePromoter = nullptr;
|
||||
QPointer<NetworkAccessManager> networkAccessManager = nullptr;
|
||||
QPointer<AboutPorymap> aboutWindow = nullptr;
|
||||
QPointer<WildMonChart> wildMonChart = nullptr;
|
||||
FilterChildrenProxyModel *mapListProxyModel;
|
||||
QStandardItemModel *mapListModel;
|
||||
QList<QStandardItem*> *mapGroupItemsList;
|
||||
QMap<QString, QModelIndex> mapListIndexes;
|
||||
QIcon mapIcon;
|
||||
|
||||
QAction *undoAction = nullptr;
|
||||
QAction *redoAction = nullptr;
|
||||
@@ -342,48 +341,61 @@ private:
|
||||
|
||||
bool isProgrammaticEventTabChange;
|
||||
bool newMapDefaultsSet = false;
|
||||
|
||||
bool tilesetNeedsRedraw = false;
|
||||
|
||||
bool userSetMap(QString, bool scrollTreeView = false);
|
||||
bool setMap(QString, bool scrollTreeView = false);
|
||||
bool setLayout(QString layoutId);
|
||||
bool setMap(QString);
|
||||
void unsetMap();
|
||||
bool userSetLayout(QString layoutId);
|
||||
bool userSetMap(QString);
|
||||
void redrawMapScene();
|
||||
void refreshMapScene();
|
||||
void setLayoutOnlyMode(bool layoutOnly);
|
||||
|
||||
bool checkProjectSanity();
|
||||
bool loadProjectData();
|
||||
bool setProjectUI();
|
||||
void clearProjectUI();
|
||||
void sortMapList();
|
||||
|
||||
void openSubWindow(QWidget * window);
|
||||
void scrollMapList(MapTree *list, QString itemName);
|
||||
void scrollMapListToCurrentMap(MapTree *list);
|
||||
void scrollMapListToCurrentLayout(MapTree *list);
|
||||
void resetMapListFilters();
|
||||
void showFileWatcherWarning(QString filepath);
|
||||
QString getExistingDirectory(QString);
|
||||
bool openProject(QString dir, bool initial = false);
|
||||
bool closeProject();
|
||||
void showProjectOpenFailure();
|
||||
void saveGlobalConfigs();
|
||||
|
||||
bool setInitialMap();
|
||||
QStandardItem* createMapItem(QString mapName, int groupNum, int inGroupNum);
|
||||
void saveGlobalConfigs();
|
||||
|
||||
void refreshRecentProjectsMenu();
|
||||
|
||||
void updateMapListIcon(const QString &mapName);
|
||||
void updateMapList();
|
||||
void mapListAddGroup();
|
||||
void mapListAddLayout();
|
||||
void mapListAddArea();
|
||||
void openMapListItem(const QModelIndex &index);
|
||||
void saveMapListTab(int index);
|
||||
|
||||
void displayMapProperties();
|
||||
void checkToolButtons();
|
||||
void clickToolButtonFromEditMode(QString editMode);
|
||||
void clickToolButtonFromEditAction(Editor::EditAction editAction);
|
||||
|
||||
void markMapEdited();
|
||||
void markMapEdited(Map*);
|
||||
void showWindowTitle();
|
||||
void updateWindowTitle();
|
||||
|
||||
void initWindow();
|
||||
void initCustomUI();
|
||||
void initExtraSignals();
|
||||
void initEditor();
|
||||
void initMiscHeapObjects();
|
||||
void initMapSortOrder();
|
||||
void initMapList();
|
||||
void initShortcuts();
|
||||
void initExtraShortcuts();
|
||||
void loadUserSettings();
|
||||
void applyMapListFilter(QString filterText);
|
||||
void restoreWindowState();
|
||||
void setTheme(QString);
|
||||
void updateTilesetEditor();
|
||||
@@ -403,6 +415,9 @@ private:
|
||||
double getMetatilesZoomScale();
|
||||
void redrawMetatileSelection();
|
||||
void scrollMetatileSelectorToSelection();
|
||||
MapListToolBar* getCurrentMapListToolBar();
|
||||
MapTree* getCurrentMapList();
|
||||
void refreshLocationsComboBox();
|
||||
|
||||
QObjectList shortcutableObjects() const;
|
||||
void addCustomHeaderValue(QString key, QJsonValue value, bool isNew = false);
|
||||
@@ -412,12 +427,6 @@ private:
|
||||
void setDivingMapsVisible(bool visible);
|
||||
};
|
||||
|
||||
enum MapListUserRoles {
|
||||
GroupRole = Qt::UserRole + 1, // Used to hold the map group number.
|
||||
TypeRole, // Used to differentiate between the different layers of the map list tree view.
|
||||
TypeRole2, // Used for various extra data needed.
|
||||
};
|
||||
|
||||
// These are namespaced in a struct to avoid colliding with e.g. class Map.
|
||||
struct MainTab {
|
||||
enum {
|
||||
@@ -437,4 +446,10 @@ struct MapViewTab {
|
||||
};
|
||||
};
|
||||
|
||||
struct MapListTab {
|
||||
enum {
|
||||
Groups = 0, Areas, Layouts
|
||||
};
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
||||
@@ -25,7 +25,7 @@ class Project : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Project(QWidget *parent = nullptr);
|
||||
Project(QObject *parent = nullptr);
|
||||
~Project();
|
||||
|
||||
Project(const Project &) = delete;
|
||||
@@ -46,11 +46,9 @@ public:
|
||||
QStringList mapLayoutsTable;
|
||||
QStringList mapLayoutsTableMaster;
|
||||
QString layoutsLabel;
|
||||
QMap<QString, MapLayout*> mapLayouts;
|
||||
QMap<QString, MapLayout*> mapLayoutsMaster;
|
||||
QMap<QString, QString> mapSecToMapHoverName;
|
||||
QMap<QString, int> mapSectionNameToValue;
|
||||
QMap<int, QString> mapSectionValueToName;
|
||||
QMap<QString, QString> layoutIdsToNames;
|
||||
QMap<QString, Layout*> mapLayouts;
|
||||
QMap<QString, Layout*> mapLayoutsMaster;
|
||||
QMap<QString, EventGraphics*> eventGraphicsMap;
|
||||
QMap<QString, int> gfxDefines;
|
||||
QString defaultSong;
|
||||
@@ -67,6 +65,8 @@ public:
|
||||
QStringList bgEventFacingDirections;
|
||||
QStringList trainerTypes;
|
||||
QStringList globalScriptLabels;
|
||||
QStringList mapSectionIdNames;
|
||||
QMap<QString, MapSectionEntry> regionMapEntries;
|
||||
QMap<QString, QMap<QString, uint16_t>> metatileLabelsMap;
|
||||
QMap<QString, uint16_t> unusedMetatileLabels;
|
||||
QMap<QString, uint32_t> metatileBehaviorMap;
|
||||
@@ -81,11 +81,10 @@ public:
|
||||
int pokemonMaxLevel;
|
||||
int maxEncounterRate;
|
||||
bool wildEncountersLoaded;
|
||||
bool saveEmptyMapsec;
|
||||
|
||||
void set_root(QString);
|
||||
|
||||
void initSignals();
|
||||
|
||||
void clearMapCache();
|
||||
void clearTilesetCache();
|
||||
void clearMapLayouts();
|
||||
@@ -115,8 +114,8 @@ public:
|
||||
QStringList tilesetLabelsOrdered;
|
||||
|
||||
Blockdata readBlockdata(QString);
|
||||
bool loadBlockdata(MapLayout*);
|
||||
bool loadLayoutBorder(MapLayout*);
|
||||
bool loadBlockdata(Layout *);
|
||||
bool loadLayoutBorder(Layout *);
|
||||
|
||||
void saveTextFile(QString path, QString text);
|
||||
void appendTextFile(QString path, QString text);
|
||||
@@ -140,12 +139,20 @@ public:
|
||||
bool readSpeciesIconPaths();
|
||||
QMap<QString, QString> speciesToIconPath;
|
||||
|
||||
void addNewMapsec(const QString &name);
|
||||
void removeMapsec(const QString &name);
|
||||
|
||||
bool hasUnsavedChanges();
|
||||
bool hasUnsavedDataChanges = false;
|
||||
|
||||
QSet<QString> getTopLevelMapFields();
|
||||
bool loadMapData(Map*);
|
||||
bool readMapLayouts();
|
||||
bool loadLayout(MapLayout *);
|
||||
Layout *loadLayout(QString layoutId);
|
||||
Layout *createNewLayout(Layout::SimpleSettings &layoutSettings);
|
||||
bool loadLayout(Layout *);
|
||||
bool loadMapLayout(Map*);
|
||||
bool loadLayoutTilesets(MapLayout*);
|
||||
bool loadLayoutTilesets(Layout *);
|
||||
void loadTilesetAssets(Tileset*);
|
||||
void loadTilesetTiles(Tileset*, QImage);
|
||||
void loadTilesetMetatiles(Tileset*);
|
||||
@@ -153,15 +160,17 @@ public:
|
||||
void loadTilesetPalettes(Tileset*);
|
||||
void readTilesetPaths(Tileset* tileset);
|
||||
|
||||
void saveLayoutBlockdata(Map*);
|
||||
void saveLayoutBorder(Map*);
|
||||
void saveLayout(Layout *);
|
||||
void saveLayoutBlockdata(Layout *);
|
||||
void saveLayoutBorder(Layout *);
|
||||
void writeBlockdata(QString, const Blockdata &);
|
||||
void saveAllMaps();
|
||||
void saveMap(Map*);
|
||||
void saveMap(Map *);
|
||||
void saveAllDataStructures();
|
||||
void saveConfig();
|
||||
void saveMapLayouts();
|
||||
void saveMapGroups();
|
||||
void saveRegionMapSections();
|
||||
void saveWildMonData();
|
||||
void saveMapConstantsHeader();
|
||||
void saveHealLocations(Map*);
|
||||
@@ -232,12 +241,13 @@ public:
|
||||
static bool mapDimensionsValid(int width, int height);
|
||||
bool calculateDefaultMapSize();
|
||||
static int getMaxObjectEvents();
|
||||
static QString getEmptyMapsecName();
|
||||
|
||||
private:
|
||||
void updateMapLayout(Map*);
|
||||
void updateLayout(Layout *);
|
||||
|
||||
void setNewMapBlockdata(Map* map);
|
||||
void setNewMapBorder(Map *map);
|
||||
void setNewLayoutBlockdata(Layout *layout);
|
||||
void setNewLayoutBorder(Layout *layout);
|
||||
void setNewMapEvents(Map *map);
|
||||
void setNewMapConnections(Map *map);
|
||||
|
||||
@@ -256,9 +266,8 @@ private:
|
||||
static int max_object_events;
|
||||
|
||||
signals:
|
||||
void reloadProject();
|
||||
void uncheckMonitorFilesAction();
|
||||
void mapCacheCleared();
|
||||
void fileChanged(QString filepath);
|
||||
void mapSectionIdNamesChanged();
|
||||
void mapLoaded(Map *map);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
#ifndef BORDERMETATILESPIXMAPITEM_H
|
||||
#define BORDERMETATILESPIXMAPITEM_H
|
||||
|
||||
#include "map.h"
|
||||
#include "maplayout.h"
|
||||
#include "metatileselector.h"
|
||||
#include <QGraphicsPixmapItem>
|
||||
|
||||
class BorderMetatilesPixmapItem : public QObject, public QGraphicsPixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
BorderMetatilesPixmapItem(Map *map_, MetatileSelector *metatileSelector) {
|
||||
this->map = map_;
|
||||
this->map->setBorderItem(this);
|
||||
BorderMetatilesPixmapItem(Layout *layout, MetatileSelector *metatileSelector) {
|
||||
this->layout = layout;
|
||||
this->layout->setBorderItem(this);
|
||||
this->metatileSelector = metatileSelector;
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
MetatileSelector *metatileSelector;
|
||||
Map *map;
|
||||
Layout *layout;
|
||||
void draw();
|
||||
signals:
|
||||
void hoveredBorderMetatileSelectionChanged(uint16_t);
|
||||
|
||||
@@ -4,19 +4,20 @@
|
||||
#include <QSpinBox>
|
||||
|
||||
#include "metatileselector.h"
|
||||
#include "mappixmapitem.h"
|
||||
#include "movementpermissionsselector.h"
|
||||
#include "layoutpixmapitem.h"
|
||||
#include "map.h"
|
||||
#include "settings.h"
|
||||
|
||||
class CollisionPixmapItem : public MapPixmapItem {
|
||||
class CollisionPixmapItem : public LayoutPixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
CollisionPixmapItem(Map *map, QSpinBox * selectedCollision, QSpinBox * selectedElevation, MetatileSelector *metatileSelector, Settings *settings, qreal *opacity)
|
||||
: MapPixmapItem(map, metatileSelector, settings){
|
||||
CollisionPixmapItem(Layout *layout, QSpinBox * selectedCollision, QSpinBox * selectedElevation, MetatileSelector *metatileSelector, Settings *settings, qreal *opacity)
|
||||
: LayoutPixmapItem(layout, metatileSelector, settings){
|
||||
this->selectedCollision = selectedCollision;
|
||||
this->selectedElevation = selectedElevation;
|
||||
this->opacity = opacity;
|
||||
map->setCollisionItem(this);
|
||||
layout->setCollisionItem(this);
|
||||
}
|
||||
QSpinBox * selectedCollision;
|
||||
QSpinBox * selectedElevation;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <QPainter>
|
||||
#include <QPointer>
|
||||
#include <QKeyEvent>
|
||||
|
||||
class ConnectionPixmapItem : public QObject, public QGraphicsPixmapItem {
|
||||
Q_OBJECT
|
||||
@@ -36,14 +37,17 @@ private:
|
||||
static const int mHeight = 16;
|
||||
|
||||
protected:
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent*) override;
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent*) override;
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*) override;
|
||||
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent*) override;
|
||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent*) override;
|
||||
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*) override;
|
||||
virtual void keyPressEvent(QKeyEvent*) override;
|
||||
virtual void focusInEvent(QFocusEvent*) override;
|
||||
|
||||
signals:
|
||||
void connectionItemDoubleClicked(MapConnection*);
|
||||
void selectionChanged(bool selected);
|
||||
void deleteRequested(MapConnection*);
|
||||
};
|
||||
|
||||
#endif // CONNECTIONPIXMAPITEM_H
|
||||
|
||||
@@ -34,11 +34,12 @@ private:
|
||||
unsigned actionId = 0;
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent*) override;
|
||||
virtual void mousePressEvent(QMouseEvent*) override;
|
||||
virtual void focusInEvent(QFocusEvent*) override;
|
||||
virtual void keyPressEvent(QKeyEvent*) override;
|
||||
|
||||
signals:
|
||||
void selected();
|
||||
void removed(MapConnection*);
|
||||
void openMapClicked(MapConnection*);
|
||||
|
||||
private slots:
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
#ifndef CURRENTSELECTEDMETATILESPIXMAPITEM_H
|
||||
#define CURRENTSELECTEDMETATILESPIXMAPITEM_H
|
||||
|
||||
#include "map.h"
|
||||
#include "metatileselector.h"
|
||||
#include <QGraphicsPixmapItem>
|
||||
|
||||
class Layout;
|
||||
|
||||
class CurrentSelectedMetatilesPixmapItem : public QGraphicsPixmapItem {
|
||||
public:
|
||||
CurrentSelectedMetatilesPixmapItem(Map *map, MetatileSelector *metatileSelector) {
|
||||
this->map = map;
|
||||
CurrentSelectedMetatilesPixmapItem(Layout *layout, MetatileSelector *metatileSelector) {
|
||||
this->layout = layout;
|
||||
this->metatileSelector = metatileSelector;
|
||||
}
|
||||
Map* map = nullptr;
|
||||
Layout *layout = nullptr;
|
||||
MetatileSelector *metatileSelector;
|
||||
void draw();
|
||||
|
||||
void setMap(Map *map) { this->map = map; }
|
||||
void setLayout(Layout *layout) { this->layout = layout; }
|
||||
};
|
||||
|
||||
QPixmap drawMetatileSelection(MetatileSelection selection, Map *map);
|
||||
QPixmap drawMetatileSelection(MetatileSelection selection, Layout *layout);
|
||||
|
||||
#endif // CURRENTSELECTEDMETATILESPIXMAPITEM_H
|
||||
|
||||
28
include/ui/eventfilters.h
Normal file
28
include/ui/eventfilters.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <QObject>
|
||||
#include <QEvent>
|
||||
|
||||
|
||||
|
||||
/// Prevent wheel scroll
|
||||
class WheelFilter : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
WheelFilter(QObject *parent) : QObject(parent) {}
|
||||
virtual ~WheelFilter() {}
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// Ctrl+Wheel = zoom
|
||||
class MapSceneEventFilter : public QObject {
|
||||
Q_OBJECT
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||
public:
|
||||
explicit MapSceneEventFilter(QObject *parent = nullptr) : QObject(parent) {}
|
||||
|
||||
signals:
|
||||
void wheelZoom(int delta);
|
||||
public slots:
|
||||
};
|
||||
@@ -9,9 +9,11 @@ class FilterChildrenProxyModel : public QSortFilterProxyModel
|
||||
|
||||
public:
|
||||
explicit FilterChildrenProxyModel(QObject *parent = nullptr);
|
||||
void setHideEmpty(bool hidden) { this->hideEmpty = hidden; }
|
||||
protected:
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const;
|
||||
|
||||
private:
|
||||
bool hideEmpty = false;
|
||||
};
|
||||
|
||||
#endif // FILTERCHILDRENPROXYMODEL_H
|
||||
|
||||
@@ -34,6 +34,7 @@ signals:
|
||||
|
||||
class Editor;
|
||||
|
||||
// TODO: This should just be MapView. It makes map-based assumptions, and no other class inherits GraphicsView.
|
||||
class GraphicsView : public QGraphicsView
|
||||
{
|
||||
public:
|
||||
@@ -44,10 +45,10 @@ public:
|
||||
// GraphicsView_Object object;
|
||||
Editor *editor;
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
void moveEvent(QMoveEvent *event);
|
||||
virtual void mousePressEvent(QMouseEvent *event) override;
|
||||
virtual void mouseMoveEvent(QMouseEvent *event) override;
|
||||
virtual void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
virtual void moveEvent(QMoveEvent *event) override;
|
||||
};
|
||||
|
||||
//Q_DECLARE_METATYPE(GraphicsView)
|
||||
|
||||
@@ -1,54 +1,58 @@
|
||||
#ifndef MAPPIXMAPITEM_H
|
||||
#define MAPPIXMAPITEM_H
|
||||
|
||||
#include "map.h"
|
||||
#include "settings.h"
|
||||
#include "metatileselector.h"
|
||||
#include <QGraphicsPixmapItem>
|
||||
|
||||
class MapPixmapItem : public QObject, public QGraphicsPixmapItem {
|
||||
class Layout;
|
||||
|
||||
class LayoutPixmapItem : public QObject, public QGraphicsPixmapItem {
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
using QGraphicsPixmapItem::paint;
|
||||
|
||||
public:
|
||||
enum class PaintMode {
|
||||
Disabled,
|
||||
Metatiles,
|
||||
EventObjects
|
||||
};
|
||||
MapPixmapItem(Map *map_, MetatileSelector *metatileSelector, Settings *settings) {
|
||||
this->map = map_;
|
||||
this->map->setMapItem(this);
|
||||
LayoutPixmapItem(Layout *layout, MetatileSelector *metatileSelector, Settings *settings) {
|
||||
this->layout = layout;
|
||||
// this->map->setMapItem(this);
|
||||
this->metatileSelector = metatileSelector;
|
||||
this->settings = settings;
|
||||
this->paintingMode = PaintMode::Metatiles;
|
||||
this->lockedAxis = MapPixmapItem::Axis::None;
|
||||
this->lockedAxis = LayoutPixmapItem::Axis::None;
|
||||
this->prevStraightPathState = false;
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
MapPixmapItem::PaintMode paintingMode;
|
||||
Map *map;
|
||||
|
||||
Layout *layout;
|
||||
|
||||
MetatileSelector *metatileSelector;
|
||||
|
||||
Settings *settings;
|
||||
|
||||
bool active;
|
||||
bool has_mouse = false;
|
||||
bool right_click;
|
||||
|
||||
int paint_tile_initial_x;
|
||||
int paint_tile_initial_y;
|
||||
bool prevStraightPathState;
|
||||
int straight_path_initial_x;
|
||||
int straight_path_initial_y;
|
||||
|
||||
QPoint metatilePos;
|
||||
|
||||
enum Axis {
|
||||
None = 0,
|
||||
X,
|
||||
Y
|
||||
};
|
||||
MapPixmapItem::Axis lockedAxis;
|
||||
|
||||
LayoutPixmapItem::Axis lockedAxis;
|
||||
|
||||
QPoint selection_origin;
|
||||
QList<QPoint> selection;
|
||||
|
||||
virtual void paint(QGraphicsSceneMouseEvent*);
|
||||
virtual void floodFill(QGraphicsSceneMouseEvent*);
|
||||
virtual void magicFill(QGraphicsSceneMouseEvent*);
|
||||
@@ -70,26 +74,33 @@ public:
|
||||
QList<CollisionSelectionItem> selectedCollisions,
|
||||
bool fromScriptCall = false);
|
||||
void floodFillSmartPath(int initialX, int initialY, bool fromScriptCall = false);
|
||||
|
||||
virtual void pick(QGraphicsSceneMouseEvent*);
|
||||
virtual void select(QGraphicsSceneMouseEvent*);
|
||||
virtual void shift(QGraphicsSceneMouseEvent*);
|
||||
void shift(int xDelta, int yDelta, bool fromScriptCall = false);
|
||||
virtual void draw(bool ignoreCache = false);
|
||||
|
||||
void updateMetatileSelection(QGraphicsSceneMouseEvent *event);
|
||||
void paintNormal(int x, int y, bool fromScriptCall = false);
|
||||
void lockNondominantAxis(QGraphicsSceneMouseEvent *event);
|
||||
QPoint adjustCoords(QPoint pos);
|
||||
|
||||
void setEditsEnabled(bool enabled) { this->editsEnabled = enabled; }
|
||||
bool getEditsEnabled() { return this->editsEnabled; }
|
||||
|
||||
private:
|
||||
void paintSmartPath(int x, int y, bool fromScriptCall = false);
|
||||
static QList<int> smartPathTable;
|
||||
|
||||
unsigned actionId_ = 0;
|
||||
|
||||
bool editsEnabled = true;
|
||||
|
||||
signals:
|
||||
void startPaint(QGraphicsSceneMouseEvent *, MapPixmapItem *);
|
||||
void endPaint(QGraphicsSceneMouseEvent *, MapPixmapItem *);
|
||||
void mouseEvent(QGraphicsSceneMouseEvent *, MapPixmapItem *);
|
||||
void startPaint(QGraphicsSceneMouseEvent *, LayoutPixmapItem *);
|
||||
void endPaint(QGraphicsSceneMouseEvent *, LayoutPixmapItem *);
|
||||
void mouseEvent(QGraphicsSceneMouseEvent *, LayoutPixmapItem *);
|
||||
void hoveredMapMetatileChanged(const QPoint &pos);
|
||||
void hoveredMapMetatileCleared();
|
||||
|
||||
@@ -45,6 +45,7 @@ public:
|
||||
private:
|
||||
Ui::MapImageExporter *ui;
|
||||
|
||||
Layout *layout = nullptr;
|
||||
Map *map = nullptr;
|
||||
Editor *editor = nullptr;
|
||||
QGraphicsScene *scene = nullptr;
|
||||
|
||||
208
include/ui/maplistmodels.h
Normal file
208
include/ui/maplistmodels.h
Normal file
@@ -0,0 +1,208 @@
|
||||
#pragma once
|
||||
#ifndef MAPLISTMODELS_H
|
||||
#define MAPLISTMODELS_H
|
||||
|
||||
#include <QTreeView>
|
||||
#include <QFontDatabase>
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QStandardItemModel>
|
||||
#include <QMap>
|
||||
|
||||
|
||||
|
||||
class Project;
|
||||
|
||||
enum MapListUserRoles {
|
||||
GroupRole = Qt::UserRole + 1, // Used to hold the map group number.
|
||||
TypeRole, // Used to differentiate between the different layers of the map list tree view.
|
||||
TypeRole2, // Used for various extra data needed.
|
||||
};
|
||||
|
||||
|
||||
|
||||
class MapTree : public QTreeView {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MapTree(QWidget *parent) : QTreeView(parent) {
|
||||
this->setDropIndicatorShown(true);
|
||||
this->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
|
||||
this->setFocusPolicy(Qt::StrongFocus);
|
||||
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void keyPressEvent(QKeyEvent *event) override;
|
||||
|
||||
public slots:
|
||||
void removeSelected();
|
||||
};
|
||||
|
||||
|
||||
|
||||
class GroupNameDelegate : public QStyledItemDelegate {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GroupNameDelegate(Project *project, QObject *parent = nullptr) : QStyledItemDelegate(parent), project(project) {}
|
||||
|
||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
|
||||
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
|
||||
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
|
||||
private:
|
||||
Project *project = nullptr;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class QRegularExpressionValidator;
|
||||
|
||||
class MapListModel : public QStandardItemModel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MapListModel(QObject *parent = nullptr) : QStandardItemModel(parent) {};
|
||||
~MapListModel() { }
|
||||
|
||||
virtual QModelIndex indexOf(QString id) const = 0;
|
||||
virtual void removeItemAt(const QModelIndex &index);
|
||||
virtual QStandardItem *getItem(const QModelIndex &index) const = 0;
|
||||
|
||||
protected:
|
||||
virtual void removeItem(QStandardItem *item) = 0;
|
||||
};
|
||||
|
||||
class MapGroupModel : public MapListModel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MapGroupModel(Project *project, QObject *parent = nullptr);
|
||||
~MapGroupModel() { }
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
Qt::DropActions supportedDropActions() const override;
|
||||
QStringList mimeTypes() const override;
|
||||
virtual QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
||||
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
|
||||
|
||||
virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||
|
||||
public:
|
||||
void setMap(QString mapName) { this->openMap = mapName; }
|
||||
|
||||
QStandardItem *createGroupItem(QString groupName, int groupIndex, QStandardItem *fromItem = nullptr);
|
||||
QStandardItem *createMapItem(QString mapName, QStandardItem *fromItem = nullptr);
|
||||
|
||||
QStandardItem *insertGroupItem(QString groupName);
|
||||
QStandardItem *insertMapItem(QString mapName, QString groupName);
|
||||
|
||||
virtual QStandardItem *getItem(const QModelIndex &index) const override;
|
||||
virtual QModelIndex indexOf(QString mapName) const override;
|
||||
|
||||
void initialize();
|
||||
|
||||
protected:
|
||||
virtual void removeItem(QStandardItem *item) override;
|
||||
|
||||
private:
|
||||
friend class MapTree;
|
||||
void updateProject();
|
||||
|
||||
private:
|
||||
Project *project;
|
||||
QStandardItem *root = nullptr;
|
||||
|
||||
QMap<QString, QStandardItem *> groupItems;
|
||||
QMap<QString, QStandardItem *> mapItems;
|
||||
|
||||
QString openMap;
|
||||
|
||||
signals:
|
||||
void dragMoveCompleted();
|
||||
};
|
||||
|
||||
|
||||
|
||||
class MapAreaModel : public MapListModel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MapAreaModel(Project *project, QObject *parent = nullptr);
|
||||
~MapAreaModel() {}
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
public:
|
||||
void setMap(QString mapName) { this->openMap = mapName; }
|
||||
|
||||
QStandardItem *createAreaItem(QString areaName);
|
||||
QStandardItem *createMapItem(QString mapName, int areaIndex, int mapIndex);
|
||||
|
||||
QStandardItem *insertAreaItem(QString areaName);
|
||||
QStandardItem *insertMapItem(QString mapName, QString areaName, int groupIndex);
|
||||
|
||||
virtual QStandardItem *getItem(const QModelIndex &index) const override;
|
||||
virtual QModelIndex indexOf(QString mapName) const override;
|
||||
|
||||
void initialize();
|
||||
|
||||
protected:
|
||||
virtual void removeItem(QStandardItem *item) override;
|
||||
|
||||
private:
|
||||
Project *project;
|
||||
QStandardItem *root = nullptr;
|
||||
|
||||
QMap<QString, QStandardItem *> areaItems;
|
||||
QMap<QString, QStandardItem *> mapItems;
|
||||
|
||||
QString openMap;
|
||||
|
||||
signals:
|
||||
void edited();
|
||||
};
|
||||
|
||||
|
||||
|
||||
class LayoutTreeModel : public MapListModel {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LayoutTreeModel(Project *project, QObject *parent = nullptr);
|
||||
~LayoutTreeModel() {}
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
public:
|
||||
void setLayout(QString layoutId) { this->openLayout = layoutId; }
|
||||
|
||||
QStandardItem *createLayoutItem(QString layoutId);
|
||||
QStandardItem *createMapItem(QString mapName);
|
||||
|
||||
QStandardItem *insertLayoutItem(QString layoutId);
|
||||
QStandardItem *insertMapItem(QString mapName, QString layoutId);
|
||||
|
||||
virtual QStandardItem *getItem(const QModelIndex &index) const override;
|
||||
virtual QModelIndex indexOf(QString layoutName) const override;
|
||||
|
||||
void initialize();
|
||||
|
||||
protected:
|
||||
virtual void removeItem(QStandardItem *item) override;
|
||||
|
||||
private:
|
||||
Project *project;
|
||||
QStandardItem *root = nullptr;
|
||||
|
||||
QMap<QString, QStandardItem *> layoutItems;
|
||||
QMap<QString, QStandardItem *> mapItems;
|
||||
|
||||
QString openLayout;
|
||||
|
||||
signals:
|
||||
void edited();
|
||||
};
|
||||
|
||||
#endif // MAPLISTMODELS_H
|
||||
52
include/ui/maplisttoolbar.h
Normal file
52
include/ui/maplisttoolbar.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#ifndef MAPLISTTOOLBAR_H
|
||||
#define MAPLISTTOOLBAR_H
|
||||
|
||||
#include "maplistmodels.h"
|
||||
#include "filterchildrenproxymodel.h"
|
||||
|
||||
#include <QFrame>
|
||||
#include <QPointer>
|
||||
|
||||
namespace Ui {
|
||||
class MapListToolBar;
|
||||
}
|
||||
|
||||
class MapListToolBar : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MapListToolBar(QWidget *parent = nullptr);
|
||||
~MapListToolBar();
|
||||
|
||||
MapTree* list() const { return m_list; }
|
||||
void setList(MapTree *list);
|
||||
|
||||
void setEditsAllowedButtonVisible(bool visible);
|
||||
void setEditsAllowed(bool allowed);
|
||||
void toggleEditsAllowed();
|
||||
|
||||
void setEmptyFoldersVisible(bool visible);
|
||||
void toggleEmptyFolders();
|
||||
|
||||
void expandList();
|
||||
void collapseList();
|
||||
|
||||
void applyFilter(const QString &filterText);
|
||||
void clearFilter();
|
||||
void setFilterLocked(bool locked) { m_filterLocked = locked; }
|
||||
bool isFilterLocked() const { return m_filterLocked; }
|
||||
|
||||
signals:
|
||||
void filterCleared(MapTree*);
|
||||
void addFolderClicked();
|
||||
|
||||
private:
|
||||
Ui::MapListToolBar *ui;
|
||||
QPointer<MapTree> m_list;
|
||||
bool m_filterLocked = false;
|
||||
bool m_editsAllowed = false;
|
||||
bool m_emptyFoldersVisible = true;
|
||||
};
|
||||
|
||||
#endif // MAPLISTTOOLBAR_H
|
||||
@@ -1,19 +0,0 @@
|
||||
#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
|
||||
@@ -73,7 +73,8 @@ public:
|
||||
private:
|
||||
QMap<int, Overlay*> overlayMap;
|
||||
protected:
|
||||
void drawForeground(QPainter *painter, const QRectF &rect);
|
||||
virtual void drawForeground(QPainter *painter, const QRectF &rect) override;
|
||||
virtual void keyPressEvent(QKeyEvent*) override;
|
||||
};
|
||||
|
||||
#endif // GRAPHICSVIEW_H
|
||||
|
||||
@@ -31,13 +31,13 @@ struct MetatileSelection
|
||||
class MetatileSelector: public SelectablePixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
MetatileSelector(int numMetatilesWide, Map *map): SelectablePixmapItem(16, 16) {
|
||||
MetatileSelector(int numMetatilesWide, Layout *layout): SelectablePixmapItem(16, 16) {
|
||||
this->externalSelection = false;
|
||||
this->prefabSelection = false;
|
||||
this->numMetatilesWide = numMetatilesWide;
|
||||
this->map = map;
|
||||
this->primaryTileset = map->layout->tileset_primary;
|
||||
this->secondaryTileset = map->layout->tileset_secondary;
|
||||
this->layout = layout;
|
||||
this->primaryTileset = layout->tileset_primary;
|
||||
this->secondaryTileset = layout->tileset_secondary;
|
||||
this->selection = MetatileSelection{};
|
||||
this->cellPos = QPoint(-1, -1);
|
||||
setAcceptHoverEvents(true);
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
void setPrefabSelection(MetatileSelection selection);
|
||||
void setExternalSelection(int, int, QList<uint16_t>, QList<QPair<uint16_t, uint16_t>>);
|
||||
QPoint getMetatileIdCoordsOnWidget(uint16_t);
|
||||
void setMap(Map*);
|
||||
void setLayout(Layout *layout);
|
||||
bool isInternalSelection() const { return (!this->externalSelection && !this->prefabSelection); }
|
||||
Tileset *primaryTileset;
|
||||
Tileset *secondaryTileset;
|
||||
@@ -65,7 +65,7 @@ private:
|
||||
bool externalSelection;
|
||||
bool prefabSelection;
|
||||
int numMetatilesWide;
|
||||
Map *map;
|
||||
Layout *layout;
|
||||
int externalSelectionWidth;
|
||||
int externalSelectionHeight;
|
||||
QList<uint16_t> externalSelectedMetatiles;
|
||||
|
||||
@@ -32,8 +32,6 @@ public slots:
|
||||
void deactivateTab(int tabIndex);
|
||||
|
||||
private:
|
||||
bool eventFilter(QObject *object, QEvent *event);
|
||||
|
||||
void actionCopyTab(int index);
|
||||
void actionAddDeleteTab(int index);
|
||||
|
||||
|
||||
@@ -23,8 +23,9 @@ public:
|
||||
bool importedMap;
|
||||
QString layoutId;
|
||||
void init();
|
||||
void init(MapSortOrder type, QVariant data);
|
||||
void init(MapLayout *);
|
||||
void initUi();
|
||||
void init(int tabIndex, QString data);
|
||||
void init(Layout *);
|
||||
static void setDefaultSettings(Project *project);
|
||||
|
||||
signals:
|
||||
@@ -37,7 +38,7 @@ private:
|
||||
bool checkNewMapGroup();
|
||||
void saveSettings();
|
||||
void useLayout(QString layoutId);
|
||||
void useLayoutSettings(MapLayout *mapLayout);
|
||||
void useLayoutSettings(Layout *mapLayout);
|
||||
|
||||
struct Settings {
|
||||
QString group;
|
||||
@@ -60,6 +61,8 @@ private:
|
||||
static struct Settings settings;
|
||||
|
||||
private slots:
|
||||
void on_checkBox_UseExistingLayout_stateChanged(int state);
|
||||
void on_comboBox_Layout_currentTextChanged(const QString &text);
|
||||
void on_pushButton_NewMap_Accept_clicked();
|
||||
void on_lineEdit_NewMap_Name_textChanged(const QString &);
|
||||
};
|
||||
|
||||
@@ -20,9 +20,9 @@ struct PrefabItem
|
||||
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);
|
||||
void initPrefabUI(MetatileSelector *selector, QWidget *prefabWidget, QLabel *emptyPrefabLabel, Layout *layout);
|
||||
void addPrefab(MetatileSelection selection, Layout *layout, QString name);
|
||||
void updatePrefabUi(Layout *layout);
|
||||
bool tryImportDefaultPrefabs(QWidget * parent, BaseGameVersion version, QString filepath = "");
|
||||
|
||||
private:
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
#define PREFABCREATIONDIALOG_H
|
||||
|
||||
#include "metatileselector.h"
|
||||
#include "map.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class Layout;
|
||||
|
||||
namespace Ui {
|
||||
class PrefabCreationDialog;
|
||||
}
|
||||
@@ -15,12 +16,12 @@ class PrefabCreationDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PrefabCreationDialog(QWidget *parent, MetatileSelector *metatileSelector, Map *map);
|
||||
explicit PrefabCreationDialog(QWidget *parent, MetatileSelector *metatileSelector, Layout *layout);
|
||||
~PrefabCreationDialog();
|
||||
void savePrefab();
|
||||
|
||||
private:
|
||||
Map *map;
|
||||
Layout *layout = nullptr;
|
||||
Ui::PrefabCreationDialog *ui;
|
||||
MetatileSelection selection;
|
||||
};
|
||||
|
||||
@@ -57,7 +57,6 @@ private:
|
||||
tsl::ordered_map<QString, RegionMap *> region_maps;
|
||||
|
||||
QString configFilepath;
|
||||
QString mapSectionFilepath;
|
||||
|
||||
poryjson::Json rmConfigJson;
|
||||
|
||||
@@ -96,7 +95,7 @@ private:
|
||||
void saveConfig();
|
||||
bool loadRegionMapEntries();
|
||||
bool saveRegionMapEntries();
|
||||
tsl::ordered_map<QString, MapSectionEntry> region_map_entries;
|
||||
QMap<QString, MapSectionEntry> region_map_entries;
|
||||
|
||||
bool buildConfigDialog();
|
||||
poryjson::Json configRegionMapDialog();
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
#include "tileseteditormetatileselector.h"
|
||||
#include "tileseteditortileselector.h"
|
||||
#include "metatilelayersitem.h"
|
||||
#include "map.h"
|
||||
|
||||
class Layout;
|
||||
|
||||
namespace Ui {
|
||||
class TilesetEditor;
|
||||
@@ -39,10 +40,10 @@ class TilesetEditor : public QMainWindow
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TilesetEditor(Project*, Map*, QWidget *parent = nullptr);
|
||||
explicit TilesetEditor(Project *project, Layout *layout, QWidget *parent = nullptr);
|
||||
~TilesetEditor();
|
||||
void update(Map *map, QString primaryTilsetLabel, QString secondaryTilesetLabel);
|
||||
void updateMap(Map *map);
|
||||
void update(Layout *layout, QString primaryTilsetLabel, QString secondaryTilesetLabel);
|
||||
void updateLayout(Layout *layout);
|
||||
void updateTilesets(QString primaryTilsetLabel, QString secondaryTilesetLabel);
|
||||
bool selectMetatile(uint16_t metatileId);
|
||||
uint16_t getSelectedMetatileId();
|
||||
@@ -155,7 +156,7 @@ private:
|
||||
MetatileLayersItem *metatileLayersItem = nullptr;
|
||||
PaletteEditor *paletteEditor = nullptr;
|
||||
Project *project = nullptr;
|
||||
Map *map = nullptr;
|
||||
Layout *layout = nullptr;
|
||||
Metatile *metatile = nullptr;
|
||||
Metatile *copiedMetatile = nullptr;
|
||||
QString copiedMetatileLabel;
|
||||
|
||||
@@ -3,13 +3,14 @@
|
||||
|
||||
#include "selectablepixmapitem.h"
|
||||
#include "tileset.h"
|
||||
#include "map.h"
|
||||
|
||||
class Layout;
|
||||
|
||||
class TilesetEditorMetatileSelector: public SelectablePixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TilesetEditorMetatileSelector(Tileset *primaryTileset, Tileset *secondaryTileset, Map *map);
|
||||
Map *map = nullptr;
|
||||
TilesetEditorMetatileSelector(Tileset *primaryTileset, Tileset *secondaryTileset, Layout *layout);
|
||||
Layout *layout = nullptr;
|
||||
void draw();
|
||||
bool select(uint16_t metatileId);
|
||||
void setTilesets(Tileset*, Tileset*, bool draw = true);
|
||||
|
||||
Reference in New Issue
Block a user