add wild encounters to config
This commit is contained in:
parent
c52b6fe4cd
commit
d794dee8c0
4 changed files with 29 additions and 0 deletions
|
@ -96,9 +96,12 @@ class ProjectConfig: public KeyValueConfigBase
|
||||||
public:
|
public:
|
||||||
ProjectConfig() {
|
ProjectConfig() {
|
||||||
this->baseGameVersion = BaseGameVersion::pokeemerald;
|
this->baseGameVersion = BaseGameVersion::pokeemerald;
|
||||||
|
this->useEncounterJson = true;
|
||||||
}
|
}
|
||||||
void setBaseGameVersion(BaseGameVersion baseGameVersion);
|
void setBaseGameVersion(BaseGameVersion baseGameVersion);
|
||||||
BaseGameVersion getBaseGameVersion();
|
BaseGameVersion getBaseGameVersion();
|
||||||
|
void setEncounterJsonActive(bool active);
|
||||||
|
bool getEncounterJsonActive();
|
||||||
void setProjectDir(QString projectDir);
|
void setProjectDir(QString projectDir);
|
||||||
protected:
|
protected:
|
||||||
QString getConfigFilepath();
|
QString getConfigFilepath();
|
||||||
|
@ -108,6 +111,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
BaseGameVersion baseGameVersion;
|
BaseGameVersion baseGameVersion;
|
||||||
QString projectDir;
|
QString projectDir;
|
||||||
|
bool useEncounterJson;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ProjectConfig projectConfig;
|
extern ProjectConfig projectConfig;
|
||||||
|
|
|
@ -337,6 +337,12 @@ 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' or 'pokeemerald'.").arg(value));
|
logWarn(QString("Invalid config value for base_game_version: '%1'. Must be 'pokeruby' or 'pokeemerald'.").arg(value));
|
||||||
}
|
}
|
||||||
|
} else if (key == "use_encounter_json") {
|
||||||
|
bool ok;
|
||||||
|
this->useEncounterJson = value.toInt(&ok);
|
||||||
|
if (!ok) {
|
||||||
|
logWarn(QString("Invalid config value for use_encounter_json: '%1'. Must be 0 or 1.").arg(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));
|
||||||
}
|
}
|
||||||
|
@ -345,6 +351,7 @@ void ProjectConfig::parseConfigKeyValue(QString key, QString value) {
|
||||||
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("use_encounter_json", QString::number(this->useEncounterJson));
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,6 +380,7 @@ void ProjectConfig::onNewConfigFileCreated() {
|
||||||
this->baseGameVersion = static_cast<BaseGameVersion>(baseGameVersionComboBox->currentData().toInt());
|
this->baseGameVersion = static_cast<BaseGameVersion>(baseGameVersionComboBox->currentData().toInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this->useEncounterJson = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectConfig::setProjectDir(QString projectDir) {
|
void ProjectConfig::setProjectDir(QString projectDir) {
|
||||||
|
@ -387,3 +395,12 @@ void ProjectConfig::setBaseGameVersion(BaseGameVersion baseGameVersion) {
|
||||||
BaseGameVersion ProjectConfig::getBaseGameVersion() {
|
BaseGameVersion ProjectConfig::getBaseGameVersion() {
|
||||||
return this->baseGameVersion;
|
return this->baseGameVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProjectConfig::setEncounterJsonActive(bool active) {
|
||||||
|
this->useEncounterJson = active;
|
||||||
|
this->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ProjectConfig::getEncounterJsonActive() {
|
||||||
|
return this->useEncounterJson;
|
||||||
|
}
|
||||||
|
|
|
@ -149,6 +149,9 @@ void MainWindow::initMapSortOrder() {
|
||||||
|
|
||||||
void MainWindow::setProjectSpecificUIVisibility()
|
void MainWindow::setProjectSpecificUIVisibility()
|
||||||
{
|
{
|
||||||
|
if (!projectConfig.getEncounterJsonActive())
|
||||||
|
ui->tabWidget->removeTab(4);
|
||||||
|
|
||||||
switch (projectConfig.getBaseGameVersion())
|
switch (projectConfig.getBaseGameVersion())
|
||||||
{
|
{
|
||||||
case BaseGameVersion::pokeruby:
|
case BaseGameVersion::pokeruby:
|
||||||
|
@ -2216,6 +2219,7 @@ void MainWindow::closeEvent(QCloseEvent *event) {
|
||||||
this->ui->splitter_main->saveState()
|
this->ui->splitter_main->saveState()
|
||||||
);
|
);
|
||||||
porymapConfig.save();
|
porymapConfig.save();
|
||||||
|
projectConfig.save();
|
||||||
|
|
||||||
QMainWindow::closeEvent(event);
|
QMainWindow::closeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -521,6 +521,8 @@ void Project::saveMapGroups() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Project::saveWildMonData() {
|
void Project::saveWildMonData() {
|
||||||
|
if (!projectConfig.getEncounterJsonActive()) return;
|
||||||
|
|
||||||
QString wildEncountersJsonFilepath = QString("%1/src/data/wild_encounters.json").arg(root);
|
QString wildEncountersJsonFilepath = QString("%1/src/data/wild_encounters.json").arg(root);
|
||||||
QFile wildEncountersFile(wildEncountersJsonFilepath);
|
QFile wildEncountersFile(wildEncountersJsonFilepath);
|
||||||
if (!wildEncountersFile.open(QIODevice::WriteOnly)) {
|
if (!wildEncountersFile.open(QIODevice::WriteOnly)) {
|
||||||
|
@ -1378,6 +1380,8 @@ void Project::deleteFile(QString path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Project::readWildMonData() {
|
void Project::readWildMonData() {
|
||||||
|
if (!projectConfig.getEncounterJsonActive()) return;
|
||||||
|
|
||||||
QString wildMonJsonFilepath = QString("%1/src/data/wild_encounters.json").arg(root);
|
QString wildMonJsonFilepath = QString("%1/src/data/wild_encounters.json").arg(root);
|
||||||
QJsonDocument wildMonsJsonDoc;
|
QJsonDocument wildMonsJsonDoc;
|
||||||
if (!parser.tryParseJsonFile(&wildMonsJsonDoc, wildMonJsonFilepath)) {
|
if (!parser.tryParseJsonFile(&wildMonsJsonDoc, wildMonJsonFilepath)) {
|
||||||
|
|
Loading…
Reference in a new issue