porymap/include/config.h

124 lines
3.4 KiB
C
Raw Normal View History

2018-12-21 15:25:28 +00:00
#ifndef CONFIG_H
#define CONFIG_H
#include <QString>
#include <QObject>
#include <QByteArrayList>
#include <QSize>
2018-12-21 15:25:28 +00:00
enum MapSortOrder {
Group = 0,
Area = 1,
Layout = 2,
};
class KeyValueConfigBase : public QObject
2018-12-21 15:25:28 +00:00
{
public:
void save();
void load();
virtual ~KeyValueConfigBase();
protected:
virtual QString getConfigFilepath() = 0;
virtual void parseConfigKeyValue(QString key, QString value) = 0;
virtual QMap<QString, QString> getKeyValueMap() = 0;
virtual void onNewConfigFileCreated() = 0;
};
class PorymapConfig: public KeyValueConfigBase
{
public:
PorymapConfig() {
this->recentProject = "";
this->recentMap = "";
this->mapSortOrder = MapSortOrder::Group;
this->prettyCursors = true;
this->collisionOpacity = 50;
2019-02-16 20:32:19 +00:00
this->metatilesZoom = 30;
this->showPlayerView = false;
this->showCursorTile = true;
this->regionMapDimensions = QSize(32, 20);
this->theme = "default";
}
void setRecentProject(QString project);
void setRecentMap(QString map);
void setMapSortOrder(MapSortOrder order);
void setPrettyCursors(bool enabled);
void setGeometry(QByteArray, QByteArray, QByteArray, QByteArray, QByteArray);
void setCollisionOpacity(int opacity);
2019-02-16 20:32:19 +00:00
void setMetatilesZoom(int zoom);
void setShowPlayerView(bool enabled);
void setShowCursorTile(bool enabled);
void setRegionMapDimensions(int width, int height);
void setTheme(QString theme);
QString getRecentProject();
QString getRecentMap();
MapSortOrder getMapSortOrder();
bool getPrettyCursors();
QMap<QString, QByteArray> getGeometry();
int getCollisionOpacity();
2019-02-16 20:32:19 +00:00
int getMetatilesZoom();
bool getShowPlayerView();
bool getShowCursorTile();
QSize getRegionMapDimensions();
QString getTheme();
protected:
QString getConfigFilepath();
void parseConfigKeyValue(QString key, QString value);
QMap<QString, QString> getKeyValueMap();
void onNewConfigFileCreated() {}
2018-12-21 15:25:28 +00:00
private:
QString recentProject;
QString recentMap;
QString stringFromByteArray(QByteArray);
QByteArray bytesFromString(QString);
MapSortOrder mapSortOrder;
bool prettyCursors;
QByteArray windowGeometry;
QByteArray windowState;
QByteArray mapSplitterState;
QByteArray eventsSlpitterState;
QByteArray mainSplitterState;
int collisionOpacity;
2019-02-16 20:32:19 +00:00
int metatilesZoom;
bool showPlayerView;
bool showCursorTile;
QSize regionMapDimensions;
QString theme;
2018-12-21 15:25:28 +00:00
};
extern PorymapConfig porymapConfig;
enum BaseGameVersion {
pokeruby,
pokefirered,
pokeemerald,
};
class ProjectConfig: public KeyValueConfigBase
{
public:
ProjectConfig() {
this->baseGameVersion = BaseGameVersion::pokeemerald;
2019-07-03 21:21:48 +01:00
this->useEncounterJson = true;
}
void setBaseGameVersion(BaseGameVersion baseGameVersion);
BaseGameVersion getBaseGameVersion();
2019-07-03 21:21:48 +01:00
void setEncounterJsonActive(bool active);
bool getEncounterJsonActive();
void setProjectDir(QString projectDir);
protected:
QString getConfigFilepath();
void parseConfigKeyValue(QString key, QString value);
QMap<QString, QString> getKeyValueMap();
void onNewConfigFileCreated();
private:
BaseGameVersion baseGameVersion;
QString projectDir;
2019-07-03 21:21:48 +01:00
bool useEncounterJson;
};
extern ProjectConfig projectConfig;
2018-12-21 15:25:28 +00:00
#endif // CONFIG_H