mirror of
https://github.com/huderlem/porymap.git
synced 2026-10-02 21:06:37 -05:00
Merge branch 'dev' of https://github.com/huderlem/porymap into utility
This commit is contained in:
@@ -79,6 +79,7 @@ public:
|
||||
this->textEditorGotoLine = "";
|
||||
this->paletteEditorBitDepth = 24;
|
||||
this->projectSettingsTab = 0;
|
||||
this->loadAllEventScripts = false;
|
||||
this->warpBehaviorWarningDisabled = false;
|
||||
this->eventDeleteWarningDisabled = false;
|
||||
this->eventOverlayEnabled = false;
|
||||
@@ -87,6 +88,7 @@ public:
|
||||
this->lastUpdateCheckVersion = porymapVersion;
|
||||
this->rateLimitTimes.clear();
|
||||
this->eventSelectionShapeMode = QGraphicsPixmapItem::MaskShape;
|
||||
this->shownInGameReloadMessage = false;
|
||||
}
|
||||
void addRecentProject(QString project);
|
||||
void setRecentProjects(QStringList projects);
|
||||
@@ -135,6 +137,7 @@ public:
|
||||
QString textEditorGotoLine;
|
||||
int paletteEditorBitDepth;
|
||||
int projectSettingsTab;
|
||||
bool loadAllEventScripts;
|
||||
bool warpBehaviorWarningDisabled;
|
||||
bool eventDeleteWarningDisabled;
|
||||
bool eventOverlayEnabled;
|
||||
@@ -146,6 +149,7 @@ public:
|
||||
QByteArray wildMonChartGeometry;
|
||||
QByteArray newMapDialogGeometry;
|
||||
QByteArray newLayoutDialogGeometry;
|
||||
bool shownInGameReloadMessage;
|
||||
|
||||
protected:
|
||||
virtual QString getConfigFilepath() override;
|
||||
@@ -320,6 +324,7 @@ public:
|
||||
this->unusedTileNormal = 0x3014;
|
||||
this->unusedTileCovered = 0x0000;
|
||||
this->unusedTileSplit = 0x0000;
|
||||
this->maxEventsPerGroup = 255;
|
||||
this->identifiers.clear();
|
||||
this->readKeys.clear();
|
||||
}
|
||||
@@ -389,6 +394,7 @@ public:
|
||||
int collisionSheetWidth;
|
||||
int collisionSheetHeight;
|
||||
QList<uint32_t> warpBehaviors;
|
||||
int maxEventsPerGroup;
|
||||
|
||||
protected:
|
||||
virtual QString getConfigFilepath() override;
|
||||
|
||||
@@ -41,14 +41,6 @@ public:
|
||||
virtual void visitSign(SignEvent *) = 0;
|
||||
};
|
||||
|
||||
struct EventGraphics
|
||||
{
|
||||
QImage spritesheet;
|
||||
int spriteWidth;
|
||||
int spriteHeight;
|
||||
bool inanimate;
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// Event base class -- purely virtual
|
||||
@@ -64,11 +56,7 @@ public:
|
||||
Event& operator=(const Event &other) = delete;
|
||||
|
||||
protected:
|
||||
Event() {
|
||||
this->spriteWidth = 16;
|
||||
this->spriteHeight = 16;
|
||||
this->usingSprite = false;
|
||||
}
|
||||
Event() {}
|
||||
|
||||
// public enums & static methods
|
||||
public:
|
||||
@@ -119,8 +107,6 @@ public:
|
||||
|
||||
static Event* create(Event::Type type);
|
||||
|
||||
static QMap<Event::Group, const QPixmap*> icons;
|
||||
|
||||
// standard public methods
|
||||
public:
|
||||
|
||||
@@ -143,8 +129,8 @@ public:
|
||||
int getZ() const { return this->elevation; }
|
||||
int getElevation() const { return this->elevation; }
|
||||
|
||||
int getPixelX() const { return (this->x * 16) - qMax(0, (this->spriteWidth - 16) / 2); }
|
||||
int getPixelY() const { return (this->y * 16) - qMax(0, this->spriteHeight - 16); }
|
||||
int getPixelX() const { return (this->x * 16) - qMax(0, (pixmap.width() - 16) / 2); }
|
||||
int getPixelY() const { return (this->y * 16) - qMax(0, pixmap.height() - 16); }
|
||||
|
||||
virtual EventFrame *getEventFrame();
|
||||
virtual EventFrame *createEventFrame() = 0;
|
||||
@@ -172,25 +158,17 @@ public:
|
||||
void setPixmapItem(DraggablePixmapItem *item);
|
||||
DraggablePixmapItem *getPixmapItem() const { return this->pixmapItem; }
|
||||
|
||||
void setUsingSprite(bool newUsingSprite) { this->usingSprite = newUsingSprite; }
|
||||
bool getUsingSprite() const { return this->usingSprite; }
|
||||
|
||||
void setSpriteWidth(int newSpriteWidth) { this->spriteWidth = newSpriteWidth; }
|
||||
int getspriteWidth() const { return this->spriteWidth; }
|
||||
|
||||
void setSpriteHeight(int newSpriteHeight) { this->spriteHeight = newSpriteHeight; }
|
||||
int getspriteHeight() const { return this->spriteHeight; }
|
||||
void setUsesDefaultPixmap(bool newUsesDefaultPixmap) { this->usesDefaultPixmap = newUsesDefaultPixmap; }
|
||||
bool getUsesDefaultPixmap() const { return this->usesDefaultPixmap; }
|
||||
|
||||
int getEventIndex();
|
||||
|
||||
void setIdName(QString newIdName) { this->idName = newIdName; }
|
||||
QString getIdName() const { return this->idName; }
|
||||
|
||||
static QString eventGroupToString(Event::Group group);
|
||||
static QString eventTypeToString(Event::Type type);
|
||||
static Event::Type eventTypeFromString(QString type);
|
||||
static void clearIcons();
|
||||
static void setIcons();
|
||||
static QString groupToString(Event::Group group);
|
||||
static QString typeToString(Event::Type type);
|
||||
static Event::Type typeFromString(QString type);
|
||||
|
||||
// protected attributes
|
||||
protected:
|
||||
@@ -204,9 +182,7 @@ protected:
|
||||
int y = 0;
|
||||
int elevation = 0;
|
||||
|
||||
int spriteWidth = 16;
|
||||
int spriteHeight = 16;
|
||||
bool usingSprite = false;
|
||||
bool usesDefaultPixmap = true;
|
||||
|
||||
// Some events can have an associated #define name that should be unique to this event.
|
||||
// e.g. object events can have a 'LOCALID', or Heal Locations have a 'HEAL_LOCATION' id.
|
||||
@@ -273,10 +249,6 @@ public:
|
||||
void setFlag(QString newFlag) { this->flag = newFlag; }
|
||||
QString getFlag() const { return this->flag; }
|
||||
|
||||
public:
|
||||
void setFrameFromMovement(QString movement);
|
||||
void setPixmapFromSpritesheet(EventGraphics * gfx);
|
||||
|
||||
|
||||
protected:
|
||||
QString gfx;
|
||||
|
||||
@@ -86,6 +86,7 @@ public:
|
||||
void removeEvent(Event *);
|
||||
void addEvent(Event *);
|
||||
int getIndexOfEvent(Event *) const;
|
||||
bool hasEvent(Event *) const;
|
||||
|
||||
void deleteConnections();
|
||||
QList<MapConnection*> getConnections() const;
|
||||
|
||||
@@ -26,6 +26,7 @@ public:
|
||||
|
||||
QString id;
|
||||
QString name;
|
||||
QString newFolderPath;
|
||||
|
||||
int width;
|
||||
int height;
|
||||
|
||||
@@ -44,25 +44,24 @@ class ParseUtil
|
||||
public:
|
||||
ParseUtil();
|
||||
void set_root(const QString &dir);
|
||||
static QString readTextFile(const QString &path);
|
||||
static QString readTextFile(const QString &path, QString *error = nullptr);
|
||||
void invalidateTextFile(const QString &path);
|
||||
static int textFileLineCount(const QString &path);
|
||||
QList<QStringList> parseAsm(const QString &filename);
|
||||
QStringList readCArray(const QString &filename, const QString &label);
|
||||
QMap<QString, QStringList> readCArrayMulti(const QString &filename);
|
||||
QMap<QString, QString> readNamedIndexCArray(const QString &text, const QString &label);
|
||||
QMap<QString, QString> readNamedIndexCArray(const QString &text, const QString &label, QString *error = nullptr);
|
||||
QString readCIncbin(const QString &text, const QString &label);
|
||||
QMap<QString, QString> readCIncbinMulti(const QString &filepath);
|
||||
QStringList readCIncbinArray(const QString &filename, const QString &label);
|
||||
QMap<QString, int> readCDefinesByRegex(const QString &filename, const QStringList ®exList);
|
||||
QMap<QString, int> readCDefinesByName(const QString &filename, const QStringList &names);
|
||||
QStringList readCDefineNames(const QString &filename, const QStringList ®exList);
|
||||
QMap<QString, int> readCDefinesByRegex(const QString &filename, const QStringList ®exList, QString *error = nullptr);
|
||||
QMap<QString, int> readCDefinesByName(const QString &filename, const QStringList &names, QString *error = nullptr);
|
||||
QStringList readCDefineNames(const QString &filename, const QStringList ®exList, QString *error = nullptr);
|
||||
tsl::ordered_map<QString, QHash<QString, QString>> readCStructs(const QString &, const QString & = "", const QHash<int, QString>& = {});
|
||||
QList<QStringList> getLabelMacros(const QList<QStringList>&, const QString&);
|
||||
QStringList getLabelValues(const QList<QStringList>&, const QString&);
|
||||
bool tryParseJsonFile(QJsonDocument *out, const QString &filepath);
|
||||
bool tryParseOrderedJsonFile(poryjson::Json::object *out, const QString &filepath);
|
||||
bool ensureFieldsExist(const QJsonObject &obj, const QList<QString> &fields);
|
||||
bool tryParseJsonFile(QJsonDocument *out, const QString &filepath, QString *error = nullptr);
|
||||
bool tryParseOrderedJsonFile(poryjson::Json::object *out, const QString &filepath, QString *error = nullptr);
|
||||
|
||||
// Returns the 1-indexed line number for the definition of scriptLabel in the scripts file at filePath.
|
||||
// Returns 0 if a definition for scriptLabel cannot be found.
|
||||
@@ -102,8 +101,8 @@ private:
|
||||
QMap<QString,QString> expressions; // Map of all define names encountered to their expressions
|
||||
QStringList filteredNames; // List of define names that matched the search text, in the order that they were encountered
|
||||
};
|
||||
ParsedDefines readCDefines(const QString &filename, const QStringList &filterList, bool useRegex);
|
||||
QMap<QString, int> evaluateCDefines(const QString &filename, const QStringList &filterList, bool useRegex);
|
||||
ParsedDefines readCDefines(const QString &filename, const QStringList &filterList, bool useRegex, QString *error);
|
||||
QMap<QString, int> evaluateCDefines(const QString &filename, const QStringList &filterList, bool useRegex, QString *error);
|
||||
bool defineNameMatchesFilter(const QString &name, const QStringList &filterList) const;
|
||||
bool defineNameMatchesFilter(const QString &name, const QList<QRegularExpression> &filterList) const;
|
||||
|
||||
|
||||
@@ -57,9 +57,8 @@ public:
|
||||
GridSettings gridSettings;
|
||||
|
||||
void setProject(Project * project);
|
||||
void save();
|
||||
void saveProject();
|
||||
void saveUiFields();
|
||||
void saveAll();
|
||||
void saveCurrent();
|
||||
void saveEncounterTabData();
|
||||
|
||||
void closeProject();
|
||||
@@ -110,15 +109,14 @@ public:
|
||||
|
||||
DraggablePixmapItem *addEventPixmapItem(Event *event);
|
||||
void removeEventPixmapItem(Event *event);
|
||||
bool eventLimitReached(Map *, Event::Type);
|
||||
void selectMapEvent(DraggablePixmapItem *item, bool toggle = false);
|
||||
DraggablePixmapItem *addNewEvent(Event::Type type);
|
||||
void updateSelectedEvents();
|
||||
bool canAddEvents(const QList<Event*> &events);
|
||||
void selectMapEvent(Event *event, bool toggle = false);
|
||||
Event *addNewEvent(Event::Type type);
|
||||
void updateEvents();
|
||||
void duplicateSelectedEvents();
|
||||
void redrawAllEvents();
|
||||
void redrawEvents(const QList<Event*> &events);
|
||||
void redrawEventPixmapItem(DraggablePixmapItem *item);
|
||||
QList<DraggablePixmapItem *> getEventPixmapItems();
|
||||
qreal getEventOpacity(const Event *event) const;
|
||||
|
||||
void updateCursorRectPos(int x, int y);
|
||||
@@ -153,7 +151,7 @@ public:
|
||||
CurrentSelectedMetatilesPixmapItem *current_metatile_selection_item = nullptr;
|
||||
QPointer<MovementPermissionsSelector> movement_permissions_selector_item = nullptr;
|
||||
|
||||
QList<DraggablePixmapItem *> *selected_events = nullptr;
|
||||
QList<Event*> selectedEvents;
|
||||
QPointer<ConnectionPixmapItem> selected_connection_item = nullptr;
|
||||
QPointer<MapConnection> connection_to_select = nullptr;
|
||||
|
||||
@@ -185,7 +183,6 @@ public:
|
||||
void shouldReselectEvents();
|
||||
void scaleMapView(int);
|
||||
static void openInTextEditor(const QString &path, int lineNum = 0);
|
||||
bool eventLimitReached(Event::Type type);
|
||||
void setCollisionGraphics();
|
||||
|
||||
public slots:
|
||||
@@ -204,6 +201,7 @@ private:
|
||||
|
||||
EditMode editMode = EditMode::None;
|
||||
|
||||
void save(bool currentOnly);
|
||||
void clearMap();
|
||||
void clearMetatileSelector();
|
||||
void clearMovementPermissionSelector();
|
||||
|
||||
@@ -182,15 +182,15 @@ public:
|
||||
|
||||
// Parse. If parse fails, return Json() and assign an error message to err.
|
||||
static Json parse(const QString & in,
|
||||
QString & err,
|
||||
QString * err = nullptr,
|
||||
JsonParse strategy = JsonParse::STANDARD);
|
||||
static Json parse(const char * in,
|
||||
QString & err,
|
||||
QString * err = nullptr,
|
||||
JsonParse strategy = JsonParse::STANDARD) {
|
||||
if (in) {
|
||||
return parse(QString(in), err, strategy);
|
||||
} else {
|
||||
err = "null input";
|
||||
if (err) *err = "null input";
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,6 +175,7 @@ private slots:
|
||||
void on_action_Reload_Project_triggered();
|
||||
void on_action_Close_Project_triggered();
|
||||
void on_action_Save_Project_triggered();
|
||||
void save(bool currentOnly = false);
|
||||
|
||||
void openWarpMap(QString map_name, int event_id, Event::Group event_group);
|
||||
|
||||
@@ -218,7 +219,6 @@ private slots:
|
||||
void on_actionMove_triggered();
|
||||
void on_actionMap_Shift_triggered();
|
||||
|
||||
void addNewEvent(Event::Type type);
|
||||
void tryAddEventTab(QWidget * tab);
|
||||
void displayEventTabs();
|
||||
void updateSelectedEvents();
|
||||
@@ -333,7 +333,7 @@ private:
|
||||
|
||||
MapHeaderForm *mapHeaderForm = nullptr;
|
||||
|
||||
QMap<Event::Group, DraggablePixmapItem*> lastSelectedEvent;
|
||||
QMap<Event::Group, Event*> lastSelectedEvent;
|
||||
|
||||
bool isProgrammaticEventTabChange;
|
||||
|
||||
@@ -361,6 +361,7 @@ private:
|
||||
NewLayoutDialog* createNewLayoutDialog(const Layout *layoutToCopy = nullptr);
|
||||
void openNewLayoutDialog();
|
||||
void openDuplicateLayoutDialog(const QString &layoutId);
|
||||
void openDuplicateMapOrLayoutDialog();
|
||||
void openNewMapGroupDialog();
|
||||
void openNewLocationDialog();
|
||||
void openSubWindow(QWidget * window);
|
||||
|
||||
@@ -45,7 +45,6 @@ public:
|
||||
QStringList layoutIdsMaster;
|
||||
QMap<QString, Layout*> mapLayouts;
|
||||
QMap<QString, Layout*> mapLayoutsMaster;
|
||||
QMap<QString, EventGraphics*> eventGraphicsMap;
|
||||
QMap<QString, int> gfxDefines;
|
||||
QString defaultSong;
|
||||
QStringList songNames;
|
||||
@@ -68,7 +67,6 @@ public:
|
||||
QMap<QString, uint16_t> unusedMetatileLabels;
|
||||
QMap<QString, uint32_t> metatileBehaviorMap;
|
||||
QMap<uint32_t, QString> metatileBehaviorMapInverse;
|
||||
QMap<QString, QString> facingDirections;
|
||||
ParseUtil parser;
|
||||
QFileSystemWatcher fileWatcher;
|
||||
QSet<QString> modifiedFiles;
|
||||
@@ -157,6 +155,7 @@ public:
|
||||
|
||||
void initTopLevelMapFields();
|
||||
bool readMapJson(const QString &mapName, QJsonDocument * out);
|
||||
bool loadMapEvent(Map *map, const QJsonObject &json, Event::Type defaultType = Event::Type::None);
|
||||
bool loadMapData(Map*);
|
||||
bool readMapLayouts();
|
||||
Layout *loadLayout(QString layoutId);
|
||||
@@ -167,13 +166,13 @@ public:
|
||||
void loadTilesetMetatileLabels(Tileset*);
|
||||
void readTilesetPaths(Tileset* tileset);
|
||||
|
||||
void saveAll();
|
||||
void saveGlobalData();
|
||||
void saveLayout(Layout *);
|
||||
void saveLayoutBlockdata(Layout *);
|
||||
void saveLayoutBorder(Layout *);
|
||||
void writeBlockdata(QString, const Blockdata &);
|
||||
void saveAllMaps();
|
||||
void saveMap(Map *);
|
||||
void saveAllDataStructures();
|
||||
void saveMap(Map *map, bool skipLayout = false);
|
||||
void saveConfig();
|
||||
void saveMapLayouts();
|
||||
void saveMapGroups();
|
||||
@@ -209,7 +208,10 @@ public:
|
||||
bool readFieldmapMasks();
|
||||
QMap<QString, QMap<QString, QString>> readObjEventGfxInfo();
|
||||
|
||||
void setEventPixmap(Event *event, bool forceLoad = false);
|
||||
QPixmap getEventPixmap(const QString &gfxName, const QString &movementName);
|
||||
QPixmap getEventPixmap(const QString &gfxName, int frame, bool hFlip);
|
||||
QPixmap getEventPixmap(Event::Group group);
|
||||
void loadEventPixmap(Event *event, bool forceLoad = false);
|
||||
|
||||
QString fixPalettePath(QString path);
|
||||
QString fixGraphicPath(QString path);
|
||||
@@ -217,6 +219,7 @@ public:
|
||||
static QString getScriptFileExtension(bool usePoryScript);
|
||||
QString getScriptDefaultString(bool usePoryScript, QString mapName) const;
|
||||
QStringList getEventScriptsFilePaths() const;
|
||||
void insertGlobalScriptLabels(QStringList &scriptLabels) const;
|
||||
|
||||
QString getDefaultPrimaryTilesetLabel() const;
|
||||
QString getDefaultSecondaryTilesetLabel() const;
|
||||
@@ -244,13 +247,25 @@ public:
|
||||
static int getMapDataSize(int width, int height);
|
||||
static bool mapDimensionsValid(int width, int height);
|
||||
bool calculateDefaultMapSize();
|
||||
static int getMaxObjectEvents();
|
||||
int getMaxEvents(Event::Group group);
|
||||
static QString getEmptyMapsecName();
|
||||
static QString getMapGroupPrefix();
|
||||
|
||||
private:
|
||||
QMap<QString, QString> mapSectionDisplayNames;
|
||||
QMap<QString, qint64> modifiedFileTimestamps;
|
||||
QMap<QString, QString> facingDirections;
|
||||
|
||||
struct EventGraphics
|
||||
{
|
||||
QString filepath;
|
||||
bool loaded = false;
|
||||
QImage spritesheet;
|
||||
int spriteWidth = -1;
|
||||
int spriteHeight = -1;
|
||||
bool inanimate = false;
|
||||
};
|
||||
QMap<QString, EventGraphics*> eventGraphicsMap;
|
||||
|
||||
void updateLayout(Layout *);
|
||||
|
||||
@@ -260,6 +275,8 @@ private:
|
||||
void ignoreWatchedFileTemporarily(QString filepath);
|
||||
void recordFileChange(const QString &filepath);
|
||||
|
||||
int maxEventsPerGroup;
|
||||
int maxObjectEvents;
|
||||
static int num_tiles_primary;
|
||||
static int num_tiles_total;
|
||||
static int num_metatiles_primary;
|
||||
@@ -267,7 +284,6 @@ private:
|
||||
static int num_pals_total;
|
||||
static int max_map_data_size;
|
||||
static int default_map_dimension;
|
||||
static int max_object_events;
|
||||
|
||||
signals:
|
||||
void fileChanged(const QString &filepath);
|
||||
@@ -280,6 +296,7 @@ signals:
|
||||
void mapSectionDisplayNameChanged(const QString &idName, const QString &displayName);
|
||||
void mapSectionIdNamesChanged(const QStringList &idNames);
|
||||
void mapsExcluded(const QStringList &excludedMapNames);
|
||||
void eventScriptLabelsRead();
|
||||
};
|
||||
|
||||
#endif // PROJECT_H
|
||||
|
||||
@@ -31,8 +31,6 @@ public:
|
||||
void invalidateUi();
|
||||
void invalidateValues();
|
||||
|
||||
void populateScriptDropdown(NoScrollComboBox * combo, Project * project);
|
||||
|
||||
virtual void setActive(bool active);
|
||||
|
||||
public:
|
||||
@@ -59,6 +57,8 @@ protected:
|
||||
bool initialized = false;
|
||||
bool connected = false;
|
||||
|
||||
void populateScriptDropdown(NoScrollComboBox * combo, Project * project);
|
||||
|
||||
private:
|
||||
Event *event;
|
||||
};
|
||||
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
signals:
|
||||
void preferencesSaved();
|
||||
void themeChanged(const QString &theme);
|
||||
void scriptSettingsChanged(bool on);
|
||||
|
||||
private:
|
||||
Ui::PreferenceEditor *ui;
|
||||
|
||||
Reference in New Issue
Block a user