Add setting to disable/enable map text file creation

This commit is contained in:
GriffinR 2021-02-19 04:04:14 -05:00 committed by huderlem
parent 80c5f74368
commit 02af128913
4 changed files with 26 additions and 2 deletions

View file

@ -44,6 +44,7 @@ determined by this file.
``enable_heal_location_respawn_data``, 1 if ``pokefirered``, project, yes, Adds ``Respawn Map`` and ``Respawn NPC`` to Heal Location events
``enable_object_event_in_connection``, 1 if ``pokefirered``, project, yes, Adds ``In Connection`` to Object events
``enable_floor_number``, 1 if ``pokefirered``, project, yes, Adds ``Floor Number`` to map headers
``create_map_text_file``, 1 if not ``pokeemerald``, project, yes, A ``text.inc`` or ``text.pory`` file will be created for any new map
``enable_triple_layer_metatiles``, 0, project, yes, Enables triple-layer metatiles (See https://github.com/pret/pokeemerald/wiki/Triple-layer-metatiles)
``custom_scripts``, , project, yes, A list of script files to load into the scripting engine

View file

@ -142,6 +142,7 @@ public:
this->enableHealLocationRespawnData = false;
this->enableObjectEventInConnection = false;
this->enableFloorNumber = false;
this->createMapTextFile = false;
this->enableTripleLayerMetatiles = false;
this->customScripts.clear();
this->readKeys.clear();
@ -172,6 +173,8 @@ public:
bool getObjectEventInConnectionEnabled();
void setFloorNumberEnabled(bool enable);
bool getFloorNumberEnabled();
void setCreateMapTextFileEnabled(bool enable);
bool getCreateMapTextFileEnabled();
void setTripleLayerMetatilesEnabled(bool enable);
bool getTripleLayerMetatilesEnabled();
void setCustomScripts(QList<QString> scripts);
@ -196,6 +199,7 @@ private:
bool enableHealLocationRespawnData;
bool enableObjectEventInConnection;
bool enableFloorNumber;
bool createMapTextFile;
bool enableTripleLayerMetatiles;
QList<QString> customScripts;
QStringList readKeys;

View file

@ -503,6 +503,12 @@ void ProjectConfig::parseConfigKeyValue(QString key, QString value) {
if (!ok) {
logWarn(QString("Invalid config value for enable_floor_number: '%1'. Must be 0 or 1.").arg(value));
}
} else if (key == "create_map_text_file") {
bool ok;
this->createMapTextFile = value.toInt(&ok);
if (!ok) {
logWarn(QString("Invalid config value for create_map_text_file: '%1'. Must be 0 or 1.").arg(value));
}
} else if (key == "enable_triple_layer_metatiles") {
bool ok;
this->enableTripleLayerMetatiles = value.toInt(&ok);
@ -535,6 +541,7 @@ void ProjectConfig::setUnreadKeys() {
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;
if (!readKeys.contains("create_map_text_file")) this->createMapTextFile = (this->baseGameVersion != BaseGameVersion::pokeemerald);
}
QMap<QString, QString> ProjectConfig::getKeyValueMap() {
@ -551,6 +558,7 @@ QMap<QString, QString> ProjectConfig::getKeyValueMap() {
map.insert("enable_heal_location_respawn_data", QString::number(this->enableHealLocationRespawnData));
map.insert("enable_object_event_in_connection", QString::number(this->enableObjectEventInConnection));
map.insert("enable_floor_number", QString::number(this->enableFloorNumber));
map.insert("create_map_text_file", QString::number(this->createMapTextFile));
map.insert("enable_triple_layer_metatiles", QString::number(this->enableTripleLayerMetatiles));
map.insert("custom_scripts", this->customScripts.join(","));
return map;
@ -591,6 +599,7 @@ void ProjectConfig::onNewConfigFileCreated() {
this->enableHealLocationRespawnData = isPokefirered;
this->enableObjectEventInConnection = isPokefirered;
this->enableFloorNumber = isPokefirered;
this->createMapTextFile = (this->baseGameVersion != BaseGameVersion::pokeemerald);
this->useEncounterJson = true;
this->usePoryScript = false;
this->enableTripleLayerMetatiles = false;
@ -713,6 +722,15 @@ bool ProjectConfig::getFloorNumberEnabled() {
return this->enableFloorNumber;
}
void ProjectConfig::setCreateMapTextFileEnabled(bool enable) {
this->createMapTextFile = enable;
this->save();
}
bool ProjectConfig::getCreateMapTextFileEnabled() {
return this->createMapTextFile;
}
void ProjectConfig::setTripleLayerMetatilesEnabled(bool enable) {
this->enableTripleLayerMetatiles = enable;
this->save();

View file

@ -1242,14 +1242,15 @@ void Project::saveMap(Map *map) {
QString text = this->getScriptDefaultString(projectConfig.getUsePoryScript(), map->name);
saveTextFile(root + "/data/maps/" + map->name + "/scripts" + this->getScriptFileExtension(projectConfig.getUsePoryScript()), text);
if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokeruby || projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered) {
bool usesTextFile = projectConfig.getCreateMapTextFileEnabled();
if (usesTextFile) {
// Create file data/maps/<map_name>/text.inc
saveTextFile(root + "/data/maps/" + map->name + "/text" + this->getScriptFileExtension(projectConfig.getUsePoryScript()), "\n");
}
// Simply append to data/event_scripts.s.
text = QString("\n\t.include \"data/maps/%1/scripts.inc\"\n").arg(map->name);
if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokeruby || projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered) {
if (usesTextFile) {
text += QString("\t.include \"data/maps/%1/text.inc\"\n").arg(map->name);
}
appendTextFile(root + "/data/event_scripts.s", text);