Stop treating map header bools as strings

This commit is contained in:
GriffinR 2022-10-14 18:11:11 -04:00
parent 614242f1fe
commit 239f3935bf
7 changed files with 57 additions and 85 deletions

View file

@ -2013,14 +2013,14 @@
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_AllowEscapeRope">
<widget class="QLabel" name="label_AllowEscaping">
<property name="text">
<string>Allow Dig &amp; Escape Rope</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QCheckBox" name="checkBox_AllowEscapeRope">
<widget class="QCheckBox" name="checkBox_AllowEscaping">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Allows the player to use Dig or Escape Rope&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>

View file

@ -42,14 +42,13 @@ public:
QString song;
QString layoutId;
QString location;
QString requiresFlash;
QString isFlyable;
bool requiresFlash;
QString weather;
QString type;
QString show_location;
QString allowRunning;
QString allowBiking;
QString allowEscapeRope;
bool show_location;
bool allowRunning;
bool allowBiking;
bool allowEscaping;
int floorNumber = 0;
QString battle_scene;
QString sharedEventsMap = "";
@ -59,6 +58,7 @@ public:
bool isPersistedToFile = true;
bool hasUnsavedDataChanges = false;
bool needsLayoutDir = true;
bool needsHealLocation = false;
QImage collision_image;
QPixmap collision_pixmap;
QImage image;

View file

@ -194,7 +194,7 @@ private slots:
void on_checkBox_ShowLocation_stateChanged(int selected);
void on_checkBox_AllowRunning_stateChanged(int selected);
void on_checkBox_AllowBiking_stateChanged(int selected);
void on_checkBox_AllowEscapeRope_stateChanged(int selected);
void on_checkBox_AllowEscaping_stateChanged(int selected);
void on_spinBox_FloorNumber_valueChanged(int offset);
void on_actionUse_Encounter_Json_triggered(bool checked);
void on_actionMonitor_Project_Files_triggered(bool checked);

View file

@ -366,28 +366,28 @@ void MainWindow::setProjectSpecificUIVisibility()
case BaseGameVersion::pokeruby:
ui->checkBox_AllowRunning->setVisible(false);
ui->checkBox_AllowBiking->setVisible(false);
ui->checkBox_AllowEscapeRope->setVisible(false);
ui->checkBox_AllowEscaping->setVisible(false);
ui->label_AllowRunning->setVisible(false);
ui->label_AllowBiking->setVisible(false);
ui->label_AllowEscapeRope->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_AllowEscapeRope->setVisible(true);
ui->checkBox_AllowEscaping->setVisible(true);
ui->label_AllowRunning->setVisible(true);
ui->label_AllowBiking->setVisible(true);
ui->label_AllowEscapeRope->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_AllowEscapeRope->setVisible(true);
ui->checkBox_AllowEscaping->setVisible(true);
ui->label_AllowRunning->setVisible(true);
ui->label_AllowBiking->setVisible(true);
ui->label_AllowEscapeRope->setVisible(true);
ui->label_AllowEscaping->setVisible(true);
// TODO: pokefirered is not set up for the Region Map Editor and vice versa.
// porymap will crash on attempt. Remove below once resolved
ui->actionRegion_Map_Editor->setVisible(true);
@ -763,13 +763,13 @@ void MainWindow::displayMapProperties() {
const QSignalBlocker blockerA(ui->checkBox_AllowRunning);
const QSignalBlocker blockerB(ui->checkBox_AllowBiking);
const QSignalBlocker blockerC(ui->spinBox_FloorNumber);
const QSignalBlocker blockerD(ui->checkBox_AllowEscapeRope);
const QSignalBlocker blockerD(ui->checkBox_AllowEscaping);
ui->checkBox_Visibility->setChecked(false);
ui->checkBox_ShowLocation->setChecked(false);
ui->checkBox_AllowRunning->setChecked(false);
ui->checkBox_AllowBiking->setChecked(false);
ui->checkBox_AllowEscapeRope->setChecked(false);
ui->checkBox_AllowEscaping->setChecked(false);
if (!editor || !editor->map || !editor->project) {
ui->frame_3->setEnabled(false);
return;
@ -787,15 +787,15 @@ void MainWindow::displayMapProperties() {
ui->comboBox_Song->setCurrentText(map->song);
ui->comboBox_Location->setCurrentText(map->location);
ui->checkBox_Visibility->setChecked(ParseUtil::gameStringToBool(map->requiresFlash));
ui->checkBox_Visibility->setChecked(map->requiresFlash);
ui->comboBox_Weather->setCurrentText(map->weather);
ui->comboBox_Type->setCurrentText(map->type);
ui->comboBox_BattleScene->setCurrentText(map->battle_scene);
ui->checkBox_ShowLocation->setChecked(ParseUtil::gameStringToBool(map->show_location));
ui->checkBox_ShowLocation->setChecked(map->show_location);
if (projectConfig.getBaseGameVersion() != BaseGameVersion::pokeruby) {
ui->checkBox_AllowRunning->setChecked(ParseUtil::gameStringToBool(map->allowRunning));
ui->checkBox_AllowBiking->setChecked(ParseUtil::gameStringToBool(map->allowBiking));
ui->checkBox_AllowEscapeRope->setChecked(ParseUtil::gameStringToBool(map->allowEscapeRope));
ui->checkBox_AllowRunning->setChecked(map->allowRunning);
ui->checkBox_AllowBiking->setChecked(map->allowBiking);
ui->checkBox_AllowEscaping->setChecked(map->allowEscaping);
}
ui->spinBox_FloorNumber->setValue(map->floorNumber);
@ -854,12 +854,7 @@ void MainWindow::on_comboBox_BattleScene_currentTextChanged(const QString &battl
void MainWindow::on_checkBox_Visibility_stateChanged(int selected)
{
if (editor && editor->map) {
bool checked = selected == Qt::Checked;
if (checked) {
editor->map->requiresFlash = "TRUE";
} else {
editor->map->requiresFlash = "FALSE";
}
editor->map->requiresFlash = (selected == Qt::Checked);
markMapEdited();
}
}
@ -867,12 +862,7 @@ void MainWindow::on_checkBox_Visibility_stateChanged(int selected)
void MainWindow::on_checkBox_ShowLocation_stateChanged(int selected)
{
if (editor && editor->map) {
bool checked = selected == Qt::Checked;
if (checked) {
editor->map->show_location = "TRUE";
} else {
editor->map->show_location = "FALSE";
}
editor->map->show_location = (selected == Qt::Checked);
markMapEdited();
}
}
@ -880,12 +870,7 @@ void MainWindow::on_checkBox_ShowLocation_stateChanged(int selected)
void MainWindow::on_checkBox_AllowRunning_stateChanged(int selected)
{
if (editor && editor->map) {
bool checked = selected == Qt::Checked;
if (checked) {
editor->map->allowRunning = "1";
} else {
editor->map->allowRunning = "0";
}
editor->map->allowRunning = (selected == Qt::Checked);
markMapEdited();
}
}
@ -893,25 +878,15 @@ void MainWindow::on_checkBox_AllowRunning_stateChanged(int selected)
void MainWindow::on_checkBox_AllowBiking_stateChanged(int selected)
{
if (editor && editor->map) {
bool checked = selected == Qt::Checked;
if (checked) {
editor->map->allowBiking = "1";
} else {
editor->map->allowBiking = "0";
}
editor->map->allowBiking = (selected == Qt::Checked);
markMapEdited();
}
}
void MainWindow::on_checkBox_AllowEscapeRope_stateChanged(int selected)
void MainWindow::on_checkBox_AllowEscaping_stateChanged(int selected)
{
if (editor && editor->map) {
bool checked = selected == Qt::Checked;
if (checked) {
editor->map->allowEscapeRope = "1";
} else {
editor->map->allowEscapeRope = "0";
}
editor->map->allowEscaping = (selected == Qt::Checked);
markMapEdited();
}
}
@ -1196,7 +1171,7 @@ void MainWindow::onNewMapCreated() {
sortMapList();
setMap(newMapName, true);
if (ParseUtil::gameStringToBool(newMap->isFlyable)) {
if (newMap->needsHealLocation) {
addNewEvent(EventType::HealLocation);
editor->project->saveHealLocationStruct(newMap);
editor->save();// required

View file

@ -193,16 +193,15 @@ bool Project::loadMapData(Map* map) {
map->song = mapObj["music"].toString();
map->layoutId = mapObj["layout"].toString();
map->location = mapObj["region_map_section"].toString();
map->requiresFlash = QString::number(mapObj["requires_flash"].toBool());
map->requiresFlash = mapObj["requires_flash"].toBool();
map->weather = mapObj["weather"].toString();
map->type = mapObj["map_type"].toString();
map->requiresFlash = QString::number(mapObj["requires_flash"].toBool());
map->show_location = QString::number(mapObj["show_map_name"].toBool());
map->show_location = mapObj["show_map_name"].toBool();
map->battle_scene = mapObj["battle_scene"].toString();
if (projectConfig.getBaseGameVersion() != BaseGameVersion::pokeruby) {
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->allowBiking = mapObj["allow_cycling"].toBool();
map->allowEscaping = mapObj["allow_escaping"].toBool();
map->allowRunning = mapObj["allow_running"].toBool();
}
if (projectConfig.getFloorNumberEnabled()) {
map->floorNumber = mapObj["floor_number"].toInt();
@ -453,17 +452,15 @@ QString Project::readMapLocation(QString map_name) {
void Project::setNewMapHeader(Map* map, int mapIndex) {
map->layoutId = QString("%1").arg(mapIndex);
map->location = mapSectionValueToName.value(0);
map->requiresFlash = "FALSE";
map->requiresFlash = false;
map->weather = weatherNames.value(0, "WEATHER_NONE");
map->type = mapTypes.value(0, "MAP_TYPE_NONE");
map->song = defaultSong;
if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokeruby) {
map->show_location = "TRUE";
} else {
map->allowBiking = "1";
map->allowEscapeRope = "0";
map->allowRunning = "1";
map->show_location = "1";
map->show_location = true;
if (projectConfig.getBaseGameVersion() != BaseGameVersion::pokeruby) {
map->allowBiking = true;
map->allowEscaping = false;
map->allowRunning = true;
}
if (projectConfig.getFloorNumberEnabled()) {
map->floorNumber = 0;
@ -1341,15 +1338,15 @@ void Project::saveMap(Map *map) {
mapObj["layout"] = map->layout->id;
mapObj["music"] = map->song;
mapObj["region_map_section"] = map->location;
mapObj["requires_flash"] = ParseUtil::gameStringToBool(map->requiresFlash);
mapObj["requires_flash"] = map->requiresFlash;
mapObj["weather"] = map->weather;
mapObj["map_type"] = map->type;
if (projectConfig.getBaseGameVersion() != BaseGameVersion::pokeruby) {
mapObj["allow_cycling"] = ParseUtil::gameStringToBool(map->allowBiking);
mapObj["allow_escaping"] = ParseUtil::gameStringToBool(map->allowEscapeRope);
mapObj["allow_running"] = ParseUtil::gameStringToBool(map->allowRunning);
mapObj["allow_cycling"] = map->allowBiking;
mapObj["allow_escaping"] = map->allowEscaping;
mapObj["allow_running"] = map->allowRunning;
}
mapObj["show_map_name"] = ParseUtil::gameStringToBool(map->show_location);
mapObj["show_map_name"] = map->show_location;
if (projectConfig.getFloorNumberEnabled()) {
mapObj["floor_number"] = map->floorNumber;
}

View file

@ -815,7 +815,7 @@ void MainWindow::setLocation(QString location) {
bool MainWindow::getRequiresFlash() {
if (!this->editor || !this->editor->map)
return false;
return ParseUtil::gameStringToBool(this->editor->map->requiresFlash);
return this->editor->map->requiresFlash;
}
void MainWindow::setRequiresFlash(bool require) {
@ -875,7 +875,7 @@ void MainWindow::setBattleScene(QString battleScene) {
bool MainWindow::getShowLocationName() {
if (!this->editor || !this->editor->map)
return false;
return ParseUtil::gameStringToBool(this->editor->map->show_location);
return this->editor->map->show_location;
}
void MainWindow::setShowLocationName(bool show) {
@ -887,7 +887,7 @@ void MainWindow::setShowLocationName(bool show) {
bool MainWindow::getAllowRunning() {
if (!this->editor || !this->editor->map)
return false;
return ParseUtil::gameStringToBool(this->editor->map->allowRunning);
return this->editor->map->allowRunning;
}
void MainWindow::setAllowRunning(bool allow) {
@ -899,7 +899,7 @@ void MainWindow::setAllowRunning(bool allow) {
bool MainWindow::getAllowBiking() {
if (!this->editor || !this->editor->map)
return false;
return ParseUtil::gameStringToBool(this->editor->map->allowBiking);
return this->editor->map->allowBiking;
}
void MainWindow::setAllowBiking(bool allow) {
@ -911,13 +911,13 @@ void MainWindow::setAllowBiking(bool allow) {
bool MainWindow::getAllowEscaping() {
if (!this->editor || !this->editor->map)
return false;
return ParseUtil::gameStringToBool(this->editor->map->allowEscapeRope);
return this->editor->map->allowEscaping;
}
void MainWindow::setAllowEscaping(bool allow) {
if (!this->ui)
return;
this->ui->checkBox_AllowEscapeRope->setChecked(allow);
this->ui->checkBox_AllowEscaping->setChecked(allow);
}
int MainWindow::getFloorNumber() {

View file

@ -266,9 +266,9 @@ void NewMapPopup::on_pushButton_NewMap_Accept_clicked() {
newMap->type = this->ui->comboBox_NewMap_Type->currentText();
newMap->location = this->ui->comboBox_NewMap_Location->currentText();
newMap->song = this->ui->comboBox_Song->currentText();
newMap->requiresFlash = "0";
newMap->requiresFlash = false;
newMap->weather = this->project->weatherNames.value(0, "WEATHER_NONE");
newMap->show_location = this->ui->checkBox_NewMap_Show_Location->isChecked() ? "1" : "0";
newMap->show_location = this->ui->checkBox_NewMap_Show_Location->isChecked();
newMap->battle_scene = this->project->mapBattleScenes.value(0, "MAP_BATTLE_SCENE_NORMAL");
if (this->existingLayout) {
@ -301,13 +301,13 @@ void NewMapPopup::on_pushButton_NewMap_Accept_clicked() {
}
if (this->ui->checkBox_NewMap_Flyable->isChecked()) {
newMap->isFlyable = "TRUE";
newMap->needsHealLocation = true;
}
if (projectConfig.getBaseGameVersion() != BaseGameVersion::pokeruby) {
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->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();
}
if (projectConfig.getFloorNumberEnabled()) {
newMap->floorNumber = this->ui->spinBox_NewMap_Floor_Number->value();