mirror of
https://github.com/huderlem/porymap.git
synced 2026-09-07 00:15:18 -05:00
Pivot map header experience based on base_game_version
This commit is contained in:
@@ -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<QAction*> 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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user