From ebdab421cba79edffc9b65943001698a14faba46 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Wed, 26 Dec 2018 12:20:51 -0600 Subject: [PATCH] Pivot map header experience based on base_game_version --- forms/mainwindow.ui | 139 +++++++++++++++++++++++++++++-------------- include/core/map.h | 3 + include/mainwindow.h | 4 ++ src/mainwindow.cpp | 64 ++++++++++++++++++++ src/project.cpp | 49 ++++++++++++++- 5 files changed, 212 insertions(+), 47 deletions(-) diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index d1ace048..20918c31 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -158,7 +158,7 @@ - 0 + 2 false @@ -482,8 +482,8 @@ 0 0 - 481 - 606 + 469 + 608 @@ -797,8 +797,8 @@ 0 0 - 300 - 70 + 324 + 77 @@ -909,8 +909,8 @@ 0 0 - 304 - 372 + 307 + 387 @@ -1226,8 +1226,8 @@ 0 0 - 385 - 655 + 381 + 657 @@ -1499,8 +1499,8 @@ 0 0 - 432 - 565 + 430 + 568 @@ -1544,8 +1544,8 @@ 0 0 - 432 - 565 + 98 + 28 @@ -1589,8 +1589,8 @@ 0 0 - 432 - 565 + 98 + 28 @@ -1634,8 +1634,8 @@ 0 0 - 432 - 565 + 98 + 28 @@ -1679,8 +1679,8 @@ 0 0 - 432 - 565 + 98 + 28 @@ -1730,8 +1730,8 @@ 0 0 - 432 - 565 + 98 + 28 @@ -1826,6 +1826,16 @@ + + + + <html><head/><body><p>Whether or not the map is dark and requires Flash to illuminate.</p></body></html> + + + + + + @@ -1860,23 +1870,6 @@ - - - - Show Location Name - - - - - - - <html><head/><body><p>Whether or not to display the location name when the player enters the map.</p></body></html> - - - - - - @@ -1894,10 +1887,68 @@ - - + + + + Show Location Name + + + + + - <html><head/><body><p>Whether or not the map is dark and requires Flash to illuminate.</p></body></html> + <html><head/><body><p>Whether or not to display the location name when the player enters the map.</p></body></html> + + + + + + + + + + Allow Running + + + + + + + <html><head/><body><p>Allows the player to use Running Shoes</p></body></html> + + + + + + + + + + Allow Biking + + + + + + + <html><head/><body><p>Allows the player to use a Bike</p></body></html> + + + + + + + + + + Allow Dig & Escape Rope + + + + + + + <html><head/><body><p>Allows the player to use Dig or Escape Rope</p></body></html> @@ -2234,8 +2285,8 @@ 0 0 - 829 - 552 + 826 + 557 @@ -2407,7 +2458,7 @@ 0 0 1117 - 20 + 21 diff --git a/include/core/map.h b/include/core/map.h index 14c9cf90..542ec4e4 100644 --- a/include/core/map.h +++ b/include/core/map.h @@ -37,6 +37,9 @@ public: QString type; QString unknown; QString show_location; + QString allowRunning; + QString allowBiking; + QString allowEscapeRope; QString battle_scene; MapLayout *layout; bool isPersistedToFile = true; diff --git a/include/mainwindow.h b/include/mainwindow.h index 24b22b5d..60871d4d 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -57,6 +57,9 @@ private slots: void on_comboBox_Type_activated(const QString &arg1); void on_comboBox_BattleScene_activated(const QString &arg1); void on_checkBox_ShowLocation_clicked(bool checked); + void on_checkBox_AllowRunning_clicked(bool checked); + void on_checkBox_AllowBiking_clicked(bool checked); + void on_checkBox_AllowEscapeRope_clicked(bool checked); void on_tabWidget_currentChanged(int index); @@ -192,6 +195,7 @@ private: void initEditor(); void initMiscHeapObjects(); void initMapSortOrder(); + void setProjectSpecificUIVisibility(); void loadUserSettings(); bool openRecentProject(); void updateTilesetEditor(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e28859be..bc2cac93 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -141,6 +141,29 @@ void MainWindow::initMapSortOrder() { sortOrder->setChecked(true); } +void MainWindow::setProjectSpecificUIVisibility() +{ + switch (projectConfig.getBaseGameVersion()) + { + case BaseGameVersion::pokeruby: + ui->checkBox_AllowRunning->setVisible(false); + ui->checkBox_AllowBiking->setVisible(false); + ui->checkBox_AllowEscapeRope->setVisible(false); + ui->label_AllowRunning->setVisible(false); + ui->label_AllowBiking->setVisible(false); + ui->label_AllowEscapeRope->setVisible(false); + break; + case BaseGameVersion::pokeemerald: + ui->checkBox_AllowRunning->setVisible(true); + ui->checkBox_AllowBiking->setVisible(true); + ui->checkBox_AllowEscapeRope->setVisible(true); + ui->label_AllowRunning->setVisible(true); + ui->label_AllowBiking->setVisible(true); + ui->label_AllowEscapeRope->setVisible(true); + break; + } +} + void MainWindow::mapSortOrder_changed(QAction *action) { QList items = ui->toolButton_MapSortOrder->menu()->actions(); @@ -199,6 +222,8 @@ bool MainWindow::openProject(QString dir) { projectConfig.setProjectDir(dir); projectConfig.load(); + this->setProjectSpecificUIVisibility(); + bool already_open = isProjectOpen() && (editor->project->root == dir); if (!already_open) { editor->project = new Project; @@ -395,6 +420,9 @@ void MainWindow::displayMapProperties() { ui->comboBox_PrimaryTileset->clear(); ui->comboBox_SecondaryTileset->clear(); ui->checkBox_ShowLocation->setChecked(false); + ui->checkBox_AllowRunning->setChecked(false); + ui->checkBox_AllowBiking->setChecked(false); + ui->checkBox_AllowEscapeRope->setChecked(false); if (!editor || !editor->map || !editor->project) { ui->frame_3->setEnabled(false); return; @@ -428,6 +456,9 @@ void MainWindow::displayMapProperties() { ui->comboBox_BattleScene->setCurrentText(map->battle_scene); ui->checkBox_ShowLocation->setChecked(map->show_location.toInt() > 0 || map->show_location == "TRUE"); + 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"); } void MainWindow::on_comboBox_Song_activated(const QString &song) @@ -494,6 +525,39 @@ void MainWindow::on_checkBox_ShowLocation_clicked(bool checked) } } +void MainWindow::on_checkBox_AllowRunning_clicked(bool checked) +{ + if (editor && editor->map) { + if (checked) { + editor->map->allowRunning = "1"; + } else { + editor->map->allowRunning = "0"; + } + } +} + +void MainWindow::on_checkBox_AllowBiking_clicked(bool checked) +{ + if (editor && editor->map) { + if (checked) { + editor->map->allowBiking = "1"; + } else { + editor->map->allowBiking = "0"; + } + } +} + +void MainWindow::on_checkBox_AllowEscapeRope_clicked(bool checked) +{ + if (editor && editor->map) { + if (checked) { + editor->map->allowEscapeRope = "1"; + } else { + editor->map->allowEscapeRope = "0"; + } + } +} + void MainWindow::loadDataStructures() { Project *project = editor->project; project->readMapLayoutsTable(); diff --git a/src/project.cpp b/src/project.cpp index f4e0ac72..01a39aa7 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -1,4 +1,5 @@ #include "project.h" +#include "config.h" #include "history.h" #include "historyitem.h" #include "log.h" @@ -186,8 +187,41 @@ bool Project::readMapHeader(Map* map) { map->weather = header->value(8); map->type = header->value(9); map->unknown = header->value(10); - map->show_location = header->value(11); - map->battle_scene = header->value(12); + if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokeruby) { + map->show_location = header->value(11); + map->battle_scene = header->value(12); + } else if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokeemerald) { + QString allow_bike = header->value(11); + if (allow_bike.startsWith("allow_bike")) { + map->allowBiking = allow_bike.split("=").last(); + } else { + logError(QString("Expected 'allow_bike', but encountered '%1' in '%2' header").arg(allow_bike).arg(map->name)); + } + + QString allow_escape_rope = header->value(12); + if (allow_escape_rope.startsWith("allow_escape_rope")) { + map->allowEscapeRope = allow_escape_rope.split("=").last(); + } else { + logError(QString("Expected 'allow_escape_rope', but encountered '%1' in '%2' header").arg(allow_escape_rope).arg(map->name)); + } + + QString allow_run = header->value(13); + if (allow_run.startsWith("allow_run")) { + map->allowRunning = allow_run.split("=").last(); + } else { + logError(QString("Expected 'allow_run', but encountered '%1' in '%2' header").arg(allow_run).arg(map->name)); + } + + QString show_map_name = header->value(14); + if (show_map_name.startsWith("show_map_name")) { + map->show_location = show_map_name.split("=").last(); + } else { + logError(QString("Expected 'show_map_name', but encountered '%1' in '%2' header").arg(show_map_name).arg(map->name)); + } + + map->battle_scene = header->value(15); + } + return true; } @@ -260,7 +294,16 @@ void Project::saveMapHeader(Map *map) { text += QString("\t.byte %1\n").arg(map->weather); text += QString("\t.byte %1\n").arg(map->type); text += QString("\t.2byte %1\n").arg(map->unknown); - text += QString("\t.byte %1\n").arg(map->show_location); + if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokeruby) { + text += QString("\t.byte %1\n").arg(map->show_location); + } else if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokeemerald) { + text += QString("\tmap_header_flags allow_bike=%1, allow_escape_rope=%2, allow_run=%3, show_map_name=%4\n") + .arg(map->allowBiking) + .arg(map->allowEscapeRope) + .arg(map->allowRunning) + .arg(map->show_location); + } + text += QString("\t.byte %1\n").arg(map->battle_scene); saveTextFile(header_path, text); }