mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-19 23:25:09 -05:00
Merge branch 'master' into label-copy
This commit is contained in:
@@ -148,7 +148,7 @@ public:
|
||||
this->enableHiddenItemQuantity = false;
|
||||
this->enableHiddenItemRequiresItemfinder = false;
|
||||
this->enableHealLocationRespawnData = false;
|
||||
this->enableObjectEventInConnection = false;
|
||||
this->enableEventCloneObject = false;
|
||||
this->enableFloorNumber = false;
|
||||
this->createMapTextFile = false;
|
||||
this->enableTripleLayerMetatiles = false;
|
||||
@@ -178,8 +178,8 @@ public:
|
||||
bool getHiddenItemRequiresItemfinderEnabled();
|
||||
void setHealLocationRespawnDataEnabled(bool enable);
|
||||
bool getHealLocationRespawnDataEnabled();
|
||||
void setObjectEventInConnectionEnabled(bool enable);
|
||||
bool getObjectEventInConnectionEnabled();
|
||||
void setEventCloneObjectEnabled(bool enable);
|
||||
bool getEventCloneObjectEnabled();
|
||||
void setFloorNumberEnabled(bool enable);
|
||||
bool getFloorNumberEnabled();
|
||||
void setCreateMapTextFileEnabled(bool enable);
|
||||
@@ -206,7 +206,7 @@ private:
|
||||
bool enableHiddenItemQuantity;
|
||||
bool enableHiddenItemRequiresItemfinder;
|
||||
bool enableHealLocationRespawnData;
|
||||
bool enableObjectEventInConnection;
|
||||
bool enableEventCloneObject;
|
||||
bool enableFloorNumber;
|
||||
bool createMapTextFile;
|
||||
bool enableTripleLayerMetatiles;
|
||||
|
||||
@@ -14,6 +14,7 @@ class EventType
|
||||
{
|
||||
public:
|
||||
static QString Object;
|
||||
static QString CloneObject;
|
||||
static QString Warp;
|
||||
static QString Trigger;
|
||||
static QString WeatherTrigger;
|
||||
@@ -23,6 +24,16 @@ public:
|
||||
static QString HealLocation;
|
||||
};
|
||||
|
||||
class EventGroup
|
||||
{
|
||||
public:
|
||||
static QString Object;
|
||||
static QString Warp;
|
||||
static QString Coord;
|
||||
static QString Bg;
|
||||
static QString Heal;
|
||||
};
|
||||
|
||||
class DraggablePixmapItem;
|
||||
class Project;
|
||||
class Event
|
||||
@@ -68,6 +79,7 @@ public:
|
||||
|
||||
static Event* createNewEvent(QString, QString, Project*);
|
||||
static Event* createNewObjectEvent(Project*);
|
||||
static Event* createNewCloneObjectEvent(Project*, QString);
|
||||
static Event* createNewWarpEvent(QString);
|
||||
static Event* createNewHealLocationEvent(QString);
|
||||
static Event* createNewTriggerEvent(Project*);
|
||||
@@ -75,8 +87,12 @@ public:
|
||||
static Event* createNewSignEvent(Project*);
|
||||
static Event* createNewHiddenItemEvent(Project*);
|
||||
static Event* createNewSecretBaseEvent(Project*);
|
||||
static bool isValidType(QString event_type);
|
||||
static QString typeToGroup(QString event_type);
|
||||
static int getIndexOffset(QString group_type);
|
||||
|
||||
OrderedJson::object buildObjectEventJSON();
|
||||
OrderedJson::object buildCloneObjectEventJSON(const QMap<QString, QString> &);
|
||||
OrderedJson::object buildWarpEventJSON(const QMap<QString, QString> &);
|
||||
OrderedJson::object buildTriggerEventJSON();
|
||||
OrderedJson::object buildWeatherTriggerEventJSON();
|
||||
@@ -86,7 +102,7 @@ public:
|
||||
void setPixmapFromSpritesheet(QImage, int, int, bool);
|
||||
int getPixelX();
|
||||
int getPixelY();
|
||||
QMap<QString, bool> getExpectedFields();
|
||||
QSet<QString> getExpectedFields();
|
||||
void readCustomValues(QJsonObject values);
|
||||
void addCustomValuesTo(OrderedJson::object *obj);
|
||||
void setFrameFromMovement(QString);
|
||||
|
||||
@@ -54,4 +54,18 @@ public:
|
||||
static int getAttributesSize(BaseGameVersion version);
|
||||
};
|
||||
|
||||
inline bool operator==(const Metatile &a, const Metatile &b) {
|
||||
return a.behavior == b.behavior &&
|
||||
a.layerType == b.layerType &&
|
||||
a.encounterType == b.encounterType &&
|
||||
a.terrainType == b.terrainType &&
|
||||
a.unusedAttributes == b.unusedAttributes &&
|
||||
a.label == b.label &&
|
||||
a.tiles == b.tiles;
|
||||
}
|
||||
|
||||
inline bool operator!=(const Metatile &a, const Metatile &b) {
|
||||
return !(operator==(a, b));
|
||||
}
|
||||
|
||||
#endif // METATILE_H
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#define REGIONMAP_H
|
||||
|
||||
#include "map.h"
|
||||
#include "project.h"
|
||||
#include "tilemaptileselector.h"
|
||||
#include "history.h"
|
||||
|
||||
@@ -15,138 +14,183 @@
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsView>
|
||||
|
||||
enum RegionMapEditorBox {
|
||||
BackgroundImage = 1,
|
||||
CityMapImage = 2,
|
||||
};
|
||||
#include <memory>
|
||||
using std::shared_ptr;
|
||||
|
||||
class RegionMapHistoryItem {
|
||||
public:
|
||||
int which;
|
||||
int mapWidth = 0;
|
||||
int mapHeight = 0;
|
||||
QVector<uint8_t> tiles;
|
||||
QString cityMap;
|
||||
RegionMapHistoryItem(int which, QVector<uint8_t> tiles, QString cityMap) {
|
||||
this->which = which;
|
||||
this->tiles = tiles;
|
||||
this->cityMap = cityMap;
|
||||
}
|
||||
RegionMapHistoryItem(int which, QVector<uint8_t> tiles, int width, int height) {
|
||||
this->which = which;
|
||||
this->tiles = tiles;
|
||||
this->mapWidth = width;
|
||||
this->mapHeight = height;
|
||||
}
|
||||
~RegionMapHistoryItem() {}
|
||||
};
|
||||
class Project;
|
||||
|
||||
class RegionMapEntry
|
||||
struct LayoutSquare
|
||||
{
|
||||
public:
|
||||
RegionMapEntry()=default;
|
||||
RegionMapEntry(int x_, int y_, int width_, int height_, QString name_) {
|
||||
this-> x = x_;
|
||||
this-> y = y_;
|
||||
this-> width = width_;
|
||||
this-> height = height_;
|
||||
this-> name = name_;
|
||||
}
|
||||
LayoutSquare() : map_section("MAPSEC_NONE"), x(-1), y(-1), has_map(false) {}
|
||||
QString map_section;
|
||||
int x;
|
||||
int y;
|
||||
int width;
|
||||
int height;
|
||||
QString name;
|
||||
|
||||
void setX(int);
|
||||
void setY(int);
|
||||
void setWidth(int);
|
||||
void setHeight(int);
|
||||
bool has_map;
|
||||
};
|
||||
|
||||
class RegionMapSquare
|
||||
struct MapSectionEntry
|
||||
{
|
||||
public:
|
||||
int x = -1;
|
||||
int y = -1;
|
||||
uint8_t tile_img_id = 0x00;
|
||||
uint8_t secid = 0x00;
|
||||
bool has_map = false;
|
||||
bool has_city_map = false;
|
||||
bool duplicated = false;
|
||||
QString map_name;
|
||||
QString mapsec;
|
||||
QString city_map_name;
|
||||
QString name = "";
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int width = 1;
|
||||
int height = 1;
|
||||
bool valid = false;
|
||||
};
|
||||
|
||||
class RegionMap
|
||||
class RegionMap : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RegionMap() = default;
|
||||
RegionMap() = delete;
|
||||
RegionMap(Project *);
|
||||
|
||||
~RegionMap() {}
|
||||
|
||||
Project *project = nullptr;
|
||||
|
||||
QVector<RegionMapSquare> map_squares;
|
||||
History<RegionMapHistoryItem*> history;
|
||||
bool loadMapData(poryjson::Json);
|
||||
bool loadTilemap(poryjson::Json);
|
||||
bool loadLayout(poryjson::Json);
|
||||
bool loadEntries();
|
||||
|
||||
QMap<QString, QString> sMapNamesMap;
|
||||
QMap<QString, RegionMapEntry> mapSecToMapEntry;
|
||||
QVector<QString> sMapNames;
|
||||
|
||||
const int padLeft = 1;
|
||||
const int padRight = 3;
|
||||
const int padTop = 2;
|
||||
const int padBottom = 3;
|
||||
|
||||
bool init(Project*);
|
||||
|
||||
bool readBkgImgBin();
|
||||
bool readLayout();
|
||||
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 clearEntries() { this->region_map_entries->clear(); }
|
||||
MapSectionEntry getEntry(QString section);
|
||||
void setEntry(QString section, MapSectionEntry entry);
|
||||
void removeEntry(QString section);
|
||||
|
||||
void save();
|
||||
void saveTileImages();
|
||||
void saveBkgImgBin();
|
||||
void saveTilemap();
|
||||
void saveLayout();
|
||||
void saveOptions(int id, QString sec, QString name, int x, int y);
|
||||
|
||||
void resize(int width, int height);
|
||||
void resizeTilemap(int width, int height, bool update = true);
|
||||
void resetSquare(int index);
|
||||
void clearLayout();
|
||||
void clearImage();
|
||||
void replaceSectionId(unsigned oldId, unsigned newId);
|
||||
void replaceSection(QString oldSection, QString newSection);
|
||||
void swapSections(QString secA, QString secB);
|
||||
|
||||
int width();
|
||||
int height();
|
||||
QSize imgSize();
|
||||
unsigned getTileId(int index);
|
||||
shared_ptr<TilemapTile> getTile(int index);
|
||||
unsigned getTileId(int x, int y);
|
||||
int getMapSquareIndex(int x, int y);
|
||||
QString pngPath();
|
||||
void setTemporaryPngPath(QString);
|
||||
QString cityTilesPath();
|
||||
void setTemporaryCityTilesPath(QString);
|
||||
shared_ptr<TilemapTile> getTile(int x, int y);
|
||||
bool squareHasMap(int index);
|
||||
QString squareMapSection(int index);
|
||||
void setSquareMapSection(int index, QString section);
|
||||
int squareX(int index);
|
||||
int squareY(int index);
|
||||
bool squareInLayout(int x, int y);
|
||||
int firstLayoutIndex() { return this->offset_left + this->offset_top * this->tilemap_width; }
|
||||
|
||||
QVector<uint8_t> getTiles();
|
||||
void setTiles(QVector<uint8_t> tileIds);
|
||||
void setTileId(int index, unsigned id);
|
||||
void setTile(int index, TilemapTile &tile);
|
||||
void setTileData(int index, unsigned id, bool hFlip, bool vFlip, int palette);
|
||||
int getMapSquareIndex(int x, int y);
|
||||
|
||||
QString getAlias() { return this->alias; }
|
||||
poryjson::Json::object config();
|
||||
|
||||
QString palPath();
|
||||
QString pngPath();
|
||||
QString entriesPath() { return this->entries_path; }
|
||||
|
||||
QByteArray getTilemap();
|
||||
void setTilemap(QByteArray newTilemap);
|
||||
|
||||
QList<LayoutSquare> getLayout(QString layer);
|
||||
void setLayout(QString layer, QList<LayoutSquare> layout);
|
||||
|
||||
bool layoutEnabled() { return this->layout_format != LayoutFormat::None; }
|
||||
|
||||
QMap<QString, QList<LayoutSquare>> getAllLayouts();
|
||||
void setAllLayouts(QMap<QString, QList<LayoutSquare>> newLayouts);
|
||||
|
||||
QStringList getLayers() { return this->layout_layers; }
|
||||
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; }
|
||||
int padBottom() { return this->tilemap_height - this->layout_height - this->offset_top; }
|
||||
|
||||
int tilemapWidth() { return this->tilemap_width; }
|
||||
int tilemapHeight() { return this->tilemap_height; }
|
||||
int tilemapSize() { return this->tilemap_width * this->tilemap_height; }
|
||||
int tilemapBytes();
|
||||
|
||||
int layoutWidth() { return this->layout_width; }
|
||||
int layoutHeight() { return this->layout_height; }
|
||||
void setLayoutDimensions(int width, int height, bool update = true);
|
||||
|
||||
int tilemapToLayoutIndex(int index);
|
||||
|
||||
TilemapFormat tilemapFormat() { return this->tilemap_format; }
|
||||
|
||||
int pixelWidth() { return this->tilemap_width * 8; }
|
||||
int pixelHeight() { return this->tilemap_height * 8; }
|
||||
|
||||
QString fullPath(QString local);
|
||||
|
||||
void commit(QUndoCommand *command);
|
||||
QUndoStack editHistory;
|
||||
|
||||
void undo();
|
||||
void redo();
|
||||
|
||||
void emitDisplay();
|
||||
|
||||
signals:
|
||||
void mapNeedsDisplaying();
|
||||
|
||||
private:
|
||||
int layout_width_;
|
||||
int layout_height_;
|
||||
int img_width_;
|
||||
int img_height_;
|
||||
// TODO: defaults needed?
|
||||
tsl::ordered_map<QString, MapSectionEntry> *region_map_entries = nullptr;
|
||||
|
||||
QString region_map_png_path;
|
||||
QString region_map_bin_path;
|
||||
QString region_map_entries_path;
|
||||
QString region_map_layout_bin_path;
|
||||
QString city_map_tiles_path;
|
||||
QString alias = "";
|
||||
|
||||
bool region_map_png_needs_saving = false;
|
||||
bool city_map_png_needs_saving = false;
|
||||
int tilemap_width;
|
||||
int tilemap_height;
|
||||
|
||||
int img_index_(int x, int y);
|
||||
int layout_index_(int x, int y);
|
||||
int layout_width;
|
||||
int layout_height;
|
||||
|
||||
int offset_left;
|
||||
int offset_top;
|
||||
|
||||
TilemapFormat tilemap_format;
|
||||
|
||||
enum class LayoutFormat { None, Binary, CArray };
|
||||
LayoutFormat layout_format;
|
||||
|
||||
QString tileset_path;
|
||||
QString tilemap_path;
|
||||
QString palette_path = "";
|
||||
|
||||
QString entries_path;
|
||||
QString layout_path;
|
||||
|
||||
QString layout_array_label;
|
||||
bool layout_uses_layers = false;
|
||||
QStringList layout_constants;
|
||||
QString layout_qualifiers;
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
QVector<shared_ptr<TilemapTile>> tilemap;
|
||||
#else
|
||||
QList<shared_ptr<TilemapTile>> tilemap;
|
||||
#endif
|
||||
|
||||
QStringList layout_layers;
|
||||
QString current_layer;
|
||||
QMap<QString, QList<LayoutSquare>> layouts;
|
||||
|
||||
int get_tilemap_index(int x, int y);
|
||||
int get_layout_index(int x, int y);
|
||||
};
|
||||
|
||||
#endif // REGIONMAP_H
|
||||
|
||||
169
include/core/regionmapeditcommands.h
Normal file
169
include/core/regionmapeditcommands.h
Normal file
@@ -0,0 +1,169 @@
|
||||
#pragma once
|
||||
#ifndef REGIONMAPEDITCOMMANDS_H
|
||||
#define REGIONMAPEDITCOMMANDS_H
|
||||
|
||||
#include "regionmap.h"
|
||||
|
||||
#include <QUndoCommand>
|
||||
#include <QList>
|
||||
|
||||
class RegionMap;
|
||||
|
||||
enum RMCommandId {
|
||||
ID_EditTilemap = 0,
|
||||
ID_EditLayout,
|
||||
ID_ResizeLayout,
|
||||
ID_EditEntry,
|
||||
ID_RemoveEntry,
|
||||
ID_AddEntry,
|
||||
ID_ResizeTilemap,
|
||||
ID_ClearEntries,
|
||||
};
|
||||
|
||||
|
||||
/// Implements a command to commit tilemap paint actions
|
||||
class EditTilemap : public QUndoCommand {
|
||||
public:
|
||||
EditTilemap(RegionMap *map, QByteArray oldTilemap, QByteArray newTilemap, unsigned actionId, QUndoCommand *parent = nullptr);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
||||
bool mergeWith(const QUndoCommand *command) override;
|
||||
int id() const override { return RMCommandId::ID_EditTilemap; }
|
||||
|
||||
protected:
|
||||
RegionMap *map;
|
||||
|
||||
QByteArray oldTilemap;
|
||||
QByteArray newTilemap;
|
||||
|
||||
unsigned actionId;
|
||||
};
|
||||
|
||||
|
||||
/// Edit region map section layout
|
||||
class EditLayout : public QUndoCommand {
|
||||
public:
|
||||
EditLayout(RegionMap *map, QString layer, int index, QList<LayoutSquare> oldLayout, QList<LayoutSquare> newLayout, QUndoCommand *parent = nullptr);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
||||
bool mergeWith(const QUndoCommand *command) override;
|
||||
int id() const override { return RMCommandId::ID_EditLayout; }
|
||||
|
||||
private:
|
||||
RegionMap *map;
|
||||
|
||||
int index;
|
||||
QString layer;
|
||||
QList<LayoutSquare> oldLayout;
|
||||
QList<LayoutSquare> newLayout;
|
||||
};
|
||||
|
||||
|
||||
/// Edit Layout Dimensions
|
||||
class ResizeLayout : public QUndoCommand {
|
||||
public:
|
||||
ResizeLayout(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;
|
||||
void redo() override;
|
||||
|
||||
bool mergeWith(const QUndoCommand *command) override;
|
||||
int id() const override { return RMCommandId::ID_ResizeLayout; }
|
||||
|
||||
private:
|
||||
RegionMap *map;
|
||||
|
||||
int oldWidth;
|
||||
int oldHeight;
|
||||
int newWidth;
|
||||
int newHeight;
|
||||
QMap<QString, QList<LayoutSquare>> oldLayouts;
|
||||
QMap<QString, QList<LayoutSquare>> newLayouts;
|
||||
};
|
||||
|
||||
|
||||
/// Edit Entry Value
|
||||
class EditEntry : public QUndoCommand {
|
||||
public:
|
||||
EditEntry(RegionMap *map, QString section, MapSectionEntry oldEntry, MapSectionEntry newEntry, QUndoCommand *parent = nullptr);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
||||
bool mergeWith(const QUndoCommand *command) override;
|
||||
int id() const override { return RMCommandId::ID_EditEntry; }
|
||||
|
||||
protected:
|
||||
RegionMap *map;
|
||||
|
||||
QString section;
|
||||
MapSectionEntry oldEntry;
|
||||
MapSectionEntry newEntry;
|
||||
};
|
||||
|
||||
|
||||
/// Remove Entry
|
||||
class RemoveEntry : public EditEntry {
|
||||
public:
|
||||
RemoveEntry(RegionMap *map, QString section, MapSectionEntry oldEntry, MapSectionEntry newEntry, QUndoCommand *parent = nullptr);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
||||
int id() const override { return RMCommandId::ID_RemoveEntry; }
|
||||
};
|
||||
|
||||
|
||||
/// Add Entry
|
||||
class AddEntry : public EditEntry {
|
||||
public:
|
||||
AddEntry(RegionMap *map, QString section, MapSectionEntry oldEntry, MapSectionEntry newEntry, QUndoCommand *parent = nullptr);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
||||
int id() const override { return RMCommandId::ID_AddEntry; }
|
||||
};
|
||||
|
||||
|
||||
/// ResizeTilemap
|
||||
class ResizeTilemap : public EditTilemap {
|
||||
public:
|
||||
ResizeTilemap(RegionMap *map, QByteArray oldTilemap, QByteArray newTilemap,
|
||||
int oldWidth, int oldHeight, int newWidth, int newHeight, QUndoCommand *parent = nullptr);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
||||
int id() const override { return RMCommandId::ID_ResizeTilemap; }
|
||||
|
||||
private:
|
||||
int oldWidth;
|
||||
int oldHeight;
|
||||
int newWidth;
|
||||
int newHeight;
|
||||
};
|
||||
|
||||
|
||||
/// ClearEntries
|
||||
class ClearEntries : public QUndoCommand {
|
||||
public:
|
||||
ClearEntries(RegionMap *map, tsl::ordered_map<QString, MapSectionEntry>, QUndoCommand *parent = nullptr);
|
||||
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
||||
bool mergeWith(const QUndoCommand *command) override { return false; }
|
||||
int id() const override { return RMCommandId::ID_ClearEntries; }
|
||||
|
||||
private:
|
||||
RegionMap *map;
|
||||
tsl::ordered_map<QString, MapSectionEntry> entries;
|
||||
};
|
||||
|
||||
#endif // REGIONMAPEDITCOMMANDS_H
|
||||
@@ -22,4 +22,15 @@ public:
|
||||
static int getIndexInTileset(int);
|
||||
};
|
||||
|
||||
inline bool operator==(const Tile &a, const Tile &b) {
|
||||
return a.tileId == b.tileId &&
|
||||
a.xflip == b.xflip &&
|
||||
a.yflip == b.yflip &&
|
||||
a.palette == b.palette;
|
||||
}
|
||||
|
||||
inline bool operator!=(const Tile &a, const Tile &b) {
|
||||
return !(operator==(a, b));
|
||||
}
|
||||
|
||||
#endif // TILE_H
|
||||
|
||||
@@ -210,7 +210,7 @@ signals:
|
||||
void selectedObjectsChanged();
|
||||
void loadMapRequested(QString, QString);
|
||||
void wildMonDataChanged();
|
||||
void warpEventDoubleClicked(QString mapName, QString warpNum);
|
||||
void warpEventDoubleClicked(QString, QString, QString);
|
||||
void currentMetatilesSelectionChanged();
|
||||
void mapRulerStatusChanged(const QString &);
|
||||
void editedMapData();
|
||||
|
||||
@@ -212,7 +212,7 @@ private slots:
|
||||
void on_action_Reload_Project_triggered();
|
||||
void on_mapList_activated(const QModelIndex &index);
|
||||
void on_action_Save_Project_triggered();
|
||||
void openWarpMap(QString map_name, QString warp_num);
|
||||
void openWarpMap(QString map_name, QString event_id, QString event_group);
|
||||
|
||||
void duplicate();
|
||||
void setClipboardData(poryjson::Json::object);
|
||||
@@ -345,7 +345,7 @@ private:
|
||||
QPointer<RegionMapEditor> regionMapEditor = nullptr;
|
||||
QPointer<ShortcutsEditor> shortcutsEditor = nullptr;
|
||||
QPointer<MapImageExporter> mapImageExporter = nullptr;
|
||||
QPointer<NewMapPopup> newmapprompt = nullptr;
|
||||
QPointer<NewMapPopup> newMapPrompt = nullptr;
|
||||
QPointer<PreferenceEditor> preferenceEditor = nullptr;
|
||||
FilterChildrenProxyModel *mapListProxyModel;
|
||||
QStandardItemModel *mapListModel;
|
||||
@@ -418,6 +418,7 @@ private:
|
||||
void initShortcuts();
|
||||
void initExtraShortcuts();
|
||||
void setProjectSpecificUIVisibility();
|
||||
void setWildEncountersUIEnabled(bool enabled);
|
||||
void loadUserSettings();
|
||||
void applyMapListFilter(QString filterText);
|
||||
void restoreWindowState();
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "wildmoninfo.h"
|
||||
#include "parseutil.h"
|
||||
#include "orderedjson.h"
|
||||
#include "regionmap.h"
|
||||
|
||||
#include <QStringList>
|
||||
#include <QList>
|
||||
@@ -60,7 +61,7 @@ public:
|
||||
QMap<QString, int> mapSectionNameToValue;
|
||||
QMap<int, QString> mapSectionValueToName;
|
||||
QMap<QString, EventGraphics*> eventGraphicsMap;
|
||||
QStringList gfxNames;
|
||||
QMap<QString, int> gfxDefines;
|
||||
QStringList songNames;
|
||||
QStringList itemNames;
|
||||
QStringList flagNames;
|
||||
@@ -244,6 +245,7 @@ signals:
|
||||
void reloadProject();
|
||||
void uncheckMonitorFilesAction();
|
||||
void mapCacheCleared();
|
||||
void disableWildEncountersUI();
|
||||
};
|
||||
|
||||
#endif // PROJECT_H
|
||||
|
||||
@@ -11,6 +11,7 @@ public:
|
||||
explicit NewEventToolButton(QWidget *parent = nullptr);
|
||||
QString getSelectedEventType();
|
||||
QAction *newObjectAction;
|
||||
QAction *newCloneObjectAction;
|
||||
QAction *newWarpAction;
|
||||
QAction *newHealLocationAction;
|
||||
QAction *newTriggerAction;
|
||||
@@ -20,6 +21,7 @@ public:
|
||||
QAction *newSecretBaseAction;
|
||||
public slots:
|
||||
void newObject();
|
||||
void newCloneObject();
|
||||
void newWarp();
|
||||
void newHealLocation();
|
||||
void newTrigger();
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "regionmaplayoutpixmapitem.h"
|
||||
#include "regionmapentriespixmapitem.h"
|
||||
#include "regionmap.h"
|
||||
#include "orderedjson.h"
|
||||
#include "project.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
@@ -24,14 +26,9 @@ public:
|
||||
explicit RegionMapEditor(QWidget *parent = 0, Project *pro = nullptr);
|
||||
~RegionMapEditor();
|
||||
|
||||
RegionMap *region_map;
|
||||
|
||||
bool loadRegionMapData();
|
||||
bool loadCityMaps();
|
||||
void setCurrentSquareOptions();
|
||||
bool load();
|
||||
|
||||
void onRegionMapTileSelectorSelectedTileChanged(unsigned id);
|
||||
void onCityMapTileSelectorSelectedTileChanged(unsigned id);
|
||||
void onRegionMapTileSelectorHoveredTileChanged(unsigned id);
|
||||
void onRegionMapTileSelectorHoveredTileCleared();
|
||||
|
||||
@@ -42,10 +39,7 @@ public:
|
||||
void onRegionMapEntriesSelectedTileChanged(QString) {};
|
||||
void onRegionMapEntryDragged(int, int);
|
||||
|
||||
void undo();
|
||||
void redo();
|
||||
|
||||
void resize(int width, int height);
|
||||
void resizeTilemap(int width, int height);
|
||||
|
||||
QObjectList shortcutableObjects() const;
|
||||
|
||||
@@ -56,14 +50,19 @@ private:
|
||||
Ui::RegionMapEditor *ui;
|
||||
Project *project;
|
||||
|
||||
History<RegionMapHistoryItem*> history;
|
||||
RegionMap *region_map = nullptr;
|
||||
tsl::ordered_map<QString, RegionMap *> region_maps;
|
||||
|
||||
int currIndex;
|
||||
unsigned selectedCityTile;
|
||||
unsigned selectedImageTile;
|
||||
poryjson::Json rmConfigJson;
|
||||
|
||||
bool configSaved = false;
|
||||
|
||||
QUndoGroup history;
|
||||
|
||||
int currIndex = 0;
|
||||
unsigned selectedImageTile = 0;
|
||||
QString activeEntry;
|
||||
|
||||
bool hasUnsavedChanges = false;
|
||||
bool cityMapFirstDraw = true;
|
||||
bool regionMapFirstDraw = true;
|
||||
bool entriesFirstDraw = true;
|
||||
@@ -72,19 +71,32 @@ private:
|
||||
double initialScale = 30.0;
|
||||
|
||||
QGraphicsScene *scene_region_map_image = nullptr;
|
||||
QGraphicsScene *scene_city_map_image = nullptr;
|
||||
QGraphicsScene *scene_region_map_layout = nullptr;
|
||||
QGraphicsScene *scene_region_map_entries = nullptr;
|
||||
QGraphicsScene *scene_region_map_tiles = nullptr;
|
||||
QGraphicsScene *scene_city_map_tiles = nullptr;
|
||||
|
||||
TilemapTileSelector *mapsquare_selector_item = nullptr;
|
||||
TilemapTileSelector *city_map_selector_item = nullptr;
|
||||
|
||||
RegionMapEntriesPixmapItem *region_map_entries_item = nullptr;
|
||||
RegionMapLayoutPixmapItem *region_map_layout_item = nullptr;
|
||||
RegionMapPixmapItem *region_map_item = nullptr;
|
||||
CityMapPixmapItem *city_map_item = nullptr;
|
||||
|
||||
bool reload();
|
||||
bool setup();
|
||||
void clear();
|
||||
|
||||
bool saveRegionMap(RegionMap *map);
|
||||
void saveConfig();
|
||||
bool loadRegionMapEntries();
|
||||
bool saveRegionMapEntries();
|
||||
tsl::ordered_map<QString, MapSectionEntry> region_map_entries;
|
||||
|
||||
bool buildConfigDialog();
|
||||
poryjson::Json configRegionMapDialog();
|
||||
poryjson::Json buildDefaultJson();
|
||||
bool verifyConfig(poryjson::Json cfg);
|
||||
|
||||
bool modified();
|
||||
|
||||
void initShortcuts();
|
||||
void displayRegionMap();
|
||||
@@ -94,47 +106,46 @@ private:
|
||||
void displayRegionMapLayoutOptions();
|
||||
void updateRegionMapLayoutOptions(int index);
|
||||
void displayRegionMapTileSelector();
|
||||
void displayCityMapTileSelector();
|
||||
void displayCityMap(QString name);
|
||||
void updateLayerDisplayed();
|
||||
void displayRegionMapEntryOptions();
|
||||
void updateRegionMapEntryOptions(QString);
|
||||
void importTileImage(bool city = false);
|
||||
|
||||
bool createCityMap(QString name);
|
||||
bool tryInsertNewMapEntry(QString);
|
||||
void setRegionMap(RegionMap *map);
|
||||
|
||||
void restoreWindowState();
|
||||
void closeEvent(QCloseEvent* event);
|
||||
|
||||
private slots:
|
||||
void on_action_RegionMap_Save_triggered();
|
||||
void on_action_RegionMap_Undo_triggered();
|
||||
void on_action_RegionMap_Redo_triggered();
|
||||
void on_actionSave_All_triggered();
|
||||
void on_action_RegionMap_Resize_triggered();
|
||||
void on_action_RegionMap_ClearImage_triggered();
|
||||
void on_action_RegionMap_ClearLayout_triggered();
|
||||
void on_action_RegionMap_ClearEntries_triggered();
|
||||
void on_action_Swap_triggered();
|
||||
void on_action_Import_RegionMap_ImageTiles_triggered();
|
||||
void on_action_Import_CityMap_ImageTiles_triggered();
|
||||
void on_action_Replace_triggered();
|
||||
void on_action_Configure_triggered();
|
||||
void on_tabWidget_Region_Map_currentChanged(int);
|
||||
void on_pushButton_RM_Options_delete_clicked();
|
||||
void on_comboBox_RM_ConnectedMap_textActivated(const QString &);
|
||||
void on_comboBox_RM_Entry_MapSection_textActivated(const QString &);
|
||||
void on_comboBox_regionSelector_textActivated(const QString &);
|
||||
void on_comboBox_layoutLayer_textActivated(const QString &);
|
||||
void on_spinBox_RM_Entry_x_valueChanged(int);
|
||||
void on_spinBox_RM_Entry_y_valueChanged(int);
|
||||
void on_spinBox_RM_Entry_width_valueChanged(int);
|
||||
void on_spinBox_RM_Entry_height_valueChanged(int);
|
||||
void on_pushButton_CityMap_add_clicked();
|
||||
void on_pushButton_entryActivate_clicked();
|
||||
void on_spinBox_RM_LayoutWidth_valueChanged(int);
|
||||
void on_spinBox_RM_LayoutHeight_valueChanged(int);
|
||||
void on_spinBox_tilePalette_valueChanged(int);
|
||||
void on_checkBox_tileHFlip_stateChanged(int);
|
||||
void on_checkBox_tileVFlip_stateChanged(int);
|
||||
void on_verticalSlider_Zoom_Map_Image_valueChanged(int);
|
||||
void on_verticalSlider_Zoom_Image_Tiles_valueChanged(int);
|
||||
void on_verticalSlider_Zoom_City_Map_valueChanged(int);
|
||||
void on_verticalSlider_Zoom_City_Tiles_valueChanged(int);
|
||||
void on_comboBox_CityMap_picker_currentTextChanged(const QString &);
|
||||
void on_lineEdit_RM_MapName_textEdited(const QString &);
|
||||
void onHoveredRegionMapTileChanged(int x, int y);
|
||||
void onHoveredRegionMapTileCleared();
|
||||
void mouseEvent_region_map(QGraphicsSceneMouseEvent *event, RegionMapPixmapItem *item);
|
||||
void mouseEvent_city_map(QGraphicsSceneMouseEvent *event, CityMapPixmapItem *item);
|
||||
};
|
||||
|
||||
#endif // REGIONMAPEDITOR_H
|
||||
|
||||
@@ -17,12 +17,14 @@ public:
|
||||
this->tile_selector = tile_selector;
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
RegionMap *region_map;
|
||||
RegionMap *region_map = nullptr;
|
||||
TilemapTileSelector *tile_selector;
|
||||
|
||||
virtual void paint(QGraphicsSceneMouseEvent *);
|
||||
virtual void fill(QGraphicsSceneMouseEvent *);
|
||||
virtual void select(QGraphicsSceneMouseEvent *);
|
||||
virtual void draw();
|
||||
void floodFill(int x, int y, std::shared_ptr<TilemapTile> oldTile, std::shared_ptr<TilemapTile> newTile);
|
||||
|
||||
signals:
|
||||
void mouseEvent(QGraphicsSceneMouseEvent *, RegionMapPixmapItem *);
|
||||
|
||||
47
include/ui/regionmappropertiesdialog.h
Normal file
47
include/ui/regionmappropertiesdialog.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef REGIONMAPPROPERTIESDIALOG_H
|
||||
#define REGIONMAPPROPERTIESDIALOG_H
|
||||
|
||||
#include "orderedjson.h"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QFileDialog>
|
||||
|
||||
class Project;
|
||||
|
||||
namespace Ui {
|
||||
class RegionMapPropertiesDialog;
|
||||
}
|
||||
|
||||
class RegionMapPropertiesDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RegionMapPropertiesDialog(QWidget *parent = nullptr);
|
||||
~RegionMapPropertiesDialog();
|
||||
|
||||
void setProject(Project *project) { this->project = project; }
|
||||
|
||||
void setProperties(poryjson::Json object);
|
||||
poryjson::Json saveToJson();
|
||||
|
||||
virtual void accept() override;
|
||||
|
||||
private:
|
||||
Ui::RegionMapPropertiesDialog *ui;
|
||||
Project *project = nullptr;
|
||||
|
||||
void hideMessages();
|
||||
|
||||
QString browse(QString filter, QFileDialog::FileMode mode);
|
||||
|
||||
private slots:
|
||||
void on_browse_tilesetImagePath_clicked();
|
||||
void on_browse_tilemapBinPath_clicked();
|
||||
void on_browse_tilemapPalettePath_clicked();
|
||||
void on_browse_layoutPath_clicked();
|
||||
|
||||
//void on_buttonBox_accepted();
|
||||
};
|
||||
|
||||
#endif // REGIONMAPPROPERTIESDIALOG_H
|
||||
@@ -1,29 +1,165 @@
|
||||
#pragma once
|
||||
#ifndef TILEMAPTILESELECTOR_H
|
||||
#define TILEMAPTILESELECTOR_H
|
||||
|
||||
#include "selectablepixmapitem.h"
|
||||
#include "paletteutil.h"
|
||||
|
||||
#include <memory>
|
||||
using std::shared_ptr;
|
||||
|
||||
enum class TilemapFormat { Plain, BPP_4, BPP_8 };
|
||||
|
||||
class TilemapTile {
|
||||
unsigned raw_ = 0;
|
||||
unsigned id_ = 0;
|
||||
bool hFlip_ = false;
|
||||
bool vFlip_ = false;
|
||||
int palette_ = 0;
|
||||
|
||||
protected:
|
||||
TilemapTile(unsigned raw, unsigned id, bool hFlip, bool vFlip, int palette) : raw_(raw), id_(id), hFlip_(hFlip), vFlip_(vFlip), palette_(palette) {}
|
||||
virtual ~TilemapTile() {}
|
||||
|
||||
public:
|
||||
TilemapTile()=default;
|
||||
|
||||
TilemapTile(TilemapTile &other) {
|
||||
this->raw_ = other.raw();
|
||||
this->id_ = other.id();
|
||||
this->hFlip_ = other.hFlip();
|
||||
this->vFlip_ = other.vFlip();
|
||||
this->palette_ = other.palette();
|
||||
}
|
||||
|
||||
TilemapTile &operator=(const TilemapTile &other) {
|
||||
this->raw_ = other.raw();
|
||||
this->id_ = other.id();
|
||||
this->hFlip_ = other.hFlip();
|
||||
this->vFlip_ = other.vFlip();
|
||||
this->palette_ = other.palette();
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual void copy(TilemapTile &other) {
|
||||
this->raw_ = other.raw();
|
||||
this->id_ = other.id();
|
||||
this->hFlip_ = other.hFlip();
|
||||
this->vFlip_ = other.vFlip();
|
||||
this->palette_ = other.palette();
|
||||
}
|
||||
|
||||
virtual unsigned raw() const { return this->raw_; }
|
||||
virtual unsigned id() const { return this->id_; }
|
||||
virtual bool hFlip() const { return this->hFlip_; }
|
||||
virtual bool vFlip() const { return this->vFlip_; }
|
||||
virtual int palette() const { return this->palette_; }
|
||||
|
||||
virtual void setId(unsigned id) { this->id_ = id; }
|
||||
virtual void setHFlip(bool hFlip) { this->hFlip_ = hFlip; }
|
||||
virtual void setVFlip(bool vFlip) { this->vFlip_ = vFlip; }
|
||||
virtual void setPalette(int palette) { this->palette_ = palette; }
|
||||
|
||||
bool operator==(const TilemapTile& other) {
|
||||
return (this->raw() == other.raw());
|
||||
}
|
||||
|
||||
virtual QString info() const {
|
||||
return QString("Tile: 0x") + QString("%1 ").arg(this->id(), 4, 16, QChar('0')).toUpper();
|
||||
}
|
||||
};
|
||||
|
||||
class PlainTile : public TilemapTile {
|
||||
public:
|
||||
PlainTile(unsigned raw) : TilemapTile(raw, raw, false, false, 0) {}
|
||||
|
||||
~PlainTile() {}
|
||||
|
||||
virtual unsigned raw () const override { return id(); }
|
||||
};
|
||||
|
||||
class BPP4Tile : public TilemapTile {
|
||||
public:
|
||||
BPP4Tile(unsigned raw) : TilemapTile(
|
||||
raw,
|
||||
raw & 0x3ff, // tileId
|
||||
!!(raw & 0x0400), // hFlip
|
||||
!!(raw & 0x0800), // vFlip
|
||||
(raw & 0xf000) >> 12 // palette
|
||||
) {}
|
||||
|
||||
~BPP4Tile() {}
|
||||
|
||||
virtual unsigned raw () const override {
|
||||
return (id()) | (hFlip() << 10) | (vFlip() << 11) | (palette() << 12);
|
||||
}
|
||||
|
||||
virtual QString info() const override {
|
||||
return TilemapTile::info() + QString("hFlip: %1 vFlip: %2 palette: %3").arg(this->hFlip()).arg(this->vFlip()).arg(this->palette());
|
||||
}
|
||||
};
|
||||
|
||||
class BPP8Tile : public TilemapTile {
|
||||
public:
|
||||
BPP8Tile(unsigned raw) : TilemapTile(
|
||||
raw,
|
||||
raw & 0x3ff, // tileId
|
||||
!!(raw & 0x0400), // hFlip
|
||||
!!(raw & 0x0800), // vFlip
|
||||
0 // palette
|
||||
) {}
|
||||
|
||||
~BPP8Tile() {}
|
||||
|
||||
virtual unsigned raw () const override {
|
||||
return (id()) | (hFlip() << 10) | (vFlip() << 11);
|
||||
}
|
||||
|
||||
virtual QString info() const override {
|
||||
return TilemapTile::info() + QString("hFlip: %1 vFlip: %2").arg(this->hFlip()).arg(this->vFlip());
|
||||
}
|
||||
};
|
||||
|
||||
class TilemapTileSelector: public SelectablePixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TilemapTileSelector(QPixmap pixmap_): SelectablePixmapItem(8, 8, 1, 1) {
|
||||
this->tilemap = pixmap_;
|
||||
this->setPixmap(this->tilemap);
|
||||
this->numTilesWide = tilemap.width() / 8;
|
||||
TilemapTileSelector(QString tilesetFilepath, TilemapFormat format, QString palFilepath): SelectablePixmapItem(8, 8, 1, 1) {
|
||||
this->tileset = QImage(tilesetFilepath);
|
||||
this->format = format;
|
||||
bool err;
|
||||
if (!palFilepath.isEmpty()) {
|
||||
this->palette = PaletteUtil::parse(palFilepath, &err);
|
||||
}
|
||||
this->setPixmap(QPixmap::fromImage(this->tileset));
|
||||
this->numTilesWide = this->tileset.width() / 8;
|
||||
this->selectedTile = 0x00;
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
void draw();
|
||||
void select(unsigned tileId);
|
||||
unsigned getSelectedTile();
|
||||
QImage setPalette(int index);
|
||||
|
||||
int pixelWidth;
|
||||
int pixelHeight;
|
||||
|
||||
void select(unsigned tileId);
|
||||
unsigned selectedTile = 0;
|
||||
|
||||
QPixmap tilemap;
|
||||
QImage tileImg(unsigned tileId);
|
||||
void selectVFlip(bool hFlip) { this->tile_hFlip = hFlip; }
|
||||
bool tile_hFlip = false;
|
||||
|
||||
void selectHFlip(bool vFlip) { this->tile_vFlip = vFlip; }
|
||||
bool tile_vFlip = false;
|
||||
|
||||
void selectPalette(int palette) {
|
||||
this->tile_palette = palette;
|
||||
this->draw();
|
||||
}
|
||||
int tile_palette = 0;
|
||||
|
||||
QImage tileset;
|
||||
TilemapFormat format = TilemapFormat::Plain;
|
||||
QList<QRgb> palette;
|
||||
QImage tileImg(shared_ptr<TilemapTile> tile);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent*);
|
||||
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
void updateMap(Map *map);
|
||||
void updateTilesets(QString primaryTilsetLabel, QString secondaryTilesetLabel);
|
||||
bool selectMetatile(uint16_t metatileId);
|
||||
uint16_t getSelectedMetatile();
|
||||
uint16_t getSelectedMetatileId();
|
||||
void setMetatileLabel(QString label);
|
||||
|
||||
QObjectList shortcutableObjects() const;
|
||||
@@ -105,6 +105,10 @@ private slots:
|
||||
|
||||
void on_copyButton_metatileLabel_clicked();
|
||||
|
||||
void on_actionCopy_triggered();
|
||||
|
||||
void on_actionPaste_triggered();
|
||||
|
||||
private:
|
||||
void initUi();
|
||||
void setMetatileBehaviors();
|
||||
@@ -129,6 +133,7 @@ private:
|
||||
void closeEvent(QCloseEvent*);
|
||||
void countMetatileUsage();
|
||||
void countTileUsage();
|
||||
bool replaceMetatile(uint16_t metatileId, Metatile * src);
|
||||
|
||||
Ui::TilesetEditor *ui;
|
||||
History<MetatileHistoryItem*> metatileHistory;
|
||||
@@ -139,6 +144,7 @@ private:
|
||||
Project *project = nullptr;
|
||||
Map *map = nullptr;
|
||||
Metatile *metatile = nullptr;
|
||||
Metatile *copiedMetatile = nullptr;
|
||||
int paletteId;
|
||||
bool tileXFlip;
|
||||
bool tileYFlip;
|
||||
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
void draw();
|
||||
bool select(uint16_t metatileId);
|
||||
void setTilesets(Tileset*, Tileset*, bool draw = true);
|
||||
uint16_t getSelectedMetatile();
|
||||
uint16_t getSelectedMetatileId();
|
||||
void updateSelectedMetatile();
|
||||
QPoint getMetatileIdCoordsOnWidget(uint16_t metatileId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user