mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-16 13:48:01 -05:00
Write config files on close / save, not on modification
This commit is contained in:
277
include/config.h
277
include/config.h
@@ -33,20 +33,17 @@ class KeyValueConfigBase
|
||||
public:
|
||||
void save();
|
||||
void load();
|
||||
void setSaveDisabled(bool disabled);
|
||||
virtual ~KeyValueConfigBase();
|
||||
virtual void reset() = 0;
|
||||
protected:
|
||||
virtual QString getConfigFilepath() = 0;
|
||||
virtual void parseConfigKeyValue(QString key, QString value) = 0;
|
||||
virtual QMap<QString, QString> getKeyValueMap() = 0;
|
||||
virtual void onNewConfigFileCreated() = 0;
|
||||
virtual void init() = 0;
|
||||
virtual void setUnreadKeys() = 0;
|
||||
bool getConfigBool(QString key, QString value);
|
||||
int getConfigInteger(QString key, QString value, int min = INT_MIN, int max = INT_MAX, int defaultValue = 0);
|
||||
uint32_t getConfigUint32(QString key, QString value, uint32_t min = 0, uint32_t max = UINT_MAX, uint32_t defaultValue = 0);
|
||||
private:
|
||||
bool saveDisabled = false;
|
||||
};
|
||||
|
||||
class PorymapConfig: public KeyValueConfigBase
|
||||
@@ -86,101 +83,24 @@ public:
|
||||
}
|
||||
void addRecentProject(QString project);
|
||||
void setRecentProjects(QStringList projects);
|
||||
void setReopenOnLaunch(bool enabled);
|
||||
void setMapSortOrder(MapSortOrder order);
|
||||
void setPrettyCursors(bool enabled);
|
||||
QString getRecentProject();
|
||||
QStringList getRecentProjects();
|
||||
void setMainGeometry(QByteArray, QByteArray, QByteArray, QByteArray, QByteArray);
|
||||
void setTilesetEditorGeometry(QByteArray, QByteArray, QByteArray);
|
||||
void setPaletteEditorGeometry(QByteArray, QByteArray);
|
||||
void setRegionMapEditorGeometry(QByteArray, QByteArray);
|
||||
void setProjectSettingsEditorGeometry(QByteArray, QByteArray);
|
||||
void setCustomScriptsEditorGeometry(QByteArray, QByteArray);
|
||||
void setCollisionOpacity(int opacity);
|
||||
void setCollisionZoom(int zoom);
|
||||
void setMetatilesZoom(int zoom);
|
||||
void setTilesetEditorMetatilesZoom(int zoom);
|
||||
void setTilesetEditorTilesZoom(int zoom);
|
||||
void setShowPlayerView(bool enabled);
|
||||
void setShowCursorTile(bool enabled);
|
||||
void setShowBorder(bool enabled);
|
||||
void setShowGrid(bool enabled);
|
||||
void setShowTilesetEditorMetatileGrid(bool enabled);
|
||||
void setShowTilesetEditorLayerGrid(bool enabled);
|
||||
void setMonitorFiles(bool monitor);
|
||||
void setTilesetCheckerboardFill(bool checkerboard);
|
||||
void setTheme(QString theme);
|
||||
void setTextEditorOpenFolder(const QString &command);
|
||||
void setTextEditorGotoLine(const QString &command);
|
||||
void setPaletteEditorBitDepth(int bitDepth);
|
||||
void setProjectSettingsTab(int tab);
|
||||
void setWarpBehaviorWarningDisabled(bool disabled);
|
||||
void setCheckForUpdates(bool enabled);
|
||||
void setLastUpdateCheckTime(QDateTime time);
|
||||
void setLastUpdateCheckVersion(QVersionNumber version);
|
||||
void setRateLimitTimes(QMap<QUrl, QDateTime> map);
|
||||
QString getRecentProject();
|
||||
QStringList getRecentProjects();
|
||||
bool getReopenOnLaunch();
|
||||
MapSortOrder getMapSortOrder();
|
||||
bool getPrettyCursors();
|
||||
QMap<QString, QByteArray> getMainGeometry();
|
||||
QMap<QString, QByteArray> getTilesetEditorGeometry();
|
||||
QMap<QString, QByteArray> getPaletteEditorGeometry();
|
||||
QMap<QString, QByteArray> getRegionMapEditorGeometry();
|
||||
QMap<QString, QByteArray> getProjectSettingsEditorGeometry();
|
||||
QMap<QString, QByteArray> getCustomScriptsEditorGeometry();
|
||||
int getCollisionOpacity();
|
||||
int getCollisionZoom();
|
||||
int getMetatilesZoom();
|
||||
int getTilesetEditorMetatilesZoom();
|
||||
int getTilesetEditorTilesZoom();
|
||||
bool getShowPlayerView();
|
||||
bool getShowCursorTile();
|
||||
bool getShowBorder();
|
||||
bool getShowGrid();
|
||||
bool getShowTilesetEditorMetatileGrid();
|
||||
bool getShowTilesetEditorLayerGrid();
|
||||
bool getMonitorFiles();
|
||||
bool getTilesetCheckerboardFill();
|
||||
QString getTheme();
|
||||
QString getTextEditorOpenFolder();
|
||||
QString getTextEditorGotoLine();
|
||||
int getPaletteEditorBitDepth();
|
||||
int getProjectSettingsTab();
|
||||
bool getWarpBehaviorWarningDisabled();
|
||||
bool getCheckForUpdates();
|
||||
QDateTime getLastUpdateCheckTime();
|
||||
QVersionNumber getLastUpdateCheckVersion();
|
||||
QMap<QUrl, QDateTime> getRateLimitTimes();
|
||||
protected:
|
||||
virtual QString getConfigFilepath() override;
|
||||
virtual void parseConfigKeyValue(QString key, QString value) override;
|
||||
virtual QMap<QString, QString> getKeyValueMap() override;
|
||||
virtual void onNewConfigFileCreated() override {};
|
||||
virtual void setUnreadKeys() override {};
|
||||
private:
|
||||
QStringList recentProjects;
|
||||
|
||||
bool reopenOnLaunch;
|
||||
QString stringFromByteArray(QByteArray);
|
||||
QByteArray bytesFromString(QString);
|
||||
MapSortOrder mapSortOrder;
|
||||
bool prettyCursors;
|
||||
QByteArray mainWindowGeometry;
|
||||
QByteArray mainWindowState;
|
||||
QByteArray mapSplitterState;
|
||||
QByteArray mainSplitterState;
|
||||
QByteArray metatilesSplitterState;
|
||||
QByteArray tilesetEditorGeometry;
|
||||
QByteArray tilesetEditorState;
|
||||
QByteArray tilesetEditorSplitterState;
|
||||
QByteArray paletteEditorGeometry;
|
||||
QByteArray paletteEditorState;
|
||||
QByteArray regionMapEditorGeometry;
|
||||
QByteArray regionMapEditorState;
|
||||
QByteArray projectSettingsEditorGeometry;
|
||||
QByteArray projectSettingsEditorState;
|
||||
QByteArray customScriptsEditorGeometry;
|
||||
QByteArray customScriptsEditorState;
|
||||
int collisionOpacity;
|
||||
int collisionZoom;
|
||||
int metatilesZoom;
|
||||
@@ -204,6 +124,35 @@ private:
|
||||
QDateTime lastUpdateCheckTime;
|
||||
QVersionNumber lastUpdateCheckVersion;
|
||||
QMap<QUrl, QDateTime> rateLimitTimes;
|
||||
|
||||
protected:
|
||||
virtual QString getConfigFilepath() override;
|
||||
virtual void parseConfigKeyValue(QString key, QString value) override;
|
||||
virtual QMap<QString, QString> getKeyValueMap() override;
|
||||
virtual void init() override {};
|
||||
virtual void setUnreadKeys() override {};
|
||||
|
||||
private:
|
||||
QString stringFromByteArray(QByteArray);
|
||||
QByteArray bytesFromString(QString);
|
||||
|
||||
QStringList recentProjects;
|
||||
QByteArray mainWindowGeometry;
|
||||
QByteArray mainWindowState;
|
||||
QByteArray mapSplitterState;
|
||||
QByteArray mainSplitterState;
|
||||
QByteArray metatilesSplitterState;
|
||||
QByteArray tilesetEditorGeometry;
|
||||
QByteArray tilesetEditorState;
|
||||
QByteArray tilesetEditorSplitterState;
|
||||
QByteArray paletteEditorGeometry;
|
||||
QByteArray paletteEditorState;
|
||||
QByteArray regionMapEditorGeometry;
|
||||
QByteArray regionMapEditorState;
|
||||
QByteArray projectSettingsEditorGeometry;
|
||||
QByteArray projectSettingsEditorState;
|
||||
QByteArray customScriptsEditorGeometry;
|
||||
QByteArray customScriptsEditorState;
|
||||
};
|
||||
|
||||
extern PorymapConfig porymapConfig;
|
||||
@@ -330,7 +279,7 @@ public:
|
||||
this->baseGameVersion = BaseGameVersion::pokeemerald;
|
||||
// Reset non-version-specific settings
|
||||
this->usePoryScript = false;
|
||||
this->enableTripleLayerMetatiles = false;
|
||||
this->tripleLayerMetatilesEnabled = false;
|
||||
this->defaultMetatileId = 1;
|
||||
this->defaultElevation = 3;
|
||||
this->defaultCollision = 0;
|
||||
@@ -354,52 +303,11 @@ public:
|
||||
static const QMap<ProjectIdentifier, QPair<QString, QString>> defaultIdentifiers;
|
||||
static const QMap<ProjectFilePath, QPair<QString, QString>> defaultPaths;
|
||||
static const QStringList versionStrings;
|
||||
static BaseGameVersion stringToBaseGameVersion(QString string, bool * ok = nullptr);
|
||||
|
||||
void reset(BaseGameVersion baseGameVersion);
|
||||
void setBaseGameVersion(BaseGameVersion baseGameVersion);
|
||||
BaseGameVersion getBaseGameVersion();
|
||||
QString getBaseGameVersionString();
|
||||
QString getBaseGameVersionString(BaseGameVersion version);
|
||||
BaseGameVersion stringToBaseGameVersion(QString string, bool * ok = nullptr);
|
||||
void setUsePoryScript(bool usePoryScript);
|
||||
bool getUsePoryScript();
|
||||
void setProjectDir(QString projectDir);
|
||||
QString getProjectDir();
|
||||
void setUseCustomBorderSize(bool enable);
|
||||
bool getUseCustomBorderSize();
|
||||
void setEventWeatherTriggerEnabled(bool enable);
|
||||
bool getEventWeatherTriggerEnabled();
|
||||
void setEventSecretBaseEnabled(bool enable);
|
||||
bool getEventSecretBaseEnabled();
|
||||
void setHiddenItemQuantityEnabled(bool enable);
|
||||
bool getHiddenItemQuantityEnabled();
|
||||
void setHiddenItemRequiresItemfinderEnabled(bool enable);
|
||||
bool getHiddenItemRequiresItemfinderEnabled();
|
||||
void setHealLocationRespawnDataEnabled(bool enable);
|
||||
bool getHealLocationRespawnDataEnabled();
|
||||
void setEventCloneObjectEnabled(bool enable);
|
||||
bool getEventCloneObjectEnabled();
|
||||
void setFloorNumberEnabled(bool enable);
|
||||
bool getFloorNumberEnabled();
|
||||
void setCreateMapTextFileEnabled(bool enable);
|
||||
bool getCreateMapTextFileEnabled();
|
||||
void setTripleLayerMetatilesEnabled(bool enable);
|
||||
bool getTripleLayerMetatilesEnabled();
|
||||
int getNumLayersInMetatile();
|
||||
int getNumTilesInMetatile();
|
||||
void setDefaultMetatileId(uint16_t metatileId);
|
||||
uint16_t getDefaultMetatileId();
|
||||
void setDefaultElevation(uint16_t elevation);
|
||||
uint16_t getDefaultElevation();
|
||||
void setDefaultCollision(uint16_t collision);
|
||||
uint16_t getDefaultCollision();
|
||||
void setNewMapBorderMetatileIds(QList<uint16_t> metatileIds);
|
||||
QList<uint16_t> getNewMapBorderMetatileIds();
|
||||
QString getDefaultPrimaryTileset();
|
||||
QString getDefaultSecondaryTileset();
|
||||
void setDefaultPrimaryTileset(QString tilesetName);
|
||||
void setDefaultSecondaryTileset(QString tilesetName);
|
||||
void setFilePath(const QString &pathId, const QString &path);
|
||||
void setFilePath(ProjectFilePath pathId, const QString &path);
|
||||
void setFilePath(const QString &pathId, const QString &path);
|
||||
QString getCustomFilePath(ProjectFilePath pathId);
|
||||
QString getCustomFilePath(const QString &pathId);
|
||||
QString getFilePath(ProjectFilePath pathId);
|
||||
@@ -408,75 +316,35 @@ public:
|
||||
QString getCustomIdentifier(ProjectIdentifier id);
|
||||
QString getCustomIdentifier(const QString &id);
|
||||
QString getIdentifier(ProjectIdentifier id);
|
||||
void setPrefabFilepath(QString filepath);
|
||||
QString getPrefabFilepath();
|
||||
void setPrefabImportPrompted(bool prompted);
|
||||
bool getPrefabImportPrompted();
|
||||
void setTilesetsHaveCallback(bool has);
|
||||
bool getTilesetsHaveCallback();
|
||||
void setTilesetsHaveIsCompressed(bool has);
|
||||
bool getTilesetsHaveIsCompressed();
|
||||
int getMetatileAttributesSize();
|
||||
void setMetatileAttributesSize(int size);
|
||||
uint32_t getMetatileBehaviorMask();
|
||||
uint32_t getMetatileTerrainTypeMask();
|
||||
uint32_t getMetatileEncounterTypeMask();
|
||||
uint32_t getMetatileLayerTypeMask();
|
||||
void setMetatileBehaviorMask(uint32_t mask);
|
||||
void setMetatileTerrainTypeMask(uint32_t mask);
|
||||
void setMetatileEncounterTypeMask(uint32_t mask);
|
||||
void setMetatileLayerTypeMask(uint32_t mask);
|
||||
uint16_t getBlockMetatileIdMask();
|
||||
uint16_t getBlockCollisionMask();
|
||||
uint16_t getBlockElevationMask();
|
||||
void setBlockMetatileIdMask(uint16_t mask);
|
||||
void setBlockCollisionMask(uint16_t mask);
|
||||
void setBlockElevationMask(uint16_t mask);
|
||||
bool getMapAllowFlagsEnabled();
|
||||
void setMapAllowFlagsEnabled(bool enabled);
|
||||
QString getBaseGameVersionString(BaseGameVersion version);
|
||||
QString getBaseGameVersionString();
|
||||
int getNumLayersInMetatile();
|
||||
int getNumTilesInMetatile();
|
||||
void setEventIconPath(Event::Group group, const QString &path);
|
||||
QString getEventIconPath(Event::Group group);
|
||||
void setPokemonIconPath(const QString &species, const QString &path);
|
||||
QString getPokemonIconPath(const QString &species);
|
||||
QHash<QString, QString> getPokemonIconPaths();
|
||||
void setCollisionSheetPath(const QString &path);
|
||||
QString getCollisionSheetPath();
|
||||
void setCollisionSheetWidth(int width);
|
||||
int getCollisionSheetWidth();
|
||||
void setCollisionSheetHeight(int height);
|
||||
int getCollisionSheetHeight();
|
||||
void setWarpBehaviors(const QSet<uint32_t> &behaviors);
|
||||
QSet<uint32_t> getWarpBehaviors();
|
||||
|
||||
protected:
|
||||
virtual QString getConfigFilepath() override;
|
||||
virtual void parseConfigKeyValue(QString key, QString value) override;
|
||||
virtual QMap<QString, QString> getKeyValueMap() override;
|
||||
virtual void onNewConfigFileCreated() override;
|
||||
virtual void setUnreadKeys() override;
|
||||
private:
|
||||
BaseGameVersion baseGameVersion;
|
||||
QString projectDir;
|
||||
QMap<ProjectIdentifier, QString> identifiers;
|
||||
QMap<ProjectFilePath, QString> filePaths;
|
||||
bool usePoryScript;
|
||||
bool useCustomBorderSize;
|
||||
bool enableEventWeatherTrigger;
|
||||
bool enableEventSecretBase;
|
||||
bool enableHiddenItemQuantity;
|
||||
bool enableHiddenItemRequiresItemfinder;
|
||||
bool enableHealLocationRespawnData;
|
||||
bool enableEventCloneObject;
|
||||
bool enableFloorNumber;
|
||||
bool createMapTextFile;
|
||||
bool enableTripleLayerMetatiles;
|
||||
bool eventWeatherTriggerEnabled;
|
||||
bool eventSecretBaseEnabled;
|
||||
bool hiddenItemQuantityEnabled;
|
||||
bool hiddenItemRequiresItemfinderEnabled;
|
||||
bool healLocationRespawnDataEnabled;
|
||||
bool eventCloneObjectEnabled;
|
||||
bool floorNumberEnabled;
|
||||
bool createMapTextFileEnabled;
|
||||
bool tripleLayerMetatilesEnabled;
|
||||
uint16_t defaultMetatileId;
|
||||
uint16_t defaultElevation;
|
||||
uint16_t defaultCollision;
|
||||
QList<uint16_t> newMapBorderMetatileIds;
|
||||
QString defaultPrimaryTileset;
|
||||
QString defaultSecondaryTileset;
|
||||
QStringList readKeys;
|
||||
QString prefabFilepath;
|
||||
bool prefabImportPrompted;
|
||||
bool tilesetsHaveCallback;
|
||||
@@ -489,13 +357,25 @@ private:
|
||||
uint16_t blockMetatileIdMask;
|
||||
uint16_t blockCollisionMask;
|
||||
uint16_t blockElevationMask;
|
||||
bool enableMapAllowFlags;
|
||||
QMap<Event::Group, QString> eventIconPaths;
|
||||
QHash<QString, QString> pokemonIconPaths;
|
||||
bool mapAllowFlagsEnabled;
|
||||
QString collisionSheetPath;
|
||||
int collisionSheetWidth;
|
||||
int collisionSheetHeight;
|
||||
QSet<uint32_t> warpBehaviors;
|
||||
|
||||
protected:
|
||||
virtual QString getConfigFilepath() override;
|
||||
virtual void parseConfigKeyValue(QString key, QString value) override;
|
||||
virtual QMap<QString, QString> getKeyValueMap() override;
|
||||
virtual void init() override;
|
||||
virtual void setUnreadKeys() override;
|
||||
|
||||
private:
|
||||
QStringList readKeys;
|
||||
QMap<ProjectIdentifier, QString> identifiers;
|
||||
QMap<ProjectFilePath, QString> filePaths;
|
||||
QMap<Event::Group, QString> eventIconPaths;
|
||||
QHash<QString, QString> pokemonIconPaths;
|
||||
};
|
||||
|
||||
extern ProjectConfig projectConfig;
|
||||
@@ -512,32 +392,29 @@ public:
|
||||
this->customScripts.clear();
|
||||
this->readKeys.clear();
|
||||
}
|
||||
void setRecentMap(const QString &map);
|
||||
QString getRecentMap();
|
||||
void setEncounterJsonActive(bool active);
|
||||
bool getEncounterJsonActive();
|
||||
void setProjectDir(QString projectDir);
|
||||
QString getProjectDir();
|
||||
void parseCustomScripts(QString input);
|
||||
QString outputCustomScripts();
|
||||
void setCustomScripts(QStringList scripts, QList<bool> enabled);
|
||||
QStringList getCustomScriptPaths();
|
||||
QList<bool> getCustomScriptsEnabled();
|
||||
void parseCustomScripts(QString input);
|
||||
QString outputCustomScripts();
|
||||
|
||||
QString projectDir;
|
||||
QString recentMap;
|
||||
bool useEncounterJson;
|
||||
|
||||
protected:
|
||||
virtual QString getConfigFilepath() override;
|
||||
virtual void parseConfigKeyValue(QString key, QString value) override;
|
||||
virtual QMap<QString, QString> getKeyValueMap() override;
|
||||
virtual void onNewConfigFileCreated() override;
|
||||
virtual void init() override;
|
||||
virtual void setUnreadKeys() override;
|
||||
#ifdef CONFIG_BACKWARDS_COMPATABILITY
|
||||
friend class ProjectConfig;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
private:
|
||||
QString projectDir;
|
||||
QString recentMap;
|
||||
bool useEncounterJson;
|
||||
QMap<QString, bool> customScripts;
|
||||
QStringList readKeys;
|
||||
QMap<QString, bool> customScripts;
|
||||
};
|
||||
|
||||
extern UserConfig userConfig;
|
||||
@@ -567,7 +444,7 @@ protected:
|
||||
virtual QString getConfigFilepath() override;
|
||||
virtual void parseConfigKeyValue(QString key, QString value) override;
|
||||
virtual QMap<QString, QString> getKeyValueMap() override;
|
||||
virtual void onNewConfigFileCreated() override { };
|
||||
virtual void init() override { };
|
||||
virtual void setUnreadKeys() override { };
|
||||
|
||||
private:
|
||||
|
||||
@@ -355,7 +355,6 @@ private:
|
||||
void showProjectOpenFailure();
|
||||
void saveGlobalConfigs();
|
||||
bool setInitialMap();
|
||||
void setRecentMap(QString map_name);
|
||||
QStandardItem* createMapItem(QString mapName, int groupNum, int inGroupNum);
|
||||
void refreshRecentProjectsMenu();
|
||||
|
||||
|
||||
@@ -153,6 +153,7 @@ public:
|
||||
void saveAllMaps();
|
||||
void saveMap(Map*);
|
||||
void saveAllDataStructures();
|
||||
void saveConfig();
|
||||
void saveMapLayouts();
|
||||
void saveMapGroups();
|
||||
void saveWildMonData();
|
||||
|
||||
Reference in New Issue
Block a user