Write config files on close / save, not on modification
This commit is contained in:
parent
3fa06229aa
commit
db598a43db
30 changed files with 458 additions and 1220 deletions
277
include/config.h
277
include/config.h
|
@ -33,20 +33,17 @@ class KeyValueConfigBase
|
||||||
public:
|
public:
|
||||||
void save();
|
void save();
|
||||||
void load();
|
void load();
|
||||||
void setSaveDisabled(bool disabled);
|
|
||||||
virtual ~KeyValueConfigBase();
|
virtual ~KeyValueConfigBase();
|
||||||
virtual void reset() = 0;
|
virtual void reset() = 0;
|
||||||
protected:
|
protected:
|
||||||
virtual QString getConfigFilepath() = 0;
|
virtual QString getConfigFilepath() = 0;
|
||||||
virtual void parseConfigKeyValue(QString key, QString value) = 0;
|
virtual void parseConfigKeyValue(QString key, QString value) = 0;
|
||||||
virtual QMap<QString, QString> getKeyValueMap() = 0;
|
virtual QMap<QString, QString> getKeyValueMap() = 0;
|
||||||
virtual void onNewConfigFileCreated() = 0;
|
virtual void init() = 0;
|
||||||
virtual void setUnreadKeys() = 0;
|
virtual void setUnreadKeys() = 0;
|
||||||
bool getConfigBool(QString key, QString value);
|
bool getConfigBool(QString key, QString value);
|
||||||
int getConfigInteger(QString key, QString value, int min = INT_MIN, int max = INT_MAX, int defaultValue = 0);
|
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);
|
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
|
class PorymapConfig: public KeyValueConfigBase
|
||||||
|
@ -86,101 +83,24 @@ public:
|
||||||
}
|
}
|
||||||
void addRecentProject(QString project);
|
void addRecentProject(QString project);
|
||||||
void setRecentProjects(QStringList projects);
|
void setRecentProjects(QStringList projects);
|
||||||
void setReopenOnLaunch(bool enabled);
|
QString getRecentProject();
|
||||||
void setMapSortOrder(MapSortOrder order);
|
QStringList getRecentProjects();
|
||||||
void setPrettyCursors(bool enabled);
|
|
||||||
void setMainGeometry(QByteArray, QByteArray, QByteArray, QByteArray, QByteArray);
|
void setMainGeometry(QByteArray, QByteArray, QByteArray, QByteArray, QByteArray);
|
||||||
void setTilesetEditorGeometry(QByteArray, QByteArray, QByteArray);
|
void setTilesetEditorGeometry(QByteArray, QByteArray, QByteArray);
|
||||||
void setPaletteEditorGeometry(QByteArray, QByteArray);
|
void setPaletteEditorGeometry(QByteArray, QByteArray);
|
||||||
void setRegionMapEditorGeometry(QByteArray, QByteArray);
|
void setRegionMapEditorGeometry(QByteArray, QByteArray);
|
||||||
void setProjectSettingsEditorGeometry(QByteArray, QByteArray);
|
void setProjectSettingsEditorGeometry(QByteArray, QByteArray);
|
||||||
void setCustomScriptsEditorGeometry(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> getMainGeometry();
|
||||||
QMap<QString, QByteArray> getTilesetEditorGeometry();
|
QMap<QString, QByteArray> getTilesetEditorGeometry();
|
||||||
QMap<QString, QByteArray> getPaletteEditorGeometry();
|
QMap<QString, QByteArray> getPaletteEditorGeometry();
|
||||||
QMap<QString, QByteArray> getRegionMapEditorGeometry();
|
QMap<QString, QByteArray> getRegionMapEditorGeometry();
|
||||||
QMap<QString, QByteArray> getProjectSettingsEditorGeometry();
|
QMap<QString, QByteArray> getProjectSettingsEditorGeometry();
|
||||||
QMap<QString, QByteArray> getCustomScriptsEditorGeometry();
|
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;
|
bool reopenOnLaunch;
|
||||||
QString stringFromByteArray(QByteArray);
|
|
||||||
QByteArray bytesFromString(QString);
|
|
||||||
MapSortOrder mapSortOrder;
|
MapSortOrder mapSortOrder;
|
||||||
bool prettyCursors;
|
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 collisionOpacity;
|
||||||
int collisionZoom;
|
int collisionZoom;
|
||||||
int metatilesZoom;
|
int metatilesZoom;
|
||||||
|
@ -204,6 +124,35 @@ private:
|
||||||
QDateTime lastUpdateCheckTime;
|
QDateTime lastUpdateCheckTime;
|
||||||
QVersionNumber lastUpdateCheckVersion;
|
QVersionNumber lastUpdateCheckVersion;
|
||||||
QMap<QUrl, QDateTime> rateLimitTimes;
|
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;
|
extern PorymapConfig porymapConfig;
|
||||||
|
@ -330,7 +279,7 @@ public:
|
||||||
this->baseGameVersion = BaseGameVersion::pokeemerald;
|
this->baseGameVersion = BaseGameVersion::pokeemerald;
|
||||||
// Reset non-version-specific settings
|
// Reset non-version-specific settings
|
||||||
this->usePoryScript = false;
|
this->usePoryScript = false;
|
||||||
this->enableTripleLayerMetatiles = false;
|
this->tripleLayerMetatilesEnabled = false;
|
||||||
this->defaultMetatileId = 1;
|
this->defaultMetatileId = 1;
|
||||||
this->defaultElevation = 3;
|
this->defaultElevation = 3;
|
||||||
this->defaultCollision = 0;
|
this->defaultCollision = 0;
|
||||||
|
@ -354,52 +303,11 @@ public:
|
||||||
static const QMap<ProjectIdentifier, QPair<QString, QString>> defaultIdentifiers;
|
static const QMap<ProjectIdentifier, QPair<QString, QString>> defaultIdentifiers;
|
||||||
static const QMap<ProjectFilePath, QPair<QString, QString>> defaultPaths;
|
static const QMap<ProjectFilePath, QPair<QString, QString>> defaultPaths;
|
||||||
static const QStringList versionStrings;
|
static const QStringList versionStrings;
|
||||||
|
static BaseGameVersion stringToBaseGameVersion(QString string, bool * ok = nullptr);
|
||||||
|
|
||||||
void reset(BaseGameVersion baseGameVersion);
|
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(ProjectFilePath pathId, const QString &path);
|
||||||
|
void setFilePath(const QString &pathId, const QString &path);
|
||||||
QString getCustomFilePath(ProjectFilePath pathId);
|
QString getCustomFilePath(ProjectFilePath pathId);
|
||||||
QString getCustomFilePath(const QString &pathId);
|
QString getCustomFilePath(const QString &pathId);
|
||||||
QString getFilePath(ProjectFilePath pathId);
|
QString getFilePath(ProjectFilePath pathId);
|
||||||
|
@ -408,75 +316,35 @@ public:
|
||||||
QString getCustomIdentifier(ProjectIdentifier id);
|
QString getCustomIdentifier(ProjectIdentifier id);
|
||||||
QString getCustomIdentifier(const QString &id);
|
QString getCustomIdentifier(const QString &id);
|
||||||
QString getIdentifier(ProjectIdentifier id);
|
QString getIdentifier(ProjectIdentifier id);
|
||||||
void setPrefabFilepath(QString filepath);
|
QString getBaseGameVersionString(BaseGameVersion version);
|
||||||
QString getPrefabFilepath();
|
QString getBaseGameVersionString();
|
||||||
void setPrefabImportPrompted(bool prompted);
|
int getNumLayersInMetatile();
|
||||||
bool getPrefabImportPrompted();
|
int getNumTilesInMetatile();
|
||||||
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);
|
|
||||||
void setEventIconPath(Event::Group group, const QString &path);
|
void setEventIconPath(Event::Group group, const QString &path);
|
||||||
QString getEventIconPath(Event::Group group);
|
QString getEventIconPath(Event::Group group);
|
||||||
void setPokemonIconPath(const QString &species, const QString &path);
|
void setPokemonIconPath(const QString &species, const QString &path);
|
||||||
QString getPokemonIconPath(const QString &species);
|
QString getPokemonIconPath(const QString &species);
|
||||||
QHash<QString, QString> getPokemonIconPaths();
|
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;
|
BaseGameVersion baseGameVersion;
|
||||||
QString projectDir;
|
QString projectDir;
|
||||||
QMap<ProjectIdentifier, QString> identifiers;
|
|
||||||
QMap<ProjectFilePath, QString> filePaths;
|
|
||||||
bool usePoryScript;
|
bool usePoryScript;
|
||||||
bool useCustomBorderSize;
|
bool useCustomBorderSize;
|
||||||
bool enableEventWeatherTrigger;
|
bool eventWeatherTriggerEnabled;
|
||||||
bool enableEventSecretBase;
|
bool eventSecretBaseEnabled;
|
||||||
bool enableHiddenItemQuantity;
|
bool hiddenItemQuantityEnabled;
|
||||||
bool enableHiddenItemRequiresItemfinder;
|
bool hiddenItemRequiresItemfinderEnabled;
|
||||||
bool enableHealLocationRespawnData;
|
bool healLocationRespawnDataEnabled;
|
||||||
bool enableEventCloneObject;
|
bool eventCloneObjectEnabled;
|
||||||
bool enableFloorNumber;
|
bool floorNumberEnabled;
|
||||||
bool createMapTextFile;
|
bool createMapTextFileEnabled;
|
||||||
bool enableTripleLayerMetatiles;
|
bool tripleLayerMetatilesEnabled;
|
||||||
uint16_t defaultMetatileId;
|
uint16_t defaultMetatileId;
|
||||||
uint16_t defaultElevation;
|
uint16_t defaultElevation;
|
||||||
uint16_t defaultCollision;
|
uint16_t defaultCollision;
|
||||||
QList<uint16_t> newMapBorderMetatileIds;
|
QList<uint16_t> newMapBorderMetatileIds;
|
||||||
QString defaultPrimaryTileset;
|
QString defaultPrimaryTileset;
|
||||||
QString defaultSecondaryTileset;
|
QString defaultSecondaryTileset;
|
||||||
QStringList readKeys;
|
|
||||||
QString prefabFilepath;
|
QString prefabFilepath;
|
||||||
bool prefabImportPrompted;
|
bool prefabImportPrompted;
|
||||||
bool tilesetsHaveCallback;
|
bool tilesetsHaveCallback;
|
||||||
|
@ -489,13 +357,25 @@ private:
|
||||||
uint16_t blockMetatileIdMask;
|
uint16_t blockMetatileIdMask;
|
||||||
uint16_t blockCollisionMask;
|
uint16_t blockCollisionMask;
|
||||||
uint16_t blockElevationMask;
|
uint16_t blockElevationMask;
|
||||||
bool enableMapAllowFlags;
|
bool mapAllowFlagsEnabled;
|
||||||
QMap<Event::Group, QString> eventIconPaths;
|
|
||||||
QHash<QString, QString> pokemonIconPaths;
|
|
||||||
QString collisionSheetPath;
|
QString collisionSheetPath;
|
||||||
int collisionSheetWidth;
|
int collisionSheetWidth;
|
||||||
int collisionSheetHeight;
|
int collisionSheetHeight;
|
||||||
QSet<uint32_t> warpBehaviors;
|
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;
|
extern ProjectConfig projectConfig;
|
||||||
|
@ -512,32 +392,29 @@ public:
|
||||||
this->customScripts.clear();
|
this->customScripts.clear();
|
||||||
this->readKeys.clear();
|
this->readKeys.clear();
|
||||||
}
|
}
|
||||||
void setRecentMap(const QString &map);
|
void parseCustomScripts(QString input);
|
||||||
QString getRecentMap();
|
QString outputCustomScripts();
|
||||||
void setEncounterJsonActive(bool active);
|
|
||||||
bool getEncounterJsonActive();
|
|
||||||
void setProjectDir(QString projectDir);
|
|
||||||
QString getProjectDir();
|
|
||||||
void setCustomScripts(QStringList scripts, QList<bool> enabled);
|
void setCustomScripts(QStringList scripts, QList<bool> enabled);
|
||||||
QStringList getCustomScriptPaths();
|
QStringList getCustomScriptPaths();
|
||||||
QList<bool> getCustomScriptsEnabled();
|
QList<bool> getCustomScriptsEnabled();
|
||||||
void parseCustomScripts(QString input);
|
|
||||||
QString outputCustomScripts();
|
QString projectDir;
|
||||||
|
QString recentMap;
|
||||||
|
bool useEncounterJson;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual QString getConfigFilepath() override;
|
virtual QString getConfigFilepath() override;
|
||||||
virtual void parseConfigKeyValue(QString key, QString value) override;
|
virtual void parseConfigKeyValue(QString key, QString value) override;
|
||||||
virtual QMap<QString, QString> getKeyValueMap() override;
|
virtual QMap<QString, QString> getKeyValueMap() override;
|
||||||
virtual void onNewConfigFileCreated() override;
|
virtual void init() override;
|
||||||
virtual void setUnreadKeys() override;
|
virtual void setUnreadKeys() override;
|
||||||
#ifdef CONFIG_BACKWARDS_COMPATABILITY
|
#ifdef CONFIG_BACKWARDS_COMPATABILITY
|
||||||
friend class ProjectConfig;
|
friend class ProjectConfig;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString projectDir;
|
|
||||||
QString recentMap;
|
|
||||||
bool useEncounterJson;
|
|
||||||
QMap<QString, bool> customScripts;
|
|
||||||
QStringList readKeys;
|
QStringList readKeys;
|
||||||
|
QMap<QString, bool> customScripts;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern UserConfig userConfig;
|
extern UserConfig userConfig;
|
||||||
|
@ -567,7 +444,7 @@ protected:
|
||||||
virtual QString getConfigFilepath() override;
|
virtual QString getConfigFilepath() override;
|
||||||
virtual void parseConfigKeyValue(QString key, QString value) override;
|
virtual void parseConfigKeyValue(QString key, QString value) override;
|
||||||
virtual QMap<QString, QString> getKeyValueMap() override;
|
virtual QMap<QString, QString> getKeyValueMap() override;
|
||||||
virtual void onNewConfigFileCreated() override { };
|
virtual void init() override { };
|
||||||
virtual void setUnreadKeys() override { };
|
virtual void setUnreadKeys() override { };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -355,7 +355,6 @@ private:
|
||||||
void showProjectOpenFailure();
|
void showProjectOpenFailure();
|
||||||
void saveGlobalConfigs();
|
void saveGlobalConfigs();
|
||||||
bool setInitialMap();
|
bool setInitialMap();
|
||||||
void setRecentMap(QString map_name);
|
|
||||||
QStandardItem* createMapItem(QString mapName, int groupNum, int inGroupNum);
|
QStandardItem* createMapItem(QString mapName, int groupNum, int inGroupNum);
|
||||||
void refreshRecentProjectsMenu();
|
void refreshRecentProjectsMenu();
|
||||||
|
|
||||||
|
|
|
@ -153,6 +153,7 @@ public:
|
||||||
void saveAllMaps();
|
void saveAllMaps();
|
||||||
void saveMap(Map*);
|
void saveMap(Map*);
|
||||||
void saveAllDataStructures();
|
void saveAllDataStructures();
|
||||||
|
void saveConfig();
|
||||||
void saveMapLayouts();
|
void saveMapLayouts();
|
||||||
void saveMapGroups();
|
void saveMapGroups();
|
||||||
void saveWildMonData();
|
void saveWildMonData();
|
||||||
|
|
750
src/config.cpp
750
src/config.cpp
|
@ -198,16 +198,9 @@ KeyValueConfigBase::~KeyValueConfigBase() {
|
||||||
void KeyValueConfigBase::load() {
|
void KeyValueConfigBase::load() {
|
||||||
reset();
|
reset();
|
||||||
QFile file(this->getConfigFilepath());
|
QFile file(this->getConfigFilepath());
|
||||||
if (!file.exists()) {
|
if (!file.exists())
|
||||||
if (!file.open(QIODevice::WriteOnly)) {
|
this->init();
|
||||||
logError(QString("Could not create config file '%1'").arg(this->getConfigFilepath()));
|
else if (!file.open(QIODevice::ReadOnly)) {
|
||||||
} else {
|
|
||||||
file.close();
|
|
||||||
this->onNewConfigFileCreated();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!file.open(QIODevice::ReadOnly)) {
|
|
||||||
logError(QString("Could not open config file '%1': ").arg(this->getConfigFilepath()) + file.errorString());
|
logError(QString("Could not open config file '%1': ").arg(this->getConfigFilepath()) + file.errorString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,15 +227,11 @@ void KeyValueConfigBase::load() {
|
||||||
this->parseConfigKeyValue(match.captured("key").trimmed().toLower(), match.captured("value").trimmed());
|
this->parseConfigKeyValue(match.captured("key").trimmed().toLower(), match.captured("value").trimmed());
|
||||||
}
|
}
|
||||||
this->setUnreadKeys();
|
this->setUnreadKeys();
|
||||||
this->save();
|
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyValueConfigBase::save() {
|
void KeyValueConfigBase::save() {
|
||||||
if (this->saveDisabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
QString text = "";
|
QString text = "";
|
||||||
QMap<QString, QString> map = this->getKeyValueMap();
|
QMap<QString, QString> map = this->getKeyValueMap();
|
||||||
for (QMap<QString, QString>::iterator it = map.begin(); it != map.end(); it++) {
|
for (QMap<QString, QString>::iterator it = map.begin(); it != map.end(); it++) {
|
||||||
|
@ -287,11 +276,6 @@ uint32_t KeyValueConfigBase::getConfigUint32(QString key, QString value, uint32_
|
||||||
return qMin(max, qMax(min, result));
|
return qMin(max, qMax(min, result));
|
||||||
}
|
}
|
||||||
|
|
||||||
// For temporarily disabling saving during frequent config changes.
|
|
||||||
void KeyValueConfigBase::setSaveDisabled(bool disabled) {
|
|
||||||
this->saveDisabled = disabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QMap<MapSortOrder, QString> mapSortOrderMap = {
|
const QMap<MapSortOrder, QString> mapSortOrderMap = {
|
||||||
{MapSortOrder::Group, "group"},
|
{MapSortOrder::Group, "group"},
|
||||||
{MapSortOrder::Layout, "layout"},
|
{MapSortOrder::Layout, "layout"},
|
||||||
|
@ -504,183 +488,10 @@ QByteArray PorymapConfig::bytesFromString(QString in) {
|
||||||
void PorymapConfig::addRecentProject(QString project) {
|
void PorymapConfig::addRecentProject(QString project) {
|
||||||
this->recentProjects.removeOne(project);
|
this->recentProjects.removeOne(project);
|
||||||
this->recentProjects.prepend(project);
|
this->recentProjects.prepend(project);
|
||||||
this->save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PorymapConfig::setRecentProjects(QStringList projects) {
|
void PorymapConfig::setRecentProjects(QStringList projects) {
|
||||||
this->recentProjects = projects;
|
this->recentProjects = projects;
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setReopenOnLaunch(bool enabled) {
|
|
||||||
this->reopenOnLaunch = enabled;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setMapSortOrder(MapSortOrder order) {
|
|
||||||
this->mapSortOrder = order;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setPrettyCursors(bool enabled) {
|
|
||||||
this->prettyCursors = enabled;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setMonitorFiles(bool monitor) {
|
|
||||||
this->monitorFiles = monitor;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setTilesetCheckerboardFill(bool checkerboard) {
|
|
||||||
this->tilesetCheckerboardFill = checkerboard;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setMainGeometry(QByteArray mainWindowGeometry_, QByteArray mainWindowState_,
|
|
||||||
QByteArray mapSplitterState_, QByteArray mainSplitterState_, QByteArray metatilesSplitterState_) {
|
|
||||||
this->mainWindowGeometry = mainWindowGeometry_;
|
|
||||||
this->mainWindowState = mainWindowState_;
|
|
||||||
this->mapSplitterState = mapSplitterState_;
|
|
||||||
this->mainSplitterState = mainSplitterState_;
|
|
||||||
this->metatilesSplitterState = metatilesSplitterState_;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setTilesetEditorGeometry(QByteArray tilesetEditorGeometry_, QByteArray tilesetEditorState_,
|
|
||||||
QByteArray tilesetEditorSplitterState_) {
|
|
||||||
this->tilesetEditorGeometry = tilesetEditorGeometry_;
|
|
||||||
this->tilesetEditorState = tilesetEditorState_;
|
|
||||||
this->tilesetEditorSplitterState = tilesetEditorSplitterState_;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setPaletteEditorGeometry(QByteArray paletteEditorGeometry_, QByteArray paletteEditorState_) {
|
|
||||||
this->paletteEditorGeometry = paletteEditorGeometry_;
|
|
||||||
this->paletteEditorState = paletteEditorState_;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setRegionMapEditorGeometry(QByteArray regionMapEditorGeometry_, QByteArray regionMapEditorState_) {
|
|
||||||
this->regionMapEditorGeometry = regionMapEditorGeometry_;
|
|
||||||
this->regionMapEditorState = regionMapEditorState_;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setProjectSettingsEditorGeometry(QByteArray projectSettingsEditorGeometry_, QByteArray projectSettingsEditorState_) {
|
|
||||||
this->projectSettingsEditorGeometry = projectSettingsEditorGeometry_;
|
|
||||||
this->projectSettingsEditorState = projectSettingsEditorState_;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setCustomScriptsEditorGeometry(QByteArray customScriptsEditorGeometry_, QByteArray customScriptsEditorState_) {
|
|
||||||
this->customScriptsEditorGeometry = customScriptsEditorGeometry_;
|
|
||||||
this->customScriptsEditorState = customScriptsEditorState_;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setCollisionOpacity(int opacity) {
|
|
||||||
this->collisionOpacity = opacity;
|
|
||||||
// don't auto-save here because this can be called very frequently.
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setCollisionZoom(int zoom) {
|
|
||||||
this->collisionZoom = zoom;
|
|
||||||
// don't auto-save here because this can be called very frequently.
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setMetatilesZoom(int zoom) {
|
|
||||||
this->metatilesZoom = zoom;
|
|
||||||
// don't auto-save here because this can be called very frequently.
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setTilesetEditorMetatilesZoom(int zoom) {
|
|
||||||
this->tilesetEditorMetatilesZoom = zoom;
|
|
||||||
// don't auto-save here because this can be called very frequently.
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setTilesetEditorTilesZoom(int zoom) {
|
|
||||||
this->tilesetEditorTilesZoom = zoom;
|
|
||||||
// don't auto-save here because this can be called very frequently.
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setShowPlayerView(bool enabled) {
|
|
||||||
this->showPlayerView = enabled;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setShowCursorTile(bool enabled) {
|
|
||||||
this->showCursorTile = enabled;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setShowBorder(bool enabled) {
|
|
||||||
this->showBorder = enabled;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setShowGrid(bool enabled) {
|
|
||||||
this->showGrid = enabled;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setShowTilesetEditorMetatileGrid(bool enabled) {
|
|
||||||
this->showTilesetEditorMetatileGrid = enabled;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setShowTilesetEditorLayerGrid(bool enabled) {
|
|
||||||
this->showTilesetEditorLayerGrid = enabled;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setTheme(QString theme) {
|
|
||||||
this->theme = theme;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setTextEditorOpenFolder(const QString &command) {
|
|
||||||
this->textEditorOpenFolder = command;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setTextEditorGotoLine(const QString &command) {
|
|
||||||
this->textEditorGotoLine = command;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setPaletteEditorBitDepth(int bitDepth) {
|
|
||||||
this->paletteEditorBitDepth = bitDepth;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setProjectSettingsTab(int tab) {
|
|
||||||
this->projectSettingsTab = tab;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setWarpBehaviorWarningDisabled(bool disabled) {
|
|
||||||
this->warpBehaviorWarningDisabled = disabled;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setCheckForUpdates(bool enabled) {
|
|
||||||
this->checkForUpdates = enabled;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setLastUpdateCheckTime(QDateTime time) {
|
|
||||||
this->lastUpdateCheckTime = time;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setLastUpdateCheckVersion(QVersionNumber version) {
|
|
||||||
this->lastUpdateCheckVersion = version;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PorymapConfig::setRateLimitTimes(QMap<QUrl, QDateTime> map) {
|
|
||||||
this->rateLimitTimes = map;
|
|
||||||
this->save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString PorymapConfig::getRecentProject() {
|
QString PorymapConfig::getRecentProject() {
|
||||||
|
@ -691,16 +502,40 @@ QStringList PorymapConfig::getRecentProjects() {
|
||||||
return this->recentProjects;
|
return this->recentProjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PorymapConfig::getReopenOnLaunch() {
|
void PorymapConfig::setMainGeometry(QByteArray mainWindowGeometry_, QByteArray mainWindowState_,
|
||||||
return this->reopenOnLaunch;
|
QByteArray mapSplitterState_, QByteArray mainSplitterState_, QByteArray metatilesSplitterState_) {
|
||||||
|
this->mainWindowGeometry = mainWindowGeometry_;
|
||||||
|
this->mainWindowState = mainWindowState_;
|
||||||
|
this->mapSplitterState = mapSplitterState_;
|
||||||
|
this->mainSplitterState = mainSplitterState_;
|
||||||
|
this->metatilesSplitterState = metatilesSplitterState_;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapSortOrder PorymapConfig::getMapSortOrder() {
|
void PorymapConfig::setTilesetEditorGeometry(QByteArray tilesetEditorGeometry_, QByteArray tilesetEditorState_,
|
||||||
return this->mapSortOrder;
|
QByteArray tilesetEditorSplitterState_) {
|
||||||
|
this->tilesetEditorGeometry = tilesetEditorGeometry_;
|
||||||
|
this->tilesetEditorState = tilesetEditorState_;
|
||||||
|
this->tilesetEditorSplitterState = tilesetEditorSplitterState_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PorymapConfig::getPrettyCursors() {
|
void PorymapConfig::setPaletteEditorGeometry(QByteArray paletteEditorGeometry_, QByteArray paletteEditorState_) {
|
||||||
return this->prettyCursors;
|
this->paletteEditorGeometry = paletteEditorGeometry_;
|
||||||
|
this->paletteEditorState = paletteEditorState_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PorymapConfig::setRegionMapEditorGeometry(QByteArray regionMapEditorGeometry_, QByteArray regionMapEditorState_) {
|
||||||
|
this->regionMapEditorGeometry = regionMapEditorGeometry_;
|
||||||
|
this->regionMapEditorState = regionMapEditorState_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PorymapConfig::setProjectSettingsEditorGeometry(QByteArray projectSettingsEditorGeometry_, QByteArray projectSettingsEditorState_) {
|
||||||
|
this->projectSettingsEditorGeometry = projectSettingsEditorGeometry_;
|
||||||
|
this->projectSettingsEditorState = projectSettingsEditorState_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PorymapConfig::setCustomScriptsEditorGeometry(QByteArray customScriptsEditorGeometry_, QByteArray customScriptsEditorState_) {
|
||||||
|
this->customScriptsEditorGeometry = customScriptsEditorGeometry_;
|
||||||
|
this->customScriptsEditorState = customScriptsEditorState_;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, QByteArray> PorymapConfig::getMainGeometry() {
|
QMap<QString, QByteArray> PorymapConfig::getMainGeometry() {
|
||||||
|
@ -761,98 +596,6 @@ QMap<QString, QByteArray> PorymapConfig::getCustomScriptsEditorGeometry() {
|
||||||
return geometry;
|
return geometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
int PorymapConfig::getCollisionOpacity() {
|
|
||||||
return this->collisionOpacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
int PorymapConfig::getCollisionZoom() {
|
|
||||||
return this->collisionZoom;
|
|
||||||
}
|
|
||||||
|
|
||||||
int PorymapConfig::getMetatilesZoom() {
|
|
||||||
return this->metatilesZoom;
|
|
||||||
}
|
|
||||||
|
|
||||||
int PorymapConfig::getTilesetEditorMetatilesZoom() {
|
|
||||||
return this->tilesetEditorMetatilesZoom;
|
|
||||||
}
|
|
||||||
|
|
||||||
int PorymapConfig::getTilesetEditorTilesZoom() {
|
|
||||||
return this->tilesetEditorTilesZoom;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PorymapConfig::getShowPlayerView() {
|
|
||||||
return this->showPlayerView;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PorymapConfig::getShowCursorTile() {
|
|
||||||
return this->showCursorTile;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PorymapConfig::getShowBorder() {
|
|
||||||
return this->showBorder;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PorymapConfig::getShowGrid() {
|
|
||||||
return this->showGrid;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PorymapConfig::getShowTilesetEditorMetatileGrid() {
|
|
||||||
return this->showTilesetEditorMetatileGrid;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PorymapConfig::getShowTilesetEditorLayerGrid() {
|
|
||||||
return this->showTilesetEditorLayerGrid;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PorymapConfig::getMonitorFiles() {
|
|
||||||
return this->monitorFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PorymapConfig::getTilesetCheckerboardFill() {
|
|
||||||
return this->tilesetCheckerboardFill;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString PorymapConfig::getTheme() {
|
|
||||||
return this->theme;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString PorymapConfig::getTextEditorOpenFolder() {
|
|
||||||
return this->textEditorOpenFolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString PorymapConfig::getTextEditorGotoLine() {
|
|
||||||
return this->textEditorGotoLine;
|
|
||||||
}
|
|
||||||
|
|
||||||
int PorymapConfig::getPaletteEditorBitDepth() {
|
|
||||||
return this->paletteEditorBitDepth;
|
|
||||||
}
|
|
||||||
|
|
||||||
int PorymapConfig::getProjectSettingsTab() {
|
|
||||||
return this->projectSettingsTab;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PorymapConfig::getWarpBehaviorWarningDisabled() {
|
|
||||||
return this->warpBehaviorWarningDisabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PorymapConfig::getCheckForUpdates() {
|
|
||||||
return this->checkForUpdates;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDateTime PorymapConfig::getLastUpdateCheckTime() {
|
|
||||||
return this->lastUpdateCheckTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVersionNumber PorymapConfig::getLastUpdateCheckVersion() {
|
|
||||||
return this->lastUpdateCheckVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMap<QUrl, QDateTime> PorymapConfig::getRateLimitTimes() {
|
|
||||||
return this->rateLimitTimes;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QStringList ProjectConfig::versionStrings = {
|
const QStringList ProjectConfig::versionStrings = {
|
||||||
"pokeruby",
|
"pokeruby",
|
||||||
"pokefirered",
|
"pokefirered",
|
||||||
|
@ -899,24 +642,24 @@ void ProjectConfig::parseConfigKeyValue(QString key, QString value) {
|
||||||
} else if (key == "use_custom_border_size") {
|
} else if (key == "use_custom_border_size") {
|
||||||
this->useCustomBorderSize = getConfigBool(key, value);
|
this->useCustomBorderSize = getConfigBool(key, value);
|
||||||
} else if (key == "enable_event_weather_trigger") {
|
} else if (key == "enable_event_weather_trigger") {
|
||||||
this->enableEventWeatherTrigger = getConfigBool(key, value);
|
this->eventWeatherTriggerEnabled = getConfigBool(key, value);
|
||||||
} else if (key == "enable_event_secret_base") {
|
} else if (key == "enable_event_secret_base") {
|
||||||
this->enableEventSecretBase = getConfigBool(key, value);
|
this->eventSecretBaseEnabled = getConfigBool(key, value);
|
||||||
} else if (key == "enable_hidden_item_quantity") {
|
} else if (key == "enable_hidden_item_quantity") {
|
||||||
this->enableHiddenItemQuantity = getConfigBool(key, value);
|
this->hiddenItemQuantityEnabled = getConfigBool(key, value);
|
||||||
} else if (key == "enable_hidden_item_requires_itemfinder") {
|
} else if (key == "enable_hidden_item_requires_itemfinder") {
|
||||||
this->enableHiddenItemRequiresItemfinder = getConfigBool(key, value);
|
this->hiddenItemRequiresItemfinderEnabled = getConfigBool(key, value);
|
||||||
} else if (key == "enable_heal_location_respawn_data") {
|
} else if (key == "enable_heal_location_respawn_data") {
|
||||||
this->enableHealLocationRespawnData = getConfigBool(key, value);
|
this->healLocationRespawnDataEnabled = getConfigBool(key, value);
|
||||||
} else if (key == "enable_event_clone_object" || key == "enable_object_event_in_connection") {
|
} else if (key == "enable_event_clone_object" || key == "enable_object_event_in_connection") {
|
||||||
this->enableEventCloneObject = getConfigBool(key, value);
|
this->eventCloneObjectEnabled = getConfigBool(key, value);
|
||||||
key = "enable_event_clone_object"; // Backwards compatibiliy, replace old name above
|
key = "enable_event_clone_object"; // Backwards compatibiliy, replace old name above
|
||||||
} else if (key == "enable_floor_number") {
|
} else if (key == "enable_floor_number") {
|
||||||
this->enableFloorNumber = getConfigBool(key, value);
|
this->floorNumberEnabled = getConfigBool(key, value);
|
||||||
} else if (key == "create_map_text_file") {
|
} else if (key == "create_map_text_file") {
|
||||||
this->createMapTextFile = getConfigBool(key, value);
|
this->createMapTextFileEnabled = getConfigBool(key, value);
|
||||||
} else if (key == "enable_triple_layer_metatiles") {
|
} else if (key == "enable_triple_layer_metatiles") {
|
||||||
this->enableTripleLayerMetatiles = getConfigBool(key, value);
|
this->tripleLayerMetatilesEnabled = getConfigBool(key, value);
|
||||||
} else if (key == "default_metatile") {
|
} else if (key == "default_metatile") {
|
||||||
this->defaultMetatileId = getConfigUint32(key, value, 0, Block::maxValue);
|
this->defaultMetatileId = getConfigUint32(key, value, 0, Block::maxValue);
|
||||||
} else if (key == "default_elevation") {
|
} else if (key == "default_elevation") {
|
||||||
|
@ -956,10 +699,10 @@ void ProjectConfig::parseConfigKeyValue(QString key, QString value) {
|
||||||
} else if (key == "block_elevation_mask") {
|
} else if (key == "block_elevation_mask") {
|
||||||
this->blockElevationMask = getConfigUint32(key, value, 0, Block::maxValue);
|
this->blockElevationMask = getConfigUint32(key, value, 0, Block::maxValue);
|
||||||
} else if (key == "enable_map_allow_flags") {
|
} else if (key == "enable_map_allow_flags") {
|
||||||
this->enableMapAllowFlags = getConfigBool(key, value);
|
this->mapAllowFlagsEnabled = getConfigBool(key, value);
|
||||||
#ifdef CONFIG_BACKWARDS_COMPATABILITY
|
#ifdef CONFIG_BACKWARDS_COMPATABILITY
|
||||||
} else if (key == "recent_map") {
|
} else if (key == "recent_map") {
|
||||||
userConfig.setRecentMap(value);
|
userConfig.recentMap = value;
|
||||||
} else if (key == "use_encounter_json") {
|
} else if (key == "use_encounter_json") {
|
||||||
userConfig.useEncounterJson = getConfigBool(key, value);
|
userConfig.useEncounterJson = getConfigBool(key, value);
|
||||||
} else if (key == "custom_scripts") {
|
} else if (key == "custom_scripts") {
|
||||||
|
@ -1028,14 +771,14 @@ void ProjectConfig::setUnreadKeys() {
|
||||||
// Set game-version specific defaults for any config field that wasn't read
|
// Set game-version specific defaults for any config field that wasn't read
|
||||||
bool isPokefirered = this->baseGameVersion == BaseGameVersion::pokefirered;
|
bool isPokefirered = this->baseGameVersion == BaseGameVersion::pokefirered;
|
||||||
if (!readKeys.contains("use_custom_border_size")) this->useCustomBorderSize = isPokefirered;
|
if (!readKeys.contains("use_custom_border_size")) this->useCustomBorderSize = isPokefirered;
|
||||||
if (!readKeys.contains("enable_event_weather_trigger")) this->enableEventWeatherTrigger = !isPokefirered;
|
if (!readKeys.contains("enable_event_weather_trigger")) this->eventWeatherTriggerEnabled = !isPokefirered;
|
||||||
if (!readKeys.contains("enable_event_secret_base")) this->enableEventSecretBase = !isPokefirered;
|
if (!readKeys.contains("enable_event_secret_base")) this->eventSecretBaseEnabled = !isPokefirered;
|
||||||
if (!readKeys.contains("enable_hidden_item_quantity")) this->enableHiddenItemQuantity = isPokefirered;
|
if (!readKeys.contains("enable_hidden_item_quantity")) this->hiddenItemQuantityEnabled = isPokefirered;
|
||||||
if (!readKeys.contains("enable_hidden_item_requires_itemfinder")) this->enableHiddenItemRequiresItemfinder = isPokefirered;
|
if (!readKeys.contains("enable_hidden_item_requires_itemfinder")) this->hiddenItemRequiresItemfinderEnabled = isPokefirered;
|
||||||
if (!readKeys.contains("enable_heal_location_respawn_data")) this->enableHealLocationRespawnData = isPokefirered;
|
if (!readKeys.contains("enable_heal_location_respawn_data")) this->healLocationRespawnDataEnabled = isPokefirered;
|
||||||
if (!readKeys.contains("enable_event_clone_object")) this->enableEventCloneObject = isPokefirered;
|
if (!readKeys.contains("enable_event_clone_object")) this->eventCloneObjectEnabled = isPokefirered;
|
||||||
if (!readKeys.contains("enable_floor_number")) this->enableFloorNumber = isPokefirered;
|
if (!readKeys.contains("enable_floor_number")) this->floorNumberEnabled = isPokefirered;
|
||||||
if (!readKeys.contains("create_map_text_file")) this->createMapTextFile = (this->baseGameVersion != BaseGameVersion::pokeemerald);
|
if (!readKeys.contains("create_map_text_file")) this->createMapTextFileEnabled = (this->baseGameVersion != BaseGameVersion::pokeemerald);
|
||||||
if (!readKeys.contains("new_map_border_metatiles")) this->newMapBorderMetatileIds = isPokefirered ? DEFAULT_BORDER_FRLG : DEFAULT_BORDER_RSE;
|
if (!readKeys.contains("new_map_border_metatiles")) this->newMapBorderMetatileIds = isPokefirered ? DEFAULT_BORDER_FRLG : DEFAULT_BORDER_RSE;
|
||||||
if (!readKeys.contains("default_secondary_tileset")) this->defaultSecondaryTileset = isPokefirered ? "gTileset_PalletTown" : "gTileset_Petalburg";
|
if (!readKeys.contains("default_secondary_tileset")) this->defaultSecondaryTileset = isPokefirered ? "gTileset_PalletTown" : "gTileset_Petalburg";
|
||||||
if (!readKeys.contains("metatile_attributes_size")) this->metatileAttributesSize = Metatile::getDefaultAttributesSize(this->baseGameVersion);
|
if (!readKeys.contains("metatile_attributes_size")) this->metatileAttributesSize = Metatile::getDefaultAttributesSize(this->baseGameVersion);
|
||||||
|
@ -1043,7 +786,7 @@ void ProjectConfig::setUnreadKeys() {
|
||||||
if (!readKeys.contains("metatile_terrain_type_mask")) this->metatileTerrainTypeMask = Metatile::getDefaultAttributesMask(this->baseGameVersion, Metatile::Attr::TerrainType);
|
if (!readKeys.contains("metatile_terrain_type_mask")) this->metatileTerrainTypeMask = Metatile::getDefaultAttributesMask(this->baseGameVersion, Metatile::Attr::TerrainType);
|
||||||
if (!readKeys.contains("metatile_encounter_type_mask")) this->metatileEncounterTypeMask = Metatile::getDefaultAttributesMask(this->baseGameVersion, Metatile::Attr::EncounterType);
|
if (!readKeys.contains("metatile_encounter_type_mask")) this->metatileEncounterTypeMask = Metatile::getDefaultAttributesMask(this->baseGameVersion, Metatile::Attr::EncounterType);
|
||||||
if (!readKeys.contains("metatile_layer_type_mask")) this->metatileLayerTypeMask = Metatile::getDefaultAttributesMask(this->baseGameVersion, Metatile::Attr::LayerType);
|
if (!readKeys.contains("metatile_layer_type_mask")) this->metatileLayerTypeMask = Metatile::getDefaultAttributesMask(this->baseGameVersion, Metatile::Attr::LayerType);
|
||||||
if (!readKeys.contains("enable_map_allow_flags")) this->enableMapAllowFlags = (this->baseGameVersion != BaseGameVersion::pokeruby);
|
if (!readKeys.contains("enable_map_allow_flags")) this->mapAllowFlagsEnabled = (this->baseGameVersion != BaseGameVersion::pokeruby);
|
||||||
if (!readKeys.contains("warp_behaviors")) this->warpBehaviors = isPokefirered ? defaultWarpBehaviors_FRLG : defaultWarpBehaviors_RSE;
|
if (!readKeys.contains("warp_behaviors")) this->warpBehaviors = isPokefirered ? defaultWarpBehaviors_FRLG : defaultWarpBehaviors_RSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1052,15 +795,15 @@ QMap<QString, QString> ProjectConfig::getKeyValueMap() {
|
||||||
map.insert("base_game_version", baseGameVersionMap.value(this->baseGameVersion));
|
map.insert("base_game_version", baseGameVersionMap.value(this->baseGameVersion));
|
||||||
map.insert("use_poryscript", QString::number(this->usePoryScript));
|
map.insert("use_poryscript", QString::number(this->usePoryScript));
|
||||||
map.insert("use_custom_border_size", QString::number(this->useCustomBorderSize));
|
map.insert("use_custom_border_size", QString::number(this->useCustomBorderSize));
|
||||||
map.insert("enable_event_weather_trigger", QString::number(this->enableEventWeatherTrigger));
|
map.insert("enable_event_weather_trigger", QString::number(this->eventWeatherTriggerEnabled));
|
||||||
map.insert("enable_event_secret_base", QString::number(this->enableEventSecretBase));
|
map.insert("enable_event_secret_base", QString::number(this->eventSecretBaseEnabled));
|
||||||
map.insert("enable_hidden_item_quantity", QString::number(this->enableHiddenItemQuantity));
|
map.insert("enable_hidden_item_quantity", QString::number(this->hiddenItemQuantityEnabled));
|
||||||
map.insert("enable_hidden_item_requires_itemfinder", QString::number(this->enableHiddenItemRequiresItemfinder));
|
map.insert("enable_hidden_item_requires_itemfinder", QString::number(this->hiddenItemRequiresItemfinderEnabled));
|
||||||
map.insert("enable_heal_location_respawn_data", QString::number(this->enableHealLocationRespawnData));
|
map.insert("enable_heal_location_respawn_data", QString::number(this->healLocationRespawnDataEnabled));
|
||||||
map.insert("enable_event_clone_object", QString::number(this->enableEventCloneObject));
|
map.insert("enable_event_clone_object", QString::number(this->eventCloneObjectEnabled));
|
||||||
map.insert("enable_floor_number", QString::number(this->enableFloorNumber));
|
map.insert("enable_floor_number", QString::number(this->floorNumberEnabled));
|
||||||
map.insert("create_map_text_file", QString::number(this->createMapTextFile));
|
map.insert("create_map_text_file", QString::number(this->createMapTextFileEnabled));
|
||||||
map.insert("enable_triple_layer_metatiles", QString::number(this->enableTripleLayerMetatiles));
|
map.insert("enable_triple_layer_metatiles", QString::number(this->tripleLayerMetatilesEnabled));
|
||||||
map.insert("default_metatile", Metatile::getMetatileIdString(this->defaultMetatileId));
|
map.insert("default_metatile", Metatile::getMetatileIdString(this->defaultMetatileId));
|
||||||
map.insert("default_elevation", QString::number(this->defaultElevation));
|
map.insert("default_elevation", QString::number(this->defaultElevation));
|
||||||
map.insert("default_collision", QString::number(this->defaultCollision));
|
map.insert("default_collision", QString::number(this->defaultCollision));
|
||||||
|
@ -1082,7 +825,7 @@ QMap<QString, QString> ProjectConfig::getKeyValueMap() {
|
||||||
map.insert("block_metatile_id_mask", "0x" + QString::number(this->blockMetatileIdMask, 16).toUpper());
|
map.insert("block_metatile_id_mask", "0x" + QString::number(this->blockMetatileIdMask, 16).toUpper());
|
||||||
map.insert("block_collision_mask", "0x" + QString::number(this->blockCollisionMask, 16).toUpper());
|
map.insert("block_collision_mask", "0x" + QString::number(this->blockCollisionMask, 16).toUpper());
|
||||||
map.insert("block_elevation_mask", "0x" + QString::number(this->blockElevationMask, 16).toUpper());
|
map.insert("block_elevation_mask", "0x" + QString::number(this->blockElevationMask, 16).toUpper());
|
||||||
map.insert("enable_map_allow_flags", QString::number(this->enableMapAllowFlags));
|
map.insert("enable_map_allow_flags", QString::number(this->mapAllowFlagsEnabled));
|
||||||
map.insert("event_icon_path_object", this->eventIconPaths[Event::Group::Object]);
|
map.insert("event_icon_path_object", this->eventIconPaths[Event::Group::Object]);
|
||||||
map.insert("event_icon_path_warp", this->eventIconPaths[Event::Group::Warp]);
|
map.insert("event_icon_path_warp", this->eventIconPaths[Event::Group::Warp]);
|
||||||
map.insert("event_icon_path_coord", this->eventIconPaths[Event::Group::Coord]);
|
map.insert("event_icon_path_coord", this->eventIconPaths[Event::Group::Coord]);
|
||||||
|
@ -1106,9 +849,10 @@ QMap<QString, QString> ProjectConfig::getKeyValueMap() {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectConfig::onNewConfigFileCreated() {
|
void ProjectConfig::init() {
|
||||||
QString dirName = QDir(this->projectDir).dirName().toLower();
|
QString dirName = QDir(this->projectDir).dirName().toLower();
|
||||||
if (baseGameVersionReverseMap.contains(dirName)) {
|
if (baseGameVersionReverseMap.contains(dirName)) {
|
||||||
|
// TODO: Improve detection (ex: emerald or pokeemerald-2 aren't currently auto-detected)
|
||||||
this->baseGameVersion = baseGameVersionReverseMap.value(dirName);
|
this->baseGameVersion = baseGameVersionReverseMap.value(dirName);
|
||||||
logInfo(QString("Auto-detected base_game_version as '%1'").arg(dirName));
|
logInfo(QString("Auto-detected base_game_version as '%1'").arg(dirName));
|
||||||
} else {
|
} else {
|
||||||
|
@ -1124,6 +868,8 @@ void ProjectConfig::onNewConfigFileCreated() {
|
||||||
baseGameVersionComboBox->addItem("pokeemerald", BaseGameVersion::pokeemerald);
|
baseGameVersionComboBox->addItem("pokeemerald", BaseGameVersion::pokeemerald);
|
||||||
form.addRow(new QLabel("Game Version"), baseGameVersionComboBox);
|
form.addRow(new QLabel("Game Version"), baseGameVersionComboBox);
|
||||||
|
|
||||||
|
// TODO: Advanced button to open the project settings window (with some settings disabled)
|
||||||
|
|
||||||
QDialogButtonBox buttonBox(QDialogButtonBox::Ok, Qt::Horizontal, &dialog);
|
QDialogButtonBox buttonBox(QDialogButtonBox::Ok, Qt::Horizontal, &dialog);
|
||||||
QObject::connect(&buttonBox, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
|
QObject::connect(&buttonBox, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
|
||||||
form.addRow(&buttonBox);
|
form.addRow(&buttonBox);
|
||||||
|
@ -1135,14 +881,6 @@ void ProjectConfig::onNewConfigFileCreated() {
|
||||||
this->setUnreadKeys(); // Initialize version-specific options
|
this->setUnreadKeys(); // Initialize version-specific options
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectConfig::setProjectDir(QString projectDir) {
|
|
||||||
this->projectDir = projectDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ProjectConfig::getProjectDir() {
|
|
||||||
return this->projectDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setFilePath(ProjectFilePath pathId, const QString &path) {
|
void ProjectConfig::setFilePath(ProjectFilePath pathId, const QString &path) {
|
||||||
if (!defaultPaths.contains(pathId)) return;
|
if (!defaultPaths.contains(pathId)) return;
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
|
@ -1208,15 +946,6 @@ QString ProjectConfig::getIdentifier(ProjectIdentifier id) {
|
||||||
return defaultIdentifiers.contains(id) ? defaultIdentifiers[id].second : QString();
|
return defaultIdentifiers.contains(id) ? defaultIdentifiers[id].second : QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectConfig::setBaseGameVersion(BaseGameVersion baseGameVersion) {
|
|
||||||
this->baseGameVersion = baseGameVersion;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
BaseGameVersion ProjectConfig::getBaseGameVersion() {
|
|
||||||
return this->baseGameVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ProjectConfig::getBaseGameVersionString(BaseGameVersion version) {
|
QString ProjectConfig::getBaseGameVersionString(BaseGameVersion version) {
|
||||||
if (!baseGameVersionMap.contains(version)) {
|
if (!baseGameVersionMap.contains(version)) {
|
||||||
version = BaseGameVersion::pokeemerald;
|
version = BaseGameVersion::pokeemerald;
|
||||||
|
@ -1228,287 +957,16 @@ QString ProjectConfig::getBaseGameVersionString() {
|
||||||
return this->getBaseGameVersionString(this->baseGameVersion);
|
return this->getBaseGameVersionString(this->baseGameVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectConfig::setUsePoryScript(bool usePoryScript) {
|
|
||||||
this->usePoryScript = usePoryScript;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProjectConfig::getUsePoryScript() {
|
|
||||||
return this->usePoryScript;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setUseCustomBorderSize(bool enable) {
|
|
||||||
this->useCustomBorderSize = enable;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProjectConfig::getUseCustomBorderSize() {
|
|
||||||
return this->useCustomBorderSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setEventWeatherTriggerEnabled(bool enable) {
|
|
||||||
this->enableEventWeatherTrigger = enable;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProjectConfig::getEventWeatherTriggerEnabled() {
|
|
||||||
return this->enableEventWeatherTrigger;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setEventSecretBaseEnabled(bool enable) {
|
|
||||||
this->enableEventSecretBase = enable;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProjectConfig::getEventSecretBaseEnabled() {
|
|
||||||
return this->enableEventSecretBase;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setHiddenItemQuantityEnabled(bool enable) {
|
|
||||||
this->enableHiddenItemQuantity = enable;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProjectConfig::getHiddenItemQuantityEnabled() {
|
|
||||||
return this->enableHiddenItemQuantity;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setHiddenItemRequiresItemfinderEnabled(bool enable) {
|
|
||||||
this->enableHiddenItemRequiresItemfinder = enable;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProjectConfig::getHiddenItemRequiresItemfinderEnabled() {
|
|
||||||
return this->enableHiddenItemRequiresItemfinder;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setHealLocationRespawnDataEnabled(bool enable) {
|
|
||||||
this->enableHealLocationRespawnData = enable;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProjectConfig::getHealLocationRespawnDataEnabled() {
|
|
||||||
return this->enableHealLocationRespawnData;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setEventCloneObjectEnabled(bool enable) {
|
|
||||||
this->enableEventCloneObject = enable;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProjectConfig::getEventCloneObjectEnabled() {
|
|
||||||
return this->enableEventCloneObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setFloorNumberEnabled(bool enable) {
|
|
||||||
this->enableFloorNumber = enable;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProjectConfig::getFloorNumberEnabled() {
|
|
||||||
return this->enableFloorNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setCreateMapTextFileEnabled(bool enable) {
|
|
||||||
this->createMapTextFile = enable;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProjectConfig::getCreateMapTextFileEnabled() {
|
|
||||||
return this->createMapTextFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setTripleLayerMetatilesEnabled(bool enable) {
|
|
||||||
this->enableTripleLayerMetatiles = enable;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProjectConfig::getTripleLayerMetatilesEnabled() {
|
|
||||||
return this->enableTripleLayerMetatiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ProjectConfig::getNumLayersInMetatile() {
|
int ProjectConfig::getNumLayersInMetatile() {
|
||||||
return this->enableTripleLayerMetatiles ? 3 : 2;
|
return this->tripleLayerMetatilesEnabled ? 3 : 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ProjectConfig::getNumTilesInMetatile() {
|
int ProjectConfig::getNumTilesInMetatile() {
|
||||||
return this->enableTripleLayerMetatiles ? 12 : 8;
|
return this->tripleLayerMetatilesEnabled ? 12 : 8;
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setDefaultMetatileId(uint16_t metatileId) {
|
|
||||||
this->defaultMetatileId = metatileId;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t ProjectConfig::getDefaultMetatileId() {
|
|
||||||
return this->defaultMetatileId;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setDefaultElevation(uint16_t elevation) {
|
|
||||||
this->defaultElevation = elevation;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t ProjectConfig::getDefaultElevation() {
|
|
||||||
return this->defaultElevation;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setDefaultCollision(uint16_t collision) {
|
|
||||||
this->defaultCollision = collision;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t ProjectConfig::getDefaultCollision() {
|
|
||||||
return this->defaultCollision;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setNewMapBorderMetatileIds(QList<uint16_t> metatileIds) {
|
|
||||||
this->newMapBorderMetatileIds = metatileIds;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<uint16_t> ProjectConfig::getNewMapBorderMetatileIds() {
|
|
||||||
return this->newMapBorderMetatileIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ProjectConfig::getDefaultPrimaryTileset() {
|
|
||||||
return this->defaultPrimaryTileset;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ProjectConfig::getDefaultSecondaryTileset() {
|
|
||||||
return this->defaultSecondaryTileset;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setDefaultPrimaryTileset(QString tilesetName) {
|
|
||||||
this->defaultPrimaryTileset = tilesetName;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setDefaultSecondaryTileset(QString tilesetName) {
|
|
||||||
this->defaultSecondaryTileset = tilesetName;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setPrefabFilepath(QString filepath) {
|
|
||||||
this->prefabFilepath = filepath;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ProjectConfig::getPrefabFilepath() {
|
|
||||||
return this->prefabFilepath;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setPrefabImportPrompted(bool prompted) {
|
|
||||||
this->prefabImportPrompted = prompted;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProjectConfig::getPrefabImportPrompted() {
|
|
||||||
return this->prefabImportPrompted;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setTilesetsHaveCallback(bool has) {
|
|
||||||
this->tilesetsHaveCallback = has;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProjectConfig::getTilesetsHaveCallback() {
|
|
||||||
return this->tilesetsHaveCallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setTilesetsHaveIsCompressed(bool has) {
|
|
||||||
this->tilesetsHaveIsCompressed = has;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProjectConfig::getTilesetsHaveIsCompressed() {
|
|
||||||
return this->tilesetsHaveIsCompressed;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ProjectConfig::getMetatileAttributesSize() {
|
|
||||||
return this->metatileAttributesSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setMetatileAttributesSize(int size) {
|
|
||||||
this->metatileAttributesSize = size;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t ProjectConfig::getMetatileBehaviorMask() {
|
|
||||||
return this->metatileBehaviorMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t ProjectConfig::getMetatileTerrainTypeMask() {
|
|
||||||
return this->metatileTerrainTypeMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t ProjectConfig::getMetatileEncounterTypeMask() {
|
|
||||||
return this->metatileEncounterTypeMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t ProjectConfig::getMetatileLayerTypeMask() {
|
|
||||||
return this->metatileLayerTypeMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setMetatileBehaviorMask(uint32_t mask) {
|
|
||||||
this->metatileBehaviorMask = mask;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setMetatileTerrainTypeMask(uint32_t mask) {
|
|
||||||
this->metatileTerrainTypeMask = mask;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setMetatileEncounterTypeMask(uint32_t mask) {
|
|
||||||
this->metatileEncounterTypeMask = mask;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setMetatileLayerTypeMask(uint32_t mask) {
|
|
||||||
this->metatileLayerTypeMask = mask;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t ProjectConfig::getBlockMetatileIdMask() {
|
|
||||||
return this->blockMetatileIdMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t ProjectConfig::getBlockCollisionMask() {
|
|
||||||
return this->blockCollisionMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t ProjectConfig::getBlockElevationMask() {
|
|
||||||
return this->blockElevationMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setBlockMetatileIdMask(uint16_t mask) {
|
|
||||||
this->blockMetatileIdMask = mask;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setBlockCollisionMask(uint16_t mask) {
|
|
||||||
this->blockCollisionMask = mask;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setBlockElevationMask(uint16_t mask) {
|
|
||||||
this->blockElevationMask = mask;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProjectConfig::getMapAllowFlagsEnabled() {
|
|
||||||
return this->enableMapAllowFlags;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setMapAllowFlagsEnabled(bool enabled) {
|
|
||||||
this->enableMapAllowFlags = enabled;
|
|
||||||
this->save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectConfig::setEventIconPath(Event::Group group, const QString &path) {
|
void ProjectConfig::setEventIconPath(Event::Group group, const QString &path) {
|
||||||
this->eventIconPaths[group] = path;
|
this->eventIconPaths[group] = path;
|
||||||
this->save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ProjectConfig::getEventIconPath(Event::Group group) {
|
QString ProjectConfig::getEventIconPath(Event::Group group) {
|
||||||
|
@ -1517,7 +975,6 @@ QString ProjectConfig::getEventIconPath(Event::Group group) {
|
||||||
|
|
||||||
void ProjectConfig::setPokemonIconPath(const QString &species, const QString &path) {
|
void ProjectConfig::setPokemonIconPath(const QString &species, const QString &path) {
|
||||||
this->pokemonIconPaths[species] = path;
|
this->pokemonIconPaths[species] = path;
|
||||||
this->save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ProjectConfig::getPokemonIconPath(const QString &species) {
|
QString ProjectConfig::getPokemonIconPath(const QString &species) {
|
||||||
|
@ -1528,43 +985,6 @@ QHash<QString, QString> ProjectConfig::getPokemonIconPaths() {
|
||||||
return this->pokemonIconPaths;
|
return this->pokemonIconPaths;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectConfig::setCollisionSheetPath(const QString &path) {
|
|
||||||
this->collisionSheetPath = path;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ProjectConfig::getCollisionSheetPath() {
|
|
||||||
return this->collisionSheetPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setCollisionSheetWidth(int width) {
|
|
||||||
this->collisionSheetWidth = width;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
int ProjectConfig::getCollisionSheetWidth() {
|
|
||||||
return this->collisionSheetWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setCollisionSheetHeight(int height) {
|
|
||||||
this->collisionSheetHeight = height;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
int ProjectConfig::getCollisionSheetHeight() {
|
|
||||||
return this->collisionSheetHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectConfig::setWarpBehaviors(const QSet<uint32_t> &behaviors) {
|
|
||||||
this->warpBehaviors = behaviors;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
QSet<uint32_t> ProjectConfig::getWarpBehaviors() {
|
|
||||||
return this->warpBehaviors;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
UserConfig userConfig;
|
UserConfig userConfig;
|
||||||
|
|
||||||
QString UserConfig::getConfigFilepath() {
|
QString UserConfig::getConfigFilepath() {
|
||||||
|
@ -1596,38 +1016,12 @@ QMap<QString, QString> UserConfig::getKeyValueMap() {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserConfig::onNewConfigFileCreated() {
|
void UserConfig::init() {
|
||||||
QString dirName = QDir(this->projectDir).dirName().toLower();
|
QString dirName = QDir(this->projectDir).dirName().toLower();
|
||||||
this->useEncounterJson = true;
|
this->useEncounterJson = true;
|
||||||
this->customScripts.clear();
|
this->customScripts.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserConfig::setProjectDir(QString projectDir) {
|
|
||||||
this->projectDir = projectDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString UserConfig::getProjectDir() {
|
|
||||||
return this->projectDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UserConfig::setRecentMap(const QString &map) {
|
|
||||||
this->recentMap = map;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString UserConfig::getRecentMap() {
|
|
||||||
return this->recentMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UserConfig::setEncounterJsonActive(bool active) {
|
|
||||||
this->useEncounterJson = active;
|
|
||||||
this->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UserConfig::getEncounterJsonActive() {
|
|
||||||
return this->useEncounterJson;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read input from the config to get the script paths and whether each is enabled or disbled.
|
// Read input from the config to get the script paths and whether each is enabled or disbled.
|
||||||
// The format is a comma-separated list of paths. Each path can be followed (before the comma)
|
// The format is a comma-separated list of paths. Each path can be followed (before the comma)
|
||||||
// by a :0 or :1 to indicate whether it should be disabled or enabled, respectively. If neither
|
// by a :0 or :1 to indicate whether it should be disabled or enabled, respectively. If neither
|
||||||
|
@ -1664,7 +1058,6 @@ void UserConfig::setCustomScripts(QStringList scripts, QList<bool> enabled) {
|
||||||
size_t size = qMin(scripts.length(), enabled.length());
|
size_t size = qMin(scripts.length(), enabled.length());
|
||||||
for (size_t i = 0; i < size; i++)
|
for (size_t i = 0; i < size; i++)
|
||||||
this->customScripts.insert(scripts.at(i), enabled.at(i));
|
this->customScripts.insert(scripts.at(i), enabled.at(i));
|
||||||
this->save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList UserConfig::getCustomScriptPaths() {
|
QStringList UserConfig::getCustomScriptPaths() {
|
||||||
|
@ -1708,7 +1101,6 @@ QMap<QString, QString> ShortcutsConfig::getKeyValueMap() {
|
||||||
|
|
||||||
void ShortcutsConfig::setDefaultShortcuts(const QObjectList &objects) {
|
void ShortcutsConfig::setDefaultShortcuts(const QObjectList &objects) {
|
||||||
storeShortcutsFromList(StoreType::Default, objects);
|
storeShortcutsFromList(StoreType::Default, objects);
|
||||||
save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QKeySequence> ShortcutsConfig::defaultShortcuts(const QObject *object) const {
|
QList<QKeySequence> ShortcutsConfig::defaultShortcuts(const QObject *object) const {
|
||||||
|
@ -1717,14 +1109,12 @@ QList<QKeySequence> ShortcutsConfig::defaultShortcuts(const QObject *object) con
|
||||||
|
|
||||||
void ShortcutsConfig::setUserShortcuts(const QObjectList &objects) {
|
void ShortcutsConfig::setUserShortcuts(const QObjectList &objects) {
|
||||||
storeShortcutsFromList(StoreType::User, objects);
|
storeShortcutsFromList(StoreType::User, objects);
|
||||||
save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShortcutsConfig::setUserShortcuts(const QMultiMap<const QObject *, QKeySequence> &objects_keySequences) {
|
void ShortcutsConfig::setUserShortcuts(const QMultiMap<const QObject *, QKeySequence> &objects_keySequences) {
|
||||||
for (auto *object : objects_keySequences.uniqueKeys())
|
for (auto *object : objects_keySequences.uniqueKeys())
|
||||||
if (!object->objectName().isEmpty() && !object->objectName().startsWith("_q_"))
|
if (!object->objectName().isEmpty() && !object->objectName().startsWith("_q_"))
|
||||||
storeShortcuts(StoreType::User, cfgKey(object), objects_keySequences.values(object));
|
storeShortcuts(StoreType::User, cfgKey(object), objects_keySequences.values(object));
|
||||||
save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QKeySequence> ShortcutsConfig::userShortcuts(const QObject *object) const {
|
QList<QKeySequence> ShortcutsConfig::userShortcuts(const QObject *object) const {
|
||||||
|
|
|
@ -47,9 +47,9 @@ uint16_t Block::rawValue() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Block::setLayout() {
|
void Block::setLayout() {
|
||||||
bitsMetatileId.setMask(projectConfig.getBlockMetatileIdMask());
|
bitsMetatileId.setMask(projectConfig.blockMetatileIdMask);
|
||||||
bitsCollision.setMask(projectConfig.getBlockCollisionMask());
|
bitsCollision.setMask(projectConfig.blockCollisionMask);
|
||||||
bitsElevation.setMask(projectConfig.getBlockElevationMask());
|
bitsElevation.setMask(projectConfig.blockElevationMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Block::operator ==(Block other) const {
|
bool Block::operator ==(Block other) const {
|
||||||
|
|
|
@ -35,7 +35,7 @@ int Event::getEventIndex() {
|
||||||
void Event::setDefaultValues(Project *) {
|
void Event::setDefaultValues(Project *) {
|
||||||
this->setX(0);
|
this->setX(0);
|
||||||
this->setY(0);
|
this->setY(0);
|
||||||
this->setElevation(projectConfig.getDefaultElevation());
|
this->setElevation(projectConfig.defaultElevation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Event::readCustomValues(QJsonObject values) {
|
void Event::readCustomValues(QJsonObject values) {
|
||||||
|
@ -195,7 +195,7 @@ EventFrame *ObjectEvent::createEventFrame() {
|
||||||
OrderedJson::object ObjectEvent::buildEventJson(Project *) {
|
OrderedJson::object ObjectEvent::buildEventJson(Project *) {
|
||||||
OrderedJson::object objectJson;
|
OrderedJson::object objectJson;
|
||||||
|
|
||||||
if (projectConfig.getEventCloneObjectEnabled()) {
|
if (projectConfig.eventCloneObjectEnabled) {
|
||||||
objectJson["type"] = "object";
|
objectJson["type"] = "object";
|
||||||
}
|
}
|
||||||
objectJson["graphics_id"] = this->getGfx();
|
objectJson["graphics_id"] = this->getGfx();
|
||||||
|
@ -259,7 +259,7 @@ const QSet<QString> expectedObjectFields = {
|
||||||
QSet<QString> ObjectEvent::getExpectedFields() {
|
QSet<QString> ObjectEvent::getExpectedFields() {
|
||||||
QSet<QString> expectedFields = QSet<QString>();
|
QSet<QString> expectedFields = QSet<QString>();
|
||||||
expectedFields = expectedObjectFields;
|
expectedFields = expectedObjectFields;
|
||||||
if (projectConfig.getEventCloneObjectEnabled()) {
|
if (projectConfig.eventCloneObjectEnabled) {
|
||||||
expectedFields.insert("type");
|
expectedFields.insert("type");
|
||||||
}
|
}
|
||||||
expectedFields << "x" << "y";
|
expectedFields << "x" << "y";
|
||||||
|
@ -788,10 +788,10 @@ OrderedJson::object HiddenItemEvent::buildEventJson(Project *) {
|
||||||
hiddenItemJson["elevation"] = this->getElevation();
|
hiddenItemJson["elevation"] = this->getElevation();
|
||||||
hiddenItemJson["item"] = this->getItem();
|
hiddenItemJson["item"] = this->getItem();
|
||||||
hiddenItemJson["flag"] = this->getFlag();
|
hiddenItemJson["flag"] = this->getFlag();
|
||||||
if (projectConfig.getHiddenItemQuantityEnabled()) {
|
if (projectConfig.hiddenItemQuantityEnabled) {
|
||||||
hiddenItemJson["quantity"] = this->getQuantity();
|
hiddenItemJson["quantity"] = this->getQuantity();
|
||||||
}
|
}
|
||||||
if (projectConfig.getHiddenItemRequiresItemfinderEnabled()) {
|
if (projectConfig.hiddenItemRequiresItemfinderEnabled) {
|
||||||
hiddenItemJson["underfoot"] = this->getUnderfoot();
|
hiddenItemJson["underfoot"] = this->getUnderfoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -806,10 +806,10 @@ bool HiddenItemEvent::loadFromJson(QJsonObject json, Project *) {
|
||||||
this->setElevation(ParseUtil::jsonToInt(json["elevation"]));
|
this->setElevation(ParseUtil::jsonToInt(json["elevation"]));
|
||||||
this->setItem(ParseUtil::jsonToQString(json["item"]));
|
this->setItem(ParseUtil::jsonToQString(json["item"]));
|
||||||
this->setFlag(ParseUtil::jsonToQString(json["flag"]));
|
this->setFlag(ParseUtil::jsonToQString(json["flag"]));
|
||||||
if (projectConfig.getHiddenItemQuantityEnabled()) {
|
if (projectConfig.hiddenItemQuantityEnabled) {
|
||||||
this->setQuantity(ParseUtil::jsonToInt(json["quantity"]));
|
this->setQuantity(ParseUtil::jsonToInt(json["quantity"]));
|
||||||
}
|
}
|
||||||
if (projectConfig.getHiddenItemRequiresItemfinderEnabled()) {
|
if (projectConfig.hiddenItemRequiresItemfinderEnabled) {
|
||||||
this->setUnderfoot(ParseUtil::jsonToBool(json["underfoot"]));
|
this->setUnderfoot(ParseUtil::jsonToBool(json["underfoot"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -821,10 +821,10 @@ bool HiddenItemEvent::loadFromJson(QJsonObject json, Project *) {
|
||||||
void HiddenItemEvent::setDefaultValues(Project *project) {
|
void HiddenItemEvent::setDefaultValues(Project *project) {
|
||||||
this->setItem(project->itemNames.value(0, "0"));
|
this->setItem(project->itemNames.value(0, "0"));
|
||||||
this->setFlag(project->flagNames.value(0, "0"));
|
this->setFlag(project->flagNames.value(0, "0"));
|
||||||
if (projectConfig.getHiddenItemQuantityEnabled()) {
|
if (projectConfig.hiddenItemQuantityEnabled) {
|
||||||
this->setQuantity(1);
|
this->setQuantity(1);
|
||||||
}
|
}
|
||||||
if (projectConfig.getHiddenItemRequiresItemfinderEnabled()) {
|
if (projectConfig.hiddenItemRequiresItemfinderEnabled) {
|
||||||
this->setUnderfoot(false);
|
this->setUnderfoot(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -839,10 +839,10 @@ const QSet<QString> expectedHiddenItemFields = {
|
||||||
QSet<QString> HiddenItemEvent::getExpectedFields() {
|
QSet<QString> HiddenItemEvent::getExpectedFields() {
|
||||||
QSet<QString> expectedFields = QSet<QString>();
|
QSet<QString> expectedFields = QSet<QString>();
|
||||||
expectedFields = expectedHiddenItemFields;
|
expectedFields = expectedHiddenItemFields;
|
||||||
if (projectConfig.getHiddenItemQuantityEnabled()) {
|
if (projectConfig.hiddenItemQuantityEnabled) {
|
||||||
expectedFields << "quantity";
|
expectedFields << "quantity";
|
||||||
}
|
}
|
||||||
if (projectConfig.getHiddenItemRequiresItemfinderEnabled()) {
|
if (projectConfig.hiddenItemRequiresItemfinderEnabled) {
|
||||||
expectedFields << "underfoot";
|
expectedFields << "underfoot";
|
||||||
}
|
}
|
||||||
expectedFields << "x" << "y";
|
expectedFields << "x" << "y";
|
||||||
|
@ -930,10 +930,10 @@ OrderedJson::object HealLocationEvent::buildEventJson(Project *) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HealLocationEvent::setDefaultValues(Project *) {
|
void HealLocationEvent::setDefaultValues(Project *) {
|
||||||
this->setElevation(projectConfig.getDefaultElevation());
|
this->setElevation(projectConfig.defaultElevation);
|
||||||
if (!this->getMap())
|
if (!this->getMap())
|
||||||
return;
|
return;
|
||||||
bool respawnEnabled = projectConfig.getHealLocationRespawnDataEnabled();
|
bool respawnEnabled = projectConfig.healLocationRespawnDataEnabled;
|
||||||
const QString mapConstant = Map::mapConstantFromName(this->getMap()->name, false);
|
const QString mapConstant = Map::mapConstantFromName(this->getMap()->name, false);
|
||||||
const QString prefix = projectConfig.getIdentifier(respawnEnabled ? ProjectIdentifier::define_spawn_prefix
|
const QString prefix = projectConfig.getIdentifier(respawnEnabled ? ProjectIdentifier::define_spawn_prefix
|
||||||
: ProjectIdentifier::define_heal_locations_prefix);
|
: ProjectIdentifier::define_heal_locations_prefix);
|
||||||
|
|
|
@ -24,7 +24,7 @@ HealLocation HealLocation::fromEvent(Event *fromEvent) {
|
||||||
healLocation.index = event->getIndex();
|
healLocation.index = event->getIndex();
|
||||||
healLocation.x = event->getX();
|
healLocation.x = event->getX();
|
||||||
healLocation.y = event->getY();
|
healLocation.y = event->getY();
|
||||||
if (projectConfig.getHealLocationRespawnDataEnabled()) {
|
if (projectConfig.healLocationRespawnDataEnabled) {
|
||||||
healLocation.respawnNPC = event->getRespawnNPC();
|
healLocation.respawnNPC = event->getRespawnNPC();
|
||||||
healLocation.respawnMap = Map::mapConstantFromName(event->getRespawnMap(), false);
|
healLocation.respawnMap = Map::mapConstantFromName(event->getRespawnMap(), false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -499,9 +499,9 @@ QStringList Map::getScriptLabels(Event::Group group) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Map::getScriptsFilePath() const {
|
QString Map::getScriptsFilePath() const {
|
||||||
const bool usePoryscript = projectConfig.getUsePoryScript();
|
const bool usePoryscript = projectConfig.usePoryScript;
|
||||||
auto path = QDir::cleanPath(QString("%1/%2/%3/scripts")
|
auto path = QDir::cleanPath(QString("%1/%2/%3/scripts")
|
||||||
.arg(projectConfig.getProjectDir())
|
.arg(projectConfig.projectDir)
|
||||||
.arg(projectConfig.getFilePath(ProjectFilePath::data_map_folders))
|
.arg(projectConfig.getFilePath(ProjectFilePath::data_map_folders))
|
||||||
.arg(this->name));
|
.arg(this->name));
|
||||||
auto extension = Project::getScriptFileExtension(usePoryscript);
|
auto extension = Project::getScriptFileExtension(usePoryscript);
|
||||||
|
|
|
@ -100,7 +100,7 @@ uint32_t Metatile::getMaxAttributesMask() {
|
||||||
{2, 0xFFFF},
|
{2, 0xFFFF},
|
||||||
{4, 0xFFFFFFFF},
|
{4, 0xFFFFFFFF},
|
||||||
};
|
};
|
||||||
return maxMasks.value(projectConfig.getMetatileAttributesSize(), 0);
|
return maxMasks.value(projectConfig.metatileAttributesSize, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Metatile::setLayout(Project * project) {
|
void Metatile::setLayout(Project * project) {
|
||||||
|
@ -109,10 +109,10 @@ void Metatile::setLayout(Project * project) {
|
||||||
for (uint16_t i = Block::getMaxMetatileId(); i > 0; i /= 16)
|
for (uint16_t i = Block::getMaxMetatileId(); i > 0; i /= 16)
|
||||||
numMetatileIdChars++;
|
numMetatileIdChars++;
|
||||||
|
|
||||||
uint32_t behaviorMask = projectConfig.getMetatileBehaviorMask();
|
uint32_t behaviorMask = projectConfig.metatileBehaviorMask;
|
||||||
uint32_t terrainTypeMask = projectConfig.getMetatileTerrainTypeMask();
|
uint32_t terrainTypeMask = projectConfig.metatileTerrainTypeMask;
|
||||||
uint32_t encounterTypeMask = projectConfig.getMetatileEncounterTypeMask();
|
uint32_t encounterTypeMask = projectConfig.metatileEncounterTypeMask;
|
||||||
uint32_t layerTypeMask = projectConfig.getMetatileLayerTypeMask();
|
uint32_t layerTypeMask = projectConfig.metatileLayerTypeMask;
|
||||||
|
|
||||||
// Calculate mask of bits not used by standard behaviors so we can preserve this data.
|
// Calculate mask of bits not used by standard behaviors so we can preserve this data.
|
||||||
uint32_t unusedMask = ~(behaviorMask | terrainTypeMask | encounterTypeMask | layerTypeMask);
|
uint32_t unusedMask = ~(behaviorMask | terrainTypeMask | encounterTypeMask | layerTypeMask);
|
||||||
|
|
|
@ -80,7 +80,7 @@ QList<Metatile*> MetatileParser::parse(QString filepath, bool *error, bool prima
|
||||||
|
|
||||||
// AdvanceMap .bvd files only contain 8 tiles of data per metatile.
|
// AdvanceMap .bvd files only contain 8 tiles of data per metatile.
|
||||||
// If the user has triple-layer metatiles enabled we need to fill the remaining 4 tiles ourselves.
|
// If the user has triple-layer metatiles enabled we need to fill the remaining 4 tiles ourselves.
|
||||||
if (projectConfig.getTripleLayerMetatilesEnabled()) {
|
if (projectConfig.tripleLayerMetatilesEnabled) {
|
||||||
Tile tile = Tile();
|
Tile tile = Tile();
|
||||||
for (int j = 0; j < 4; j++)
|
for (int j = 0; j < 4; j++)
|
||||||
tiles.append(tile);
|
tiles.append(tile);
|
||||||
|
|
|
@ -9,15 +9,10 @@
|
||||||
static const int DefaultWaitTime = 120;
|
static const int DefaultWaitTime = 120;
|
||||||
|
|
||||||
NetworkAccessManager::NetworkAccessManager(QObject * parent) : QNetworkAccessManager(parent) {
|
NetworkAccessManager::NetworkAccessManager(QObject * parent) : QNetworkAccessManager(parent) {
|
||||||
// We store rate limit end times in the user's config so that Porymap will still respect them after a restart.
|
|
||||||
// To avoid reading/writing to a local file during network operations, we only read/write the file when the
|
|
||||||
// manager is created/destroyed respectively.
|
|
||||||
this->rateLimitTimes = porymapConfig.getRateLimitTimes();
|
|
||||||
this->setRedirectPolicy(QNetworkRequest::NoLessSafeRedirectPolicy);
|
this->setRedirectPolicy(QNetworkRequest::NoLessSafeRedirectPolicy);
|
||||||
};
|
};
|
||||||
|
|
||||||
NetworkAccessManager::~NetworkAccessManager() {
|
NetworkAccessManager::~NetworkAccessManager() {
|
||||||
porymapConfig.setRateLimitTimes(this->rateLimitTimes);
|
|
||||||
qDeleteAll(this->cache);
|
qDeleteAll(this->cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,8 +42,9 @@ NetworkReplyData * NetworkAccessManager::get(const QUrl &url) {
|
||||||
data->m_url = url;
|
data->m_url = url;
|
||||||
|
|
||||||
// If we are rate-limited, don't send a new request.
|
// If we are rate-limited, don't send a new request.
|
||||||
if (this->rateLimitTimes.contains(url)) {
|
// We store rate limit end times in the user's config so that Porymap will still respect them after a restart.
|
||||||
auto time = this->rateLimitTimes.value(url);
|
if (porymapConfig.rateLimitTimes.contains(url)) {
|
||||||
|
auto time = porymapConfig.rateLimitTimes.value(url);
|
||||||
if (!time.isNull() && time > QDateTime::currentDateTime()) {
|
if (!time.isNull() && time > QDateTime::currentDateTime()) {
|
||||||
data->m_retryAfter = time;
|
data->m_retryAfter = time;
|
||||||
data->m_error = QString("Rate limit reached. Please try again after %1.").arg(data->m_retryAfter.toString());
|
data->m_error = QString("Rate limit reached. Please try again after %1.").arg(data->m_retryAfter.toString());
|
||||||
|
@ -56,7 +52,7 @@ NetworkReplyData * NetworkAccessManager::get(const QUrl &url) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
// Rate limiting expired
|
// Rate limiting expired
|
||||||
this->rateLimitTimes.remove(url);
|
porymapConfig.rateLimitTimes.remove(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
QNetworkReply * reply = QNetworkAccessManager::get(this->getRequest(url));
|
QNetworkReply * reply = QNetworkAccessManager::get(this->getRequest(url));
|
||||||
|
@ -117,7 +113,7 @@ void NetworkAccessManager::processReply(QNetworkReply * reply, NetworkReplyData
|
||||||
data->m_error = "Service busy or unavailable. ";
|
data->m_error = "Service busy or unavailable. ";
|
||||||
}
|
}
|
||||||
data->m_error.append(QString("Please try again after %1.").arg(data->m_retryAfter.toString()));
|
data->m_error.append(QString("Please try again after %1.").arg(data->m_retryAfter.toString()));
|
||||||
this->rateLimitTimes.insert(url, data->m_retryAfter);
|
porymapConfig.rateLimitTimes.insert(url, data->m_retryAfter);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +125,7 @@ void NetworkAccessManager::processReply(QNetworkReply * reply, NetworkReplyData
|
||||||
data->m_retryAfter = ok ? QDateTime::fromSecsSinceEpoch(limitReset).toLocalTime()
|
data->m_retryAfter = ok ? QDateTime::fromSecsSinceEpoch(limitReset).toLocalTime()
|
||||||
: QDateTime::currentDateTime().addSecs(DefaultWaitTime);;
|
: QDateTime::currentDateTime().addSecs(DefaultWaitTime);;
|
||||||
data->m_error = QString("Too many requests. Please try again after %1.").arg(data->m_retryAfter.toString());
|
data->m_error = QString("Too many requests. Please try again after %1.").arg(data->m_retryAfter.toString());
|
||||||
this->rateLimitTimes.insert(url, data->m_retryAfter);
|
porymapConfig.rateLimitTimes.insert(url, data->m_retryAfter);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -238,7 +238,7 @@ bool Tileset::appendToHeaders(QString root, QString friendlyName, bool usingAsm)
|
||||||
dataString.append(QString("\t.4byte gTilesetTiles_%1\n").arg(friendlyName));
|
dataString.append(QString("\t.4byte gTilesetTiles_%1\n").arg(friendlyName));
|
||||||
dataString.append(QString("\t.4byte gTilesetPalettes_%1\n").arg(friendlyName));
|
dataString.append(QString("\t.4byte gTilesetPalettes_%1\n").arg(friendlyName));
|
||||||
dataString.append(QString("\t.4byte gMetatiles_%1\n").arg(friendlyName));
|
dataString.append(QString("\t.4byte gMetatiles_%1\n").arg(friendlyName));
|
||||||
if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered) {
|
if (projectConfig.baseGameVersion == BaseGameVersion::pokefirered) {
|
||||||
dataString.append("\t.4byte NULL @ animation callback\n");
|
dataString.append("\t.4byte NULL @ animation callback\n");
|
||||||
dataString.append(QString("\t.4byte gMetatileAttributes_%1\n").arg(friendlyName));
|
dataString.append(QString("\t.4byte gMetatileAttributes_%1\n").arg(friendlyName));
|
||||||
} else {
|
} else {
|
||||||
|
@ -248,13 +248,13 @@ bool Tileset::appendToHeaders(QString root, QString friendlyName, bool usingAsm)
|
||||||
} else {
|
} else {
|
||||||
// Append to C file
|
// Append to C file
|
||||||
dataString.append(QString("const struct Tileset %1 =\n{\n").arg(this->name));
|
dataString.append(QString("const struct Tileset %1 =\n{\n").arg(this->name));
|
||||||
if (projectConfig.getTilesetsHaveIsCompressed()) dataString.append(" .isCompressed = TRUE,\n");
|
if (projectConfig.tilesetsHaveIsCompressed) dataString.append(" .isCompressed = TRUE,\n");
|
||||||
dataString.append(QString(" .isSecondary = %1,\n").arg(isSecondaryStr));
|
dataString.append(QString(" .isSecondary = %1,\n").arg(isSecondaryStr));
|
||||||
dataString.append(QString(" .tiles = gTilesetTiles_%1,\n").arg(friendlyName));
|
dataString.append(QString(" .tiles = gTilesetTiles_%1,\n").arg(friendlyName));
|
||||||
dataString.append(QString(" .palettes = gTilesetPalettes_%1,\n").arg(friendlyName));
|
dataString.append(QString(" .palettes = gTilesetPalettes_%1,\n").arg(friendlyName));
|
||||||
dataString.append(QString(" .metatiles = gMetatiles_%1,\n").arg(friendlyName));
|
dataString.append(QString(" .metatiles = gMetatiles_%1,\n").arg(friendlyName));
|
||||||
dataString.append(QString(" .metatileAttributes = gMetatileAttributes_%1,\n").arg(friendlyName));
|
dataString.append(QString(" .metatileAttributes = gMetatileAttributes_%1,\n").arg(friendlyName));
|
||||||
if (projectConfig.getTilesetsHaveCallback()) dataString.append(" .callback = NULL,\n");
|
if (projectConfig.tilesetsHaveCallback) dataString.append(" .callback = NULL,\n");
|
||||||
dataString.append("};\n");
|
dataString.append("};\n");
|
||||||
}
|
}
|
||||||
file.write(dataString.toUtf8());
|
file.write(dataString.toUtf8());
|
||||||
|
@ -325,7 +325,7 @@ bool Tileset::appendToMetatiles(QString root, QString friendlyName, bool usingAs
|
||||||
} else {
|
} else {
|
||||||
// Append to C file
|
// Append to C file
|
||||||
dataString.append(QString("const u16 gMetatiles_%1[] = INCBIN_U16(\"%2\");\n").arg(friendlyName, metatilesPath));
|
dataString.append(QString("const u16 gMetatiles_%1[] = INCBIN_U16(\"%2\");\n").arg(friendlyName, metatilesPath));
|
||||||
QString numBits = QString::number(projectConfig.getMetatileAttributesSize() * 8);
|
QString numBits = QString::number(projectConfig.metatileAttributesSize * 8);
|
||||||
dataString.append(QString("const u%1 gMetatileAttributes_%2[] = INCBIN_U%1(\"%3\");\n").arg(numBits, friendlyName, metatileAttrsPath));
|
dataString.append(QString("const u%1 gMetatileAttributes_%2[] = INCBIN_U%1(\"%3\");\n").arg(numBits, friendlyName, metatileAttrsPath));
|
||||||
}
|
}
|
||||||
file.write(dataString.toUtf8());
|
file.write(dataString.toUtf8());
|
||||||
|
@ -358,7 +358,7 @@ QHash<int, QString> Tileset::getHeaderMemberMap(bool usingAsm)
|
||||||
int paddingOffset = usingAsm ? 1 : 0;
|
int paddingOffset = usingAsm ? 1 : 0;
|
||||||
|
|
||||||
// The position of metatileAttributes changes between games
|
// The position of metatileAttributes changes between games
|
||||||
bool isPokefirered = (projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered);
|
bool isPokefirered = (projectConfig.baseGameVersion == BaseGameVersion::pokefirered);
|
||||||
int metatileAttrPosition = (isPokefirered ? 6 : 5) + paddingOffset;
|
int metatileAttrPosition = (isPokefirered ? 6 : 5) + paddingOffset;
|
||||||
|
|
||||||
auto map = QHash<int, QString>();
|
auto map = QHash<int, QString>();
|
||||||
|
|
|
@ -1501,7 +1501,7 @@ void Editor::displayMovementPermissionSelector() {
|
||||||
connect(movement_permissions_selector_item, &SelectablePixmapItem::selectionChanged, [this](int x, int y, int, int) {
|
connect(movement_permissions_selector_item, &SelectablePixmapItem::selectionChanged, [this](int x, int y, int, int) {
|
||||||
this->setCollisionTabSpinBoxes(x, y);
|
this->setCollisionTabSpinBoxes(x, y);
|
||||||
});
|
});
|
||||||
movement_permissions_selector_item->select(projectConfig.getDefaultCollision(), projectConfig.getDefaultElevation());
|
movement_permissions_selector_item->select(projectConfig.defaultCollision, projectConfig.defaultElevation);
|
||||||
}
|
}
|
||||||
|
|
||||||
scene_collision_metatiles->addItem(movement_permissions_selector_item);
|
scene_collision_metatiles->addItem(movement_permissions_selector_item);
|
||||||
|
@ -1684,7 +1684,7 @@ int Editor::getBorderDrawDistance(int dimension) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::onToggleGridClicked(bool checked) {
|
void Editor::onToggleGridClicked(bool checked) {
|
||||||
porymapConfig.setShowGrid(checked);
|
porymapConfig.showGrid = checked;
|
||||||
if (ui->graphicsView_Map->scene())
|
if (ui->graphicsView_Map->scene())
|
||||||
ui->graphicsView_Map->scene()->update();
|
ui->graphicsView_Map->scene()->update();
|
||||||
}
|
}
|
||||||
|
@ -1947,7 +1947,7 @@ void Editor::toggleBorderVisibility(bool visible, bool enableScriptCallback)
|
||||||
{
|
{
|
||||||
this->setBorderItemsVisible(visible);
|
this->setBorderItemsVisible(visible);
|
||||||
this->setConnectionItemsVisible(visible);
|
this->setConnectionItemsVisible(visible);
|
||||||
porymapConfig.setShowBorder(visible);
|
porymapConfig.showBorder = visible;
|
||||||
if (enableScriptCallback)
|
if (enableScriptCallback)
|
||||||
Scripting::cb_BorderVisibilityToggled(visible);
|
Scripting::cb_BorderVisibilityToggled(visible);
|
||||||
}
|
}
|
||||||
|
@ -1993,7 +1993,7 @@ void Editor::redrawObject(DraggablePixmapItem *item) {
|
||||||
|
|
||||||
// Warp events display a warning if they're not positioned on a metatile with a warp behavior.
|
// Warp events display a warning if they're not positioned on a metatile with a warp behavior.
|
||||||
void Editor::updateWarpEventWarning(Event *event) {
|
void Editor::updateWarpEventWarning(Event *event) {
|
||||||
if (porymapConfig.getWarpBehaviorWarningDisabled())
|
if (porymapConfig.warpBehaviorWarningDisabled)
|
||||||
return;
|
return;
|
||||||
if (!project || !map || !event || event->getEventType() != Event::Type::Warp)
|
if (!project || !map || !event || event->getEventType() != Event::Type::Warp)
|
||||||
return;
|
return;
|
||||||
|
@ -2004,7 +2004,7 @@ void Editor::updateWarpEventWarning(Event *event) {
|
||||||
metatile = Tileset::getMetatile(block.metatileId(), map->layout->tileset_primary, map->layout->tileset_secondary);
|
metatile = Tileset::getMetatile(block.metatileId(), map->layout->tileset_primary, map->layout->tileset_secondary);
|
||||||
}
|
}
|
||||||
// metatile may be null if the warp is in the map border. Display the warning in this case
|
// metatile may be null if the warp is in the map border. Display the warning in this case
|
||||||
bool validWarpBehavior = metatile && projectConfig.getWarpBehaviors().contains(metatile->behavior());
|
bool validWarpBehavior = metatile && projectConfig.warpBehaviors.contains(metatile->behavior());
|
||||||
warpEvent->setWarningEnabled(!validWarpBehavior);
|
warpEvent->setWarningEnabled(!validWarpBehavior);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2014,7 +2014,7 @@ void Editor::updateWarpEventWarning(Event *event) {
|
||||||
// events when the Events tab is opened. This does not cover the case where metatiles are painted while
|
// events when the Events tab is opened. This does not cover the case where metatiles are painted while
|
||||||
// still on the Events tab, such as by Undo/Redo or the scripting API.
|
// still on the Events tab, such as by Undo/Redo or the scripting API.
|
||||||
void Editor::updateWarpEventWarnings() {
|
void Editor::updateWarpEventWarnings() {
|
||||||
if (porymapConfig.getWarpBehaviorWarningDisabled())
|
if (porymapConfig.warpBehaviorWarningDisabled)
|
||||||
return;
|
return;
|
||||||
if (selected_events) {
|
if (selected_events) {
|
||||||
for (auto selection : *selected_events)
|
for (auto selection : *selected_events)
|
||||||
|
@ -2189,7 +2189,7 @@ void Editor::openScript(const QString &scriptLabel) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::openInTextEditor(const QString &path, int lineNum) {
|
void Editor::openInTextEditor(const QString &path, int lineNum) {
|
||||||
QString command = porymapConfig.getTextEditorGotoLine();
|
QString command = porymapConfig.textEditorGotoLine;
|
||||||
if (command.isEmpty()) {
|
if (command.isEmpty()) {
|
||||||
// Open map scripts in the system's default editor.
|
// Open map scripts in the system's default editor.
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
||||||
|
@ -2206,7 +2206,7 @@ void Editor::openInTextEditor(const QString &path, int lineNum) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::openProjectInTextEditor() const {
|
void Editor::openProjectInTextEditor() const {
|
||||||
QString command = porymapConfig.getTextEditorOpenFolder();
|
QString command = porymapConfig.textEditorOpenFolder;
|
||||||
if (command.contains("%D"))
|
if (command.contains("%D"))
|
||||||
command.replace("%D", '\"' + project->root + '\"');
|
command.replace("%D", '\"' + project->root + '\"');
|
||||||
else
|
else
|
||||||
|
@ -2279,7 +2279,7 @@ void Editor::setCollisionTabSpinBoxes(uint16_t collision, uint16_t elevation) {
|
||||||
|
|
||||||
// Custom collision graphics may be provided by the user.
|
// Custom collision graphics may be provided by the user.
|
||||||
void Editor::setCollisionGraphics() {
|
void Editor::setCollisionGraphics() {
|
||||||
QString filepath = projectConfig.getCollisionSheetPath();
|
QString filepath = projectConfig.collisionSheetPath;
|
||||||
|
|
||||||
QImage imgSheet;
|
QImage imgSheet;
|
||||||
if (filepath.isEmpty()) {
|
if (filepath.isEmpty()) {
|
||||||
|
@ -2299,8 +2299,8 @@ void Editor::setCollisionGraphics() {
|
||||||
|
|
||||||
// Users are not required to provide an image that gives an icon for every elevation/collision combination.
|
// Users are not required to provide an image that gives an icon for every elevation/collision combination.
|
||||||
// Instead they tell us how many are provided in their image by specifying the number of columns and rows.
|
// Instead they tell us how many are provided in their image by specifying the number of columns and rows.
|
||||||
const int imgColumns = projectConfig.getCollisionSheetWidth();
|
const int imgColumns = projectConfig.collisionSheetWidth;
|
||||||
const int imgRows = projectConfig.getCollisionSheetHeight();
|
const int imgRows = projectConfig.collisionSheetHeight;
|
||||||
|
|
||||||
// Create a pixmap for the selector on the Collision tab. If a project was previously opened we'll also need to refresh the selector.
|
// Create a pixmap for the selector on the Collision tab. If a project was previously opened we'll also need to refresh the selector.
|
||||||
this->collisionSheetPixmap = QPixmap::fromImage(imgSheet).scaled(MovementPermissionsSelector::CellWidth * imgColumns,
|
this->collisionSheetPixmap = QPixmap::fromImage(imgSheet).scaled(MovementPermissionsSelector::CellWidth * imgColumns,
|
||||||
|
|
|
@ -70,14 +70,14 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
logInfo(QString("Launching Porymap v%1").arg(QCoreApplication::applicationVersion()));
|
logInfo(QString("Launching Porymap v%1").arg(QCoreApplication::applicationVersion()));
|
||||||
|
|
||||||
this->initWindow();
|
this->initWindow();
|
||||||
if (porymapConfig.getReopenOnLaunch() && this->openProject(porymapConfig.getRecentProject(), true))
|
if (porymapConfig.reopenOnLaunch && this->openProject(porymapConfig.getRecentProject(), true))
|
||||||
on_toolButton_Paint_clicked();
|
on_toolButton_Paint_clicked();
|
||||||
|
|
||||||
// there is a bug affecting macOS users, where the trackpad deilveres a bad touch-release gesture
|
// there is a bug affecting macOS users, where the trackpad deilveres a bad touch-release gesture
|
||||||
// the warning is a bit annoying, so it is disabled here
|
// the warning is a bit annoying, so it is disabled here
|
||||||
QLoggingCategory::setFilterRules(QStringLiteral("qt.pointer.dispatch=false"));
|
QLoggingCategory::setFilterRules(QStringLiteral("qt.pointer.dispatch=false"));
|
||||||
|
|
||||||
if (porymapConfig.getCheckForUpdates())
|
if (porymapConfig.checkForUpdates)
|
||||||
this->checkForUpdates(false);
|
this->checkForUpdates(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,12 +285,12 @@ void MainWindow::checkForUpdates(bool requestedByUser) {
|
||||||
openSubWindow(this->updatePromoter);
|
openSubWindow(this->updatePromoter);
|
||||||
} else {
|
} else {
|
||||||
// This is an automatic update check. Only run if we haven't done one in the last 5 minutes
|
// This is an automatic update check. Only run if we haven't done one in the last 5 minutes
|
||||||
QDateTime lastCheck = porymapConfig.getLastUpdateCheckTime();
|
QDateTime lastCheck = porymapConfig.lastUpdateCheckTime;
|
||||||
if (lastCheck.addSecs(5*60) >= QDateTime::currentDateTime())
|
if (lastCheck.addSecs(5*60) >= QDateTime::currentDateTime())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->updatePromoter->checkForUpdates();
|
this->updatePromoter->checkForUpdates();
|
||||||
porymapConfig.setLastUpdateCheckTime(QDateTime::currentDateTime());
|
porymapConfig.lastUpdateCheckTime = QDateTime::currentDateTime();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void MainWindow::checkForUpdates(bool) {}
|
void MainWindow::checkForUpdates(bool) {}
|
||||||
|
@ -420,7 +420,7 @@ void MainWindow::setProjectSpecificUI()
|
||||||
// TODO: This index should come from an enum
|
// TODO: This index should come from an enum
|
||||||
ui->mainTabBar->setTabEnabled(4, editor->project->wildEncountersLoaded);
|
ui->mainTabBar->setTabEnabled(4, editor->project->wildEncountersLoaded);
|
||||||
|
|
||||||
bool hasFlags = projectConfig.getMapAllowFlagsEnabled();
|
bool hasFlags = projectConfig.mapAllowFlagsEnabled;
|
||||||
ui->checkBox_AllowRunning->setVisible(hasFlags);
|
ui->checkBox_AllowRunning->setVisible(hasFlags);
|
||||||
ui->checkBox_AllowBiking->setVisible(hasFlags);
|
ui->checkBox_AllowBiking->setVisible(hasFlags);
|
||||||
ui->checkBox_AllowEscaping->setVisible(hasFlags);
|
ui->checkBox_AllowEscaping->setVisible(hasFlags);
|
||||||
|
@ -428,11 +428,11 @@ void MainWindow::setProjectSpecificUI()
|
||||||
ui->label_AllowBiking->setVisible(hasFlags);
|
ui->label_AllowBiking->setVisible(hasFlags);
|
||||||
ui->label_AllowEscaping->setVisible(hasFlags);
|
ui->label_AllowEscaping->setVisible(hasFlags);
|
||||||
|
|
||||||
ui->newEventToolButton->newWeatherTriggerAction->setVisible(projectConfig.getEventWeatherTriggerEnabled());
|
ui->newEventToolButton->newWeatherTriggerAction->setVisible(projectConfig.eventWeatherTriggerEnabled);
|
||||||
ui->newEventToolButton->newSecretBaseAction->setVisible(projectConfig.getEventSecretBaseEnabled());
|
ui->newEventToolButton->newSecretBaseAction->setVisible(projectConfig.eventSecretBaseEnabled);
|
||||||
ui->newEventToolButton->newCloneObjectAction->setVisible(projectConfig.getEventCloneObjectEnabled());
|
ui->newEventToolButton->newCloneObjectAction->setVisible(projectConfig.eventCloneObjectEnabled);
|
||||||
|
|
||||||
bool floorNumEnabled = projectConfig.getFloorNumberEnabled();
|
bool floorNumEnabled = projectConfig.floorNumberEnabled;
|
||||||
ui->spinBox_FloorNumber->setVisible(floorNumEnabled);
|
ui->spinBox_FloorNumber->setVisible(floorNumEnabled);
|
||||||
ui->label_FloorNumber->setVisible(floorNumEnabled);
|
ui->label_FloorNumber->setVisible(floorNumEnabled);
|
||||||
|
|
||||||
|
@ -457,8 +457,7 @@ void MainWindow::mapSortOrder_changed(QAction *action)
|
||||||
if (i != mapSortOrder)
|
if (i != mapSortOrder)
|
||||||
{
|
{
|
||||||
ui->toolButton_MapSortOrder->setIcon(action->icon());
|
ui->toolButton_MapSortOrder->setIcon(action->icon());
|
||||||
mapSortOrder = static_cast<MapSortOrder>(i);
|
porymapConfig.mapSortOrder = static_cast<MapSortOrder>(i);
|
||||||
porymapConfig.setMapSortOrder(mapSortOrder);
|
|
||||||
if (isProjectOpen())
|
if (isProjectOpen())
|
||||||
{
|
{
|
||||||
sortMapList();
|
sortMapList();
|
||||||
|
@ -485,26 +484,26 @@ void MainWindow::applyMapListFilter(QString filterText)
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::loadUserSettings() {
|
void MainWindow::loadUserSettings() {
|
||||||
ui->actionBetter_Cursors->setChecked(porymapConfig.getPrettyCursors());
|
ui->actionBetter_Cursors->setChecked(porymapConfig.prettyCursors);
|
||||||
this->editor->settings->betterCursors = porymapConfig.getPrettyCursors();
|
this->editor->settings->betterCursors = porymapConfig.prettyCursors;
|
||||||
ui->actionPlayer_View_Rectangle->setChecked(porymapConfig.getShowPlayerView());
|
ui->actionPlayer_View_Rectangle->setChecked(porymapConfig.showPlayerView);
|
||||||
this->editor->settings->playerViewRectEnabled = porymapConfig.getShowPlayerView();
|
this->editor->settings->playerViewRectEnabled = porymapConfig.showPlayerView;
|
||||||
ui->actionCursor_Tile_Outline->setChecked(porymapConfig.getShowCursorTile());
|
ui->actionCursor_Tile_Outline->setChecked(porymapConfig.showCursorTile);
|
||||||
this->editor->settings->cursorTileRectEnabled = porymapConfig.getShowCursorTile();
|
this->editor->settings->cursorTileRectEnabled = porymapConfig.showCursorTile;
|
||||||
ui->checkBox_ToggleBorder->setChecked(porymapConfig.getShowBorder());
|
ui->checkBox_ToggleBorder->setChecked(porymapConfig.showBorder);
|
||||||
ui->checkBox_ToggleGrid->setChecked(porymapConfig.getShowGrid());
|
ui->checkBox_ToggleGrid->setChecked(porymapConfig.showGrid);
|
||||||
mapSortOrder = porymapConfig.getMapSortOrder();
|
mapSortOrder = porymapConfig.mapSortOrder;
|
||||||
ui->horizontalSlider_CollisionTransparency->blockSignals(true);
|
ui->horizontalSlider_CollisionTransparency->blockSignals(true);
|
||||||
this->editor->collisionOpacity = static_cast<qreal>(porymapConfig.getCollisionOpacity()) / 100;
|
this->editor->collisionOpacity = static_cast<qreal>(porymapConfig.collisionOpacity) / 100;
|
||||||
ui->horizontalSlider_CollisionTransparency->setValue(porymapConfig.getCollisionOpacity());
|
ui->horizontalSlider_CollisionTransparency->setValue(porymapConfig.collisionOpacity);
|
||||||
ui->horizontalSlider_CollisionTransparency->blockSignals(false);
|
ui->horizontalSlider_CollisionTransparency->blockSignals(false);
|
||||||
ui->horizontalSlider_MetatileZoom->blockSignals(true);
|
ui->horizontalSlider_MetatileZoom->blockSignals(true);
|
||||||
ui->horizontalSlider_MetatileZoom->setValue(porymapConfig.getMetatilesZoom());
|
ui->horizontalSlider_MetatileZoom->setValue(porymapConfig.metatilesZoom);
|
||||||
ui->horizontalSlider_MetatileZoom->blockSignals(false);
|
ui->horizontalSlider_MetatileZoom->blockSignals(false);
|
||||||
ui->horizontalSlider_CollisionZoom->blockSignals(true);
|
ui->horizontalSlider_CollisionZoom->blockSignals(true);
|
||||||
ui->horizontalSlider_CollisionZoom->setValue(porymapConfig.getCollisionZoom());
|
ui->horizontalSlider_CollisionZoom->setValue(porymapConfig.collisionZoom);
|
||||||
ui->horizontalSlider_CollisionZoom->blockSignals(false);
|
ui->horizontalSlider_CollisionZoom->blockSignals(false);
|
||||||
setTheme(porymapConfig.getTheme());
|
setTheme(porymapConfig.theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::restoreWindowState() {
|
void MainWindow::restoreWindowState() {
|
||||||
|
@ -558,32 +557,38 @@ bool MainWindow::openProject(const QString &dir, bool initial) {
|
||||||
this->statusBar()->showMessage(openMessage);
|
this->statusBar()->showMessage(openMessage);
|
||||||
logInfo(openMessage);
|
logInfo(openMessage);
|
||||||
|
|
||||||
// TODO: Don't save these yet
|
userConfig.projectDir = dir;
|
||||||
userConfig.setProjectDir(dir);
|
|
||||||
userConfig.load();
|
userConfig.load();
|
||||||
projectConfig.setProjectDir(dir);
|
projectConfig.projectDir = dir;
|
||||||
projectConfig.load();
|
projectConfig.load();
|
||||||
|
|
||||||
this->newMapDefaultsSet = false;
|
this->newMapDefaultsSet = false;
|
||||||
|
|
||||||
Scripting::init(this);
|
Scripting::init(this);
|
||||||
|
|
||||||
|
// Create the project
|
||||||
this->editor->project = new Project(this);
|
this->editor->project = new Project(this);
|
||||||
QObject::connect(this->editor->project, &Project::reloadProject, this, &MainWindow::on_action_Reload_Project_triggered);
|
QObject::connect(this->editor->project, &Project::reloadProject, this, &MainWindow::on_action_Reload_Project_triggered);
|
||||||
QObject::connect(this->editor->project, &Project::mapCacheCleared, this, &MainWindow::onMapCacheCleared);
|
QObject::connect(this->editor->project, &Project::mapCacheCleared, this, &MainWindow::onMapCacheCleared);
|
||||||
QObject::connect(this->editor->project, &Project::uncheckMonitorFilesAction, [this]() {
|
QObject::connect(this->editor->project, &Project::uncheckMonitorFilesAction, [this]() {
|
||||||
porymapConfig.setMonitorFiles(false);
|
porymapConfig.monitorFiles = false;
|
||||||
if (this->preferenceEditor)
|
if (this->preferenceEditor)
|
||||||
this->preferenceEditor->updateFields();
|
this->preferenceEditor->updateFields();
|
||||||
});
|
});
|
||||||
this->editor->project->set_root(dir);
|
this->editor->project->set_root(dir);
|
||||||
|
|
||||||
|
// Load the project
|
||||||
if (!(loadDataStructures() && populateMapList() && setInitialMap())) {
|
if (!(loadDataStructures() && populateMapList() && setInitialMap())) {
|
||||||
this->statusBar()->showMessage(QString("Failed to open %1").arg(projectString));
|
this->statusBar()->showMessage(QString("Failed to open %1").arg(projectString));
|
||||||
showProjectOpenFailure();
|
showProjectOpenFailure();
|
||||||
delete this->editor->project;
|
delete this->editor->project;
|
||||||
|
// TODO: Allow changing project settings at this point
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only create the config files once the project has opened successfully in case the user selected an invalid directory
|
||||||
|
userConfig.save();
|
||||||
|
projectConfig.save();
|
||||||
|
|
||||||
showWindowTitle();
|
showWindowTitle();
|
||||||
this->statusBar()->showMessage(QString("Opened %1").arg(projectString));
|
this->statusBar()->showMessage(QString("Opened %1").arg(projectString));
|
||||||
|
@ -619,7 +624,7 @@ bool MainWindow::setInitialMap() {
|
||||||
names = editor->project->mapNames;
|
names = editor->project->mapNames;
|
||||||
|
|
||||||
// Try to set most recently-opened map, if it's still in the list.
|
// Try to set most recently-opened map, if it's still in the list.
|
||||||
QString recentMap = userConfig.getRecentMap();
|
QString recentMap = userConfig.recentMap;
|
||||||
if (!recentMap.isEmpty() && names.contains(recentMap) && setMap(recentMap, true))
|
if (!recentMap.isEmpty() && names.contains(recentMap) && setMap(recentMap, true))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -687,11 +692,7 @@ QString MainWindow::getExistingDirectory(QString dir) {
|
||||||
|
|
||||||
void MainWindow::on_action_Open_Project_triggered()
|
void MainWindow::on_action_Open_Project_triggered()
|
||||||
{
|
{
|
||||||
QString recent = ".";
|
QString dir = getExistingDirectory(!userConfig.recentMap.isEmpty() ? userConfig.recentMap : ".");
|
||||||
if (!userConfig.getRecentMap().isEmpty()) {
|
|
||||||
recent = userConfig.getRecentMap();
|
|
||||||
}
|
|
||||||
QString dir = getExistingDirectory(recent);
|
|
||||||
if (!dir.isEmpty())
|
if (!dir.isEmpty())
|
||||||
openProject(dir);
|
openProject(dir);
|
||||||
}
|
}
|
||||||
|
@ -743,7 +744,7 @@ bool MainWindow::setMap(QString map_name, bool scrollTreeView) {
|
||||||
connect(editor->map, &Map::mapNeedsRedrawing, this, &MainWindow::onMapNeedsRedrawing);
|
connect(editor->map, &Map::mapNeedsRedrawing, this, &MainWindow::onMapNeedsRedrawing);
|
||||||
connect(editor->map, &Map::modified, [this](){ this->markMapEdited(); });
|
connect(editor->map, &Map::modified, [this](){ this->markMapEdited(); });
|
||||||
|
|
||||||
setRecentMap(map_name);
|
userConfig.recentMap = map_name;
|
||||||
updateMapList();
|
updateMapList();
|
||||||
|
|
||||||
Scripting::cb_MapOpened(map_name);
|
Scripting::cb_MapOpened(map_name);
|
||||||
|
@ -829,10 +830,6 @@ void MainWindow::openWarpMap(QString map_name, int event_id, Event::Group event_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setRecentMap(QString mapName) {
|
|
||||||
userConfig.setRecentMap(mapName);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::displayMapProperties() {
|
void MainWindow::displayMapProperties() {
|
||||||
// Block signals to the comboboxes while they are being modified
|
// Block signals to the comboboxes while they are being modified
|
||||||
const QSignalBlocker blocker1(ui->comboBox_Song);
|
const QSignalBlocker blocker1(ui->comboBox_Song);
|
||||||
|
@ -1407,7 +1404,7 @@ void MainWindow::updateTilesetEditor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
double MainWindow::getMetatilesZoomScale() {
|
double MainWindow::getMetatilesZoomScale() {
|
||||||
return pow(3.0, static_cast<double>(porymapConfig.getMetatilesZoom() - 30) / 30.0);
|
return pow(3.0, static_cast<double>(porymapConfig.metatilesZoom - 30) / 30.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::redrawMetatileSelection() {
|
void MainWindow::redrawMetatileSelection() {
|
||||||
|
@ -1541,8 +1538,8 @@ void MainWindow::copy() {
|
||||||
collisions.clear();
|
collisions.clear();
|
||||||
for (int i = 0; i < metatiles.length(); i++) {
|
for (int i = 0; i < metatiles.length(); i++) {
|
||||||
OrderedJson::object collision;
|
OrderedJson::object collision;
|
||||||
collision["collision"] = projectConfig.getDefaultCollision();
|
collision["collision"] = projectConfig.defaultCollision;
|
||||||
collision["elevation"] = projectConfig.getDefaultElevation();
|
collision["elevation"] = projectConfig.defaultElevation;
|
||||||
collisions.append(collision);
|
collisions.append(collision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1781,10 +1778,10 @@ void MainWindow::on_mapViewTab_tabBarClicked(int index)
|
||||||
editor->setEditingCollision();
|
editor->setEditingCollision();
|
||||||
} else if (index == 2) {
|
} else if (index == 2) {
|
||||||
editor->setEditingMap();
|
editor->setEditingMap();
|
||||||
if (projectConfig.getPrefabFilepath().isEmpty() && !projectConfig.getPrefabImportPrompted()) {
|
if (projectConfig.prefabFilepath.isEmpty() && !projectConfig.prefabImportPrompted) {
|
||||||
// User hasn't set up prefabs and hasn't been prompted before.
|
// User hasn't set up prefabs and hasn't been prompted before.
|
||||||
// Ask if they'd like to import the default prefabs file.
|
// Ask if they'd like to import the default prefabs file.
|
||||||
if (prefab.tryImportDefaultPrefabs(this, projectConfig.getBaseGameVersion()))
|
if (prefab.tryImportDefaultPrefabs(this, projectConfig.baseGameVersion))
|
||||||
prefab.updatePrefabUi(this->editor->map);
|
prefab.updatePrefabUi(this->editor->map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1830,14 +1827,14 @@ void MainWindow::on_actionZoom_Out_triggered() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionBetter_Cursors_triggered() {
|
void MainWindow::on_actionBetter_Cursors_triggered() {
|
||||||
porymapConfig.setPrettyCursors(ui->actionBetter_Cursors->isChecked());
|
porymapConfig.prettyCursors = ui->actionBetter_Cursors->isChecked();
|
||||||
this->editor->settings->betterCursors = ui->actionBetter_Cursors->isChecked();
|
this->editor->settings->betterCursors = ui->actionBetter_Cursors->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionPlayer_View_Rectangle_triggered()
|
void MainWindow::on_actionPlayer_View_Rectangle_triggered()
|
||||||
{
|
{
|
||||||
bool enabled = ui->actionPlayer_View_Rectangle->isChecked();
|
bool enabled = ui->actionPlayer_View_Rectangle->isChecked();
|
||||||
porymapConfig.setShowPlayerView(enabled);
|
porymapConfig.showPlayerView = enabled;
|
||||||
this->editor->settings->playerViewRectEnabled = enabled;
|
this->editor->settings->playerViewRectEnabled = enabled;
|
||||||
if ((this->editor->map_item && this->editor->map_item->has_mouse)
|
if ((this->editor->map_item && this->editor->map_item->has_mouse)
|
||||||
|| (this->editor->collision_item && this->editor->collision_item->has_mouse)) {
|
|| (this->editor->collision_item && this->editor->collision_item->has_mouse)) {
|
||||||
|
@ -1849,7 +1846,7 @@ void MainWindow::on_actionPlayer_View_Rectangle_triggered()
|
||||||
void MainWindow::on_actionCursor_Tile_Outline_triggered()
|
void MainWindow::on_actionCursor_Tile_Outline_triggered()
|
||||||
{
|
{
|
||||||
bool enabled = ui->actionCursor_Tile_Outline->isChecked();
|
bool enabled = ui->actionCursor_Tile_Outline->isChecked();
|
||||||
porymapConfig.setShowCursorTile(enabled);
|
porymapConfig.showCursorTile = enabled;
|
||||||
this->editor->settings->cursorTileRectEnabled = enabled;
|
this->editor->settings->cursorTileRectEnabled = enabled;
|
||||||
if ((this->editor->map_item && this->editor->map_item->has_mouse)
|
if ((this->editor->map_item && this->editor->map_item->has_mouse)
|
||||||
|| (this->editor->collision_item && this->editor->collision_item->has_mouse)) {
|
|| (this->editor->collision_item && this->editor->collision_item->has_mouse)) {
|
||||||
|
@ -2198,7 +2195,7 @@ void MainWindow::eventTabChanged(int index) {
|
||||||
|
|
||||||
void MainWindow::on_horizontalSlider_CollisionTransparency_valueChanged(int value) {
|
void MainWindow::on_horizontalSlider_CollisionTransparency_valueChanged(int value) {
|
||||||
this->editor->collisionOpacity = static_cast<qreal>(value) / 100;
|
this->editor->collisionOpacity = static_cast<qreal>(value) / 100;
|
||||||
porymapConfig.setCollisionOpacity(value);
|
porymapConfig.collisionOpacity = value;
|
||||||
this->editor->collision_item->draw(true);
|
this->editor->collision_item->draw(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2635,7 +2632,7 @@ void MainWindow::on_pushButton_ChangeDimensions_clicked()
|
||||||
heightSpinBox->setValue(editor->map->getHeight());
|
heightSpinBox->setValue(editor->map->getHeight());
|
||||||
bwidthSpinBox->setValue(editor->map->getBorderWidth());
|
bwidthSpinBox->setValue(editor->map->getBorderWidth());
|
||||||
bheightSpinBox->setValue(editor->map->getBorderHeight());
|
bheightSpinBox->setValue(editor->map->getBorderHeight());
|
||||||
if (projectConfig.getUseCustomBorderSize()) {
|
if (projectConfig.useCustomBorderSize) {
|
||||||
form.addRow(new QLabel("Map Width"), widthSpinBox);
|
form.addRow(new QLabel("Map Width"), widthSpinBox);
|
||||||
form.addRow(new QLabel("Map Height"), heightSpinBox);
|
form.addRow(new QLabel("Map Height"), heightSpinBox);
|
||||||
form.addRow(new QLabel("Border Width"), bwidthSpinBox);
|
form.addRow(new QLabel("Border Width"), bwidthSpinBox);
|
||||||
|
@ -2777,7 +2774,7 @@ void MainWindow::on_actionPreferences_triggered() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::togglePreferenceSpecificUi() {
|
void MainWindow::togglePreferenceSpecificUi() {
|
||||||
if (porymapConfig.getTextEditorOpenFolder().isEmpty())
|
if (porymapConfig.textEditorOpenFolder.isEmpty())
|
||||||
ui->actionOpen_Project_in_Text_Editor->setEnabled(false);
|
ui->actionOpen_Project_in_Text_Editor->setEnabled(false);
|
||||||
else
|
else
|
||||||
ui->actionOpen_Project_in_Text_Editor->setEnabled(true);
|
ui->actionOpen_Project_in_Text_Editor->setEnabled(true);
|
||||||
|
@ -2797,7 +2794,7 @@ void MainWindow::openProjectSettingsEditor(int tab) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionProject_Settings_triggered() {
|
void MainWindow::on_actionProject_Settings_triggered() {
|
||||||
this->openProjectSettingsEditor(porymapConfig.getProjectSettingsTab());
|
this->openProjectSettingsEditor(porymapConfig.projectSettingsTab);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onWarpBehaviorWarningClicked() {
|
void MainWindow::onWarpBehaviorWarningClicked() {
|
||||||
|
@ -2843,7 +2840,7 @@ void MainWindow::reloadScriptEngine() {
|
||||||
Scripting::init(this);
|
Scripting::init(this);
|
||||||
Scripting::populateGlobalObject(this);
|
Scripting::populateGlobalObject(this);
|
||||||
// Lying to the scripts here, simulating a project reload
|
// Lying to the scripts here, simulating a project reload
|
||||||
Scripting::cb_ProjectOpened(projectConfig.getProjectDir());
|
Scripting::cb_ProjectOpened(projectConfig.projectDir);
|
||||||
if (editor && editor->map)
|
if (editor && editor->map)
|
||||||
Scripting::cb_MapOpened(editor->map->name);
|
Scripting::cb_MapOpened(editor->map->name);
|
||||||
}
|
}
|
||||||
|
@ -2870,7 +2867,7 @@ void MainWindow::on_tableWidget_CustomHeaderFields_cellChanged(int, int)
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_horizontalSlider_MetatileZoom_valueChanged(int value) {
|
void MainWindow::on_horizontalSlider_MetatileZoom_valueChanged(int value) {
|
||||||
porymapConfig.setMetatilesZoom(value);
|
porymapConfig.metatilesZoom = value;
|
||||||
double scale = pow(3.0, static_cast<double>(value - 30) / 30.0);
|
double scale = pow(3.0, static_cast<double>(value - 30) / 30.0);
|
||||||
|
|
||||||
QTransform transform;
|
QTransform transform;
|
||||||
|
@ -2895,7 +2892,7 @@ void MainWindow::on_horizontalSlider_MetatileZoom_valueChanged(int value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_horizontalSlider_CollisionZoom_valueChanged(int value) {
|
void MainWindow::on_horizontalSlider_CollisionZoom_valueChanged(int value) {
|
||||||
porymapConfig.setCollisionZoom(value);
|
porymapConfig.collisionZoom = value;
|
||||||
double scale = pow(3.0, static_cast<double>(value - 30) / 30.0);
|
double scale = pow(3.0, static_cast<double>(value - 30) / 30.0);
|
||||||
|
|
||||||
QTransform transform;
|
QTransform transform;
|
||||||
|
@ -2981,7 +2978,6 @@ bool MainWindow::askToFixRegionMapEditor() {
|
||||||
// Attempt to close any open sub-windows of the main window, giving each a chance to abort the process.
|
// Attempt to close any open sub-windows of the main window, giving each a chance to abort the process.
|
||||||
// Each of these are expected to be a QPointer to a widget with WA_DeleteOnClose set, so manually deleting
|
// Each of these are expected to be a QPointer to a widget with WA_DeleteOnClose set, so manually deleting
|
||||||
// and nullifying the pointer members is not necessary here.
|
// and nullifying the pointer members is not necessary here.
|
||||||
// TODO: Testing
|
|
||||||
bool MainWindow::closeSupplementaryWindows() {
|
bool MainWindow::closeSupplementaryWindows() {
|
||||||
if (this->tilesetEditor && !this->tilesetEditor->close())
|
if (this->tilesetEditor && !this->tilesetEditor->close())
|
||||||
return false;
|
return false;
|
||||||
|
@ -3022,9 +3018,6 @@ bool MainWindow::closeProject() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
projectConfig.save();
|
|
||||||
userConfig.save();
|
|
||||||
|
|
||||||
editor->closeProject();
|
editor->closeProject();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
128
src/project.cpp
128
src/project.cpp
|
@ -49,7 +49,7 @@ Project::~Project()
|
||||||
void Project::initSignals() {
|
void Project::initSignals() {
|
||||||
// detect changes to specific filepaths being monitored
|
// detect changes to specific filepaths being monitored
|
||||||
QObject::connect(&fileWatcher, &QFileSystemWatcher::fileChanged, [this](QString changed){
|
QObject::connect(&fileWatcher, &QFileSystemWatcher::fileChanged, [this](QString changed){
|
||||||
if (!porymapConfig.getMonitorFiles()) return;
|
if (!porymapConfig.monitorFiles) return;
|
||||||
if (modifiedFileTimestamps.contains(changed)) {
|
if (modifiedFileTimestamps.contains(changed)) {
|
||||||
if (QDateTime::currentMSecsSinceEpoch() < modifiedFileTimestamps[changed]) {
|
if (QDateTime::currentMSecsSinceEpoch() < modifiedFileTimestamps[changed]) {
|
||||||
return;
|
return;
|
||||||
|
@ -77,7 +77,7 @@ void Project::initSignals() {
|
||||||
emit reloadProject();
|
emit reloadProject();
|
||||||
} else if (choice == QMessageBox::No) {
|
} else if (choice == QMessageBox::No) {
|
||||||
if (showAgainCheck.isChecked()) {
|
if (showAgainCheck.isChecked()) {
|
||||||
porymapConfig.setMonitorFiles(false);
|
porymapConfig.monitorFiles = false;
|
||||||
emit uncheckMonitorFilesAction();
|
emit uncheckMonitorFilesAction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,13 +162,13 @@ const QSet<QString> defaultTopLevelMapFields = {
|
||||||
|
|
||||||
QSet<QString> Project::getTopLevelMapFields() {
|
QSet<QString> Project::getTopLevelMapFields() {
|
||||||
QSet<QString> topLevelMapFields = defaultTopLevelMapFields;
|
QSet<QString> topLevelMapFields = defaultTopLevelMapFields;
|
||||||
if (projectConfig.getMapAllowFlagsEnabled()) {
|
if (projectConfig.mapAllowFlagsEnabled) {
|
||||||
topLevelMapFields.insert("allow_cycling");
|
topLevelMapFields.insert("allow_cycling");
|
||||||
topLevelMapFields.insert("allow_escaping");
|
topLevelMapFields.insert("allow_escaping");
|
||||||
topLevelMapFields.insert("allow_running");
|
topLevelMapFields.insert("allow_running");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (projectConfig.getFloorNumberEnabled()) {
|
if (projectConfig.floorNumberEnabled) {
|
||||||
topLevelMapFields.insert("floor_number");
|
topLevelMapFields.insert("floor_number");
|
||||||
}
|
}
|
||||||
return topLevelMapFields;
|
return topLevelMapFields;
|
||||||
|
@ -197,12 +197,12 @@ bool Project::loadMapData(Map* map) {
|
||||||
map->show_location = ParseUtil::jsonToBool(mapObj["show_map_name"]);
|
map->show_location = ParseUtil::jsonToBool(mapObj["show_map_name"]);
|
||||||
map->battle_scene = ParseUtil::jsonToQString(mapObj["battle_scene"]);
|
map->battle_scene = ParseUtil::jsonToQString(mapObj["battle_scene"]);
|
||||||
|
|
||||||
if (projectConfig.getMapAllowFlagsEnabled()) {
|
if (projectConfig.mapAllowFlagsEnabled) {
|
||||||
map->allowBiking = ParseUtil::jsonToBool(mapObj["allow_cycling"]);
|
map->allowBiking = ParseUtil::jsonToBool(mapObj["allow_cycling"]);
|
||||||
map->allowEscaping = ParseUtil::jsonToBool(mapObj["allow_escaping"]);
|
map->allowEscaping = ParseUtil::jsonToBool(mapObj["allow_escaping"]);
|
||||||
map->allowRunning = ParseUtil::jsonToBool(mapObj["allow_running"]);
|
map->allowRunning = ParseUtil::jsonToBool(mapObj["allow_running"]);
|
||||||
}
|
}
|
||||||
if (projectConfig.getFloorNumberEnabled()) {
|
if (projectConfig.floorNumberEnabled) {
|
||||||
map->floorNumber = ParseUtil::jsonToInt(mapObj["floor_number"]);
|
map->floorNumber = ParseUtil::jsonToInt(mapObj["floor_number"]);
|
||||||
}
|
}
|
||||||
map->sharedEventsMap = ParseUtil::jsonToQString(mapObj["shared_events_map"]);
|
map->sharedEventsMap = ParseUtil::jsonToQString(mapObj["shared_events_map"]);
|
||||||
|
@ -211,11 +211,10 @@ bool Project::loadMapData(Map* map) {
|
||||||
// Events
|
// Events
|
||||||
map->events[Event::Group::Object].clear();
|
map->events[Event::Group::Object].clear();
|
||||||
QJsonArray objectEventsArr = mapObj["object_events"].toArray();
|
QJsonArray objectEventsArr = mapObj["object_events"].toArray();
|
||||||
bool hasCloneObjects = projectConfig.getEventCloneObjectEnabled();
|
|
||||||
for (int i = 0; i < objectEventsArr.size(); i++) {
|
for (int i = 0; i < objectEventsArr.size(); i++) {
|
||||||
QJsonObject event = objectEventsArr[i].toObject();
|
QJsonObject event = objectEventsArr[i].toObject();
|
||||||
// If clone objects are not enabled then no type field is present
|
// If clone objects are not enabled then no type field is present
|
||||||
QString type = hasCloneObjects ? ParseUtil::jsonToQString(event["type"]) : "object";
|
QString type = projectConfig.eventCloneObjectEnabled ? ParseUtil::jsonToQString(event["type"]) : "object";
|
||||||
if (type.isEmpty() || type == "object") {
|
if (type.isEmpty() || type == "object") {
|
||||||
ObjectEvent *object = new ObjectEvent();
|
ObjectEvent *object = new ObjectEvent();
|
||||||
object->loadFromJson(event, this);
|
object->loadFromJson(event, this);
|
||||||
|
@ -297,11 +296,11 @@ bool Project::loadMapData(Map* map) {
|
||||||
heal->setMap(map);
|
heal->setMap(map);
|
||||||
heal->setX(loc.x);
|
heal->setX(loc.x);
|
||||||
heal->setY(loc.y);
|
heal->setY(loc.y);
|
||||||
heal->setElevation(projectConfig.getDefaultElevation());
|
heal->setElevation(projectConfig.defaultElevation);
|
||||||
heal->setLocationName(loc.mapName);
|
heal->setLocationName(loc.mapName);
|
||||||
heal->setIdName(loc.idName);
|
heal->setIdName(loc.idName);
|
||||||
heal->setIndex(loc.index);
|
heal->setIndex(loc.index);
|
||||||
if (projectConfig.getHealLocationRespawnDataEnabled()) {
|
if (projectConfig.healLocationRespawnDataEnabled) {
|
||||||
heal->setRespawnMap(mapConstantsToMapNames.value(QString(mapPrefix + loc.respawnMap)));
|
heal->setRespawnMap(mapConstantsToMapNames.value(QString(mapPrefix + loc.respawnMap)));
|
||||||
heal->setRespawnNPC(loc.respawnNPC);
|
heal->setRespawnNPC(loc.respawnNPC);
|
||||||
}
|
}
|
||||||
|
@ -438,7 +437,6 @@ bool Project::readMapLayouts() {
|
||||||
"border_filepath",
|
"border_filepath",
|
||||||
"blockdata_filepath",
|
"blockdata_filepath",
|
||||||
};
|
};
|
||||||
bool useCustomBorderSize = projectConfig.getUseCustomBorderSize();
|
|
||||||
for (int i = 0; i < layouts.size(); i++) {
|
for (int i = 0; i < layouts.size(); i++) {
|
||||||
QJsonObject layoutObj = layouts[i].toObject();
|
QJsonObject layoutObj = layouts[i].toObject();
|
||||||
if (layoutObj.isEmpty())
|
if (layoutObj.isEmpty())
|
||||||
|
@ -479,7 +477,7 @@ bool Project::readMapLayouts() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
layout->height = lheight;
|
layout->height = lheight;
|
||||||
if (useCustomBorderSize) {
|
if (projectConfig.useCustomBorderSize) {
|
||||||
int bwidth = ParseUtil::jsonToInt(layoutObj["border_width"]);
|
int bwidth = ParseUtil::jsonToInt(layoutObj["border_width"]);
|
||||||
if (bwidth <= 0) { // 0 is an expected border width/height that should be handled, GF used it for the RS layouts in FRLG
|
if (bwidth <= 0) { // 0 is an expected border width/height that should be handled, GF used it for the RS layouts in FRLG
|
||||||
logWarn(QString("Invalid 'border_width' value '%1' for %2 in %3. Must be greater than 0. Using default (%4) instead.")
|
logWarn(QString("Invalid 'border_width' value '%1' for %2 in %3. Must be greater than 0. Using default (%4) instead.")
|
||||||
|
@ -545,7 +543,6 @@ void Project::saveMapLayouts() {
|
||||||
OrderedJson::object layoutsObj;
|
OrderedJson::object layoutsObj;
|
||||||
layoutsObj["layouts_table_label"] = layoutsLabel;
|
layoutsObj["layouts_table_label"] = layoutsLabel;
|
||||||
|
|
||||||
bool useCustomBorderSize = projectConfig.getUseCustomBorderSize();
|
|
||||||
OrderedJson::array layoutsArr;
|
OrderedJson::array layoutsArr;
|
||||||
for (QString layoutId : mapLayoutsTableMaster) {
|
for (QString layoutId : mapLayoutsTableMaster) {
|
||||||
MapLayout *layout = mapLayouts.value(layoutId);
|
MapLayout *layout = mapLayouts.value(layoutId);
|
||||||
|
@ -554,7 +551,7 @@ void Project::saveMapLayouts() {
|
||||||
layoutObj["name"] = layout->name;
|
layoutObj["name"] = layout->name;
|
||||||
layoutObj["width"] = layout->width;
|
layoutObj["width"] = layout->width;
|
||||||
layoutObj["height"] = layout->height;
|
layoutObj["height"] = layout->height;
|
||||||
if (useCustomBorderSize) {
|
if (projectConfig.useCustomBorderSize) {
|
||||||
layoutObj["border_width"] = layout->border_width;
|
layoutObj["border_width"] = layout->border_width;
|
||||||
layoutObj["border_height"] = layout->border_height;
|
layoutObj["border_height"] = layout->border_height;
|
||||||
}
|
}
|
||||||
|
@ -768,7 +765,7 @@ void Project::saveHealLocationsData(Map *map) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the definition text for each data table
|
// Create the definition text for each data table
|
||||||
bool respawnEnabled = projectConfig.getHealLocationRespawnDataEnabled();
|
bool respawnEnabled = projectConfig.healLocationRespawnDataEnabled;
|
||||||
const QString qualifiers = QString(healLocationDataQualifiers.isStatic ? "static " : "")
|
const QString qualifiers = QString(healLocationDataQualifiers.isStatic ? "static " : "")
|
||||||
+ QString(healLocationDataQualifiers.isConst ? "const " : "");
|
+ QString(healLocationDataQualifiers.isConst ? "const " : "");
|
||||||
|
|
||||||
|
@ -951,10 +948,9 @@ void Project::saveTilesetMetatileAttributes(Tileset *tileset) {
|
||||||
QFile attrs_file(tileset->metatile_attrs_path);
|
QFile attrs_file(tileset->metatile_attrs_path);
|
||||||
if (attrs_file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
if (attrs_file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
int attrSize = projectConfig.getMetatileAttributesSize();
|
|
||||||
for (Metatile *metatile : tileset->metatiles) {
|
for (Metatile *metatile : tileset->metatiles) {
|
||||||
uint32_t attributes = metatile->getAttributes();
|
uint32_t attributes = metatile->getAttributes();
|
||||||
for (int i = 0; i < attrSize; i++)
|
for (int i = 0; i < projectConfig.metatileAttributesSize; i++)
|
||||||
data.append(static_cast<char>(attributes >> (8 * i)));
|
data.append(static_cast<char>(attributes >> (8 * i)));
|
||||||
}
|
}
|
||||||
attrs_file.write(data);
|
attrs_file.write(data);
|
||||||
|
@ -1090,7 +1086,7 @@ void Project::setNewMapBlockdata(Map *map) {
|
||||||
map->layout->blockdata.clear();
|
map->layout->blockdata.clear();
|
||||||
int width = map->getWidth();
|
int width = map->getWidth();
|
||||||
int height = map->getHeight();
|
int height = map->getHeight();
|
||||||
Block block(projectConfig.getDefaultMetatileId(), projectConfig.getDefaultCollision(), projectConfig.getDefaultElevation());
|
Block block(projectConfig.defaultMetatileId, projectConfig.defaultCollision, projectConfig.defaultElevation);
|
||||||
for (int i = 0; i < width * height; i++) {
|
for (int i = 0; i < width * height; i++) {
|
||||||
map->layout->blockdata.append(block);
|
map->layout->blockdata.append(block);
|
||||||
}
|
}
|
||||||
|
@ -1119,8 +1115,7 @@ void Project::setNewMapBorder(Map *map) {
|
||||||
int width = map->getBorderWidth();
|
int width = map->getBorderWidth();
|
||||||
int height = map->getBorderHeight();
|
int height = map->getBorderHeight();
|
||||||
|
|
||||||
const QList<uint16_t> configMetatileIds = projectConfig.getNewMapBorderMetatileIds();
|
if (projectConfig.newMapBorderMetatileIds.length() != width * height) {
|
||||||
if (configMetatileIds.length() != width * height) {
|
|
||||||
// Border size doesn't match the number of default border metatiles.
|
// Border size doesn't match the number of default border metatiles.
|
||||||
// Fill the border with empty metatiles.
|
// Fill the border with empty metatiles.
|
||||||
for (int i = 0; i < width * height; i++) {
|
for (int i = 0; i < width * height; i++) {
|
||||||
|
@ -1129,7 +1124,7 @@ void Project::setNewMapBorder(Map *map) {
|
||||||
} else {
|
} else {
|
||||||
// Fill the border with the default metatiles from the config.
|
// Fill the border with the default metatiles from the config.
|
||||||
for (int i = 0; i < width * height; i++) {
|
for (int i = 0; i < width * height; i++) {
|
||||||
map->layout->border.append(configMetatileIds.at(i));
|
map->layout->border.append(projectConfig.newMapBorderMetatileIds.at(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1172,18 +1167,17 @@ void Project::saveMap(Map *map) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create file data/maps/<map_name>/scripts.inc
|
// Create file data/maps/<map_name>/scripts.inc
|
||||||
QString text = this->getScriptDefaultString(projectConfig.getUsePoryScript(), map->name);
|
QString text = this->getScriptDefaultString(projectConfig.usePoryScript, map->name);
|
||||||
saveTextFile(mapDataDir + "/scripts" + this->getScriptFileExtension(projectConfig.getUsePoryScript()), text);
|
saveTextFile(mapDataDir + "/scripts" + this->getScriptFileExtension(projectConfig.usePoryScript), text);
|
||||||
|
|
||||||
bool usesTextFile = projectConfig.getCreateMapTextFileEnabled();
|
if (projectConfig.createMapTextFileEnabled) {
|
||||||
if (usesTextFile) {
|
|
||||||
// Create file data/maps/<map_name>/text.inc
|
// Create file data/maps/<map_name>/text.inc
|
||||||
saveTextFile(mapDataDir + "/text" + this->getScriptFileExtension(projectConfig.getUsePoryScript()), "\n");
|
saveTextFile(mapDataDir + "/text" + this->getScriptFileExtension(projectConfig.usePoryScript), "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simply append to data/event_scripts.s.
|
// Simply append to data/event_scripts.s.
|
||||||
text = QString("\n\t.include \"%1%2/scripts.inc\"\n").arg(basePath, map->name);
|
text = QString("\n\t.include \"%1%2/scripts.inc\"\n").arg(basePath, map->name);
|
||||||
if (usesTextFile) {
|
if (projectConfig.createMapTextFileEnabled) {
|
||||||
text += QString("\t.include \"%1%2/text.inc\"\n").arg(basePath, map->name);
|
text += QString("\t.include \"%1%2/text.inc\"\n").arg(basePath, map->name);
|
||||||
}
|
}
|
||||||
appendTextFile(root + "/" + projectConfig.getFilePath(ProjectFilePath::data_event_scripts), text);
|
appendTextFile(root + "/" + projectConfig.getFilePath(ProjectFilePath::data_event_scripts), text);
|
||||||
|
@ -1214,13 +1208,13 @@ void Project::saveMap(Map *map) {
|
||||||
mapObj["requires_flash"] = map->requiresFlash;
|
mapObj["requires_flash"] = map->requiresFlash;
|
||||||
mapObj["weather"] = map->weather;
|
mapObj["weather"] = map->weather;
|
||||||
mapObj["map_type"] = map->type;
|
mapObj["map_type"] = map->type;
|
||||||
if (projectConfig.getMapAllowFlagsEnabled()) {
|
if (projectConfig.mapAllowFlagsEnabled) {
|
||||||
mapObj["allow_cycling"] = map->allowBiking;
|
mapObj["allow_cycling"] = map->allowBiking;
|
||||||
mapObj["allow_escaping"] = map->allowEscaping;
|
mapObj["allow_escaping"] = map->allowEscaping;
|
||||||
mapObj["allow_running"] = map->allowRunning;
|
mapObj["allow_running"] = map->allowRunning;
|
||||||
}
|
}
|
||||||
mapObj["show_map_name"] = map->show_location;
|
mapObj["show_map_name"] = map->show_location;
|
||||||
if (projectConfig.getFloorNumberEnabled()) {
|
if (projectConfig.floorNumberEnabled) {
|
||||||
mapObj["floor_number"] = map->floorNumber;
|
mapObj["floor_number"] = map->floorNumber;
|
||||||
}
|
}
|
||||||
mapObj["battle_scene"] = map->battle_scene;
|
mapObj["battle_scene"] = map->battle_scene;
|
||||||
|
@ -1328,6 +1322,12 @@ void Project::saveAllDataStructures() {
|
||||||
saveMapGroups();
|
saveMapGroups();
|
||||||
saveMapConstantsHeader();
|
saveMapConstantsHeader();
|
||||||
saveWildMonData();
|
saveWildMonData();
|
||||||
|
saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Project::saveConfig() {
|
||||||
|
projectConfig.save();
|
||||||
|
userConfig.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Project::loadTilesetAssets(Tileset* tileset) {
|
void Project::loadTilesetAssets(Tileset* tileset) {
|
||||||
|
@ -1466,7 +1466,7 @@ void Project::loadTilesetMetatiles(Tileset* tileset) {
|
||||||
if (attrs_file.open(QIODevice::ReadOnly)) {
|
if (attrs_file.open(QIODevice::ReadOnly)) {
|
||||||
QByteArray data = attrs_file.readAll();
|
QByteArray data = attrs_file.readAll();
|
||||||
int num_metatiles = tileset->metatiles.count();
|
int num_metatiles = tileset->metatiles.count();
|
||||||
int attrSize = projectConfig.getMetatileAttributesSize();
|
int attrSize = projectConfig.metatileAttributesSize;
|
||||||
int num_metatileAttrs = data.length() / attrSize;
|
int num_metatileAttrs = data.length() / attrSize;
|
||||||
if (num_metatiles != num_metatileAttrs) {
|
if (num_metatiles != num_metatileAttrs) {
|
||||||
logWarn(QString("Metatile count %1 does not match metatile attribute count %2 in %3").arg(num_metatiles).arg(num_metatileAttrs).arg(tileset->name));
|
logWarn(QString("Metatile count %1 does not match metatile attribute count %2 in %3").arg(num_metatiles).arg(num_metatileAttrs).arg(tileset->name));
|
||||||
|
@ -1603,7 +1603,7 @@ bool Project::readWildMonData() {
|
||||||
wildMonData.clear();
|
wildMonData.clear();
|
||||||
encounterGroupLabels.clear();
|
encounterGroupLabels.clear();
|
||||||
this->wildEncountersLoaded = false;
|
this->wildEncountersLoaded = false;
|
||||||
if (!userConfig.getEncounterJsonActive()) {
|
if (!userConfig.useEncounterJson) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1813,7 +1813,7 @@ Project::DataQualifiers Project::getDataQualifiers(QString text, QString label)
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Project::getDefaultPrimaryTilesetLabel() {
|
QString Project::getDefaultPrimaryTilesetLabel() {
|
||||||
QString defaultLabel = projectConfig.getDefaultPrimaryTileset();
|
QString defaultLabel = projectConfig.defaultPrimaryTileset;
|
||||||
if (!this->primaryTilesetLabels.contains(defaultLabel)) {
|
if (!this->primaryTilesetLabels.contains(defaultLabel)) {
|
||||||
QString firstLabel = this->primaryTilesetLabels.first();
|
QString firstLabel = this->primaryTilesetLabels.first();
|
||||||
logWarn(QString("Unable to find default primary tileset '%1', using '%2' instead.").arg(defaultLabel).arg(firstLabel));
|
logWarn(QString("Unable to find default primary tileset '%1', using '%2' instead.").arg(defaultLabel).arg(firstLabel));
|
||||||
|
@ -1823,7 +1823,7 @@ QString Project::getDefaultPrimaryTilesetLabel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Project::getDefaultSecondaryTilesetLabel() {
|
QString Project::getDefaultSecondaryTilesetLabel() {
|
||||||
QString defaultLabel = projectConfig.getDefaultSecondaryTileset();
|
QString defaultLabel = projectConfig.defaultSecondaryTileset;
|
||||||
if (!this->secondaryTilesetLabels.contains(defaultLabel)) {
|
if (!this->secondaryTilesetLabels.contains(defaultLabel)) {
|
||||||
QString firstLabel = this->secondaryTilesetLabels.first();
|
QString firstLabel = this->secondaryTilesetLabels.first();
|
||||||
logWarn(QString("Unable to find default secondary tileset '%1', using '%2' instead.").arg(defaultLabel).arg(firstLabel));
|
logWarn(QString("Unable to find default secondary tileset '%1', using '%2' instead.").arg(defaultLabel).arg(firstLabel));
|
||||||
|
@ -1975,9 +1975,6 @@ bool Project::readFieldmapMasks() {
|
||||||
const QStringList defineNames = defines.keys();
|
const QStringList defineNames = defines.keys();
|
||||||
this->disabledSettingsNames = QSet<QString>(defineNames.constBegin(), defineNames.constEnd());
|
this->disabledSettingsNames = QSet<QString>(defineNames.constBegin(), defineNames.constEnd());
|
||||||
|
|
||||||
// Avoid repeatedly writing the config file
|
|
||||||
projectConfig.setSaveDisabled(true);
|
|
||||||
|
|
||||||
// Read Block masks
|
// Read Block masks
|
||||||
auto readBlockMask = [defines](const QString name, uint16_t *value) {
|
auto readBlockMask = [defines](const QString name, uint16_t *value) {
|
||||||
auto it = defines.find(name);
|
auto it = defines.find(name);
|
||||||
|
@ -1992,21 +1989,22 @@ bool Project::readFieldmapMasks() {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
uint16_t blockMask;
|
uint16_t blockMask;
|
||||||
if (readBlockMask(metatileIdMaskName, &blockMask))
|
if (readBlockMask(metatileIdMaskName, &blockMask))
|
||||||
projectConfig.setBlockMetatileIdMask(blockMask);
|
projectConfig.blockMetatileIdMask = blockMask;
|
||||||
if (readBlockMask(collisionMaskName, &blockMask))
|
if (readBlockMask(collisionMaskName, &blockMask))
|
||||||
projectConfig.setBlockCollisionMask(blockMask);
|
projectConfig.blockCollisionMask = blockMask;
|
||||||
if (readBlockMask(elevationMaskName, &blockMask))
|
if (readBlockMask(elevationMaskName, &blockMask))
|
||||||
projectConfig.setBlockElevationMask(blockMask);
|
projectConfig.blockElevationMask = blockMask;
|
||||||
|
|
||||||
// Read RSE metatile attribute masks
|
// Read RSE metatile attribute masks
|
||||||
auto it = defines.find(behaviorMaskName);
|
auto it = defines.find(behaviorMaskName);
|
||||||
if (it != defines.end())
|
if (it != defines.end())
|
||||||
projectConfig.setMetatileBehaviorMask(static_cast<uint32_t>(it.value()));
|
projectConfig.metatileBehaviorMask = static_cast<uint32_t>(it.value());
|
||||||
it = defines.find(layerTypeMaskName);
|
it = defines.find(layerTypeMaskName);
|
||||||
if (it != defines.end())
|
if (it != defines.end())
|
||||||
projectConfig.setMetatileLayerTypeMask(static_cast<uint32_t>(it.value()));
|
projectConfig.metatileLayerTypeMask = static_cast<uint32_t>(it.value());
|
||||||
|
|
||||||
// pokefirered keeps its attribute masks in a separate table, parse this too.
|
// pokefirered keeps its attribute masks in a separate table, parse this too.
|
||||||
const QString attrTableName = projectConfig.getIdentifier(ProjectIdentifier::symbol_attribute_table);
|
const QString attrTableName = projectConfig.getIdentifier(ProjectIdentifier::symbol_attribute_table);
|
||||||
|
@ -2023,13 +2021,13 @@ bool Project::readFieldmapMasks() {
|
||||||
// Read terrain type mask
|
// Read terrain type mask
|
||||||
uint32_t mask = attrTable.value(terrainTypeTableName).toUInt(&ok, 0);
|
uint32_t mask = attrTable.value(terrainTypeTableName).toUInt(&ok, 0);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
projectConfig.setMetatileTerrainTypeMask(mask);
|
projectConfig.metatileTerrainTypeMask = mask;
|
||||||
this->disabledSettingsNames.insert(terrainTypeTableName);
|
this->disabledSettingsNames.insert(terrainTypeTableName);
|
||||||
}
|
}
|
||||||
// Read encounter type mask
|
// Read encounter type mask
|
||||||
mask = attrTable.value(encounterTypeTableName).toUInt(&ok, 0);
|
mask = attrTable.value(encounterTypeTableName).toUInt(&ok, 0);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
projectConfig.setMetatileEncounterTypeMask(mask);
|
projectConfig.metatileEncounterTypeMask = mask;
|
||||||
this->disabledSettingsNames.insert(encounterTypeTableName);
|
this->disabledSettingsNames.insert(encounterTypeTableName);
|
||||||
}
|
}
|
||||||
// If we haven't already parsed behavior and layer type then try those too
|
// If we haven't already parsed behavior and layer type then try those too
|
||||||
|
@ -2037,7 +2035,7 @@ bool Project::readFieldmapMasks() {
|
||||||
// Read behavior mask
|
// Read behavior mask
|
||||||
mask = attrTable.value(behaviorTableName).toUInt(&ok, 0);
|
mask = attrTable.value(behaviorTableName).toUInt(&ok, 0);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
projectConfig.setMetatileBehaviorMask(mask);
|
projectConfig.metatileBehaviorMask = mask;
|
||||||
this->disabledSettingsNames.insert(behaviorTableName);
|
this->disabledSettingsNames.insert(behaviorTableName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2045,12 +2043,11 @@ bool Project::readFieldmapMasks() {
|
||||||
// Read layer type mask
|
// Read layer type mask
|
||||||
mask = attrTable.value(layerTypeTableName).toUInt(&ok, 0);
|
mask = attrTable.value(layerTypeTableName).toUInt(&ok, 0);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
projectConfig.setMetatileLayerTypeMask(mask);
|
projectConfig.metatileLayerTypeMask = mask;
|
||||||
this->disabledSettingsNames.insert(layerTypeTableName);
|
this->disabledSettingsNames.insert(layerTypeTableName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
projectConfig.setSaveDisabled(false);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2102,7 +2099,7 @@ bool Project::readHealLocations() {
|
||||||
static const QRegularExpression re_comments("//.*?(\r\n?|\n)|/\\*.*?\\*/", QRegularExpression::DotMatchesEverythingOption);
|
static const QRegularExpression re_comments("//.*?(\r\n?|\n)|/\\*.*?\\*/", QRegularExpression::DotMatchesEverythingOption);
|
||||||
text.replace(re_comments, "");
|
text.replace(re_comments, "");
|
||||||
|
|
||||||
bool respawnEnabled = projectConfig.getHealLocationRespawnDataEnabled();
|
bool respawnEnabled = projectConfig.healLocationRespawnDataEnabled;
|
||||||
|
|
||||||
// Search for the name of the main Heal Locations table
|
// Search for the name of the main Heal Locations table
|
||||||
const QRegularExpression tableNameExpr(QString("%1\\s+(?<name>[A-Za-z0-9_]+)\\[").arg(projectConfig.getIdentifier(ProjectIdentifier::symbol_heal_locations_type)));
|
const QRegularExpression tableNameExpr(QString("%1\\s+(?<name>[A-Za-z0-9_]+)\\[").arg(projectConfig.getIdentifier(ProjectIdentifier::symbol_heal_locations_type)));
|
||||||
|
@ -2260,7 +2257,7 @@ bool Project::readWeatherNames() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Project::readCoordEventWeatherNames() {
|
bool Project::readCoordEventWeatherNames() {
|
||||||
if (!projectConfig.getEventWeatherTriggerEnabled())
|
if (!projectConfig.eventWeatherTriggerEnabled)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
const QStringList prefixes = {projectConfig.getIdentifier(ProjectIdentifier::regex_coord_event_weather)};
|
const QStringList prefixes = {projectConfig.getIdentifier(ProjectIdentifier::regex_coord_event_weather)};
|
||||||
|
@ -2273,7 +2270,7 @@ bool Project::readCoordEventWeatherNames() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Project::readSecretBaseIds() {
|
bool Project::readSecretBaseIds() {
|
||||||
if (!projectConfig.getEventSecretBaseEnabled())
|
if (!projectConfig.eventSecretBaseEnabled)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
const QStringList prefixes = {projectConfig.getIdentifier(ProjectIdentifier::regex_secret_bases)};
|
const QStringList prefixes = {projectConfig.getIdentifier(ProjectIdentifier::regex_secret_bases)};
|
||||||
|
@ -2316,7 +2313,7 @@ bool Project::readMetatileBehaviors() {
|
||||||
if (defines.isEmpty()) {
|
if (defines.isEmpty()) {
|
||||||
// Not having any metatile behavior names is ok (their values will be displayed instead).
|
// Not having any metatile behavior names is ok (their values will be displayed instead).
|
||||||
// If the user's metatiles can have nonzero values then warn them, as they likely want names.
|
// If the user's metatiles can have nonzero values then warn them, as they likely want names.
|
||||||
if (projectConfig.getMetatileBehaviorMask())
|
if (projectConfig.metatileBehaviorMask)
|
||||||
logWarn(QString("Failed to read metatile behaviors from %1.").arg(filename));
|
logWarn(QString("Failed to read metatile behaviors from %1.").arg(filename));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2357,7 +2354,7 @@ bool Project::readObjEventGfxConstants() {
|
||||||
|
|
||||||
bool Project::readMiscellaneousConstants() {
|
bool Project::readMiscellaneousConstants() {
|
||||||
miscConstants.clear();
|
miscConstants.clear();
|
||||||
if (userConfig.getEncounterJsonActive()) {
|
if (userConfig.useEncounterJson) {
|
||||||
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_pokemon);
|
const QString filename = projectConfig.getFilePath(ProjectFilePath::constants_pokemon);
|
||||||
const QString minLevelName = projectConfig.getIdentifier(ProjectIdentifier::define_min_level);
|
const QString minLevelName = projectConfig.getIdentifier(ProjectIdentifier::define_min_level);
|
||||||
const QString maxLevelName = projectConfig.getIdentifier(ProjectIdentifier::define_max_level);
|
const QString maxLevelName = projectConfig.getIdentifier(ProjectIdentifier::define_max_level);
|
||||||
|
@ -2436,9 +2433,8 @@ QStringList Project::getEventScriptsFilePaths() const {
|
||||||
QStringList filePaths(QDir::cleanPath(root + "/" + projectConfig.getFilePath(ProjectFilePath::data_event_scripts)));
|
QStringList filePaths(QDir::cleanPath(root + "/" + projectConfig.getFilePath(ProjectFilePath::data_event_scripts)));
|
||||||
const QString scriptsDir = QDir::cleanPath(root + "/" + projectConfig.getFilePath(ProjectFilePath::data_scripts_folders));
|
const QString scriptsDir = QDir::cleanPath(root + "/" + projectConfig.getFilePath(ProjectFilePath::data_scripts_folders));
|
||||||
const QString mapsDir = QDir::cleanPath(root + "/" + projectConfig.getFilePath(ProjectFilePath::data_map_folders));
|
const QString mapsDir = QDir::cleanPath(root + "/" + projectConfig.getFilePath(ProjectFilePath::data_map_folders));
|
||||||
const bool usePoryscript = projectConfig.getUsePoryScript();
|
|
||||||
|
|
||||||
if (usePoryscript) {
|
if (projectConfig.usePoryScript) {
|
||||||
QDirIterator it_pory_shared(scriptsDir, {"*.pory"}, QDir::Files);
|
QDirIterator it_pory_shared(scriptsDir, {"*.pory"}, QDir::Files);
|
||||||
while (it_pory_shared.hasNext())
|
while (it_pory_shared.hasNext())
|
||||||
filePaths << it_pory_shared.next();
|
filePaths << it_pory_shared.next();
|
||||||
|
@ -2739,7 +2735,7 @@ QString Project::getExistingFilepath(QString filepath) {
|
||||||
if (filepath.isEmpty() || QFile::exists(filepath))
|
if (filepath.isEmpty() || QFile::exists(filepath))
|
||||||
return filepath;
|
return filepath;
|
||||||
|
|
||||||
filepath = QDir::cleanPath(projectConfig.getProjectDir() + QDir::separator() + filepath);
|
filepath = QDir::cleanPath(projectConfig.projectDir + QDir::separator() + filepath);
|
||||||
if (QFile::exists(filepath))
|
if (QFile::exists(filepath))
|
||||||
return filepath;
|
return filepath;
|
||||||
|
|
||||||
|
@ -2752,25 +2748,19 @@ QString Project::getExistingFilepath(QString filepath) {
|
||||||
// can be limited by fieldmap defines)
|
// can be limited by fieldmap defines)
|
||||||
// Once we've read data from the project files we can adjust these accordingly.
|
// Once we've read data from the project files we can adjust these accordingly.
|
||||||
void Project::applyParsedLimits() {
|
void Project::applyParsedLimits() {
|
||||||
// Avoid repeatedly writing the config file
|
|
||||||
projectConfig.setSaveDisabled(true);
|
|
||||||
|
|
||||||
uint32_t maxMask = Metatile::getMaxAttributesMask();
|
uint32_t maxMask = Metatile::getMaxAttributesMask();
|
||||||
projectConfig.setMetatileBehaviorMask(projectConfig.getMetatileBehaviorMask() & maxMask);
|
projectConfig.metatileBehaviorMask &= maxMask;
|
||||||
projectConfig.setMetatileTerrainTypeMask(projectConfig.getMetatileTerrainTypeMask() & maxMask);
|
projectConfig.metatileTerrainTypeMask &= maxMask;
|
||||||
projectConfig.setMetatileEncounterTypeMask(projectConfig.getMetatileEncounterTypeMask() & maxMask);
|
projectConfig.metatileEncounterTypeMask &= maxMask;
|
||||||
projectConfig.setMetatileLayerTypeMask(projectConfig.getMetatileLayerTypeMask() & maxMask);
|
projectConfig.metatileLayerTypeMask &= maxMask;
|
||||||
|
|
||||||
Block::setLayout();
|
Block::setLayout();
|
||||||
Metatile::setLayout(this);
|
Metatile::setLayout(this);
|
||||||
|
|
||||||
Project::num_metatiles_primary = qMin(Project::num_metatiles_primary, Block::getMaxMetatileId() + 1);
|
Project::num_metatiles_primary = qMin(Project::num_metatiles_primary, Block::getMaxMetatileId() + 1);
|
||||||
projectConfig.setDefaultMetatileId(qMin(projectConfig.getDefaultMetatileId(), Block::getMaxMetatileId()));
|
projectConfig.defaultMetatileId = qMin(projectConfig.defaultMetatileId, Block::getMaxMetatileId());
|
||||||
projectConfig.setDefaultElevation(qMin(projectConfig.getDefaultElevation(), Block::getMaxElevation()));
|
projectConfig.defaultElevation = qMin(projectConfig.defaultElevation, Block::getMaxElevation());
|
||||||
projectConfig.setDefaultCollision(qMin(projectConfig.getDefaultCollision(), Block::getMaxCollision()));
|
projectConfig.defaultCollision = qMin(projectConfig.defaultCollision, Block::getMaxCollision());
|
||||||
projectConfig.setCollisionSheetHeight(qMin(projectConfig.getCollisionSheetHeight(), Block::getMaxElevation() + 1));
|
projectConfig.collisionSheetHeight = qMin(projectConfig.collisionSheetHeight, Block::getMaxElevation() + 1);
|
||||||
projectConfig.setCollisionSheetWidth(qMin(projectConfig.getCollisionSheetWidth(), Block::getMaxCollision() + 1));
|
projectConfig.collisionSheetWidth = qMin(projectConfig.collisionSheetWidth, Block::getMaxCollision() + 1);
|
||||||
|
|
||||||
projectConfig.setSaveDisabled(false);
|
|
||||||
projectConfig.save();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -295,7 +295,7 @@ int MainWindow::getBorderHeight() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setBorderDimensions(int width, int height) {
|
void MainWindow::setBorderDimensions(int width, int height) {
|
||||||
if (!this->editor || !this->editor->map || !projectConfig.getUseCustomBorderSize())
|
if (!this->editor || !this->editor->map || !projectConfig.useCustomBorderSize)
|
||||||
return;
|
return;
|
||||||
if (width < 1 || height < 1 || width > MAX_BORDER_WIDTH || height > MAX_BORDER_HEIGHT)
|
if (width < 1 || height < 1 || width > MAX_BORDER_WIDTH || height > MAX_BORDER_HEIGHT)
|
||||||
return;
|
return;
|
||||||
|
@ -305,7 +305,7 @@ void MainWindow::setBorderDimensions(int width, int height) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setBorderWidth(int width) {
|
void MainWindow::setBorderWidth(int width) {
|
||||||
if (!this->editor || !this->editor->map || !projectConfig.getUseCustomBorderSize())
|
if (!this->editor || !this->editor->map || !projectConfig.useCustomBorderSize)
|
||||||
return;
|
return;
|
||||||
if (width < 1 || width > MAX_BORDER_WIDTH)
|
if (width < 1 || width > MAX_BORDER_WIDTH)
|
||||||
return;
|
return;
|
||||||
|
@ -315,7 +315,7 @@ void MainWindow::setBorderWidth(int width) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setBorderHeight(int height) {
|
void MainWindow::setBorderHeight(int height) {
|
||||||
if (!this->editor || !this->editor->map || !projectConfig.getUseCustomBorderSize())
|
if (!this->editor || !this->editor->map || !projectConfig.useCustomBorderSize)
|
||||||
return;
|
return;
|
||||||
if (height < 1 || height > MAX_BORDER_HEIGHT)
|
if (height < 1 || height > MAX_BORDER_HEIGHT)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -15,7 +15,7 @@ void CityMapPixmapItem::init() {
|
||||||
if (!binFile.open(QIODevice::ReadOnly)) return;
|
if (!binFile.open(QIODevice::ReadOnly)) return;
|
||||||
|
|
||||||
data = binFile.readAll();
|
data = binFile.readAll();
|
||||||
if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokeruby) {
|
if (projectConfig.baseGameVersion == BaseGameVersion::pokeruby) {
|
||||||
for (int i = 0; i < data.size(); i++)
|
for (int i = 0; i < data.size(); i++)
|
||||||
data[i] = data[i] ^ 0x80;
|
data[i] = data[i] ^ 0x80;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ void CityMapPixmapItem::save() {
|
||||||
logError(QString("Cannot save city map tilemap to %1.").arg(file));
|
logError(QString("Cannot save city map tilemap to %1.").arg(file));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokeruby) {
|
if (projectConfig.baseGameVersion == BaseGameVersion::pokeruby) {
|
||||||
for (int i = 0; i < data.size(); i++)
|
for (int i = 0; i < data.size(); i++)
|
||||||
data[i] = data[i] ^ 0x80;
|
data[i] = data[i] ^ 0x80;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
CustomScriptsEditor::CustomScriptsEditor(QWidget *parent) :
|
CustomScriptsEditor::CustomScriptsEditor(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::CustomScriptsEditor),
|
ui(new Ui::CustomScriptsEditor),
|
||||||
baseDir(userConfig.getProjectDir() + QDir::separator())
|
baseDir(userConfig.projectDir + QDir::separator())
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
@ -23,7 +23,7 @@ CustomScriptsEditor::CustomScriptsEditor(QWidget *parent) :
|
||||||
for (int i = 0; i < paths.length(); i++)
|
for (int i = 0; i < paths.length(); i++)
|
||||||
this->displayScript(paths.at(i), enabled.at(i));
|
this->displayScript(paths.at(i), enabled.at(i));
|
||||||
|
|
||||||
this->fileDialogDir = userConfig.getProjectDir();
|
this->fileDialogDir = userConfig.projectDir;
|
||||||
|
|
||||||
connect(ui->button_CreateNewScript, &QAbstractButton::clicked, this, &CustomScriptsEditor::createNewScript);
|
connect(ui->button_CreateNewScript, &QAbstractButton::clicked, this, &CustomScriptsEditor::createNewScript);
|
||||||
connect(ui->button_LoadScript, &QAbstractButton::clicked, this, &CustomScriptsEditor::loadScript);
|
connect(ui->button_LoadScript, &QAbstractButton::clicked, this, &CustomScriptsEditor::loadScript);
|
||||||
|
|
|
@ -360,7 +360,7 @@ void ObjectFrame::initialize() {
|
||||||
|
|
||||||
// script
|
// script
|
||||||
this->combo_script->setCurrentText(this->object->getScript());
|
this->combo_script->setCurrentText(this->object->getScript());
|
||||||
if (porymapConfig.getTextEditorGotoLine().isEmpty())
|
if (porymapConfig.textEditorGotoLine.isEmpty())
|
||||||
this->button_script->hide();
|
this->button_script->hide();
|
||||||
|
|
||||||
// flag
|
// flag
|
||||||
|
@ -858,16 +858,16 @@ void HiddenItemFrame::initialize() {
|
||||||
this->combo_flag->setTextItem(this->hiddenItem->getFlag());
|
this->combo_flag->setTextItem(this->hiddenItem->getFlag());
|
||||||
|
|
||||||
// quantity
|
// quantity
|
||||||
if (projectConfig.getHiddenItemQuantityEnabled()) {
|
if (projectConfig.hiddenItemQuantityEnabled) {
|
||||||
this->spinner_quantity->setValue(this->hiddenItem->getQuantity());
|
this->spinner_quantity->setValue(this->hiddenItem->getQuantity());
|
||||||
}
|
}
|
||||||
this->hideable_quantity->setVisible(projectConfig.getHiddenItemQuantityEnabled());
|
this->hideable_quantity->setVisible(projectConfig.hiddenItemQuantityEnabled);
|
||||||
|
|
||||||
// underfoot
|
// underfoot
|
||||||
if (projectConfig.getHiddenItemRequiresItemfinderEnabled()) {
|
if (projectConfig.hiddenItemRequiresItemfinderEnabled) {
|
||||||
this->check_itemfinder->setChecked(this->hiddenItem->getUnderfoot());
|
this->check_itemfinder->setChecked(this->hiddenItem->getUnderfoot());
|
||||||
}
|
}
|
||||||
this->hideable_itemfinder->setVisible(projectConfig.getHiddenItemRequiresItemfinderEnabled());
|
this->hideable_itemfinder->setVisible(projectConfig.hiddenItemRequiresItemfinderEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HiddenItemFrame::populate(Project *project) {
|
void HiddenItemFrame::populate(Project *project) {
|
||||||
|
@ -971,7 +971,7 @@ void HealLocationFrame::connectSignals(MainWindow *window) {
|
||||||
|
|
||||||
EventFrame::connectSignals(window);
|
EventFrame::connectSignals(window);
|
||||||
|
|
||||||
if (projectConfig.getHealLocationRespawnDataEnabled()) {
|
if (projectConfig.healLocationRespawnDataEnabled) {
|
||||||
this->combo_respawn_map->disconnect();
|
this->combo_respawn_map->disconnect();
|
||||||
connect(this->combo_respawn_map, &QComboBox::currentTextChanged, [this](const QString &text) {
|
connect(this->combo_respawn_map, &QComboBox::currentTextChanged, [this](const QString &text) {
|
||||||
this->healLocation->setRespawnMap(text);
|
this->healLocation->setRespawnMap(text);
|
||||||
|
@ -992,7 +992,7 @@ void HealLocationFrame::initialize() {
|
||||||
const QSignalBlocker blocker(this);
|
const QSignalBlocker blocker(this);
|
||||||
EventFrame::initialize();
|
EventFrame::initialize();
|
||||||
|
|
||||||
bool respawnEnabled = projectConfig.getHealLocationRespawnDataEnabled();
|
bool respawnEnabled = projectConfig.healLocationRespawnDataEnabled;
|
||||||
if (respawnEnabled) {
|
if (respawnEnabled) {
|
||||||
this->combo_respawn_map->setTextItem(this->healLocation->getRespawnMap());
|
this->combo_respawn_map->setTextItem(this->healLocation->getRespawnMap());
|
||||||
this->spinner_respawn_npc->setValue(this->healLocation->getRespawnNPC());
|
this->spinner_respawn_npc->setValue(this->healLocation->getRespawnNPC());
|
||||||
|
@ -1008,6 +1008,6 @@ void HealLocationFrame::populate(Project *project) {
|
||||||
const QSignalBlocker blocker(this);
|
const QSignalBlocker blocker(this);
|
||||||
EventFrame::populate(project);
|
EventFrame::populate(project);
|
||||||
|
|
||||||
if (projectConfig.getHealLocationRespawnDataEnabled())
|
if (projectConfig.healLocationRespawnDataEnabled)
|
||||||
this->combo_respawn_map->addItems(project->mapNames);
|
this->combo_respawn_map->addItems(project->mapNames);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,6 @@ QImage getMetatileImage(
|
||||||
QList<QList<QRgb>> palettes = Tileset::getBlockPalettes(primaryTileset, secondaryTileset, useTruePalettes);
|
QList<QList<QRgb>> palettes = Tileset::getBlockPalettes(primaryTileset, secondaryTileset, useTruePalettes);
|
||||||
|
|
||||||
QPainter metatile_painter(&metatile_image);
|
QPainter metatile_painter(&metatile_image);
|
||||||
bool isTripleLayerMetatile = projectConfig.getTripleLayerMetatilesEnabled();
|
|
||||||
const int numLayers = 3; // When rendering, metatiles always have 3 layers
|
const int numLayers = 3; // When rendering, metatiles always have 3 layers
|
||||||
uint32_t layerType = metatile->layerType();
|
uint32_t layerType = metatile->layerType();
|
||||||
for (int layer = 0; layer < numLayers; layer++)
|
for (int layer = 0; layer < numLayers; layer++)
|
||||||
|
@ -60,7 +59,7 @@ QImage getMetatileImage(
|
||||||
// Get the tile to render next
|
// Get the tile to render next
|
||||||
Tile tile;
|
Tile tile;
|
||||||
int tileOffset = (y * 2) + x;
|
int tileOffset = (y * 2) + x;
|
||||||
if (isTripleLayerMetatile) {
|
if (projectConfig.tripleLayerMetatilesEnabled) {
|
||||||
tile = metatile->tiles.value(tileOffset + (l * 4));
|
tile = metatile->tiles.value(tileOffset + (l * 4));
|
||||||
} else {
|
} else {
|
||||||
// "Vanilla" metatiles only have 8 tiles, but render 12.
|
// "Vanilla" metatiles only have 8 tiles, but render 12.
|
||||||
|
|
|
@ -49,7 +49,7 @@ void NewMapPopup::init() {
|
||||||
ui->spinBox_NewMap_Floor_Number->setMaximum(127);
|
ui->spinBox_NewMap_Floor_Number->setMaximum(127);
|
||||||
|
|
||||||
// Hide config specific ui elements
|
// Hide config specific ui elements
|
||||||
bool hasFlags = projectConfig.getMapAllowFlagsEnabled();
|
bool hasFlags = projectConfig.mapAllowFlagsEnabled;
|
||||||
ui->checkBox_NewMap_Allow_Running->setVisible(hasFlags);
|
ui->checkBox_NewMap_Allow_Running->setVisible(hasFlags);
|
||||||
ui->checkBox_NewMap_Allow_Biking->setVisible(hasFlags);
|
ui->checkBox_NewMap_Allow_Biking->setVisible(hasFlags);
|
||||||
ui->checkBox_NewMap_Allow_Escape_Rope->setVisible(hasFlags);
|
ui->checkBox_NewMap_Allow_Escape_Rope->setVisible(hasFlags);
|
||||||
|
@ -57,13 +57,13 @@ void NewMapPopup::init() {
|
||||||
ui->label_NewMap_Allow_Biking->setVisible(hasFlags);
|
ui->label_NewMap_Allow_Biking->setVisible(hasFlags);
|
||||||
ui->label_NewMap_Allow_Escape_Rope->setVisible(hasFlags);
|
ui->label_NewMap_Allow_Escape_Rope->setVisible(hasFlags);
|
||||||
|
|
||||||
bool hasCustomBorders = projectConfig.getUseCustomBorderSize();
|
bool hasCustomBorders = projectConfig.useCustomBorderSize;
|
||||||
ui->spinBox_NewMap_BorderWidth->setVisible(hasCustomBorders);
|
ui->spinBox_NewMap_BorderWidth->setVisible(hasCustomBorders);
|
||||||
ui->spinBox_NewMap_BorderHeight->setVisible(hasCustomBorders);
|
ui->spinBox_NewMap_BorderHeight->setVisible(hasCustomBorders);
|
||||||
ui->label_NewMap_BorderWidth->setVisible(hasCustomBorders);
|
ui->label_NewMap_BorderWidth->setVisible(hasCustomBorders);
|
||||||
ui->label_NewMap_BorderHeight->setVisible(hasCustomBorders);
|
ui->label_NewMap_BorderHeight->setVisible(hasCustomBorders);
|
||||||
|
|
||||||
bool hasFloorNumber = projectConfig.getFloorNumberEnabled();
|
bool hasFloorNumber = projectConfig.floorNumberEnabled;
|
||||||
ui->spinBox_NewMap_Floor_Number->setVisible(hasFloorNumber);
|
ui->spinBox_NewMap_Floor_Number->setVisible(hasFloorNumber);
|
||||||
ui->label_NewMap_Floor_Number->setVisible(hasFloorNumber);
|
ui->label_NewMap_Floor_Number->setVisible(hasFloorNumber);
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ void NewMapPopup::on_pushButton_NewMap_Accept_clicked() {
|
||||||
layout->name = QString("%1_Layout").arg(newMap->name);
|
layout->name = QString("%1_Layout").arg(newMap->name);
|
||||||
layout->width = this->ui->spinBox_NewMap_Width->value();
|
layout->width = this->ui->spinBox_NewMap_Width->value();
|
||||||
layout->height = this->ui->spinBox_NewMap_Height->value();
|
layout->height = this->ui->spinBox_NewMap_Height->value();
|
||||||
if (projectConfig.getUseCustomBorderSize()) {
|
if (projectConfig.useCustomBorderSize) {
|
||||||
layout->border_width = this->ui->spinBox_NewMap_BorderWidth->value();
|
layout->border_width = this->ui->spinBox_NewMap_BorderWidth->value();
|
||||||
layout->border_height = this->ui->spinBox_NewMap_BorderHeight->value();
|
layout->border_height = this->ui->spinBox_NewMap_BorderHeight->value();
|
||||||
} else {
|
} else {
|
||||||
|
@ -296,12 +296,12 @@ void NewMapPopup::on_pushButton_NewMap_Accept_clicked() {
|
||||||
newMap->needsHealLocation = true;
|
newMap->needsHealLocation = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (projectConfig.getMapAllowFlagsEnabled()) {
|
if (projectConfig.mapAllowFlagsEnabled) {
|
||||||
newMap->allowRunning = this->ui->checkBox_NewMap_Allow_Running->isChecked();
|
newMap->allowRunning = this->ui->checkBox_NewMap_Allow_Running->isChecked();
|
||||||
newMap->allowBiking = this->ui->checkBox_NewMap_Allow_Biking->isChecked();
|
newMap->allowBiking = this->ui->checkBox_NewMap_Allow_Biking->isChecked();
|
||||||
newMap->allowEscaping = this->ui->checkBox_NewMap_Allow_Escape_Rope->isChecked();
|
newMap->allowEscaping = this->ui->checkBox_NewMap_Allow_Escape_Rope->isChecked();
|
||||||
}
|
}
|
||||||
if (projectConfig.getFloorNumberEnabled()) {
|
if (projectConfig.floorNumberEnabled) {
|
||||||
newMap->floorNumber = this->ui->spinBox_NewMap_Floor_Number->value();
|
newMap->floorNumber = this->ui->spinBox_NewMap_Floor_Number->value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ NewTilesetDialog::NewTilesetDialog(Project* project, QWidget *parent) :
|
||||||
QRegularExpressionValidator *validator = new QRegularExpressionValidator(expression);
|
QRegularExpressionValidator *validator = new QRegularExpressionValidator(expression);
|
||||||
this->ui->nameLineEdit->setValidator(validator);
|
this->ui->nameLineEdit->setValidator(validator);
|
||||||
|
|
||||||
bool checkerboard = porymapConfig.getTilesetCheckerboardFill();
|
bool checkerboard = porymapConfig.tilesetCheckerboardFill;
|
||||||
this->ui->fillCheckBox->setChecked(checkerboard);
|
this->ui->fillCheckBox->setChecked(checkerboard);
|
||||||
this->checkerboardFill = checkerboard;
|
this->checkerboardFill = checkerboard;
|
||||||
|
|
||||||
|
@ -46,5 +46,5 @@ void NewTilesetDialog::NameOrSecondaryChanged() {
|
||||||
|
|
||||||
void NewTilesetDialog::FillChanged() {
|
void NewTilesetDialog::FillChanged() {
|
||||||
this->checkerboardFill = this->ui->fillCheckBox->isChecked();
|
this->checkerboardFill = this->ui->fillCheckBox->isChecked();
|
||||||
porymapConfig.setTilesetCheckerboardFill(this->checkerboardFill);
|
porymapConfig.tilesetCheckerboardFill = this->checkerboardFill;
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ PaletteEditor::PaletteEditor(Project *project, Tileset *primaryTileset, Tileset
|
||||||
connect(this->pickButtons[i], &QToolButton::clicked, [this, i](){ this->pickColor(i); });
|
connect(this->pickButtons[i], &QToolButton::clicked, [this, i](){ this->pickColor(i); });
|
||||||
}
|
}
|
||||||
|
|
||||||
int bitDepth = porymapConfig.getPaletteEditorBitDepth();
|
int bitDepth = porymapConfig.paletteEditorBitDepth;
|
||||||
if (bitDepth == 15) {
|
if (bitDepth == 15) {
|
||||||
this->ui->bit_depth_15->setChecked(true);
|
this->ui->bit_depth_15->setChecked(true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -233,7 +233,7 @@ void PaletteEditor::setBitDepth(int bits) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this->bitDepth = bits;
|
this->bitDepth = bits;
|
||||||
porymapConfig.setPaletteEditorBitDepth(bits);
|
porymapConfig.paletteEditorBitDepth = bits;
|
||||||
refreshColorUis();
|
refreshColorUis();
|
||||||
setSignalsEnabled(true);
|
setSignalsEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ const QString defaultFilepath = "prefabs.json";
|
||||||
|
|
||||||
void Prefab::loadPrefabs() {
|
void Prefab::loadPrefabs() {
|
||||||
this->items.clear();
|
this->items.clear();
|
||||||
QString filepath = projectConfig.getPrefabFilepath();
|
QString filepath = projectConfig.prefabFilepath;
|
||||||
if (filepath.isEmpty()) return;
|
if (filepath.isEmpty()) return;
|
||||||
|
|
||||||
ParseUtil parser;
|
ParseUtil parser;
|
||||||
|
@ -86,15 +86,14 @@ void Prefab::loadPrefabs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Prefab::savePrefabs() {
|
void Prefab::savePrefabs() {
|
||||||
QString filepath = projectConfig.getPrefabFilepath();
|
if (projectConfig.prefabFilepath.isEmpty())
|
||||||
if (filepath.isEmpty()) {
|
projectConfig.prefabFilepath = defaultFilepath;
|
||||||
filepath = defaultFilepath;
|
|
||||||
projectConfig.setPrefabFilepath(filepath);
|
QString filepath = projectConfig.prefabFilepath;
|
||||||
}
|
|
||||||
|
|
||||||
QFileInfo info(filepath);
|
QFileInfo info(filepath);
|
||||||
if (info.isRelative()) {
|
if (info.isRelative()) {
|
||||||
filepath = QDir::cleanPath(projectConfig.getProjectDir() + QDir::separator() + filepath);
|
filepath = QDir::cleanPath(projectConfig.projectDir + QDir::separator() + filepath);
|
||||||
}
|
}
|
||||||
QFile prefabsFile(filepath);
|
QFile prefabsFile(filepath);
|
||||||
if (!prefabsFile.open(QIODevice::WriteOnly)) {
|
if (!prefabsFile.open(QIODevice::WriteOnly)) {
|
||||||
|
@ -287,7 +286,7 @@ bool Prefab::tryImportDefaultPrefabs(QWidget * parent, BaseGameVersion version,
|
||||||
if (fileInfo.suffix().isEmpty())
|
if (fileInfo.suffix().isEmpty())
|
||||||
filepath += ".json";
|
filepath += ".json";
|
||||||
if (fileInfo.isRelative()) {
|
if (fileInfo.isRelative()) {
|
||||||
absFilepath = QDir::cleanPath(projectConfig.getProjectDir() + QDir::separator() + filepath);
|
absFilepath = QDir::cleanPath(projectConfig.projectDir + QDir::separator() + filepath);
|
||||||
} else {
|
} else {
|
||||||
absFilepath = filepath;
|
absFilepath = filepath;
|
||||||
}
|
}
|
||||||
|
@ -313,10 +312,10 @@ bool Prefab::tryImportDefaultPrefabs(QWidget * parent, BaseGameVersion version,
|
||||||
bool acceptedImport = (prompt == QMessageBox::Yes);
|
bool acceptedImport = (prompt == QMessageBox::Yes);
|
||||||
if (acceptedImport) {
|
if (acceptedImport) {
|
||||||
// Sets up the default prefabs.json filepath.
|
// Sets up the default prefabs.json filepath.
|
||||||
projectConfig.setPrefabFilepath(filepath);
|
projectConfig.prefabFilepath = filepath;
|
||||||
QFile prefabsFile(absFilepath);
|
QFile prefabsFile(absFilepath);
|
||||||
if (!prefabsFile.open(QIODevice::WriteOnly)) {
|
if (!prefabsFile.open(QIODevice::WriteOnly)) {
|
||||||
projectConfig.setPrefabFilepath(QString());
|
projectConfig.prefabFilepath = QString();
|
||||||
|
|
||||||
logError(QString("Error: Could not open %1 for writing").arg(absFilepath));
|
logError(QString("Error: Could not open %1 for writing").arg(absFilepath));
|
||||||
QMessageBox messageBox(parent);
|
QMessageBox messageBox(parent);
|
||||||
|
@ -346,7 +345,7 @@ bool Prefab::tryImportDefaultPrefabs(QWidget * parent, BaseGameVersion version,
|
||||||
this->loadPrefabs();
|
this->loadPrefabs();
|
||||||
}
|
}
|
||||||
|
|
||||||
projectConfig.setPrefabImportPrompted(true);
|
projectConfig.prefabImportPrompted = true;
|
||||||
return acceptedImport;
|
return acceptedImport;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,28 +44,26 @@ void PreferenceEditor::initFields() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferenceEditor::updateFields() {
|
void PreferenceEditor::updateFields() {
|
||||||
themeSelector->setCurrentText(porymapConfig.getTheme());
|
themeSelector->setCurrentText(porymapConfig.theme);
|
||||||
ui->lineEdit_TextEditorOpenFolder->setText(porymapConfig.getTextEditorOpenFolder());
|
ui->lineEdit_TextEditorOpenFolder->setText(porymapConfig.textEditorOpenFolder);
|
||||||
ui->lineEdit_TextEditorGotoLine->setText(porymapConfig.getTextEditorGotoLine());
|
ui->lineEdit_TextEditorGotoLine->setText(porymapConfig.textEditorGotoLine);
|
||||||
ui->checkBox_MonitorProjectFiles->setChecked(porymapConfig.getMonitorFiles());
|
ui->checkBox_MonitorProjectFiles->setChecked(porymapConfig.monitorFiles);
|
||||||
ui->checkBox_OpenRecentProject->setChecked(porymapConfig.getReopenOnLaunch());
|
ui->checkBox_OpenRecentProject->setChecked(porymapConfig.reopenOnLaunch);
|
||||||
ui->checkBox_CheckForUpdates->setChecked(porymapConfig.getCheckForUpdates());
|
ui->checkBox_CheckForUpdates->setChecked(porymapConfig.checkForUpdates);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreferenceEditor::saveFields() {
|
void PreferenceEditor::saveFields() {
|
||||||
if (themeSelector->currentText() != porymapConfig.getTheme()) {
|
if (themeSelector->currentText() != porymapConfig.theme) {
|
||||||
const auto theme = themeSelector->currentText();
|
const auto theme = themeSelector->currentText();
|
||||||
porymapConfig.setTheme(theme);
|
porymapConfig.theme = theme;
|
||||||
emit themeChanged(theme);
|
emit themeChanged(theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
porymapConfig.setSaveDisabled(true);
|
porymapConfig.textEditorOpenFolder = ui->lineEdit_TextEditorOpenFolder->text();
|
||||||
porymapConfig.setTextEditorOpenFolder(ui->lineEdit_TextEditorOpenFolder->text());
|
porymapConfig.textEditorGotoLine = ui->lineEdit_TextEditorGotoLine->text();
|
||||||
porymapConfig.setTextEditorGotoLine(ui->lineEdit_TextEditorGotoLine->text());
|
porymapConfig.monitorFiles = ui->checkBox_MonitorProjectFiles->isChecked();
|
||||||
porymapConfig.setMonitorFiles(ui->checkBox_MonitorProjectFiles->isChecked());
|
porymapConfig.reopenOnLaunch = ui->checkBox_OpenRecentProject->isChecked();
|
||||||
porymapConfig.setReopenOnLaunch(ui->checkBox_OpenRecentProject->isChecked());
|
porymapConfig.checkForUpdates = ui->checkBox_CheckForUpdates->isChecked();
|
||||||
porymapConfig.setCheckForUpdates(ui->checkBox_CheckForUpdates->isChecked());
|
|
||||||
porymapConfig.setSaveDisabled(false);
|
|
||||||
porymapConfig.save();
|
porymapConfig.save();
|
||||||
|
|
||||||
emit preferencesSaved();
|
emit preferencesSaved();
|
||||||
|
|
|
@ -18,7 +18,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(QWidget *parent, Project *project)
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::ProjectSettingsEditor),
|
ui(new Ui::ProjectSettingsEditor),
|
||||||
project(project),
|
project(project),
|
||||||
baseDir(userConfig.getProjectDir() + QDir::separator())
|
baseDir(projectConfig.projectDir + QDir::separator())
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
@ -109,7 +109,7 @@ void ProjectSettingsEditor::initUi() {
|
||||||
static const QRegularExpression expression_HexList(QString("^(%1,)*%1$").arg(regex_Hex)); // Comma-separated list of hex values
|
static const QRegularExpression expression_HexList(QString("^(%1,)*%1$").arg(regex_Hex)); // Comma-separated list of hex values
|
||||||
QRegularExpressionValidator *validator_HexList = new QRegularExpressionValidator(expression_HexList);
|
QRegularExpressionValidator *validator_HexList = new QRegularExpressionValidator(expression_HexList);
|
||||||
ui->lineEdit_BorderMetatiles->setValidator(validator_HexList);
|
ui->lineEdit_BorderMetatiles->setValidator(validator_HexList);
|
||||||
this->setBorderMetatilesUi(projectConfig.getUseCustomBorderSize());
|
this->setBorderMetatilesUi(projectConfig.useCustomBorderSize);
|
||||||
|
|
||||||
// Validate that the text added to the warp behavior list could be a valid define
|
// Validate that the text added to the warp behavior list could be a valid define
|
||||||
// (we don't care whether it actually is a metatile behavior define)
|
// (we don't care whether it actually is a metatile behavior define)
|
||||||
|
@ -184,12 +184,12 @@ void ProjectSettingsEditor::disableParsedSetting(QWidget * widget, const QString
|
||||||
|
|
||||||
// Remember the current settings tab for future sessions
|
// Remember the current settings tab for future sessions
|
||||||
void ProjectSettingsEditor::on_mainTabs_tabBarClicked(int index) {
|
void ProjectSettingsEditor::on_mainTabs_tabBarClicked(int index) {
|
||||||
porymapConfig.setProjectSettingsTab(index);
|
porymapConfig.projectSettingsTab = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectSettingsEditor::setTab(int index) {
|
void ProjectSettingsEditor::setTab(int index) {
|
||||||
ui->mainTabs->setCurrentIndex(index);
|
ui->mainTabs->setCurrentIndex(index);
|
||||||
porymapConfig.setProjectSettingsTab(index);
|
porymapConfig.projectSettingsTab = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectSettingsEditor::setBorderMetatilesUi(bool customSize) {
|
void ProjectSettingsEditor::setBorderMetatilesUi(bool customSize) {
|
||||||
|
@ -424,10 +424,10 @@ void ProjectSettingsEditor::refresh() {
|
||||||
this->refreshing = true; // Block signals
|
this->refreshing = true; // Block signals
|
||||||
|
|
||||||
// Set combo box texts
|
// Set combo box texts
|
||||||
ui->comboBox_DefaultPrimaryTileset->setTextItem(projectConfig.getDefaultPrimaryTileset());
|
ui->comboBox_DefaultPrimaryTileset->setTextItem(projectConfig.defaultPrimaryTileset);
|
||||||
ui->comboBox_DefaultSecondaryTileset->setTextItem(projectConfig.getDefaultSecondaryTileset());
|
ui->comboBox_DefaultSecondaryTileset->setTextItem(projectConfig.defaultSecondaryTileset);
|
||||||
ui->comboBox_BaseGameVersion->setTextItem(projectConfig.getBaseGameVersionString());
|
ui->comboBox_BaseGameVersion->setTextItem(projectConfig.getBaseGameVersionString());
|
||||||
ui->comboBox_AttributesSize->setTextItem(QString::number(projectConfig.getMetatileAttributesSize()));
|
ui->comboBox_AttributesSize->setTextItem(QString::number(projectConfig.metatileAttributesSize));
|
||||||
this->updateAttributeLimits(ui->comboBox_AttributesSize->currentText());
|
this->updateAttributeLimits(ui->comboBox_AttributesSize->currentText());
|
||||||
|
|
||||||
this->prevIconSpecies = QString();
|
this->prevIconSpecies = QString();
|
||||||
|
@ -435,45 +435,44 @@ void ProjectSettingsEditor::refresh() {
|
||||||
this->updatePokemonIconPath(ui->comboBox_IconSpecies->currentText());
|
this->updatePokemonIconPath(ui->comboBox_IconSpecies->currentText());
|
||||||
|
|
||||||
// Set check box states
|
// Set check box states
|
||||||
ui->checkBox_UsePoryscript->setChecked(projectConfig.getUsePoryScript());
|
ui->checkBox_UsePoryscript->setChecked(projectConfig.usePoryScript);
|
||||||
ui->checkBox_ShowWildEncounterTables->setChecked(userConfig.getEncounterJsonActive());
|
ui->checkBox_ShowWildEncounterTables->setChecked(userConfig.useEncounterJson);
|
||||||
ui->checkBox_CreateTextFile->setChecked(projectConfig.getCreateMapTextFileEnabled());
|
ui->checkBox_CreateTextFile->setChecked(projectConfig.createMapTextFileEnabled);
|
||||||
ui->checkBox_EnableTripleLayerMetatiles->setChecked(projectConfig.getTripleLayerMetatilesEnabled());
|
ui->checkBox_EnableTripleLayerMetatiles->setChecked(projectConfig.tripleLayerMetatilesEnabled);
|
||||||
ui->checkBox_EnableRequiresItemfinder->setChecked(projectConfig.getHiddenItemRequiresItemfinderEnabled());
|
ui->checkBox_EnableRequiresItemfinder->setChecked(projectConfig.hiddenItemRequiresItemfinderEnabled);
|
||||||
ui->checkBox_EnableQuantity->setChecked(projectConfig.getHiddenItemQuantityEnabled());
|
ui->checkBox_EnableQuantity->setChecked(projectConfig.hiddenItemQuantityEnabled);
|
||||||
ui->checkBox_EnableCloneObjects->setChecked(projectConfig.getEventCloneObjectEnabled());
|
ui->checkBox_EnableCloneObjects->setChecked(projectConfig.eventCloneObjectEnabled);
|
||||||
ui->checkBox_EnableWeatherTriggers->setChecked(projectConfig.getEventWeatherTriggerEnabled());
|
ui->checkBox_EnableWeatherTriggers->setChecked(projectConfig.eventWeatherTriggerEnabled);
|
||||||
ui->checkBox_EnableSecretBases->setChecked(projectConfig.getEventSecretBaseEnabled());
|
ui->checkBox_EnableSecretBases->setChecked(projectConfig.eventSecretBaseEnabled);
|
||||||
ui->checkBox_EnableRespawn->setChecked(projectConfig.getHealLocationRespawnDataEnabled());
|
ui->checkBox_EnableRespawn->setChecked(projectConfig.healLocationRespawnDataEnabled);
|
||||||
ui->checkBox_EnableAllowFlags->setChecked(projectConfig.getMapAllowFlagsEnabled());
|
ui->checkBox_EnableAllowFlags->setChecked(projectConfig.mapAllowFlagsEnabled);
|
||||||
ui->checkBox_EnableFloorNumber->setChecked(projectConfig.getFloorNumberEnabled());
|
ui->checkBox_EnableFloorNumber->setChecked(projectConfig.floorNumberEnabled);
|
||||||
ui->checkBox_EnableCustomBorderSize->setChecked(projectConfig.getUseCustomBorderSize());
|
ui->checkBox_EnableCustomBorderSize->setChecked(projectConfig.useCustomBorderSize);
|
||||||
ui->checkBox_OutputCallback->setChecked(projectConfig.getTilesetsHaveCallback());
|
ui->checkBox_OutputCallback->setChecked(projectConfig.tilesetsHaveCallback);
|
||||||
ui->checkBox_OutputIsCompressed->setChecked(projectConfig.getTilesetsHaveIsCompressed());
|
ui->checkBox_OutputIsCompressed->setChecked(projectConfig.tilesetsHaveIsCompressed);
|
||||||
ui->checkBox_DisableWarning->setChecked(porymapConfig.getWarpBehaviorWarningDisabled());
|
ui->checkBox_DisableWarning->setChecked(porymapConfig.warpBehaviorWarningDisabled);
|
||||||
|
|
||||||
// Set spin box values
|
// Set spin box values
|
||||||
ui->spinBox_Elevation->setValue(projectConfig.getDefaultElevation());
|
ui->spinBox_Elevation->setValue(projectConfig.defaultElevation);
|
||||||
ui->spinBox_Collision->setValue(projectConfig.getDefaultCollision());
|
ui->spinBox_Collision->setValue(projectConfig.defaultCollision);
|
||||||
ui->spinBox_FillMetatile->setValue(projectConfig.getDefaultMetatileId());
|
ui->spinBox_FillMetatile->setValue(projectConfig.defaultMetatileId);
|
||||||
ui->spinBox_MaxElevation->setValue(projectConfig.getCollisionSheetHeight() - 1);
|
ui->spinBox_MaxElevation->setValue(projectConfig.collisionSheetHeight - 1);
|
||||||
ui->spinBox_MaxCollision->setValue(projectConfig.getCollisionSheetWidth() - 1);
|
ui->spinBox_MaxCollision->setValue(projectConfig.collisionSheetWidth - 1);
|
||||||
ui->spinBox_BehaviorMask->setValue(projectConfig.getMetatileBehaviorMask() & ui->spinBox_BehaviorMask->maximum());
|
ui->spinBox_BehaviorMask->setValue(projectConfig.metatileBehaviorMask & ui->spinBox_BehaviorMask->maximum());
|
||||||
ui->spinBox_EncounterTypeMask->setValue(projectConfig.getMetatileEncounterTypeMask() & ui->spinBox_EncounterTypeMask->maximum());
|
ui->spinBox_EncounterTypeMask->setValue(projectConfig.metatileEncounterTypeMask & ui->spinBox_EncounterTypeMask->maximum());
|
||||||
ui->spinBox_LayerTypeMask->setValue(projectConfig.getMetatileLayerTypeMask() & ui->spinBox_LayerTypeMask->maximum());
|
ui->spinBox_LayerTypeMask->setValue(projectConfig.metatileLayerTypeMask & ui->spinBox_LayerTypeMask->maximum());
|
||||||
ui->spinBox_TerrainTypeMask->setValue(projectConfig.getMetatileTerrainTypeMask() & ui->spinBox_TerrainTypeMask->maximum());
|
ui->spinBox_TerrainTypeMask->setValue(projectConfig.metatileTerrainTypeMask & ui->spinBox_TerrainTypeMask->maximum());
|
||||||
ui->spinBox_MetatileIdMask->setValue(projectConfig.getBlockMetatileIdMask() & ui->spinBox_MetatileIdMask->maximum());
|
ui->spinBox_MetatileIdMask->setValue(projectConfig.blockMetatileIdMask & ui->spinBox_MetatileIdMask->maximum());
|
||||||
ui->spinBox_CollisionMask->setValue(projectConfig.getBlockCollisionMask() & ui->spinBox_CollisionMask->maximum());
|
ui->spinBox_CollisionMask->setValue(projectConfig.blockCollisionMask & ui->spinBox_CollisionMask->maximum());
|
||||||
ui->spinBox_ElevationMask->setValue(projectConfig.getBlockElevationMask() & ui->spinBox_ElevationMask->maximum());
|
ui->spinBox_ElevationMask->setValue(projectConfig.blockElevationMask & ui->spinBox_ElevationMask->maximum());
|
||||||
|
|
||||||
// Set (and sync) border metatile IDs
|
// Set (and sync) border metatile IDs
|
||||||
auto metatileIds = projectConfig.getNewMapBorderMetatileIds();
|
this->setBorderMetatileIds(false, projectConfig.newMapBorderMetatileIds);
|
||||||
this->setBorderMetatileIds(false, metatileIds);
|
this->setBorderMetatileIds(true, projectConfig.newMapBorderMetatileIds);
|
||||||
this->setBorderMetatileIds(true, metatileIds);
|
|
||||||
|
|
||||||
// Set line edit texts
|
// Set line edit texts
|
||||||
ui->lineEdit_PrefabsPath->setText(projectConfig.getPrefabFilepath());
|
ui->lineEdit_PrefabsPath->setText(projectConfig.prefabFilepath);
|
||||||
ui->lineEdit_CollisionGraphics->setText(projectConfig.getCollisionSheetPath());
|
ui->lineEdit_CollisionGraphics->setText(projectConfig.collisionSheetPath);
|
||||||
ui->lineEdit_ObjectsIcon->setText(projectConfig.getEventIconPath(Event::Group::Object));
|
ui->lineEdit_ObjectsIcon->setText(projectConfig.getEventIconPath(Event::Group::Object));
|
||||||
ui->lineEdit_WarpsIcon->setText(projectConfig.getEventIconPath(Event::Group::Warp));
|
ui->lineEdit_WarpsIcon->setText(projectConfig.getEventIconPath(Event::Group::Warp));
|
||||||
ui->lineEdit_TriggersIcon->setText(projectConfig.getEventIconPath(Event::Group::Coord));
|
ui->lineEdit_TriggersIcon->setText(projectConfig.getEventIconPath(Event::Group::Coord));
|
||||||
|
@ -485,9 +484,8 @@ void ProjectSettingsEditor::refresh() {
|
||||||
lineEdit->setText(projectConfig.getCustomIdentifier(lineEdit->objectName()));
|
lineEdit->setText(projectConfig.getCustomIdentifier(lineEdit->objectName()));
|
||||||
|
|
||||||
// Set warp behaviors
|
// Set warp behaviors
|
||||||
auto behaviorValues = projectConfig.getWarpBehaviors();
|
|
||||||
QStringList behaviorNames;
|
QStringList behaviorNames;
|
||||||
for (auto value : behaviorValues) {
|
for (auto value : projectConfig.warpBehaviors) {
|
||||||
if (project->metatileBehaviorMapInverse.contains(value))
|
if (project->metatileBehaviorMapInverse.contains(value))
|
||||||
behaviorNames.append(project->metatileBehaviorMapInverse.value(value));
|
behaviorNames.append(project->metatileBehaviorMapInverse.value(value));
|
||||||
}
|
}
|
||||||
|
@ -500,50 +498,47 @@ void ProjectSettingsEditor::save() {
|
||||||
if (!this->hasUnsavedChanges)
|
if (!this->hasUnsavedChanges)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Prevent a call to save() for each of the config settings
|
|
||||||
projectConfig.setSaveDisabled(true);
|
|
||||||
|
|
||||||
// Save combo box settings
|
// Save combo box settings
|
||||||
projectConfig.setDefaultPrimaryTileset(ui->comboBox_DefaultPrimaryTileset->currentText());
|
projectConfig.defaultPrimaryTileset = ui->comboBox_DefaultPrimaryTileset->currentText();
|
||||||
projectConfig.setDefaultSecondaryTileset(ui->comboBox_DefaultSecondaryTileset->currentText());
|
projectConfig.defaultSecondaryTileset = ui->comboBox_DefaultSecondaryTileset->currentText();
|
||||||
projectConfig.setBaseGameVersion(projectConfig.stringToBaseGameVersion(ui->comboBox_BaseGameVersion->currentText()));
|
projectConfig.baseGameVersion = projectConfig.stringToBaseGameVersion(ui->comboBox_BaseGameVersion->currentText());
|
||||||
projectConfig.setMetatileAttributesSize(ui->comboBox_AttributesSize->currentText().toInt());
|
projectConfig.metatileAttributesSize = ui->comboBox_AttributesSize->currentText().toInt();
|
||||||
|
|
||||||
// Save check box settings
|
// Save check box settings
|
||||||
projectConfig.setUsePoryScript(ui->checkBox_UsePoryscript->isChecked());
|
projectConfig.usePoryScript = ui->checkBox_UsePoryscript->isChecked();
|
||||||
userConfig.setEncounterJsonActive(ui->checkBox_ShowWildEncounterTables->isChecked());
|
userConfig.useEncounterJson = ui->checkBox_ShowWildEncounterTables->isChecked();
|
||||||
projectConfig.setCreateMapTextFileEnabled(ui->checkBox_CreateTextFile->isChecked());
|
projectConfig.createMapTextFileEnabled = ui->checkBox_CreateTextFile->isChecked();
|
||||||
projectConfig.setTripleLayerMetatilesEnabled(ui->checkBox_EnableTripleLayerMetatiles->isChecked());
|
projectConfig.tripleLayerMetatilesEnabled = ui->checkBox_EnableTripleLayerMetatiles->isChecked();
|
||||||
projectConfig.setHiddenItemRequiresItemfinderEnabled(ui->checkBox_EnableRequiresItemfinder->isChecked());
|
projectConfig.hiddenItemRequiresItemfinderEnabled = ui->checkBox_EnableRequiresItemfinder->isChecked();
|
||||||
projectConfig.setHiddenItemQuantityEnabled(ui->checkBox_EnableQuantity->isChecked());
|
projectConfig.hiddenItemQuantityEnabled = ui->checkBox_EnableQuantity->isChecked();
|
||||||
projectConfig.setEventCloneObjectEnabled(ui->checkBox_EnableCloneObjects->isChecked());
|
projectConfig.eventCloneObjectEnabled = ui->checkBox_EnableCloneObjects->isChecked();
|
||||||
projectConfig.setEventWeatherTriggerEnabled(ui->checkBox_EnableWeatherTriggers->isChecked());
|
projectConfig.eventWeatherTriggerEnabled = ui->checkBox_EnableWeatherTriggers->isChecked();
|
||||||
projectConfig.setEventSecretBaseEnabled(ui->checkBox_EnableSecretBases->isChecked());
|
projectConfig.eventSecretBaseEnabled = ui->checkBox_EnableSecretBases->isChecked();
|
||||||
projectConfig.setHealLocationRespawnDataEnabled(ui->checkBox_EnableRespawn->isChecked());
|
projectConfig.healLocationRespawnDataEnabled = ui->checkBox_EnableRespawn->isChecked();
|
||||||
projectConfig.setMapAllowFlagsEnabled(ui->checkBox_EnableAllowFlags->isChecked());
|
projectConfig.mapAllowFlagsEnabled = ui->checkBox_EnableAllowFlags->isChecked();
|
||||||
projectConfig.setFloorNumberEnabled(ui->checkBox_EnableFloorNumber->isChecked());
|
projectConfig.floorNumberEnabled = ui->checkBox_EnableFloorNumber->isChecked();
|
||||||
projectConfig.setUseCustomBorderSize(ui->checkBox_EnableCustomBorderSize->isChecked());
|
projectConfig.useCustomBorderSize = ui->checkBox_EnableCustomBorderSize->isChecked();
|
||||||
projectConfig.setTilesetsHaveCallback(ui->checkBox_OutputCallback->isChecked());
|
projectConfig.tilesetsHaveCallback = ui->checkBox_OutputCallback->isChecked();
|
||||||
projectConfig.setTilesetsHaveIsCompressed(ui->checkBox_OutputIsCompressed->isChecked());
|
projectConfig.tilesetsHaveIsCompressed = ui->checkBox_OutputIsCompressed->isChecked();
|
||||||
porymapConfig.setWarpBehaviorWarningDisabled(ui->checkBox_DisableWarning->isChecked());
|
porymapConfig.warpBehaviorWarningDisabled = ui->checkBox_DisableWarning->isChecked();
|
||||||
|
|
||||||
// Save spin box settings
|
// Save spin box settings
|
||||||
projectConfig.setDefaultElevation(ui->spinBox_Elevation->value());
|
projectConfig.defaultElevation = ui->spinBox_Elevation->value();
|
||||||
projectConfig.setDefaultCollision(ui->spinBox_Collision->value());
|
projectConfig.defaultCollision = ui->spinBox_Collision->value();
|
||||||
projectConfig.setDefaultMetatileId(ui->spinBox_FillMetatile->value());
|
projectConfig.defaultMetatileId = ui->spinBox_FillMetatile->value();
|
||||||
projectConfig.setCollisionSheetHeight(ui->spinBox_MaxElevation->value() + 1);
|
projectConfig.collisionSheetHeight = ui->spinBox_MaxElevation->value() + 1;
|
||||||
projectConfig.setCollisionSheetWidth(ui->spinBox_MaxCollision->value() + 1);
|
projectConfig.collisionSheetWidth = ui->spinBox_MaxCollision->value() + 1;
|
||||||
projectConfig.setMetatileBehaviorMask(ui->spinBox_BehaviorMask->value());
|
projectConfig.metatileBehaviorMask = ui->spinBox_BehaviorMask->value();
|
||||||
projectConfig.setMetatileTerrainTypeMask(ui->spinBox_TerrainTypeMask->value());
|
projectConfig.metatileTerrainTypeMask = ui->spinBox_TerrainTypeMask->value();
|
||||||
projectConfig.setMetatileEncounterTypeMask(ui->spinBox_EncounterTypeMask->value());
|
projectConfig.metatileEncounterTypeMask = ui->spinBox_EncounterTypeMask->value();
|
||||||
projectConfig.setMetatileLayerTypeMask(ui->spinBox_LayerTypeMask->value());
|
projectConfig.metatileLayerTypeMask = ui->spinBox_LayerTypeMask->value();
|
||||||
projectConfig.setBlockMetatileIdMask(ui->spinBox_MetatileIdMask->value());
|
projectConfig.blockMetatileIdMask = ui->spinBox_MetatileIdMask->value();
|
||||||
projectConfig.setBlockCollisionMask(ui->spinBox_CollisionMask->value());
|
projectConfig.blockCollisionMask = ui->spinBox_CollisionMask->value();
|
||||||
projectConfig.setBlockElevationMask(ui->spinBox_ElevationMask->value());
|
projectConfig.blockElevationMask = ui->spinBox_ElevationMask->value();
|
||||||
|
|
||||||
// Save line edit settings
|
// Save line edit settings
|
||||||
projectConfig.setPrefabFilepath(ui->lineEdit_PrefabsPath->text());
|
projectConfig.prefabFilepath = ui->lineEdit_PrefabsPath->text();
|
||||||
projectConfig.setCollisionSheetPath(ui->lineEdit_CollisionGraphics->text());
|
projectConfig.collisionSheetPath = ui->lineEdit_CollisionGraphics->text();
|
||||||
projectConfig.setEventIconPath(Event::Group::Object, ui->lineEdit_ObjectsIcon->text());
|
projectConfig.setEventIconPath(Event::Group::Object, ui->lineEdit_ObjectsIcon->text());
|
||||||
projectConfig.setEventIconPath(Event::Group::Warp, ui->lineEdit_WarpsIcon->text());
|
projectConfig.setEventIconPath(Event::Group::Warp, ui->lineEdit_WarpsIcon->text());
|
||||||
projectConfig.setEventIconPath(Event::Group::Coord, ui->lineEdit_TriggersIcon->text());
|
projectConfig.setEventIconPath(Event::Group::Coord, ui->lineEdit_TriggersIcon->text());
|
||||||
|
@ -555,14 +550,13 @@ void ProjectSettingsEditor::save() {
|
||||||
projectConfig.setIdentifier(lineEdit->objectName(), lineEdit->text());
|
projectConfig.setIdentifier(lineEdit->objectName(), lineEdit->text());
|
||||||
|
|
||||||
// Save warp behaviors
|
// Save warp behaviors
|
||||||
|
projectConfig.warpBehaviors.clear();
|
||||||
QStringList behaviorNames = this->getWarpBehaviorsList();
|
QStringList behaviorNames = this->getWarpBehaviorsList();
|
||||||
QSet<uint32_t> behaviorValues;
|
|
||||||
for (auto name : behaviorNames)
|
for (auto name : behaviorNames)
|
||||||
behaviorValues.insert(project->metatileBehaviorMap.value(name));
|
projectConfig.warpBehaviors.insert(project->metatileBehaviorMap.value(name));
|
||||||
projectConfig.setWarpBehaviors(behaviorValues);
|
|
||||||
|
|
||||||
// Save border metatile IDs
|
// Save border metatile IDs
|
||||||
projectConfig.setNewMapBorderMetatileIds(this->getBorderMetatileIds(ui->checkBox_EnableCustomBorderSize->isChecked()));
|
projectConfig.newMapBorderMetatileIds = this->getBorderMetatileIds(ui->checkBox_EnableCustomBorderSize->isChecked());
|
||||||
|
|
||||||
// Save pokemon icon paths
|
// Save pokemon icon paths
|
||||||
const QString species = ui->comboBox_IconSpecies->currentText();
|
const QString species = ui->comboBox_IconSpecies->currentText();
|
||||||
|
@ -571,8 +565,10 @@ void ProjectSettingsEditor::save() {
|
||||||
for (auto i = this->editedPokemonIconPaths.cbegin(), end = this->editedPokemonIconPaths.cend(); i != end; i++)
|
for (auto i = this->editedPokemonIconPaths.cbegin(), end = this->editedPokemonIconPaths.cend(); i != end; i++)
|
||||||
projectConfig.setPokemonIconPath(i.key(), i.value());
|
projectConfig.setPokemonIconPath(i.key(), i.value());
|
||||||
|
|
||||||
projectConfig.setSaveDisabled(false);
|
|
||||||
projectConfig.save();
|
projectConfig.save();
|
||||||
|
userConfig.save();
|
||||||
|
porymapConfig.save();
|
||||||
|
|
||||||
this->hasUnsavedChanges = false;
|
this->hasUnsavedChanges = false;
|
||||||
|
|
||||||
// Technically, a reload is not required for several of the config settings.
|
// Technically, a reload is not required for several of the config settings.
|
||||||
|
@ -611,7 +607,7 @@ void ProjectSettingsEditor::importDefaultPrefabsClicked(bool) {
|
||||||
// If the prompt is accepted the prefabs file will be created and its filepath will be saved in the config.
|
// If the prompt is accepted the prefabs file will be created and its filepath will be saved in the config.
|
||||||
BaseGameVersion version = projectConfig.stringToBaseGameVersion(ui->comboBox_BaseGameVersion->currentText());
|
BaseGameVersion version = projectConfig.stringToBaseGameVersion(ui->comboBox_BaseGameVersion->currentText());
|
||||||
if (prefab.tryImportDefaultPrefabs(this, version, ui->lineEdit_PrefabsPath->text())) {
|
if (prefab.tryImportDefaultPrefabs(this, version, ui->lineEdit_PrefabsPath->text())) {
|
||||||
ui->lineEdit_PrefabsPath->setText(projectConfig.getPrefabFilepath()); // Refresh with new filepath
|
ui->lineEdit_PrefabsPath->setText(projectConfig.prefabFilepath); // Refresh with new filepath
|
||||||
this->hasUnsavedChanges = true;
|
this->hasUnsavedChanges = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,7 +202,7 @@ void buildFireredDefaults(poryjson::Json &json) {
|
||||||
|
|
||||||
poryjson::Json RegionMapEditor::buildDefaultJson() {
|
poryjson::Json RegionMapEditor::buildDefaultJson() {
|
||||||
poryjson::Json defaultJson;
|
poryjson::Json defaultJson;
|
||||||
switch (projectConfig.getBaseGameVersion()) {
|
switch (projectConfig.baseGameVersion) {
|
||||||
case BaseGameVersion::pokeemerald:
|
case BaseGameVersion::pokeemerald:
|
||||||
buildEmeraldDefaults(defaultJson);
|
buildEmeraldDefaults(defaultJson);
|
||||||
break;
|
break;
|
||||||
|
@ -345,7 +345,7 @@ bool RegionMapEditor::buildConfigDialog() {
|
||||||
|
|
||||||
// for sake of convenience, option to just use defaults for each basegame version
|
// for sake of convenience, option to just use defaults for each basegame version
|
||||||
QPushButton *config_useProjectDefault;
|
QPushButton *config_useProjectDefault;
|
||||||
switch (projectConfig.getBaseGameVersion()) {
|
switch (projectConfig.baseGameVersion) {
|
||||||
case BaseGameVersion::pokefirered:
|
case BaseGameVersion::pokefirered:
|
||||||
config_useProjectDefault = new QPushButton("\nUse pokefirered defaults\n");
|
config_useProjectDefault = new QPushButton("\nUse pokefirered defaults\n");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -53,6 +53,7 @@ void ShortcutsEditor::saveShortcuts() {
|
||||||
}
|
}
|
||||||
|
|
||||||
shortcutsConfig.setUserShortcuts(objects_keySequences);
|
shortcutsConfig.setUserShortcuts(objects_keySequences);
|
||||||
|
shortcutsConfig.save();
|
||||||
emit shortcutsSaved();
|
emit shortcutsSaved();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@ void TilesetEditor::initUi() {
|
||||||
|
|
||||||
void TilesetEditor::setAttributesUi() {
|
void TilesetEditor::setAttributesUi() {
|
||||||
// Behavior
|
// Behavior
|
||||||
if (projectConfig.getMetatileBehaviorMask()) {
|
if (projectConfig.metatileBehaviorMask) {
|
||||||
for (int num : project->metatileBehaviorMapInverse.keys()) {
|
for (int num : project->metatileBehaviorMapInverse.keys()) {
|
||||||
this->ui->comboBox_metatileBehaviors->addItem(project->metatileBehaviorMapInverse[num], num);
|
this->ui->comboBox_metatileBehaviors->addItem(project->metatileBehaviorMapInverse[num], num);
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ void TilesetEditor::setAttributesUi() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Terrain Type
|
// Terrain Type
|
||||||
if (projectConfig.getMetatileTerrainTypeMask()) {
|
if (projectConfig.metatileTerrainTypeMask) {
|
||||||
this->ui->comboBox_terrainType->addItem("Normal", TERRAIN_NONE);
|
this->ui->comboBox_terrainType->addItem("Normal", TERRAIN_NONE);
|
||||||
this->ui->comboBox_terrainType->addItem("Grass", TERRAIN_GRASS);
|
this->ui->comboBox_terrainType->addItem("Grass", TERRAIN_GRASS);
|
||||||
this->ui->comboBox_terrainType->addItem("Water", TERRAIN_WATER);
|
this->ui->comboBox_terrainType->addItem("Water", TERRAIN_WATER);
|
||||||
|
@ -138,7 +138,7 @@ void TilesetEditor::setAttributesUi() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encounter Type
|
// Encounter Type
|
||||||
if (projectConfig.getMetatileEncounterTypeMask()) {
|
if (projectConfig.metatileEncounterTypeMask) {
|
||||||
this->ui->comboBox_encounterType->addItem("None", ENCOUNTER_NONE);
|
this->ui->comboBox_encounterType->addItem("None", ENCOUNTER_NONE);
|
||||||
this->ui->comboBox_encounterType->addItem("Land", ENCOUNTER_LAND);
|
this->ui->comboBox_encounterType->addItem("Land", ENCOUNTER_LAND);
|
||||||
this->ui->comboBox_encounterType->addItem("Water", ENCOUNTER_WATER);
|
this->ui->comboBox_encounterType->addItem("Water", ENCOUNTER_WATER);
|
||||||
|
@ -150,13 +150,13 @@ void TilesetEditor::setAttributesUi() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Layer Type
|
// Layer Type
|
||||||
if (!projectConfig.getTripleLayerMetatilesEnabled()) {
|
if (!projectConfig.tripleLayerMetatilesEnabled) {
|
||||||
this->ui->comboBox_layerType->addItem("Normal - Middle/Top", METATILE_LAYER_MIDDLE_TOP);
|
this->ui->comboBox_layerType->addItem("Normal - Middle/Top", METATILE_LAYER_MIDDLE_TOP);
|
||||||
this->ui->comboBox_layerType->addItem("Covered - Bottom/Middle", METATILE_LAYER_BOTTOM_MIDDLE);
|
this->ui->comboBox_layerType->addItem("Covered - Bottom/Middle", METATILE_LAYER_BOTTOM_MIDDLE);
|
||||||
this->ui->comboBox_layerType->addItem("Split - Bottom/Top", METATILE_LAYER_BOTTOM_TOP);
|
this->ui->comboBox_layerType->addItem("Split - Bottom/Top", METATILE_LAYER_BOTTOM_TOP);
|
||||||
this->ui->comboBox_layerType->setEditable(false);
|
this->ui->comboBox_layerType->setEditable(false);
|
||||||
this->ui->comboBox_layerType->setMinimumContentsLength(0);
|
this->ui->comboBox_layerType->setMinimumContentsLength(0);
|
||||||
if (!projectConfig.getMetatileLayerTypeMask()) {
|
if (!projectConfig.metatileLayerTypeMask) {
|
||||||
// User doesn't have triple layer metatiles, but has no layer type attribute.
|
// User doesn't have triple layer metatiles, but has no layer type attribute.
|
||||||
// Porymap is still using the layer type value to render metatiles, and with
|
// Porymap is still using the layer type value to render metatiles, and with
|
||||||
// no mask set every metatile will be "Middle/Top", so just display the combo
|
// no mask set every metatile will be "Middle/Top", so just display the combo
|
||||||
|
@ -188,7 +188,7 @@ void TilesetEditor::initMetatileSelector()
|
||||||
connect(this->metatileSelector, &TilesetEditorMetatileSelector::selectedMetatileChanged,
|
connect(this->metatileSelector, &TilesetEditorMetatileSelector::selectedMetatileChanged,
|
||||||
this, &TilesetEditor::onSelectedMetatileChanged);
|
this, &TilesetEditor::onSelectedMetatileChanged);
|
||||||
|
|
||||||
bool showGrid = porymapConfig.getShowTilesetEditorMetatileGrid();
|
bool showGrid = porymapConfig.showTilesetEditorMetatileGrid;
|
||||||
this->ui->actionMetatile_Grid->setChecked(showGrid);
|
this->ui->actionMetatile_Grid->setChecked(showGrid);
|
||||||
this->metatileSelector->showGrid = showGrid;
|
this->metatileSelector->showGrid = showGrid;
|
||||||
|
|
||||||
|
@ -198,7 +198,7 @@ void TilesetEditor::initMetatileSelector()
|
||||||
|
|
||||||
this->ui->graphicsView_Metatiles->setScene(this->metatilesScene);
|
this->ui->graphicsView_Metatiles->setScene(this->metatilesScene);
|
||||||
this->ui->graphicsView_Metatiles->setResizeAnchor(QGraphicsView::AnchorViewCenter);
|
this->ui->graphicsView_Metatiles->setResizeAnchor(QGraphicsView::AnchorViewCenter);
|
||||||
this->ui->horizontalSlider_MetatilesZoom->setValue(porymapConfig.getTilesetEditorMetatilesZoom());
|
this->ui->horizontalSlider_MetatilesZoom->setValue(porymapConfig.tilesetEditorMetatilesZoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TilesetEditor::initMetatileLayersItem() {
|
void TilesetEditor::initMetatileLayersItem() {
|
||||||
|
@ -213,7 +213,7 @@ void TilesetEditor::initMetatileLayersItem() {
|
||||||
connect(this->metatileLayersItem, &MetatileLayersItem::hoveredTileCleared,
|
connect(this->metatileLayersItem, &MetatileLayersItem::hoveredTileCleared,
|
||||||
this, &TilesetEditor::onHoveredTileCleared);
|
this, &TilesetEditor::onHoveredTileCleared);
|
||||||
|
|
||||||
bool showGrid = porymapConfig.getShowTilesetEditorLayerGrid();
|
bool showGrid = porymapConfig.showTilesetEditorLayerGrid;
|
||||||
this->ui->actionLayer_Grid->setChecked(showGrid);
|
this->ui->actionLayer_Grid->setChecked(showGrid);
|
||||||
this->metatileLayersItem->showGrid = showGrid;
|
this->metatileLayersItem->showGrid = showGrid;
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ void TilesetEditor::initTileSelector()
|
||||||
|
|
||||||
this->ui->graphicsView_Tiles->setScene(this->tilesScene);
|
this->ui->graphicsView_Tiles->setScene(this->tilesScene);
|
||||||
this->ui->graphicsView_Tiles->setResizeAnchor(QGraphicsView::AnchorViewCenter);
|
this->ui->graphicsView_Tiles->setResizeAnchor(QGraphicsView::AnchorViewCenter);
|
||||||
this->ui->horizontalSlider_TilesZoom->setValue(porymapConfig.getTilesetEditorTilesZoom());
|
this->ui->horizontalSlider_TilesZoom->setValue(porymapConfig.tilesetEditorTilesZoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TilesetEditor::initSelectedTileItem() {
|
void TilesetEditor::initSelectedTileItem() {
|
||||||
|
@ -1070,13 +1070,13 @@ void TilesetEditor::on_actionShow_UnusedTiles_toggled(bool checked) {
|
||||||
void TilesetEditor::on_actionMetatile_Grid_triggered(bool checked) {
|
void TilesetEditor::on_actionMetatile_Grid_triggered(bool checked) {
|
||||||
this->metatileSelector->showGrid = checked;
|
this->metatileSelector->showGrid = checked;
|
||||||
this->metatileSelector->draw();
|
this->metatileSelector->draw();
|
||||||
porymapConfig.setShowTilesetEditorMetatileGrid(checked);
|
porymapConfig.showTilesetEditorMetatileGrid = checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TilesetEditor::on_actionLayer_Grid_triggered(bool checked) {
|
void TilesetEditor::on_actionLayer_Grid_triggered(bool checked) {
|
||||||
this->metatileLayersItem->showGrid = checked;
|
this->metatileLayersItem->showGrid = checked;
|
||||||
this->metatileLayersItem->draw();
|
this->metatileLayersItem->draw();
|
||||||
porymapConfig.setShowTilesetEditorLayerGrid(checked);
|
porymapConfig.showTilesetEditorLayerGrid = checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TilesetEditor::countMetatileUsage() {
|
void TilesetEditor::countMetatileUsage() {
|
||||||
|
@ -1188,7 +1188,7 @@ void TilesetEditor::on_copyButton_metatileLabel_clicked() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TilesetEditor::on_horizontalSlider_MetatilesZoom_valueChanged(int value) {
|
void TilesetEditor::on_horizontalSlider_MetatilesZoom_valueChanged(int value) {
|
||||||
porymapConfig.setTilesetEditorMetatilesZoom(value);
|
porymapConfig.tilesetEditorMetatilesZoom = value;
|
||||||
this->redrawMetatileSelector();
|
this->redrawMetatileSelector();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1196,7 +1196,7 @@ void TilesetEditor::redrawMetatileSelector() {
|
||||||
QSize size(this->metatileSelector->pixmap().width(), this->metatileSelector->pixmap().height());
|
QSize size(this->metatileSelector->pixmap().width(), this->metatileSelector->pixmap().height());
|
||||||
this->ui->graphicsView_Metatiles->setSceneRect(0, 0, size.width(), size.height());
|
this->ui->graphicsView_Metatiles->setSceneRect(0, 0, size.width(), size.height());
|
||||||
|
|
||||||
double scale = pow(3.0, static_cast<double>(porymapConfig.getTilesetEditorMetatilesZoom() - 30) / 30.0);
|
double scale = pow(3.0, static_cast<double>(porymapConfig.tilesetEditorMetatilesZoom - 30) / 30.0);
|
||||||
QTransform transform;
|
QTransform transform;
|
||||||
transform.scale(scale, scale);
|
transform.scale(scale, scale);
|
||||||
size *= scale;
|
size *= scale;
|
||||||
|
@ -1213,7 +1213,7 @@ void TilesetEditor::redrawMetatileSelector() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TilesetEditor::on_horizontalSlider_TilesZoom_valueChanged(int value) {
|
void TilesetEditor::on_horizontalSlider_TilesZoom_valueChanged(int value) {
|
||||||
porymapConfig.setTilesetEditorTilesZoom(value);
|
porymapConfig.tilesetEditorTilesZoom = value;
|
||||||
this->redrawTileSelector();
|
this->redrawTileSelector();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1221,7 +1221,7 @@ void TilesetEditor::redrawTileSelector() {
|
||||||
QSize size(this->tileSelector->pixmap().width(), this->tileSelector->pixmap().height());
|
QSize size(this->tileSelector->pixmap().width(), this->tileSelector->pixmap().height());
|
||||||
this->ui->graphicsView_Tiles->setSceneRect(0, 0, size.width(), size.height());
|
this->ui->graphicsView_Tiles->setSceneRect(0, 0, size.width(), size.height());
|
||||||
|
|
||||||
double scale = pow(3.0, static_cast<double>(porymapConfig.getTilesetEditorTilesZoom() - 30) / 30.0);
|
double scale = pow(3.0, static_cast<double>(porymapConfig.tilesetEditorTilesZoom - 30) / 30.0);
|
||||||
QTransform transform;
|
QTransform transform;
|
||||||
transform.scale(scale, scale);
|
transform.scale(scale, scale);
|
||||||
size *= scale;
|
size *= scale;
|
||||||
|
|
|
@ -20,8 +20,7 @@ UpdatePromoter::UpdatePromoter(QWidget *parent, NetworkAccessManager *manager)
|
||||||
this->updatePreferences();
|
this->updatePreferences();
|
||||||
ui->checkBox_StopAlerts->setVisible(false);
|
ui->checkBox_StopAlerts->setVisible(false);
|
||||||
connect(ui->checkBox_StopAlerts, &QCheckBox::stateChanged, [this](int state) {
|
connect(ui->checkBox_StopAlerts, &QCheckBox::stateChanged, [this](int state) {
|
||||||
bool enable = (state != Qt::Checked);
|
porymapConfig.checkForUpdates = (state != Qt::Checked);
|
||||||
porymapConfig.setCheckForUpdates(enable);
|
|
||||||
emit this->changedPreferences();
|
emit this->changedPreferences();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -141,11 +140,11 @@ void UpdatePromoter::processWebpage(const QJsonDocument &data, const QUrl &nextU
|
||||||
// Alert the user about the new version if the dialog wasn't already open.
|
// Alert the user about the new version if the dialog wasn't already open.
|
||||||
// Show the window, but also show the option to turn off automatic alerts in the future.
|
// Show the window, but also show the option to turn off automatic alerts in the future.
|
||||||
// We only show this alert once for a given release.
|
// We only show this alert once for a given release.
|
||||||
if (!this->isVisible() && this->newVersion > porymapConfig.getLastUpdateCheckVersion()) {
|
if (!this->isVisible() && this->newVersion > porymapConfig.lastUpdateCheckVersion) {
|
||||||
ui->checkBox_StopAlerts->setVisible(true);
|
ui->checkBox_StopAlerts->setVisible(true);
|
||||||
this->show();
|
this->show();
|
||||||
}
|
}
|
||||||
porymapConfig.setLastUpdateCheckVersion(this->newVersion);
|
porymapConfig.lastUpdateCheckVersion = this->newVersion;
|
||||||
} else {
|
} else {
|
||||||
ui->label_Status->setText("Your version of Porymap is up to date!");
|
ui->label_Status->setText("Your version of Porymap is up to date!");
|
||||||
ui->label_Warning->setVisible(false);
|
ui->label_Warning->setVisible(false);
|
||||||
|
@ -173,7 +172,7 @@ void UpdatePromoter::error(const QString &err, const QDateTime retryAfter) {
|
||||||
|
|
||||||
void UpdatePromoter::updatePreferences() {
|
void UpdatePromoter::updatePreferences() {
|
||||||
const QSignalBlocker blocker(ui->checkBox_StopAlerts);
|
const QSignalBlocker blocker(ui->checkBox_StopAlerts);
|
||||||
ui->checkBox_StopAlerts->setChecked(!porymapConfig.getCheckForUpdates());
|
ui->checkBox_StopAlerts->setChecked(!porymapConfig.checkForUpdates);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdatePromoter::dialogButtonClicked(QAbstractButton *button) {
|
void UpdatePromoter::dialogButtonClicked(QAbstractButton *button) {
|
||||||
|
|
Loading…
Reference in a new issue