diff --git a/docsrc/manual/settings-and-options.rst b/docsrc/manual/settings-and-options.rst index dd57dc27..60328bdd 100644 --- a/docsrc/manual/settings-and-options.rst +++ b/docsrc/manual/settings-and-options.rst @@ -47,6 +47,7 @@ your project root as ``porymap.user.cfg``. You should add this file to your giti ``enable_hidden_item_requires_itemfinder``, 1 if ``pokefirered``, project, yes, Adds ``Requires Itemfinder`` to Hidden Item events ``enable_heal_location_respawn_data``, 1 if ``pokefirered``, project, yes, Adds ``Respawn Map`` and ``Respawn NPC`` to Heal Location events ``enable_floor_number``, 1 if ``pokefirered``, project, yes, Adds ``Floor Number`` to map headers + ``enable_map_allow_flags``, 1 if not ``pokeruby``, project, yes, "Adds ``Allow Running``, ``Allow Biking``, and ``Allow Dig & Escape Rope`` 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) ``new_map_metatile``, 1, project, yes, The metatile id that will be used to fill new maps diff --git a/include/config.h b/include/config.h index 5dd4f38e..9ceda88b 100644 --- a/include/config.h +++ b/include/config.h @@ -270,6 +270,7 @@ public: uint32_t getMetatileTerrainTypeMask(); uint32_t getMetatileEncounterTypeMask(); uint32_t getMetatileLayerTypeMask(); + bool getMapAllowFlagsEnabled(); protected: virtual QString getConfigFilepath() override; virtual void parseConfigKeyValue(QString key, QString value) override; @@ -306,6 +307,7 @@ private: uint32_t metatileTerrainTypeMask; uint32_t metatileEncounterTypeMask; uint32_t metatileLayerTypeMask; + bool enableMapAllowFlags; }; extern ProjectConfig projectConfig; diff --git a/src/config.cpp b/src/config.cpp index ae5abe92..c4acb43e 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -574,6 +574,8 @@ void ProjectConfig::parseConfigKeyValue(QString key, QString value) { this->metatileEncounterTypeMask = getConfigLong(key, value, 0, 0xFFFFFFFF, 0); } else if (key == "metatile_layer_type_mask") { this->metatileLayerTypeMask = getConfigLong(key, value, 0, 0xFFFFFFFF, 0); + } else if (key == "enable_map_allow_flags") { + this->enableMapAllowFlags = getConfigBool(key, value); #ifdef CONFIG_BACKWARDS_COMPATABILITY } else if (key == "recent_map") { userConfig.setRecentMap(value); @@ -630,6 +632,7 @@ void ProjectConfig::setUnreadKeys() { if (!readKeys.contains("metatile_terrain_type_mask")) this->metatileTerrainTypeMask = layout[Metatile::Attr::TerrainType].mask; if (!readKeys.contains("metatile_encounter_type_mask")) this->metatileEncounterTypeMask = layout[Metatile::Attr::EncounterType].mask; if (!readKeys.contains("metatile_layer_type_mask")) this-> metatileLayerTypeMask = layout[Metatile::Attr::LayerType].mask; + if (!readKeys.contains("enable_map_allow_flags")) this->enableMapAllowFlags = (this->baseGameVersion != BaseGameVersion::pokeruby); } QMap ProjectConfig::getKeyValueMap() { @@ -666,6 +669,7 @@ QMap ProjectConfig::getKeyValueMap() { map.insert("metatile_terrain_type_mask", "0x" + QString::number(this->metatileTerrainTypeMask, 16).toUpper()); map.insert("metatile_encounter_type_mask", "0x" + QString::number(this->metatileEncounterTypeMask, 16).toUpper()); map.insert("metatile_layer_type_mask", "0x" + QString::number(this->metatileLayerTypeMask, 16).toUpper()); + map.insert("enable_map_allow_flags", QString::number(this->enableMapAllowFlags)); return map; } @@ -935,6 +939,10 @@ uint32_t ProjectConfig::getMetatileLayerTypeMask() { return this->metatileLayerTypeMask; } +bool ProjectConfig::getMapAllowFlagsEnabled() { + return this->enableMapAllowFlags; +} + UserConfig userConfig; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e850118c..2dc0dc0b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -376,36 +376,13 @@ void MainWindow::setProjectSpecificUIVisibility() ui->actionUse_Poryscript->setChecked(projectConfig.getUsePoryScript()); this->setWildEncountersUIEnabled(userConfig.getEncounterJsonActive()); - switch (projectConfig.getBaseGameVersion()) - { - case BaseGameVersion::pokeruby: - ui->checkBox_AllowRunning->setVisible(false); - ui->checkBox_AllowBiking->setVisible(false); - ui->checkBox_AllowEscaping->setVisible(false); - ui->label_AllowRunning->setVisible(false); - ui->label_AllowBiking->setVisible(false); - ui->label_AllowEscaping->setVisible(false); - ui->actionRegion_Map_Editor->setVisible(true); - break; - case BaseGameVersion::pokeemerald: - ui->checkBox_AllowRunning->setVisible(true); - ui->checkBox_AllowBiking->setVisible(true); - ui->checkBox_AllowEscaping->setVisible(true); - ui->label_AllowRunning->setVisible(true); - ui->label_AllowBiking->setVisible(true); - ui->label_AllowEscaping->setVisible(true); - ui->actionRegion_Map_Editor->setVisible(true); - break; - case BaseGameVersion::pokefirered: - ui->checkBox_AllowRunning->setVisible(true); - ui->checkBox_AllowBiking->setVisible(true); - ui->checkBox_AllowEscaping->setVisible(true); - ui->label_AllowRunning->setVisible(true); - ui->label_AllowBiking->setVisible(true); - ui->label_AllowEscaping->setVisible(true); - ui->actionRegion_Map_Editor->setVisible(true); - break; - } + bool hasFlags = projectConfig.getMapAllowFlagsEnabled(); + ui->checkBox_AllowRunning->setVisible(hasFlags); + ui->checkBox_AllowBiking->setVisible(hasFlags); + ui->checkBox_AllowEscaping->setVisible(hasFlags); + ui->label_AllowRunning->setVisible(hasFlags); + ui->label_AllowBiking->setVisible(hasFlags); + ui->label_AllowEscaping->setVisible(hasFlags); ui->newEventToolButton->newWeatherTriggerAction->setVisible(projectConfig.getEventWeatherTriggerEnabled()); ui->newEventToolButton->newSecretBaseAction->setVisible(projectConfig.getEventSecretBaseEnabled()); @@ -806,11 +783,9 @@ void MainWindow::displayMapProperties() { ui->comboBox_Type->setCurrentText(map->type); ui->comboBox_BattleScene->setCurrentText(map->battle_scene); ui->checkBox_ShowLocation->setChecked(map->show_location); - if (projectConfig.getBaseGameVersion() != BaseGameVersion::pokeruby) { - ui->checkBox_AllowRunning->setChecked(map->allowRunning); - ui->checkBox_AllowBiking->setChecked(map->allowBiking); - ui->checkBox_AllowEscaping->setChecked(map->allowEscaping); - } + ui->checkBox_AllowRunning->setChecked(map->allowRunning); + ui->checkBox_AllowBiking->setChecked(map->allowBiking); + ui->checkBox_AllowEscaping->setChecked(map->allowEscaping); ui->spinBox_FloorNumber->setValue(map->floorNumber); // Custom fields table. diff --git a/src/project.cpp b/src/project.cpp index c6a1dd5c..dbf04f41 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -164,7 +164,7 @@ const QSet defaultTopLevelMapFields = { QSet Project::getTopLevelMapFields() { QSet topLevelMapFields = defaultTopLevelMapFields; - if (projectConfig.getBaseGameVersion() != BaseGameVersion::pokeruby) { + if (projectConfig.getMapAllowFlagsEnabled()) { topLevelMapFields.insert("allow_cycling"); topLevelMapFields.insert("allow_escaping"); topLevelMapFields.insert("allow_running"); @@ -199,7 +199,7 @@ bool Project::loadMapData(Map* map) { map->show_location = ParseUtil::jsonToBool(mapObj["show_map_name"]); map->battle_scene = ParseUtil::jsonToQString(mapObj["battle_scene"]); - if (projectConfig.getBaseGameVersion() != BaseGameVersion::pokeruby) { + if (projectConfig.getMapAllowFlagsEnabled()) { map->allowBiking = ParseUtil::jsonToBool(mapObj["allow_cycling"]); map->allowEscaping = ParseUtil::jsonToBool(mapObj["allow_escaping"]); map->allowRunning = ParseUtil::jsonToBool(mapObj["allow_running"]); @@ -382,15 +382,10 @@ void Project::setNewMapHeader(Map* map, int mapIndex) { map->type = mapTypes.value(0, "MAP_TYPE_NONE"); map->song = defaultSong; map->show_location = true; - if (projectConfig.getBaseGameVersion() != BaseGameVersion::pokeruby) { - map->allowBiking = true; - map->allowEscaping = false; - map->allowRunning = true; - } - if (projectConfig.getFloorNumberEnabled()) { - map->floorNumber = 0; - } - + map->allowBiking = true; + map->allowEscaping = false; + map->allowRunning = true; + map->floorNumber = 0; map->battle_scene = mapBattleScenes.value(0, "MAP_BATTLE_SCENE_NORMAL"); } @@ -1263,7 +1258,7 @@ void Project::saveMap(Map *map) { mapObj["requires_flash"] = map->requiresFlash; mapObj["weather"] = map->weather; mapObj["map_type"] = map->type; - if (projectConfig.getBaseGameVersion() != BaseGameVersion::pokeruby) { + if (projectConfig.getMapAllowFlagsEnabled()) { mapObj["allow_cycling"] = map->allowBiking; mapObj["allow_escaping"] = map->allowEscaping; mapObj["allow_running"] = map->allowRunning; diff --git a/src/ui/newmappopup.cpp b/src/ui/newmappopup.cpp index 31d85954..9965e7d3 100644 --- a/src/ui/newmappopup.cpp +++ b/src/ui/newmappopup.cpp @@ -46,7 +46,7 @@ void NewMapPopup::init() { ui->spinBox_NewMap_Floor_Number->setMaximum(127); // Hide config specific ui elements - bool hasFlags = (projectConfig.getBaseGameVersion() != BaseGameVersion::pokeruby); + bool hasFlags = projectConfig.getMapAllowFlagsEnabled(); ui->checkBox_NewMap_Allow_Running->setVisible(hasFlags); ui->checkBox_NewMap_Allow_Biking->setVisible(hasFlags); ui->checkBox_NewMap_Allow_Escape_Rope->setVisible(hasFlags); @@ -291,7 +291,7 @@ void NewMapPopup::on_pushButton_NewMap_Accept_clicked() { newMap->needsHealLocation = true; } - if (projectConfig.getBaseGameVersion() != BaseGameVersion::pokeruby) { + if (projectConfig.getMapAllowFlagsEnabled()) { newMap->allowRunning = this->ui->checkBox_NewMap_Allow_Running->isChecked(); newMap->allowBiking = this->ui->checkBox_NewMap_Allow_Biking->isChecked(); newMap->allowEscaping = this->ui->checkBox_NewMap_Allow_Escape_Rope->isChecked();