Merge branch 'dev' of https://github.com/huderlem/porymap into event-selection

This commit is contained in:
GriffinR
2025-02-12 16:10:01 -05:00
36 changed files with 533 additions and 717 deletions

View File

@@ -80,6 +80,7 @@ public:
this->paletteEditorBitDepth = 24;
this->projectSettingsTab = 0;
this->warpBehaviorWarningDisabled = false;
this->eventDeleteWarningDisabled = false;
this->checkForUpdates = true;
this->lastUpdateCheckTime = QDateTime();
this->lastUpdateCheckVersion = porymapVersion;
@@ -134,6 +135,7 @@ public:
int paletteEditorBitDepth;
int projectSettingsTab;
bool warpBehaviorWarningDisabled;
bool eventDeleteWarningDisabled;
bool checkForUpdates;
QDateTime lastUpdateCheckTime;
QVersionNumber lastUpdateCheckVersion;
@@ -187,11 +189,6 @@ enum ProjectIdentifier {
symbol_obj_event_gfx_pointers,
symbol_pokemon_icon_table,
symbol_wild_encounters,
symbol_heal_locations_type,
symbol_heal_locations,
symbol_spawn_points,
symbol_spawn_maps,
symbol_spawn_npcs,
symbol_attribute_table,
symbol_tilesets_prefix,
symbol_dynamic_map_name,
@@ -217,7 +214,6 @@ enum ProjectIdentifier {
define_attribute_encounter,
define_metatile_label_prefix,
define_heal_locations_prefix,
define_spawn_prefix,
define_map_prefix,
define_map_dynamic,
define_map_empty,
@@ -250,6 +246,7 @@ enum ProjectFilePath {
json_map_groups,
json_layouts,
json_wild_encounters,
json_heal_locations,
json_region_map_entries,
json_region_porymap_cfg,
tilesets_headers,
@@ -263,14 +260,12 @@ enum ProjectFilePath {
data_obj_event_pic_tables,
data_obj_event_gfx,
data_pokemon_gfx,
data_heal_locations,
constants_global,
constants_items,
constants_flags,
constants_vars,
constants_weather,
constants_songs,
constants_heal_locations,
constants_pokemon,
constants_map_types,
constants_trainer_types,

View File

@@ -10,7 +10,6 @@
#include <QPointer>
#include "orderedjson.h"
using OrderedJson = poryjson::Json;
class Project;
@@ -125,7 +124,7 @@ public:
// standard public methods
public:
virtual Event *duplicate() = 0;
virtual Event *duplicate() const = 0;
void setMap(Map *newMap) { this->map = newMap; }
Map *getMap() const { return this->map; }
@@ -155,7 +154,7 @@ public:
Event::Type getEventType() const { return this->eventType; }
virtual OrderedJson::object buildEventJson(Project *project) = 0;
virtual bool loadFromJson(QJsonObject json, Project *project) = 0;
virtual bool loadFromJson(const QJsonObject &json, Project *project) = 0;
virtual void setDefaultValues(Project *project);
@@ -168,10 +167,10 @@ public:
virtual void loadPixmap(Project *project);
void setPixmap(QPixmap newPixmap) { this->pixmap = newPixmap; }
QPixmap getPixmap() { return this->pixmap; }
QPixmap getPixmap() const { return this->pixmap; }
void setPixmapItem(DraggablePixmapItem *item);
DraggablePixmapItem *getPixmapItem() { return this->pixmapItem; }
DraggablePixmapItem *getPixmapItem() const { return this->pixmapItem; }
void setUsingSprite(bool newUsingSprite) { this->usingSprite = newUsingSprite; }
bool getUsingSprite() const { return this->usingSprite; }
@@ -184,6 +183,9 @@ public:
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);
@@ -206,6 +208,11 @@ protected:
int spriteHeight = 16;
bool usingSprite = false;
// 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.
// When deleting events like this we want to warn the user that the #define may also be deleted.
QString idName;
QMap<QString, QJsonValue> customAttributes;
QPixmap pixmap;
@@ -227,14 +234,14 @@ public:
}
virtual ~ObjectEvent() {}
virtual Event *duplicate() override;
virtual Event *duplicate() const override;
virtual void accept(EventVisitor *visitor) override { visitor->visitObject(this); }
virtual EventFrame *createEventFrame() override;
virtual OrderedJson::object buildEventJson(Project *project) override;
virtual bool loadFromJson(QJsonObject json, Project *project) override;
virtual bool loadFromJson(const QJsonObject &json, Project *project) override;
virtual void setDefaultValues(Project *project) override;
@@ -243,28 +250,28 @@ public:
virtual void loadPixmap(Project *project) override;
void setGfx(QString newGfx) { this->gfx = newGfx; }
QString getGfx() { return this->gfx; }
QString getGfx() const { return this->gfx; }
void setMovement(QString newMovement) { this->movement = newMovement; }
QString getMovement() { return this->movement; }
QString getMovement() const { return this->movement; }
void setRadiusX(int newRadiusX) { this->radiusX = newRadiusX; }
int getRadiusX() { return this->radiusX; }
int getRadiusX() const { return this->radiusX; }
void setRadiusY(int newRadiusY) { this->radiusY = newRadiusY; }
int getRadiusY() { return this->radiusY; }
int getRadiusY() const { return this->radiusY; }
void setTrainerType(QString newTrainerType) { this->trainerType = newTrainerType; }
QString getTrainerType() { return this->trainerType; }
QString getTrainerType() const { return this->trainerType; }
void setSightRadiusBerryTreeID(QString newValue) { this->sightRadiusBerryTreeID = newValue; }
QString getSightRadiusBerryTreeID() { return this->sightRadiusBerryTreeID; }
QString getSightRadiusBerryTreeID() const { return this->sightRadiusBerryTreeID; }
void setScript(QString newScript) { this->script = newScript; }
QString getScript() { return this->script; }
QString getScript() const { return this->script; }
void setFlag(QString newFlag) { this->flag = newFlag; }
QString getFlag() { return this->flag; }
QString getFlag() const { return this->flag; }
public:
void setFrameFromMovement(QString movement);
@@ -300,12 +307,12 @@ public:
}
virtual ~CloneObjectEvent() {}
virtual Event *duplicate() override;
virtual Event *duplicate() const override;
virtual EventFrame *createEventFrame() override;
virtual OrderedJson::object buildEventJson(Project *project) override;
virtual bool loadFromJson(QJsonObject json, Project *project) override;
virtual bool loadFromJson(const QJsonObject &json, Project *project) override;
virtual void setDefaultValues(Project *project) override;
@@ -314,10 +321,10 @@ public:
virtual void loadPixmap(Project *project) override;
void setTargetMap(QString newTargetMap) { this->targetMap = newTargetMap; }
QString getTargetMap() { return this->targetMap; }
QString getTargetMap() const { return this->targetMap; }
void setTargetID(int newTargetID) { this->targetID = newTargetID; }
int getTargetID() { return this->targetID; }
int getTargetID() const { return this->targetID; }
private:
QString targetMap;
@@ -338,22 +345,22 @@ public:
}
virtual ~WarpEvent() {}
virtual Event *duplicate() override;
virtual Event *duplicate() const override;
virtual EventFrame *createEventFrame() override;
virtual OrderedJson::object buildEventJson(Project *project) override;
virtual bool loadFromJson(QJsonObject json, Project *project) override;
virtual bool loadFromJson(const QJsonObject &json, Project *project) override;
virtual void setDefaultValues(Project *project) override;
virtual QSet<QString> getExpectedFields() override;
void setDestinationMap(QString newDestinationMap) { this->destinationMap = newDestinationMap; }
QString getDestinationMap() { return this->destinationMap; }
QString getDestinationMap() const { return this->destinationMap; }
void setDestinationWarpID(QString newDestinationWarpID) { this->destinationWarpID = newDestinationWarpID; }
QString getDestinationWarpID() { return this->destinationWarpID; }
QString getDestinationWarpID() const { return this->destinationWarpID; }
void setWarningEnabled(bool enabled);
@@ -373,12 +380,12 @@ public:
CoordEvent() : Event() {}
virtual ~CoordEvent() {}
virtual Event *duplicate() override = 0;
virtual Event *duplicate() const override = 0;
virtual EventFrame *createEventFrame() override = 0;
virtual OrderedJson::object buildEventJson(Project *project) override = 0;
virtual bool loadFromJson(QJsonObject json, Project *project) override = 0;
virtual bool loadFromJson(const QJsonObject &json, Project *project) override = 0;
virtual void setDefaultValues(Project *project) override = 0;
@@ -399,27 +406,27 @@ public:
}
virtual ~TriggerEvent() {}
virtual Event *duplicate() override;
virtual Event *duplicate() const override;
virtual void accept(EventVisitor *visitor) override { visitor->visitTrigger(this); }
virtual EventFrame *createEventFrame() override;
virtual OrderedJson::object buildEventJson(Project *project) override;
virtual bool loadFromJson(QJsonObject json, Project *project) override;
virtual bool loadFromJson(const QJsonObject &json, Project *project) override;
virtual void setDefaultValues(Project *project) override;
virtual QSet<QString> getExpectedFields() override;
void setScriptVar(QString newScriptVar) { this->scriptVar = newScriptVar; }
QString getScriptVar() { return this->scriptVar; }
QString getScriptVar() const { return this->scriptVar; }
void setScriptVarValue(QString newScriptVarValue) { this->scriptVarValue = newScriptVarValue; }
QString getScriptVarValue() { return this->scriptVarValue; }
QString getScriptVarValue() const { return this->scriptVarValue; }
void setScriptLabel(QString newScriptLabel) { this->scriptLabel = newScriptLabel; }
QString getScriptLabel() { return this->scriptLabel; }
QString getScriptLabel() const { return this->scriptLabel; }
private:
QString scriptVar;
@@ -441,19 +448,19 @@ public:
}
virtual ~WeatherTriggerEvent() {}
virtual Event *duplicate() override;
virtual Event *duplicate() const override;
virtual EventFrame *createEventFrame() override;
virtual OrderedJson::object buildEventJson(Project *project) override;
virtual bool loadFromJson(QJsonObject json, Project *project) override;
virtual bool loadFromJson(const QJsonObject &json, Project *project) override;
virtual void setDefaultValues(Project *project) override;
virtual QSet<QString> getExpectedFields() override;
void setWeather(QString newWeather) { this->weather = newWeather; }
QString getWeather() { return this->weather; }
QString getWeather() const { return this->weather; }
private:
QString weather;
@@ -472,12 +479,12 @@ public:
}
virtual ~BGEvent() {}
virtual Event *duplicate() override = 0;
virtual Event *duplicate() const override = 0;
virtual EventFrame *createEventFrame() override = 0;
virtual OrderedJson::object buildEventJson(Project *project) override = 0;
virtual bool loadFromJson(QJsonObject json, Project *project) override = 0;
virtual bool loadFromJson(const QJsonObject &json, Project *project) override = 0;
virtual void setDefaultValues(Project *project) override = 0;
@@ -497,24 +504,24 @@ public:
}
virtual ~SignEvent() {}
virtual Event *duplicate() override;
virtual Event *duplicate() const override;
virtual void accept(EventVisitor *visitor) override { visitor->visitSign(this); }
virtual EventFrame *createEventFrame() override;
virtual OrderedJson::object buildEventJson(Project *project) override;
virtual bool loadFromJson(QJsonObject json, Project *project) override;
virtual bool loadFromJson(const QJsonObject &json, Project *project) override;
virtual void setDefaultValues(Project *project) override;
virtual QSet<QString> getExpectedFields() override;
void setFacingDirection(QString newFacingDirection) { this->facingDirection = newFacingDirection; }
QString getFacingDirection() { return this->facingDirection; }
QString getFacingDirection() const { return this->facingDirection; }
void setScriptLabel(QString newScriptLabel) { this->scriptLabel = newScriptLabel; }
QString getScriptLabel() { return this->scriptLabel; }
QString getScriptLabel() const { return this->scriptLabel; }
private:
QString facingDirection;
@@ -534,28 +541,28 @@ public:
}
virtual ~HiddenItemEvent() {}
virtual Event *duplicate() override;
virtual Event *duplicate() const override;
virtual EventFrame *createEventFrame() override;
virtual OrderedJson::object buildEventJson(Project *project) override;
virtual bool loadFromJson(QJsonObject json, Project *project) override;
virtual bool loadFromJson(const QJsonObject &json, Project *project) override;
virtual void setDefaultValues(Project *project) override;
virtual QSet<QString> getExpectedFields() override;
void setItem(QString newItem) { this->item = newItem; }
QString getItem() { return this->item; }
QString getItem() const { return this->item; }
void setFlag(QString newFlag) { this->flag = newFlag; }
QString getFlag() { return this->flag; }
QString getFlag() const { return this->flag; }
void setQuantity(int newQuantity) { this->quantity = newQuantity; }
int getQuantity() { return this->quantity; }
int getQuantity() const { return this->quantity; }
void setUnderfoot(bool newUnderfoot) { this->underfoot = newUnderfoot; }
bool getUnderfoot() { return this->underfoot; }
bool getUnderfoot() const { return this->underfoot; }
private:
QString item;
@@ -579,19 +586,19 @@ public:
}
virtual ~SecretBaseEvent() {}
virtual Event *duplicate() override;
virtual Event *duplicate() const override;
virtual EventFrame *createEventFrame() override;
virtual OrderedJson::object buildEventJson(Project *project) override;
virtual bool loadFromJson(QJsonObject json, Project *project) override;
virtual bool loadFromJson(const QJsonObject &json, Project *project) override;
virtual void setDefaultValues(Project *project) override;
virtual QSet<QString> getExpectedFields() override;
void setBaseID(QString newBaseID) { this->baseID = newBaseID; }
QString getBaseID() { return this->baseID; }
QString getBaseID() const { return this->baseID; }
private:
QString baseID;
@@ -611,38 +618,26 @@ public:
}
virtual ~HealLocationEvent() {}
virtual Event *duplicate() override { return nullptr; }
virtual Event *duplicate() const override;
virtual EventFrame *createEventFrame() override;
virtual OrderedJson::object buildEventJson(Project *project) override;
virtual bool loadFromJson(QJsonObject, Project *) override { return false; }
virtual bool loadFromJson(const QJsonObject &, Project *) override;
virtual void setDefaultValues(Project *project) override;
virtual QSet<QString> getExpectedFields() override { return QSet<QString>(); }
virtual QSet<QString> getExpectedFields() override;
void setIndex(int newIndex) { this->index = newIndex; }
int getIndex() { return this->index; }
void setRespawnMapName(QString newRespawnMapName) { this->respawnMapName = newRespawnMapName; }
QString getRespawnMapName() const { return this->respawnMapName; }
void setLocationName(QString newLocationName) { this->locationName = newLocationName; }
QString getLocationName() { return this->locationName; }
void setIdName(QString newIdName) { this->idName = newIdName; }
QString getIdName() { return this->idName; }
void setRespawnMap(QString newRespawnMap) { this->respawnMap = newRespawnMap; }
QString getRespawnMap() { return this->respawnMap; }
void setRespawnNPC(uint8_t newRespawnNPC) { this->respawnNPC = newRespawnNPC; }
uint8_t getRespawnNPC() { return this->respawnNPC; }
void setRespawnNPC(QString newRespawnNPC) { this->respawnNPC = newRespawnNPC; }
QString getRespawnNPC() const { return this->respawnNPC; }
private:
int index = -1;
QString locationName;
QString idName;
QString respawnMap;
uint8_t respawnNPC = 0;
QString respawnMapName;
QString respawnNPC;
};
@@ -656,7 +651,7 @@ public:
virtual void visitTrigger(TriggerEvent *trigger) override { this->scripts << trigger->getScriptLabel(); };
virtual void visitSign(SignEvent *sign) override { this->scripts << sign->getScriptLabel(); };
QStringList getScripts() { return this->scripts; }
QStringList getScripts() const { return this->scripts; }
private:
QStringList scripts;

View File

@@ -1,28 +0,0 @@
#pragma once
#ifndef HEALLOCATION_H
#define HEALLOCATION_H
#include <QString>
#include <QDebug>
class Event;
class HealLocation {
public:
HealLocation()=default;
HealLocation(QString, QString, int, int16_t, int16_t, QString = "", uint8_t = 1);
friend QDebug operator<<(QDebug debug, const HealLocation &hl);
public:
QString idName;
QString mapName;
int index;
int16_t x;
int16_t y;
QString respawnMap;
uint8_t respawnNPC;
static HealLocation fromEvent(Event *);
};
#endif // HEALLOCATION_H

View File

@@ -2,7 +2,6 @@
#ifndef PARSEUTIL_H
#define PARSEUTIL_H
#include "heallocation.h"
#include "log.h"
#include "orderedjson.h"
#include "orderedmap.h"
@@ -78,11 +77,11 @@ public:
static QString removeLineComments(QString text, const QStringList &commentSymbols);
static QStringList splitShellCommand(QStringView command);
static int gameStringToInt(QString gameString, bool * ok = nullptr);
static bool gameStringToBool(QString gameString, bool * ok = nullptr);
static QString jsonToQString(QJsonValue value, bool * ok = nullptr);
static int jsonToInt(QJsonValue value, bool * ok = nullptr);
static bool jsonToBool(QJsonValue value, bool * ok = nullptr);
static int gameStringToInt(const QString &gameString, bool * ok = nullptr);
static bool gameStringToBool(const QString &gameString, bool * ok = nullptr);
static QString jsonToQString(const QJsonValue &value, bool * ok = nullptr);
static int jsonToInt(const QJsonValue &value, bool * ok = nullptr);
static bool jsonToBool(const QJsonValue &value, bool * ok = nullptr);
private:
QString root;

View File

@@ -46,7 +46,6 @@ public:
public:
Ui::MainWindow* ui;
QObject *parent = nullptr;
QPointer<Project> project = nullptr;
QPointer<Map> map = nullptr;

View File

@@ -247,4 +247,7 @@ protected:
} // namespace poryjson
using OrderedJson = poryjson::Json;
using OrderedJsonDoc = poryjson::JsonDoc;
#endif // ORDERED_JSON_H

View File

@@ -4,7 +4,6 @@
#include "map.h"
#include "blockdata.h"
#include "heallocation.h"
#include "wildmoninfo.h"
#include "parseutil.h"
#include "orderedjson.h"
@@ -35,8 +34,8 @@ public:
QStringList mapNames;
QStringList groupNames;
QMap<QString, QStringList> groupNameToMapNames;
QList<HealLocation> healLocations;
QMap<QString, int> healLocationNameToValue;
QStringList healLocationSaveOrder;
QMap<QString, QList<HealLocationEvent*>> healLocations;
QMap<QString, QString> mapConstantsToMapNames;
QMap<QString, QString> mapNamesToMapConstants;
QMap<QString, QString> mapNameToLayoutId;
@@ -87,15 +86,7 @@ public:
void clearTilesetCache();
void clearMapLayouts();
void clearEventGraphics();
struct DataQualifiers
{
bool isStatic;
bool isConst;
};
DataQualifiers getDataQualifiers(QString, QString);
DataQualifiers healLocationDataQualifiers;
QString healLocationsTableName;
void clearHealLocations();
bool sanityCheck();
bool load();
@@ -142,7 +133,8 @@ public:
bool isIdentifierUnique(const QString &identifier) const;
bool isValidNewIdentifier(QString identifier) const;
QString toUniqueIdentifier(const QString &identifier) const;
QString getProjectTitle();
QString getProjectTitle() const;
QString getNewHealLocationName(const Map* map) const;
bool readWildMonData();
tsl::ordered_map<QString, tsl::ordered_map<QString, WildPokemonHeader>> wildMonData;
@@ -187,7 +179,7 @@ public:
void saveMapGroups();
void saveRegionMapSections();
void saveWildMonData();
void saveHealLocations(Map*);
void saveHealLocations();
void saveTilesets(Tileset*, Tileset*);
void saveTilesetMetatileLabels(Tileset*, Tileset*);
void appendTilesetLabel(const QString &label, const QString &isSecondaryStr);
@@ -207,7 +199,6 @@ public:
bool readBgEventFacingDirections();
bool readTrainerTypes();
bool readMetatileBehaviors();
bool readHealLocationConstants();
bool readHealLocations();
bool readMiscellaneousConstants();
bool readEventScriptLabels();
@@ -267,9 +258,6 @@ private:
void setNewLayoutBlockdata(Layout *layout);
void setNewLayoutBorder(Layout *layout);
void saveHealLocationsData(Map *map);
void saveHealLocationsConstants();
void ignoreWatchedFileTemporarily(QString filepath);
static int num_tiles_primary;

View File

@@ -267,10 +267,11 @@ public:
virtual void populate(Project *project) override;
public:
QLineEdit *line_edit_id;
QFrame *hideable_respawn_map;
QFrame *hideable_respawn_npc;
NoScrollComboBox *combo_respawn_map;
NoScrollSpinBox *spinner_respawn_npc;
NoScrollComboBox *combo_respawn_npc;
private:
HealLocationEvent *healLocation;

View File

@@ -79,6 +79,7 @@ private:
bool positionIsValid(const QPoint &pos) const;
bool selectionIsValid();
void hoverChanged();
int numPrimaryMetatilesRounded() const;
signals:
void hoveredMetatileSelectionChanged(uint16_t);

View File

@@ -51,6 +51,7 @@ private:
void drawCounts();
QImage buildAllMetatilesImage();
QImage buildImage(int metatileIdStart, int numMetatiles);
int numPrimaryMetatilesRounded() const;
signals:
void hoveredMetatileChanged(uint16_t);