diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui
index 68d458c9..676b8174 100644
--- a/forms/mainwindow.ui
+++ b/forms/mainwindow.ui
@@ -2094,6 +2094,23 @@
+ -
+
+
+ Floor Number
+
+
+
+ -
+
+
+ <html><head/><body><p>Floor number to be used for maps with elevators.</p></body></html>
+
+
+ 127
+
+
+
diff --git a/forms/newmappopup.ui b/forms/newmappopup.ui
index 209c078d..41aaaf77 100644
--- a/forms/newmappopup.ui
+++ b/forms/newmappopup.ui
@@ -231,6 +231,23 @@
+ -
+
+
+ Floor Number
+
+
+
+ -
+
+
+ <html><head/><body><p>Floor number to be used for maps with elevators.</p></body></html>
+
+
+ 127
+
+
+
diff --git a/include/core/map.h b/include/core/map.h
index 8ecc0a9e..7f9ff989 100644
--- a/include/core/map.h
+++ b/include/core/map.h
@@ -35,6 +35,7 @@ public:
QString allowRunning;
QString allowBiking;
QString allowEscapeRope;
+ int floorNumber;
QString battle_scene;
QString sharedEventsMap = "";
QString sharedScriptsMap = "";
diff --git a/src/config.cpp b/src/config.cpp
index ed76cd1b..50e5ca83 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -324,11 +324,13 @@ QString PorymapConfig::getTheme() {
const QMap baseGameVersionMap = {
{BaseGameVersion::pokeruby, "pokeruby"},
+ {BaseGameVersion::pokefirered, "pokefirered"},
{BaseGameVersion::pokeemerald, "pokeemerald"},
};
const QMap baseGameVersionReverseMap = {
{"pokeruby", BaseGameVersion::pokeruby},
+ {"pokefirered", BaseGameVersion::pokefirered},
{"pokeemerald", BaseGameVersion::pokeemerald},
};
@@ -346,7 +348,7 @@ void ProjectConfig::parseConfigKeyValue(QString key, QString value) {
this->baseGameVersion = baseGameVersionReverseMap.value(baseGameVersion);
} else {
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', 'pokefirered' or 'pokeemerald'.").arg(value));
}
} else if (key == "use_encounter_json") {
bool ok;
@@ -387,6 +389,7 @@ void ProjectConfig::onNewConfigFileCreated() {
QComboBox *baseGameVersionComboBox = new QComboBox();
baseGameVersionComboBox->addItem("pokeruby", BaseGameVersion::pokeruby);
+ baseGameVersionComboBox->addItem("pokefirered", BaseGameVersion::pokefirered);
baseGameVersionComboBox->addItem("pokeemerald", BaseGameVersion::pokeemerald);
form.addRow(new QLabel("Game Version"), baseGameVersionComboBox);
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index fc0c2f12..4fe9f98b 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -160,19 +160,31 @@ void MainWindow::setProjectSpecificUIVisibility()
ui->checkBox_AllowRunning->setVisible(false);
ui->checkBox_AllowBiking->setVisible(false);
ui->checkBox_AllowEscapeRope->setVisible(false);
+ ui->spinBox_FloorNumber->setVisible(false);
ui->label_AllowRunning->setVisible(false);
ui->label_AllowBiking->setVisible(false);
ui->label_AllowEscapeRope->setVisible(false);
+ ui->label_FloorNumber->setVisible(false);
break;
case BaseGameVersion::pokeemerald:
ui->checkBox_AllowRunning->setVisible(true);
ui->checkBox_AllowBiking->setVisible(true);
ui->checkBox_AllowEscapeRope->setVisible(true);
+ ui->spinBox_FloorNumber->setVisible(false);
ui->label_AllowRunning->setVisible(true);
ui->label_AllowBiking->setVisible(true);
ui->label_AllowEscapeRope->setVisible(true);
+ ui->label_FloorNumber->setVisible(false);
break;
case BaseGameVersion::pokefirered:
+ ui->checkBox_AllowRunning->setVisible(true);
+ ui->checkBox_AllowBiking->setVisible(true);
+ ui->checkBox_AllowEscapeRope->setVisible(true);
+ ui->spinBox_FloorNumber->setVisible(true);
+ ui->label_AllowRunning->setVisible(true);
+ ui->label_AllowBiking->setVisible(true);
+ ui->label_AllowEscapeRope->setVisible(true);
+ ui->label_FloorNumber->setVisible(true);
break;
}
}
@@ -504,6 +516,7 @@ void MainWindow::displayMapProperties() {
ui->checkBox_AllowRunning->setChecked(map->allowRunning.toInt() > 0 || map->allowRunning == "TRUE");
ui->checkBox_AllowBiking->setChecked(map->allowBiking.toInt() > 0 || map->allowBiking == "TRUE");
ui->checkBox_AllowEscapeRope->setChecked(map->allowEscapeRope.toInt() > 0 || map->allowEscapeRope == "TRUE");
+ ui->spinBox_FloorNumber->setValue(map->floorNumber);
// Custom fields table.
ui->tableWidget_CustomHeaderFields->blockSignals(true);
@@ -620,7 +633,6 @@ bool MainWindow::loadDataStructures() {
&& project->readMapBattleScenes()
&& project->readWeatherNames()
&& project->readCoordEventWeatherNames()
- && project->readSecretBaseIds()
&& project->readBgEventFacingDirections()
&& project->readMetatileBehaviors()
&& project->readTilesetProperties()
@@ -628,6 +640,8 @@ bool MainWindow::loadDataStructures() {
&& project->readMiscellaneousConstants()
&& project->readSpeciesIconPaths()
&& project->readWildMonData();
+ if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokeemerald || projectConfig.getBaseGameVersion() == BaseGameVersion::pokeruby)
+ success = success && project->readSecretBaseIds();
if (!success) {
return false;
}
diff --git a/src/project.cpp b/src/project.cpp
index 20c864cc..294b6d45 100644
--- a/src/project.cpp
+++ b/src/project.cpp
@@ -100,8 +100,8 @@ QMap Project::getTopLevelMapFields() {
{"requires_flash", true},
{"weather", true},
{"map_type", true},
- {"allow_bike", true},
- {"allow_escape_rope", true},
+ {"allow_cycling", true},
+ {"allow_escaping", true},
{"allow_running", true},
{"show_map_name", true},
{"battle_scene", true},
@@ -113,6 +113,31 @@ QMap Project::getTopLevelMapFields() {
{"shared_events_map", true},
{"shared_scripts_map", true},
};
+ } else if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered) {
+ return QMap
+ {
+ {"id", true},
+ {"name", true},
+ {"layout", true},
+ {"music", true},
+ {"region_map_section", true},
+ {"requires_flash", true},
+ {"weather", true},
+ {"map_type", true},
+ {"allow_cycling", true},
+ {"allow_escaping", true},
+ {"allow_running", true},
+ {"show_map_name", true},
+ {"floor_number", true},
+ {"battle_scene", true},
+ {"connections", true},
+ {"object_events", true},
+ {"warp_events", true},
+ {"coord_events", true},
+ {"bg_events", true},
+ {"shared_events_map", true},
+ {"shared_scripts_map", true},
+ };
} else if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokeruby) {
return QMap
{
@@ -164,9 +189,14 @@ bool Project::loadMapData(Map* map) {
map->show_location = QString::number(mapObj["show_map_name"].toBool());
map->battle_scene = mapObj["battle_scene"].toString();
if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokeemerald) {
- map->allowBiking = QString::number(mapObj["allow_bike"].toBool());
- map->allowEscapeRope = QString::number(mapObj["allow_escape_rope"].toBool());
+ map->allowBiking = QString::number(mapObj["allow_cycling"].toBool());
+ map->allowEscapeRope = QString::number(mapObj["allow_escaping"].toBool());
map->allowRunning = QString::number(mapObj["allow_running"].toBool());
+ } else if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered) {
+ map->allowBiking = QString::number(mapObj["allow_cycling"].toBool());
+ map->allowEscapeRope = QString::number(mapObj["allow_escaping"].toBool());
+ map->allowRunning = QString::number(mapObj["allow_running"].toBool());
+ map->floorNumber = mapObj["floor_number"].toInt();
}
map->sharedEventsMap = mapObj["shared_events_map"].toString();
map->sharedScriptsMap = mapObj["shared_scripts_map"].toString();
@@ -386,6 +416,12 @@ void Project::setNewMapHeader(Map* map, int mapIndex) {
map->allowEscapeRope = "0";
map->allowRunning = "1";
map->show_location = "1";
+ } else if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered) {
+ map->allowBiking = "1";
+ map->allowEscapeRope = "0";
+ map->allowRunning = "1";
+ map->show_location = "1";
+ map->floorNumber = 0;
}
map->battle_scene = "MAP_BATTLE_SCENE_NORMAL";
@@ -446,6 +482,8 @@ bool Project::readMapLayouts() {
};
for (int i = 0; i < layouts.size(); i++) {
QJsonObject layoutObj = layouts[i].toObject();
+ if (layoutObj.isEmpty())
+ continue;
if (!parser.ensureFieldsExist(layoutObj, requiredFields)) {
logError(QString("Layout %1 is missing field(s) in %2.").arg(i).arg(layoutsFilepath));
return false;
@@ -1048,14 +1086,14 @@ 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) {
+ if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokeruby || projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered) {
// Create file data/maps//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) {
+ if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokeruby || projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered) {
text += QString("\t.include \"data/maps/%1/text.inc\"\n").arg(map->name);
}
appendTextFile(root + "/data/event_scripts.s", text);
@@ -1115,10 +1153,11 @@ void Project::saveMap(Map *map) {
mapObj["requires_flash"] = map->requiresFlash.toInt() > 0 || map->requiresFlash == "TRUE";
mapObj["weather"] = map->weather;
mapObj["map_type"] = map->type;
- mapObj["allow_bike"] = map->allowBiking.toInt() > 0 || map->allowBiking == "TRUE";
- mapObj["allow_escape_rope"] = map->allowEscapeRope.toInt() > 0 || map->allowEscapeRope == "TRUE";
+ mapObj["allow_cycling"] = map->allowBiking.toInt() > 0 || map->allowBiking == "TRUE";
+ mapObj["allow_escaping"] = map->allowEscapeRope.toInt() > 0 || map->allowEscapeRope == "TRUE";
mapObj["allow_running"] = map->allowRunning.toInt() > 0 || map->allowRunning == "TRUE";
mapObj["show_map_name"] = map->show_location.toInt() > 0 || map->show_location == "TRUE";
+ mapObj["floor_number"] = map->floorNumber;
mapObj["battle_scene"] = map->battle_scene;
// Connections
@@ -1863,6 +1902,9 @@ bool Project::readMovementTypes() {
}
bool Project::readInitialFacingDirections() {
+ // TODO: This file is not yet decompiled in pokefirered. Remove once resolved
+ if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered)
+ return true;
QString filename = "src/event_object_movement.c";
facingDirections = parser.readNamedIndexCArray(filename, "gInitialMovementTypeFacingDirections");
if (facingDirections.isEmpty()) {
@@ -1909,6 +1951,8 @@ bool Project::readWeatherNames() {
}
bool Project::readCoordEventWeatherNames() {
+ if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered)
+ return true;
coordEventWeatherNames->clear();
QStringList prefixes = (QStringList() << "COORD_EVENT_WEATHER_");
QString filename = "include/constants/weather.h";
diff --git a/src/ui/newmappopup.cpp b/src/ui/newmappopup.cpp
index e0938227..9ba8936f 100644
--- a/src/ui/newmappopup.cpp
+++ b/src/ui/newmappopup.cpp
@@ -81,19 +81,31 @@ void NewMapPopup::setDefaultValues(int groupNum, QString mapSec) {
ui->checkBox_NewMap_Allow_Running->setVisible(false);
ui->checkBox_NewMap_Allow_Biking->setVisible(false);
ui->checkBox_NewMap_Allow_Escape_Rope->setVisible(false);
+ ui->spinBox_NewMap_Floor_Number->setVisible(false);
ui->label_NewMap_Allow_Running->setVisible(false);
ui->label_NewMap_Allow_Biking->setVisible(false);
ui->label_NewMap_Allow_Escape_Rope->setVisible(false);
+ ui->label_NewMap_Floor_Number->setVisible(false);
break;
case BaseGameVersion::pokeemerald:
ui->checkBox_NewMap_Allow_Running->setVisible(true);
ui->checkBox_NewMap_Allow_Biking->setVisible(true);
ui->checkBox_NewMap_Allow_Escape_Rope->setVisible(true);
+ ui->spinBox_NewMap_Floor_Number->setVisible(false);
ui->label_NewMap_Allow_Running->setVisible(true);
ui->label_NewMap_Allow_Biking->setVisible(true);
ui->label_NewMap_Allow_Escape_Rope->setVisible(true);
+ ui->label_NewMap_Floor_Number->setVisible(false);
break;
case BaseGameVersion::pokefirered:
+ ui->checkBox_NewMap_Allow_Running->setVisible(true);
+ ui->checkBox_NewMap_Allow_Biking->setVisible(true);
+ ui->checkBox_NewMap_Allow_Escape_Rope->setVisible(true);
+ ui->spinBox_NewMap_Floor_Number->setVisible(true);
+ ui->label_NewMap_Allow_Running->setVisible(true);
+ ui->label_NewMap_Allow_Biking->setVisible(true);
+ ui->label_NewMap_Allow_Escape_Rope->setVisible(true);
+ ui->label_NewMap_Floor_Number->setVisible(true);
break;
}
}
@@ -152,6 +164,11 @@ void NewMapPopup::on_pushButton_NewMap_Accept_clicked() {
newMap->allowRunning = this->ui->checkBox_NewMap_Allow_Running->isChecked() ? "1" : "0";
newMap->allowBiking = this->ui->checkBox_NewMap_Allow_Biking->isChecked() ? "1" : "0";
newMap->allowEscapeRope = this->ui->checkBox_NewMap_Allow_Escape_Rope->isChecked() ? "1" : "0";
+ } else if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered) {
+ newMap->allowRunning = this->ui->checkBox_NewMap_Allow_Running->isChecked() ? "1" : "0";
+ newMap->allowBiking = this->ui->checkBox_NewMap_Allow_Biking->isChecked() ? "1" : "0";
+ newMap->allowEscapeRope = this->ui->checkBox_NewMap_Allow_Escape_Rope->isChecked() ? "1" : "0";
+ newMap->floorNumber = this->ui->spinBox_NewMap_Floor_Number->value();
}
group = project->groupNames->indexOf(this->ui->comboBox_NewMap_Group->currentText());