porymap/include/project.h

253 lines
7.4 KiB
C
Raw Normal View History

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"
#include "event.h"
2019-06-13 03:20:28 +01:00
#include "wildmoninfo.h"
#include "parseutil.h"
#include "orderedjson.h"
#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>
#include <QFileSystemWatcher>
2018-09-27 00:33:08 +01: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";
class Project : public QObject
2018-09-27 00:33:08 +01:00
{
Q_OBJECT
2018-09-27 00:33:08 +01:00
public:
Project(QWidget *parent = nullptr);
~Project();
Project(const Project &) = delete;
Project & operator = (const Project &) = delete;
inline QWidget *parentWidget() const { return static_cast<QWidget *>(parent()); }
public:
2018-09-27 00:33:08 +01:00
QString root;
QStringList groupNames;
QMap<QString, int> mapGroups;
2018-09-27 00:33:08 +01:00
QList<QStringList> groupedMapNames;
QStringList mapNames;
2019-07-03 03:08:58 +01:00
QMap<QString, QVariant> miscConstants;
QList<HealLocation> healLocations;
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;
QMap<QString, QString> mapSecToMapHoverName;
QMap<QString, int> mapSectionNameToValue;
QMap<int, QString> mapSectionValueToName;
QMap<QString, EventGraphics*> eventGraphicsMap;
2022-02-06 02:31:54 +00:00
QMap<QString, int> gfxDefines;
QStringList songNames;
QStringList itemNames;
QStringList flagNames;
QStringList varNames;
QStringList movementTypes;
QStringList mapTypes;
QStringList mapBattleScenes;
QStringList weatherNames;
QStringList coordEventWeatherNames;
QStringList secretBaseIds;
QStringList bgEventFacingDirections;
QStringList trainerTypes;
QStringList globalScriptLabels;
QMap<QString, int> metatileBehaviorMap;
QMap<int, QString> metatileBehaviorMapInverse;
2019-04-03 00:51:33 +01:00
QMap<QString, QString> facingDirections;
ParseUtil parser;
QFileSystemWatcher fileWatcher;
QMap<QString, qint64> modifiedFileTimestamps;
void set_root(QString);
2018-09-27 00:33:08 +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);
QMap<QString, DataQualifiers> dataQualifiers;
QMap<QString, Map*> mapCache;
2018-09-27 00:33:08 +01:00
Map* loadMap(QString);
Map* getMap(QString);
QMap<QString, Tileset*> tilesetCache;
2018-10-03 01:01:15 +01:00
Tileset* loadTileset(QString, Tileset *tileset = nullptr);
Tileset* getTileset(QString, bool forceLoad = false);
QMap<QString, QStringList> tilesetLabels;
QList<QString> tilesetLabelsOrdered;
2018-09-27 00:33:08 +01:00
2021-02-14 21:34:17 +00:00
Blockdata readBlockdata(QString);
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);
bool readMapGroups();
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);
bool readWildMonData();
tsl::ordered_map<QString, tsl::ordered_map<QString, WildPokemonHeader>> wildMonData;
QVector<EncounterField> wildMonFields;
QVector<QString> encounterGroupLabels;
QVector<poryjson::Json::object> extraEncounterGroups;
2019-07-03 02:44:19 +01:00
bool readSpeciesIconPaths();
2019-06-13 03:20:28 +01:00
QMap<QString, QString> speciesToIconPath;
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();
bool loadLayout(MapLayout *);
bool loadMapLayout(Map*);
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*);
void loadTilesetMetatileLabels(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*);
void saveTilesets(Tileset*, Tileset*);
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();
2019-03-23 14:49:30 +00:00
QMap<QString, QStringList> getTilesetLabels();
bool readTilesetProperties();
bool readMaxMapDataSize();
2020-02-12 14:12:12 +00:00
bool readRegionMapSections();
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();
bool readMetatileBehaviors();
bool readHealLocations();
bool readMiscellaneousConstants();
bool readEventScriptLabels();
bool readObjEventGfxConstants();
bool readSongNames();
bool readEventGraphics();
QMap<QString, QMap<QString, QString>> readObjEventGfxInfo();
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);
QString getScriptFileExtension(bool usePoryScript) const;
QString getScriptDefaultString(bool usePoryScript, QString mapName) const;
QString getMapScriptsFilePath(const QString &mapName) const;
QStringList getEventScriptsFilePaths() const;
QCompleter *getEventScriptLabelCompleter(QStringList additionalScriptLabels);
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();
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();
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);
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;
QStringListModel eventScriptLabelModel;
QCompleter eventScriptLabelCompleter;
signals:
void reloadProject();
void uncheckMonitorFilesAction();
void mapCacheCleared();
void disableWildEncountersUI();
2018-09-27 00:33:08 +01:00
};
#endif // PROJECT_H