Store recent map in ProjectConfig instead of PorymapConfig

This commit is contained in:
BigBahss 2021-02-03 12:13:24 -05:00 committed by huderlem
parent 3d394bc4bb
commit 36a6212af6
3 changed files with 20 additions and 20 deletions

View file

@ -38,7 +38,6 @@ public:
} }
virtual void reset() override { virtual void reset() override {
this->recentProject = ""; this->recentProject = "";
this->recentMap = "";
this->mapSortOrder = MapSortOrder::Group; this->mapSortOrder = MapSortOrder::Group;
this->prettyCursors = true; this->prettyCursors = true;
this->collisionOpacity = 50; this->collisionOpacity = 50;
@ -52,7 +51,6 @@ public:
this->textEditorGotoLine = ""; this->textEditorGotoLine = "";
} }
void setRecentProject(QString project); void setRecentProject(QString project);
void setRecentMap(QString map);
void setMapSortOrder(MapSortOrder order); void setMapSortOrder(MapSortOrder order);
void setPrettyCursors(bool enabled); void setPrettyCursors(bool enabled);
void setMainGeometry(QByteArray, QByteArray, QByteArray, QByteArray); void setMainGeometry(QByteArray, QByteArray, QByteArray, QByteArray);
@ -69,7 +67,6 @@ public:
void setTextEditorOpenFolder(const QString &command); void setTextEditorOpenFolder(const QString &command);
void setTextEditorGotoLine(const QString &command); void setTextEditorGotoLine(const QString &command);
QString getRecentProject(); QString getRecentProject();
QString getRecentMap();
MapSortOrder getMapSortOrder(); MapSortOrder getMapSortOrder();
bool getPrettyCursors(); bool getPrettyCursors();
QMap<QString, QByteArray> getMainGeometry(); QMap<QString, QByteArray> getMainGeometry();
@ -93,7 +90,6 @@ protected:
virtual void setUnreadKeys() override {}; virtual void setUnreadKeys() override {};
private: private:
QString recentProject; QString recentProject;
QString recentMap;
QString stringFromByteArray(QByteArray); QString stringFromByteArray(QByteArray);
QByteArray bytesFromString(QString); QByteArray bytesFromString(QString);
MapSortOrder mapSortOrder; MapSortOrder mapSortOrder;
@ -136,6 +132,7 @@ public:
} }
virtual void reset() override { virtual void reset() override {
this->baseGameVersion = BaseGameVersion::pokeemerald; this->baseGameVersion = BaseGameVersion::pokeemerald;
this->recentMap = QString();
this->useEncounterJson = true; this->useEncounterJson = true;
this->useCustomBorderSize = false; this->useCustomBorderSize = false;
this->enableEventWeatherTrigger = true; this->enableEventWeatherTrigger = true;
@ -151,6 +148,8 @@ public:
} }
void setBaseGameVersion(BaseGameVersion baseGameVersion); void setBaseGameVersion(BaseGameVersion baseGameVersion);
BaseGameVersion getBaseGameVersion(); BaseGameVersion getBaseGameVersion();
void setRecentMap(const QString &map);
QString getRecentMap();
void setEncounterJsonActive(bool active); void setEncounterJsonActive(bool active);
bool getEncounterJsonActive(); bool getEncounterJsonActive();
void setUsePoryScript(bool usePoryScript); void setUsePoryScript(bool usePoryScript);
@ -186,6 +185,7 @@ protected:
private: private:
BaseGameVersion baseGameVersion; BaseGameVersion baseGameVersion;
QString projectDir; QString projectDir;
QString recentMap;
bool useEncounterJson; bool useEncounterJson;
bool usePoryScript; bool usePoryScript;
bool useCustomBorderSize; bool useCustomBorderSize;

View file

@ -109,8 +109,6 @@ QString PorymapConfig::getConfigFilepath() {
void PorymapConfig::parseConfigKeyValue(QString key, QString value) { void PorymapConfig::parseConfigKeyValue(QString key, QString value) {
if (key == "recent_project") { if (key == "recent_project") {
this->recentProject = value; this->recentProject = value;
} else if (key == "recent_map") {
this->recentMap = value;
} else if (key == "pretty_cursors") { } else if (key == "pretty_cursors") {
bool ok; bool ok;
this->prettyCursors = value.toInt(&ok); this->prettyCursors = value.toInt(&ok);
@ -202,7 +200,6 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) {
QMap<QString, QString> PorymapConfig::getKeyValueMap() { QMap<QString, QString> PorymapConfig::getKeyValueMap() {
QMap<QString, QString> map; QMap<QString, QString> map;
map.insert("recent_project", this->recentProject); map.insert("recent_project", this->recentProject);
map.insert("recent_map", this->recentMap);
map.insert("pretty_cursors", this->prettyCursors ? "1" : "0"); map.insert("pretty_cursors", this->prettyCursors ? "1" : "0");
map.insert("map_sort_order", mapSortOrderMap.value(this->mapSortOrder)); map.insert("map_sort_order", mapSortOrderMap.value(this->mapSortOrder));
map.insert("main_window_geometry", stringFromByteArray(this->mainWindowGeometry)); map.insert("main_window_geometry", stringFromByteArray(this->mainWindowGeometry));
@ -250,11 +247,6 @@ void PorymapConfig::setRecentProject(QString project) {
this->save(); this->save();
} }
void PorymapConfig::setRecentMap(QString map) {
this->recentMap = map;
this->save();
}
void PorymapConfig::setMapSortOrder(MapSortOrder order) { void PorymapConfig::setMapSortOrder(MapSortOrder order) {
this->mapSortOrder = order; this->mapSortOrder = order;
this->save(); this->save();
@ -339,10 +331,6 @@ QString PorymapConfig::getRecentProject() {
return this->recentProject; return this->recentProject;
} }
QString PorymapConfig::getRecentMap() {
return this->recentMap;
}
MapSortOrder PorymapConfig::getMapSortOrder() { MapSortOrder PorymapConfig::getMapSortOrder() {
return this->mapSortOrder; return this->mapSortOrder;
} }
@ -453,6 +441,8 @@ void ProjectConfig::parseConfigKeyValue(QString key, QString value) {
this->baseGameVersion = BaseGameVersion::pokeemerald; this->baseGameVersion = BaseGameVersion::pokeemerald;
logWarn(QString("Invalid config value for base_game_version: '%1'. Must be 'pokeruby', 'pokefirered' or 'pokeemerald'.").arg(value)); logWarn(QString("Invalid config value for base_game_version: '%1'. Must be 'pokeruby', 'pokefirered' or 'pokeemerald'.").arg(value));
} }
} else if (key == "recent_map") {
this->recentMap = value;
} else if (key == "use_encounter_json") { } else if (key == "use_encounter_json") {
bool ok; bool ok;
this->useEncounterJson = value.toInt(&ok); this->useEncounterJson = value.toInt(&ok);
@ -550,6 +540,7 @@ void ProjectConfig::setUnreadKeys() {
QMap<QString, QString> ProjectConfig::getKeyValueMap() { QMap<QString, QString> ProjectConfig::getKeyValueMap() {
QMap<QString, QString> map; QMap<QString, QString> map;
map.insert("base_game_version", baseGameVersionMap.value(this->baseGameVersion)); map.insert("base_game_version", baseGameVersionMap.value(this->baseGameVersion));
map.insert("recent_map", this->recentMap);
map.insert("use_encounter_json", QString::number(this->useEncounterJson)); map.insert("use_encounter_json", QString::number(this->useEncounterJson));
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));
@ -623,6 +614,15 @@ BaseGameVersion ProjectConfig::getBaseGameVersion() {
return this->baseGameVersion; return this->baseGameVersion;
} }
void ProjectConfig::setRecentMap(const QString &map) {
this->recentMap = map;
this->save();
}
QString ProjectConfig::getRecentMap() {
return this->recentMap;
}
void ProjectConfig::setEncounterJsonActive(bool active) { void ProjectConfig::setEncounterJsonActive(bool active) {
this->useEncounterJson = active; this->useEncounterJson = active;
this->save(); this->save();

View file

@ -541,7 +541,7 @@ QString MainWindow::getDefaultMap() {
if (editor && editor->project) { if (editor && editor->project) {
QList<QStringList> names = editor->project->groupedMapNames; QList<QStringList> names = editor->project->groupedMapNames;
if (!names.isEmpty()) { if (!names.isEmpty()) {
QString recentMap = porymapConfig.getRecentMap(); QString recentMap = projectConfig.getRecentMap();
if (!recentMap.isNull() && recentMap.length() > 0) { if (!recentMap.isNull() && recentMap.length() > 0) {
for (int i = 0; i < names.length(); i++) { for (int i = 0; i < names.length(); i++) {
if (names.value(i).contains(recentMap)) { if (names.value(i).contains(recentMap)) {
@ -568,8 +568,8 @@ QString MainWindow::getExistingDirectory(QString dir) {
void MainWindow::on_action_Open_Project_triggered() void MainWindow::on_action_Open_Project_triggered()
{ {
QString recent = "."; QString recent = ".";
if (!porymapConfig.getRecentMap().isNull() && porymapConfig.getRecentMap().length() > 0) { if (!projectConfig.getRecentMap().isEmpty()) {
recent = porymapConfig.getRecentMap(); recent = projectConfig.getRecentMap();
} }
QString dir = getExistingDirectory(recent); QString dir = getExistingDirectory(recent);
if (!dir.isEmpty()) { if (!dir.isEmpty()) {
@ -711,7 +711,7 @@ void MainWindow::openWarpMap(QString map_name, QString warp_num) {
} }
void MainWindow::setRecentMap(QString mapName) { void MainWindow::setRecentMap(QString mapName) {
porymapConfig.setRecentMap(mapName); projectConfig.setRecentMap(mapName);
} }
void MainWindow::displayMapProperties() { void MainWindow::displayMapProperties() {