2020-09-13 23:37:55 +01:00
|
|
|
#pragma once
|
2018-09-27 00:33:08 +01:00
|
|
|
#ifndef PROJECT_H
|
|
|
|
#define PROJECT_H
|
|
|
|
|
|
|
|
#include "map.h"
|
|
|
|
#include "blockdata.h"
|
|
|
|
#include "heallocation.h"
|
2019-06-13 03:20:28 +01:00
|
|
|
#include "wildmoninfo.h"
|
2019-05-06 17:42:09 +01:00
|
|
|
#include "parseutil.h"
|
2020-03-06 03:46:25 +00:00
|
|
|
#include "orderedjson.h"
|
2022-03-01 20:32:44 +00:00
|
|
|
#include "regionmap.h"
|
2018-09-27 00:33:08 +01:00
|
|
|
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QList>
|
2019-06-15 23:49:30 +01:00
|
|
|
#include <QVector>
|
|
|
|
#include <QPair>
|
2018-09-27 00:33:08 +01:00
|
|
|
#include <QStandardItem>
|
2019-07-03 03:08:58 +01:00
|
|
|
#include <QVariant>
|
2020-04-08 05:42:38 +01:00
|
|
|
#include <QFileSystemWatcher>
|
2018-09-27 00:33:08 +01:00
|
|
|
|
2022-01-24 22:17:31 +00:00
|
|
|
struct EventGraphics
|
|
|
|
{
|
|
|
|
QImage spritesheet;
|
|
|
|
int spriteWidth;
|
|
|
|
int spriteHeight;
|
|
|
|
bool inanimate;
|
|
|
|
};
|
|
|
|
|
2018-09-27 00:33:08 +01:00
|
|
|
static QString NONE_MAP_CONSTANT = "MAP_NONE";
|
|
|
|
static QString NONE_MAP_NAME = "None";
|
|
|
|
|
2020-04-12 01:39:50 +01:00
|
|
|
class Project : public QObject
|
2018-09-27 00:33:08 +01:00
|
|
|
{
|
2020-04-12 01:39:50 +01:00
|
|
|
Q_OBJECT
|
2018-09-27 00:33:08 +01:00
|
|
|
public:
|
2020-04-12 01:39:50 +01:00
|
|
|
Project(QWidget *parent = nullptr);
|
2020-04-07 19:20:31 +01:00
|
|
|
~Project();
|
|
|
|
|
|
|
|
Project(const Project &) = delete;
|
|
|
|
Project & operator = (const Project &) = delete;
|
|
|
|
|
2021-02-15 16:43:18 +00:00
|
|
|
inline QWidget *parentWidget() const { return static_cast<QWidget *>(parent()); }
|
|
|
|
|
2020-04-07 19:20:31 +01:00
|
|
|
public:
|
2018-09-27 00:33:08 +01:00
|
|
|
QString root;
|
2021-02-15 09:21:41 +00:00
|
|
|
QStringList groupNames;
|
|
|
|
QMap<QString, int> mapGroups;
|
2018-09-27 00:33:08 +01:00
|
|
|
QList<QStringList> groupedMapNames;
|
2021-02-15 09:21:41 +00:00
|
|
|
QStringList mapNames;
|
2019-07-03 03:08:58 +01:00
|
|
|
QMap<QString, QVariant> miscConstants;
|
2020-04-29 17:34:49 +01:00
|
|
|
QList<HealLocation> healLocations;
|
2022-09-09 22:41:50 +01:00
|
|
|
QMap<QString, int> healLocationNameToValue;
|
2021-02-15 09:21:41 +00:00
|
|
|
QMap<QString, QString> mapConstantsToMapNames;
|
|
|
|
QMap<QString, QString> mapNamesToMapConstants;
|
|
|
|
QStringList mapLayoutsTable;
|
|
|
|
QStringList mapLayoutsTableMaster;
|
2019-02-01 17:43:25 +00:00
|
|
|
QString layoutsLabel;
|
2018-09-27 00:33:08 +01:00
|
|
|
QMap<QString, MapLayout*> mapLayouts;
|
|
|
|
QMap<QString, MapLayout*> mapLayoutsMaster;
|
2021-02-15 09:21:41 +00:00
|
|
|
QMap<QString, QString> mapSecToMapHoverName;
|
2019-02-25 18:31:34 +00:00
|
|
|
QMap<QString, int> mapSectionNameToValue;
|
|
|
|
QMap<int, QString> mapSectionValueToName;
|
2022-01-24 22:17:31 +00:00
|
|
|
QMap<QString, EventGraphics*> eventGraphicsMap;
|
2022-02-06 02:31:54 +00:00
|
|
|
QMap<QString, int> gfxDefines;
|
2022-01-21 20:22:20 +00:00
|
|
|
QStringList songNames;
|
2021-02-15 16:33:30 +00:00
|
|
|
QStringList itemNames;
|
|
|
|
QStringList flagNames;
|
|
|
|
QStringList varNames;
|
|
|
|
QStringList movementTypes;
|
|
|
|
QStringList mapTypes;
|
|
|
|
QStringList mapBattleScenes;
|
|
|
|
QStringList weatherNames;
|
|
|
|
QStringList coordEventWeatherNames;
|
|
|
|
QStringList secretBaseIds;
|
|
|
|
QStringList bgEventFacingDirections;
|
|
|
|
QStringList trainerTypes;
|
2021-04-16 14:04:38 +01:00
|
|
|
QStringList globalScriptLabels;
|
2018-10-03 01:01:09 +01:00
|
|
|
QMap<QString, int> metatileBehaviorMap;
|
|
|
|
QMap<int, QString> metatileBehaviorMapInverse;
|
2019-04-03 00:51:33 +01:00
|
|
|
QMap<QString, QString> facingDirections;
|
2019-05-06 17:42:09 +01:00
|
|
|
ParseUtil parser;
|
2020-04-08 05:42:38 +01:00
|
|
|
QFileSystemWatcher fileWatcher;
|
2020-04-25 22:11:14 +01:00
|
|
|
QMap<QString, qint64> modifiedFileTimestamps;
|
2022-09-28 01:17:55 +01:00
|
|
|
bool usingAsmTilesets;
|
2019-05-06 17:42:09 +01:00
|
|
|
|
2022-07-19 22:56:12 +01:00
|
|
|
const QPixmap entitiesPixmap = QPixmap(":/images/Entities_16x16.png");
|
|
|
|
|
2019-05-06 17:42:09 +01:00
|
|
|
void set_root(QString);
|
2018-09-27 00:33:08 +01:00
|
|
|
|
2020-04-12 01:39:50 +01:00
|
|
|
void initSignals();
|
|
|
|
|
2020-04-08 01:25:09 +01:00
|
|
|
void clearMapCache();
|
|
|
|
void clearTilesetCache();
|
|
|
|
|
2019-04-29 01:20:48 +01:00
|
|
|
struct DataQualifiers
|
|
|
|
{
|
|
|
|
bool isStatic;
|
|
|
|
bool isConst;
|
|
|
|
};
|
|
|
|
DataQualifiers getDataQualifiers(QString, QString);
|
2022-09-09 22:41:50 +01:00
|
|
|
DataQualifiers healLocationDataQualifiers;
|
2019-04-29 01:20:48 +01:00
|
|
|
|
2021-02-15 16:33:30 +00:00
|
|
|
QMap<QString, Map*> mapCache;
|
2018-09-27 00:33:08 +01:00
|
|
|
Map* loadMap(QString);
|
|
|
|
Map* getMap(QString);
|
|
|
|
|
2021-02-15 16:33:30 +00:00
|
|
|
QMap<QString, Tileset*> tilesetCache;
|
2018-10-03 01:01:15 +01:00
|
|
|
Tileset* loadTileset(QString, Tileset *tileset = nullptr);
|
|
|
|
Tileset* getTileset(QString, bool forceLoad = false);
|
2019-09-21 21:59:14 +01:00
|
|
|
QMap<QString, QStringList> tilesetLabels;
|
2022-09-28 01:17:55 +01:00
|
|
|
QStringList tilesetLabelsOrdered;
|
2018-09-27 00:33:08 +01:00
|
|
|
|
2021-02-14 21:34:17 +00:00
|
|
|
Blockdata readBlockdata(QString);
|
2021-07-20 03:02:31 +01:00
|
|
|
bool loadBlockdata(MapLayout*);
|
|
|
|
bool loadLayoutBorder(MapLayout*);
|
2018-09-27 00:33:08 +01:00
|
|
|
|
|
|
|
void saveTextFile(QString path, QString text);
|
|
|
|
void appendTextFile(QString path, QString text);
|
|
|
|
void deleteFile(QString path);
|
|
|
|
|
2020-02-12 16:22:40 +00:00
|
|
|
bool readMapGroups();
|
2020-09-19 20:05:27 +01:00
|
|
|
Map* addNewMapToGroup(QString, int, Map*, bool, bool);
|
2018-09-27 00:33:08 +01:00
|
|
|
QString getNewMapName();
|
|
|
|
QString getProjectTitle();
|
|
|
|
|
2018-10-05 07:02:40 +01:00
|
|
|
QString readMapLayoutId(QString map_name);
|
|
|
|
QString readMapLocation(QString map_name);
|
|
|
|
|
2020-02-12 15:13:58 +00:00
|
|
|
bool readWildMonData();
|
2020-04-20 15:18:03 +01:00
|
|
|
tsl::ordered_map<QString, tsl::ordered_map<QString, WildPokemonHeader>> wildMonData;
|
|
|
|
|
2019-09-30 00:07:34 +01:00
|
|
|
QVector<EncounterField> wildMonFields;
|
2019-06-26 20:15:50 +01:00
|
|
|
QVector<QString> encounterGroupLabels;
|
2020-03-06 03:46:25 +00:00
|
|
|
QVector<poryjson::Json::object> extraEncounterGroups;
|
2019-07-03 02:44:19 +01:00
|
|
|
|
2020-02-12 15:13:58 +00:00
|
|
|
bool readSpeciesIconPaths();
|
2019-06-13 03:20:28 +01:00
|
|
|
QMap<QString, QString> speciesToIconPath;
|
|
|
|
|
2019-02-03 16:38:45 +00:00
|
|
|
QMap<QString, bool> getTopLevelMapFields();
|
2019-02-01 17:43:25 +00:00
|
|
|
bool loadMapData(Map*);
|
2020-02-12 00:34:08 +00:00
|
|
|
bool readMapLayouts();
|
2021-07-20 03:02:31 +01:00
|
|
|
bool loadLayout(MapLayout *);
|
2020-02-12 16:22:40 +00:00
|
|
|
bool loadMapLayout(Map*);
|
2021-07-20 03:02:31 +01:00
|
|
|
bool loadLayoutTilesets(MapLayout*);
|
2018-09-27 00:33:08 +01:00
|
|
|
void loadTilesetAssets(Tileset*);
|
2018-10-03 01:01:24 +01:00
|
|
|
void loadTilesetTiles(Tileset*, QImage);
|
|
|
|
void loadTilesetMetatiles(Tileset*);
|
2019-04-04 06:44:31 +01:00
|
|
|
void loadTilesetMetatileLabels(Tileset*);
|
2022-09-28 01:17:55 +01:00
|
|
|
void loadTilesetPalettes(Tileset*);
|
|
|
|
void readTilesetPaths(Tileset* tileset);
|
2018-09-27 00:33:08 +01:00
|
|
|
|
2019-02-01 17:43:25 +00:00
|
|
|
void saveLayoutBlockdata(Map*);
|
|
|
|
void saveLayoutBorder(Map*);
|
2021-02-14 21:34:17 +00:00
|
|
|
void writeBlockdata(QString, const Blockdata &);
|
2018-09-27 00:33:08 +01:00
|
|
|
void saveAllMaps();
|
|
|
|
void saveMap(Map*);
|
|
|
|
void saveAllDataStructures();
|
2019-02-01 17:43:25 +00:00
|
|
|
void saveMapLayouts();
|
|
|
|
void saveMapGroups();
|
2019-06-15 23:49:30 +01:00
|
|
|
void saveWildMonData();
|
2018-09-27 00:33:08 +01:00
|
|
|
void saveMapConstantsHeader();
|
|
|
|
void saveHealLocationStruct(Map*);
|
2018-10-03 01:01:09 +01:00
|
|
|
void saveTilesets(Tileset*, Tileset*);
|
2019-04-04 06:44:31 +01:00
|
|
|
void saveTilesetMetatileLabels(Tileset*, Tileset*);
|
2019-03-21 23:50:50 +00:00
|
|
|
void saveTilesetMetatileAttributes(Tileset*);
|
|
|
|
void saveTilesetMetatiles(Tileset*);
|
|
|
|
void saveTilesetTilesImage(Tileset*);
|
2020-05-03 16:00:56 +01:00
|
|
|
void saveTilesetPalettes(Tileset*);
|
2018-09-27 00:33:08 +01:00
|
|
|
|
2020-03-16 07:57:39 +00:00
|
|
|
QString defaultSong;
|
2018-09-27 00:33:08 +01:00
|
|
|
QStringList getVisibilities();
|
2022-10-08 23:05:11 +01:00
|
|
|
void insertTilesetLabel(QString label, bool isSecondary);
|
|
|
|
void insertTilesetLabel(QString label, QString isSecondaryStr);
|
2022-09-28 01:17:55 +01:00
|
|
|
bool readTilesetLabels();
|
2020-02-12 15:13:58 +00:00
|
|
|
bool readTilesetProperties();
|
2020-05-16 23:52:46 +01:00
|
|
|
bool readMaxMapDataSize();
|
2020-02-12 14:12:12 +00:00
|
|
|
bool readRegionMapSections();
|
2020-02-12 15:13:58 +00:00
|
|
|
bool readItemNames();
|
|
|
|
bool readFlagNames();
|
|
|
|
bool readVarNames();
|
|
|
|
bool readMovementTypes();
|
|
|
|
bool readInitialFacingDirections();
|
|
|
|
bool readMapTypes();
|
|
|
|
bool readMapBattleScenes();
|
|
|
|
bool readWeatherNames();
|
|
|
|
bool readCoordEventWeatherNames();
|
|
|
|
bool readSecretBaseIds();
|
|
|
|
bool readBgEventFacingDirections();
|
2020-03-27 14:51:57 +00:00
|
|
|
bool readTrainerTypes();
|
2020-02-12 15:13:58 +00:00
|
|
|
bool readMetatileBehaviors();
|
2022-09-09 22:41:50 +01:00
|
|
|
bool readHealLocationConstants();
|
2020-02-12 15:13:58 +00:00
|
|
|
bool readHealLocations();
|
|
|
|
bool readMiscellaneousConstants();
|
2021-01-30 03:05:40 +00:00
|
|
|
bool readEventScriptLabels();
|
2022-01-21 20:22:20 +00:00
|
|
|
bool readObjEventGfxConstants();
|
|
|
|
bool readSongNames();
|
2022-01-24 22:17:31 +00:00
|
|
|
bool readEventGraphics();
|
2022-07-02 18:40:04 +01:00
|
|
|
QMap<QString, QMap<QString, QString>> readObjEventGfxInfo();
|
2022-01-24 22:17:31 +00:00
|
|
|
|
2022-07-19 22:56:12 +01:00
|
|
|
void setEventPixmap(Event *event, bool forceLoad = false);
|
2018-09-27 00:33:08 +01:00
|
|
|
|
2018-10-03 01:01:41 +01:00
|
|
|
QString fixPalettePath(QString path);
|
2018-09-27 00:33:08 +01:00
|
|
|
QString fixGraphicPath(QString path);
|
|
|
|
|
2020-11-21 22:33:16 +00:00
|
|
|
QString getScriptFileExtension(bool usePoryScript) const;
|
|
|
|
QString getScriptDefaultString(bool usePoryScript, QString mapName) const;
|
|
|
|
QString getMapScriptsFilePath(const QString &mapName) const;
|
2020-12-04 14:29:38 +00:00
|
|
|
QStringList getEventScriptsFilePaths() const;
|
2021-04-16 14:04:38 +01:00
|
|
|
QCompleter *getEventScriptLabelCompleter(QStringList additionalScriptLabels);
|
2022-07-19 22:56:12 +01:00
|
|
|
QStringList getGlobalScriptLabels();
|
2018-09-27 00:33:08 +01:00
|
|
|
|
2019-02-01 17:43:25 +00:00
|
|
|
void saveMapHealEvents(Map *map);
|
2018-09-27 00:33:08 +01:00
|
|
|
|
|
|
|
static int getNumTilesPrimary();
|
|
|
|
static int getNumTilesTotal();
|
|
|
|
static int getNumMetatilesPrimary();
|
|
|
|
static int getNumMetatilesTotal();
|
|
|
|
static int getNumPalettesPrimary();
|
|
|
|
static int getNumPalettesTotal();
|
2020-05-16 21:57:03 +01:00
|
|
|
static int getMaxMapDataSize();
|
|
|
|
static int getDefaultMapSize();
|
|
|
|
static int getMaxMapWidth();
|
|
|
|
static int getMaxMapHeight();
|
2020-05-16 23:52:46 +01:00
|
|
|
static int getMapDataSize(int width, int height);
|
|
|
|
static bool mapDimensionsValid(int width, int height);
|
2020-05-16 21:57:03 +01:00
|
|
|
bool calculateDefaultMapSize();
|
2020-07-10 21:34:42 +01:00
|
|
|
static int getMaxObjectEvents();
|
2019-05-06 17:42:09 +01:00
|
|
|
|
2018-09-27 00:33:08 +01:00
|
|
|
private:
|
|
|
|
void updateMapLayout(Map*);
|
|
|
|
|
|
|
|
void setNewMapHeader(Map* map, int mapIndex);
|
|
|
|
void setNewMapLayout(Map* map);
|
|
|
|
void setNewMapBlockdata(Map* map);
|
|
|
|
void setNewMapBorder(Map *map);
|
|
|
|
void setNewMapEvents(Map *map);
|
|
|
|
void setNewMapConnections(Map *map);
|
|
|
|
|
2020-04-25 22:11:14 +01:00
|
|
|
void ignoreWatchedFileTemporarily(QString filepath);
|
|
|
|
|
2018-09-27 00:33:08 +01:00
|
|
|
static int num_tiles_primary;
|
|
|
|
static int num_tiles_total;
|
|
|
|
static int num_metatiles_primary;
|
|
|
|
static int num_metatiles_total;
|
|
|
|
static int num_pals_primary;
|
|
|
|
static int num_pals_total;
|
2020-05-16 21:57:03 +01:00
|
|
|
static int max_map_data_size;
|
|
|
|
static int default_map_size;
|
2020-07-10 21:34:42 +01:00
|
|
|
static int max_object_events;
|
2020-04-12 01:39:50 +01:00
|
|
|
|
2021-04-16 14:04:38 +01:00
|
|
|
QStringListModel eventScriptLabelModel;
|
|
|
|
QCompleter eventScriptLabelCompleter;
|
2020-04-12 01:39:50 +01:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void reloadProject();
|
2020-04-21 02:54:16 +01:00
|
|
|
void uncheckMonitorFilesAction();
|
2020-06-06 14:51:36 +01:00
|
|
|
void mapCacheCleared();
|
2022-03-23 03:49:49 +00:00
|
|
|
void disableWildEncountersUI();
|
2018-09-27 00:33:08 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PROJECT_H
|