2018-12-21 15:25:28 +00:00
|
|
|
#ifndef CONFIG_H
|
|
|
|
#define CONFIG_H
|
|
|
|
|
|
|
|
#include <QString>
|
2018-12-25 21:26:13 +00:00
|
|
|
#include <QObject>
|
2019-01-07 23:14:44 +00:00
|
|
|
#include <QByteArrayList>
|
2019-01-15 22:06:18 +00:00
|
|
|
#include <QSize>
|
2020-11-01 12:35:20 +00:00
|
|
|
#include <QKeySequence>
|
|
|
|
#include <QMultiMap>
|
2018-12-21 15:25:28 +00:00
|
|
|
|
|
|
|
enum MapSortOrder {
|
|
|
|
Group = 0,
|
|
|
|
Area = 1,
|
|
|
|
Layout = 2,
|
|
|
|
};
|
|
|
|
|
2018-12-25 21:26:13 +00:00
|
|
|
class KeyValueConfigBase : public QObject
|
2018-12-21 15:25:28 +00:00
|
|
|
{
|
|
|
|
public:
|
2018-12-25 20:41:06 +00:00
|
|
|
void save();
|
|
|
|
void load();
|
|
|
|
virtual ~KeyValueConfigBase();
|
2020-04-07 19:44:14 +01:00
|
|
|
virtual void reset() = 0;
|
2018-12-25 20:41:06 +00:00
|
|
|
protected:
|
2018-12-25 21:26:13 +00:00
|
|
|
virtual QString getConfigFilepath() = 0;
|
2018-12-25 20:41:06 +00:00
|
|
|
virtual void parseConfigKeyValue(QString key, QString value) = 0;
|
|
|
|
virtual QMap<QString, QString> getKeyValueMap() = 0;
|
2018-12-25 21:26:13 +00:00
|
|
|
virtual void onNewConfigFileCreated() = 0;
|
2020-05-26 22:01:18 +01:00
|
|
|
virtual void setUnreadKeys() = 0;
|
2018-12-25 20:41:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class PorymapConfig: public KeyValueConfigBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PorymapConfig() {
|
2020-04-07 19:44:14 +01:00
|
|
|
reset();
|
|
|
|
}
|
|
|
|
virtual void reset() override {
|
2018-12-25 20:41:06 +00:00
|
|
|
this->recentProject = "";
|
|
|
|
this->recentMap = "";
|
|
|
|
this->mapSortOrder = MapSortOrder::Group;
|
|
|
|
this->prettyCursors = true;
|
2019-01-06 18:53:31 +00:00
|
|
|
this->collisionOpacity = 50;
|
2019-02-16 20:32:19 +00:00
|
|
|
this->metatilesZoom = 30;
|
2019-01-09 15:35:34 +00:00
|
|
|
this->showPlayerView = false;
|
|
|
|
this->showCursorTile = true;
|
2020-04-08 05:42:38 +01:00
|
|
|
this->monitorFiles = true;
|
2019-01-15 22:06:18 +00:00
|
|
|
this->regionMapDimensions = QSize(32, 20);
|
2019-08-14 23:02:00 +01:00
|
|
|
this->theme = "default";
|
2018-12-25 20:41:06 +00:00
|
|
|
}
|
|
|
|
void setRecentProject(QString project);
|
|
|
|
void setRecentMap(QString map);
|
|
|
|
void setMapSortOrder(MapSortOrder order);
|
|
|
|
void setPrettyCursors(bool enabled);
|
2020-09-15 19:57:46 +01:00
|
|
|
void setMainGeometry(QByteArray, QByteArray, QByteArray, QByteArray);
|
|
|
|
void setTilesetEditorGeometry(QByteArray, QByteArray);
|
2020-09-16 02:43:52 +01:00
|
|
|
void setPaletteEditorGeometry(QByteArray, QByteArray);
|
2020-09-16 00:03:15 +01:00
|
|
|
void setRegionMapEditorGeometry(QByteArray, QByteArray);
|
2019-01-06 18:53:31 +00:00
|
|
|
void setCollisionOpacity(int opacity);
|
2019-02-16 20:32:19 +00:00
|
|
|
void setMetatilesZoom(int zoom);
|
2019-01-09 15:35:34 +00:00
|
|
|
void setShowPlayerView(bool enabled);
|
|
|
|
void setShowCursorTile(bool enabled);
|
2020-04-08 05:42:38 +01:00
|
|
|
void setMonitorFiles(bool monitor);
|
2019-01-15 22:06:18 +00:00
|
|
|
void setRegionMapDimensions(int width, int height);
|
2019-08-14 23:02:00 +01:00
|
|
|
void setTheme(QString theme);
|
2018-12-25 20:41:06 +00:00
|
|
|
QString getRecentProject();
|
|
|
|
QString getRecentMap();
|
|
|
|
MapSortOrder getMapSortOrder();
|
|
|
|
bool getPrettyCursors();
|
2020-09-15 19:57:46 +01:00
|
|
|
QMap<QString, QByteArray> getMainGeometry();
|
|
|
|
QMap<QString, QByteArray> getTilesetEditorGeometry();
|
2020-09-16 02:43:52 +01:00
|
|
|
QMap<QString, QByteArray> getPaletteEditorGeometry();
|
2020-09-16 00:03:15 +01:00
|
|
|
QMap<QString, QByteArray> getRegionMapEditorGeometry();
|
2019-01-06 18:53:31 +00:00
|
|
|
int getCollisionOpacity();
|
2019-02-16 20:32:19 +00:00
|
|
|
int getMetatilesZoom();
|
2019-01-09 15:35:34 +00:00
|
|
|
bool getShowPlayerView();
|
|
|
|
bool getShowCursorTile();
|
2020-04-08 05:42:38 +01:00
|
|
|
bool getMonitorFiles();
|
2019-01-15 22:06:18 +00:00
|
|
|
QSize getRegionMapDimensions();
|
2019-08-14 23:02:00 +01:00
|
|
|
QString getTheme();
|
2018-12-25 20:41:06 +00:00
|
|
|
protected:
|
2020-04-07 19:44:14 +01:00
|
|
|
virtual QString getConfigFilepath() override;
|
|
|
|
virtual void parseConfigKeyValue(QString key, QString value) override;
|
|
|
|
virtual QMap<QString, QString> getKeyValueMap() override;
|
2020-05-26 22:01:18 +01:00
|
|
|
virtual void onNewConfigFileCreated() override {};
|
|
|
|
virtual void setUnreadKeys() override {};
|
2018-12-21 15:25:28 +00:00
|
|
|
private:
|
2018-12-25 20:41:06 +00:00
|
|
|
QString recentProject;
|
|
|
|
QString recentMap;
|
2019-01-07 23:14:44 +00:00
|
|
|
QString stringFromByteArray(QByteArray);
|
|
|
|
QByteArray bytesFromString(QString);
|
2018-12-25 20:41:06 +00:00
|
|
|
MapSortOrder mapSortOrder;
|
|
|
|
bool prettyCursors;
|
2020-09-15 19:57:46 +01:00
|
|
|
QByteArray mainWindowGeometry;
|
|
|
|
QByteArray mainWindowState;
|
2019-01-07 23:14:44 +00:00
|
|
|
QByteArray mapSplitterState;
|
|
|
|
QByteArray eventsSlpitterState;
|
|
|
|
QByteArray mainSplitterState;
|
2020-09-15 19:57:46 +01:00
|
|
|
QByteArray tilesetEditorGeometry;
|
|
|
|
QByteArray tilesetEditorState;
|
2020-09-16 02:43:52 +01:00
|
|
|
QByteArray paletteEditorGeometry;
|
|
|
|
QByteArray paletteEditorState;
|
2020-09-16 00:03:15 +01:00
|
|
|
QByteArray regionMapEditorGeometry;
|
|
|
|
QByteArray regionMapEditorState;
|
2019-01-06 18:53:31 +00:00
|
|
|
int collisionOpacity;
|
2019-02-16 20:32:19 +00:00
|
|
|
int metatilesZoom;
|
2019-01-09 15:35:34 +00:00
|
|
|
bool showPlayerView;
|
|
|
|
bool showCursorTile;
|
2020-04-08 05:42:38 +01:00
|
|
|
bool monitorFiles;
|
2019-01-15 22:06:18 +00:00
|
|
|
QSize regionMapDimensions;
|
2019-08-14 23:02:00 +01:00
|
|
|
QString theme;
|
2018-12-21 15:25:28 +00:00
|
|
|
};
|
|
|
|
|
2018-12-25 20:41:06 +00:00
|
|
|
extern PorymapConfig porymapConfig;
|
|
|
|
|
2018-12-25 21:26:13 +00:00
|
|
|
enum BaseGameVersion {
|
|
|
|
pokeruby,
|
2019-01-09 00:04:41 +00:00
|
|
|
pokefirered,
|
2018-12-25 21:26:13 +00:00
|
|
|
pokeemerald,
|
|
|
|
};
|
|
|
|
|
|
|
|
class ProjectConfig: public KeyValueConfigBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ProjectConfig() {
|
2020-04-07 19:44:14 +01:00
|
|
|
reset();
|
|
|
|
}
|
|
|
|
virtual void reset() override {
|
2018-12-25 21:26:13 +00:00
|
|
|
this->baseGameVersion = BaseGameVersion::pokeemerald;
|
2019-07-03 21:21:48 +01:00
|
|
|
this->useEncounterJson = true;
|
2020-04-07 19:44:14 +01:00
|
|
|
this->useCustomBorderSize = false;
|
2020-05-22 22:51:56 +01:00
|
|
|
this->enableEventWeatherTrigger = true;
|
|
|
|
this->enableEventSecretBase = true;
|
|
|
|
this->enableHiddenItemQuantity = false;
|
|
|
|
this->enableHiddenItemRequiresItemfinder = false;
|
|
|
|
this->enableHealLocationRespawnData = false;
|
|
|
|
this->enableObjectEventInConnection = false;
|
|
|
|
this->enableFloorNumber = false;
|
2020-06-25 06:32:42 +01:00
|
|
|
this->enableTripleLayerMetatiles = false;
|
2020-05-08 17:26:23 +01:00
|
|
|
this->customScripts.clear();
|
2020-05-26 22:01:18 +01:00
|
|
|
this->readKeys.clear();
|
2018-12-25 21:26:13 +00:00
|
|
|
}
|
|
|
|
void setBaseGameVersion(BaseGameVersion baseGameVersion);
|
|
|
|
BaseGameVersion getBaseGameVersion();
|
2019-07-03 21:21:48 +01:00
|
|
|
void setEncounterJsonActive(bool active);
|
|
|
|
bool getEncounterJsonActive();
|
2019-10-22 13:48:41 +01:00
|
|
|
void setUsePoryScript(bool usePoryScript);
|
|
|
|
bool getUsePoryScript();
|
2018-12-25 21:26:13 +00:00
|
|
|
void setProjectDir(QString projectDir);
|
2020-05-08 17:26:23 +01:00
|
|
|
QString getProjectDir();
|
2020-03-13 06:23:47 +00:00
|
|
|
void setUseCustomBorderSize(bool enable);
|
|
|
|
bool getUseCustomBorderSize();
|
2020-05-22 22:51:56 +01:00
|
|
|
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 setObjectEventInConnectionEnabled(bool enable);
|
|
|
|
bool getObjectEventInConnectionEnabled();
|
|
|
|
void setFloorNumberEnabled(bool enable);
|
|
|
|
bool getFloorNumberEnabled();
|
2020-06-25 06:32:42 +01:00
|
|
|
void setTripleLayerMetatilesEnabled(bool enable);
|
|
|
|
bool getTripleLayerMetatilesEnabled();
|
2020-05-08 17:26:23 +01:00
|
|
|
void setCustomScripts(QList<QString> scripts);
|
|
|
|
QList<QString> getCustomScripts();
|
2018-12-25 21:26:13 +00:00
|
|
|
protected:
|
2020-04-07 19:44:14 +01:00
|
|
|
virtual QString getConfigFilepath() override;
|
|
|
|
virtual void parseConfigKeyValue(QString key, QString value) override;
|
|
|
|
virtual QMap<QString, QString> getKeyValueMap() override;
|
|
|
|
virtual void onNewConfigFileCreated() override;
|
2020-05-26 22:01:18 +01:00
|
|
|
virtual void setUnreadKeys() override;
|
2018-12-25 21:26:13 +00:00
|
|
|
private:
|
|
|
|
BaseGameVersion baseGameVersion;
|
|
|
|
QString projectDir;
|
2019-07-03 21:21:48 +01:00
|
|
|
bool useEncounterJson;
|
2019-10-22 13:48:41 +01:00
|
|
|
bool usePoryScript;
|
2020-03-13 06:23:47 +00:00
|
|
|
bool useCustomBorderSize;
|
2020-05-22 22:51:56 +01:00
|
|
|
bool enableEventWeatherTrigger;
|
|
|
|
bool enableEventSecretBase;
|
|
|
|
bool enableHiddenItemQuantity;
|
|
|
|
bool enableHiddenItemRequiresItemfinder;
|
|
|
|
bool enableHealLocationRespawnData;
|
|
|
|
bool enableObjectEventInConnection;
|
|
|
|
bool enableFloorNumber;
|
2020-06-25 06:32:42 +01:00
|
|
|
bool enableTripleLayerMetatiles;
|
2020-05-08 17:26:23 +01:00
|
|
|
QList<QString> customScripts;
|
2020-05-26 22:01:18 +01:00
|
|
|
QStringList readKeys;
|
2018-12-25 21:26:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern ProjectConfig projectConfig;
|
|
|
|
|
2020-11-01 12:35:20 +00:00
|
|
|
class QAction;
|
2020-11-03 10:58:10 +00:00
|
|
|
class Shortcut;
|
2020-11-01 12:35:20 +00:00
|
|
|
|
|
|
|
class ShortcutsConfig : public KeyValueConfigBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ShortcutsConfig() :
|
2020-11-08 13:36:02 +00:00
|
|
|
user_shortcuts({ }),
|
|
|
|
default_shortcuts({ })
|
|
|
|
{ }
|
|
|
|
|
|
|
|
virtual void reset() override { user_shortcuts.clear(); }
|
|
|
|
|
|
|
|
void setDefaultShortcuts(const QObjectList &objects);
|
|
|
|
void setDefaultShortcuts(const QMultiMap<const QObject *, QKeySequence> &objects_keySequences);
|
|
|
|
QList<QKeySequence> defaultShortcuts(const QObject *object) const;
|
|
|
|
|
|
|
|
void setUserShortcuts(const QObjectList &objects);
|
|
|
|
void setUserShortcuts(const QMultiMap<const QObject *, QKeySequence> &objects_keySequences);
|
|
|
|
QList<QKeySequence> userShortcuts(const QObject *object) const;
|
|
|
|
|
|
|
|
static bool objectNameIsValid(const QObject *object);
|
2020-11-01 12:35:20 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual QString getConfigFilepath() override;
|
|
|
|
virtual void parseConfigKeyValue(QString key, QString value) override;
|
|
|
|
virtual QMap<QString, QString> getKeyValueMap() override;
|
2020-11-08 13:36:02 +00:00
|
|
|
virtual void onNewConfigFileCreated() override { };
|
|
|
|
virtual void setUnreadKeys() override { };
|
2020-11-01 12:35:20 +00:00
|
|
|
|
|
|
|
private:
|
2020-11-08 13:36:02 +00:00
|
|
|
QMultiMap<QString, QKeySequence> user_shortcuts;
|
|
|
|
QMultiMap<QString, QKeySequence> default_shortcuts;
|
2020-11-01 12:35:20 +00:00
|
|
|
|
2020-11-05 11:32:31 +00:00
|
|
|
enum StoreType {
|
|
|
|
User,
|
|
|
|
Default
|
|
|
|
};
|
|
|
|
|
2020-11-08 13:36:02 +00:00
|
|
|
QString cfgKey(const QObject *object) const;
|
|
|
|
QList<QKeySequence> currentShortcuts(const QObject *object) const;
|
|
|
|
|
|
|
|
void storeShortcutsFromList(StoreType storeType, const QObjectList &objects);
|
2020-11-05 11:32:31 +00:00
|
|
|
void storeShortcuts(
|
|
|
|
StoreType storeType,
|
|
|
|
const QString &cfgKey,
|
|
|
|
const QList<QKeySequence> &keySequences);
|
2020-11-01 12:35:20 +00:00
|
|
|
};
|
|
|
|
|
2020-11-08 13:36:02 +00:00
|
|
|
// Call setDefaultShortcuts() prior to applying user shortcuts.
|
2020-11-01 12:35:20 +00:00
|
|
|
extern ShortcutsConfig shortcutsConfig;
|
|
|
|
|
2018-12-21 15:25:28 +00:00
|
|
|
#endif // CONFIG_H
|