Set project-specific config defaults
This commit is contained in:
parent
125a287b9c
commit
90aa26197d
2 changed files with 21 additions and 1 deletions
|
@ -24,6 +24,7 @@ protected:
|
||||||
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 onNewConfigFileCreated() = 0;
|
||||||
|
virtual void setUnreadKeys() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PorymapConfig: public KeyValueConfigBase
|
class PorymapConfig: public KeyValueConfigBase
|
||||||
|
@ -73,7 +74,8 @@ 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 onNewConfigFileCreated() override {};
|
||||||
|
virtual void setUnreadKeys() override {};
|
||||||
private:
|
private:
|
||||||
QString recentProject;
|
QString recentProject;
|
||||||
QString recentMap;
|
QString recentMap;
|
||||||
|
@ -121,6 +123,7 @@ public:
|
||||||
this->enableObjectEventInConnection = false;
|
this->enableObjectEventInConnection = false;
|
||||||
this->enableFloorNumber = false;
|
this->enableFloorNumber = false;
|
||||||
this->customScripts.clear();
|
this->customScripts.clear();
|
||||||
|
this->readKeys.clear();
|
||||||
}
|
}
|
||||||
void setBaseGameVersion(BaseGameVersion baseGameVersion);
|
void setBaseGameVersion(BaseGameVersion baseGameVersion);
|
||||||
BaseGameVersion getBaseGameVersion();
|
BaseGameVersion getBaseGameVersion();
|
||||||
|
@ -153,6 +156,7 @@ protected:
|
||||||
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 onNewConfigFileCreated() override;
|
||||||
|
virtual void setUnreadKeys() override;
|
||||||
private:
|
private:
|
||||||
BaseGameVersion baseGameVersion;
|
BaseGameVersion baseGameVersion;
|
||||||
QString projectDir;
|
QString projectDir;
|
||||||
|
@ -167,6 +171,7 @@ private:
|
||||||
bool enableObjectEventInConnection;
|
bool enableObjectEventInConnection;
|
||||||
bool enableFloorNumber;
|
bool enableFloorNumber;
|
||||||
QList<QString> customScripts;
|
QList<QString> customScripts;
|
||||||
|
QStringList readKeys;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ProjectConfig projectConfig;
|
extern ProjectConfig projectConfig;
|
||||||
|
|
|
@ -56,6 +56,7 @@ void KeyValueConfigBase::load() {
|
||||||
|
|
||||||
this->parseConfigKeyValue(match.captured("key").toLower(), match.captured("value"));
|
this->parseConfigKeyValue(match.captured("key").toLower(), match.captured("value"));
|
||||||
}
|
}
|
||||||
|
this->setUnreadKeys();
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
@ -434,6 +435,20 @@ void ProjectConfig::parseConfigKeyValue(QString key, QString value) {
|
||||||
} else {
|
} else {
|
||||||
logWarn(QString("Invalid config key found in config file %1: '%2'").arg(this->getConfigFilepath()).arg(key));
|
logWarn(QString("Invalid config key found in config file %1: '%2'").arg(this->getConfigFilepath()).arg(key));
|
||||||
}
|
}
|
||||||
|
readKeys.append(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectConfig::setUnreadKeys() {
|
||||||
|
// Set game-version specific defaults for any config field that wasn't read
|
||||||
|
bool isPokefirered = this->baseGameVersion == BaseGameVersion::pokefirered;
|
||||||
|
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_secret_base")) this->enableEventSecretBase = !isPokefirered;
|
||||||
|
if (!readKeys.contains("enable_hidden_item_quantity")) this->enableHiddenItemQuantity = isPokefirered;
|
||||||
|
if (!readKeys.contains("enable_hidden_item_requires_itemfinder")) this->enableHiddenItemRequiresItemfinder = isPokefirered;
|
||||||
|
if (!readKeys.contains("enable_heal_location_respawn_data")) this->enableHealLocationRespawnData = isPokefirered;
|
||||||
|
if (!readKeys.contains("enable_object_event_in_connection")) this->enableObjectEventInConnection = isPokefirered;
|
||||||
|
if (!readKeys.contains("enable_floor_number")) this->enableFloorNumber = isPokefirered;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, QString> ProjectConfig::getKeyValueMap() {
|
QMap<QString, QString> ProjectConfig::getKeyValueMap() {
|
||||||
|
|
Loading…
Reference in a new issue