Support custom fields for top-level map attributes

This commit is contained in:
Marcus Huderle 2019-02-03 10:38:45 -06:00 committed by huderlem
parent d70145d89a
commit a894bea71b
8 changed files with 455 additions and 197 deletions

View file

@ -14,8 +14,8 @@
<string>porymap</string> <string>porymap</string>
</property> </property>
<widget class="QWidget" name="centralWidget"> <widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item row="0" column="0"> <item>
<widget class="QSplitter" name="splitter_main"> <widget class="QSplitter" name="splitter_main">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -1856,209 +1856,337 @@
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_Attributes"> <widget class="QWidget" name="tab_Attributes">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<attribute name="title"> <attribute name="title">
<string>Header</string> <string>Header</string>
</attribute> </attribute>
<widget class="QFrame" name="frame_3"> <layout class="QVBoxLayout" name="gridLayout_Attributes">
<property name="enabled"> <property name="spacing">
<bool>false</bool> <number>0</number>
</property> </property>
<property name="geometry"> <property name="leftMargin">
<rect> <number>0</number>
<x>10</x>
<y>10</y>
<width>381</width>
<height>311</height>
</rect>
</property> </property>
<property name="sizePolicy"> <property name="topMargin">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <number>0</number>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="frameShape"> <property name="rightMargin">
<enum>QFrame::StyledPanel</enum> <number>0</number>
</property> </property>
<property name="frameShadow"> <property name="bottomMargin">
<enum>QFrame::Raised</enum> <number>0</number>
</property> </property>
<layout class="QFormLayout" name="formLayout_2"> <item>
<property name="verticalSpacing"> <widget class="QFrame" name="frame_3">
<number>12</number> <property name="enabled">
</property> <bool>false</bool>
<item row="0" column="0"> </property>
<widget class="QLabel" name="label_3"> <property name="sizePolicy">
<property name="text"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<string>Song</string> <horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::FieldsStayAtSizeHint</enum>
</property> </property>
</widget> <property name="verticalSpacing">
</item> <number>12</number>
<item row="0" column="1">
<widget class="QComboBox" name="comboBox_Song">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The default background music for this map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="editable"> <property name="bottomMargin">
<bool>true</bool> <number>9</number>
</property> </property>
</widget> <item row="0" column="0">
</item> <widget class="QLabel" name="label_3">
<item row="1" column="0"> <property name="text">
<widget class="QLabel" name="label_4"> <string>Song</string>
<property name="text"> </property>
<string>Location</string> </widget>
</property> </item>
</widget> <item row="0" column="1">
</item> <widget class="QComboBox" name="comboBox_Song">
<item row="1" column="1"> <property name="toolTip">
<widget class="QComboBox" name="comboBox_Location"> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The default background music for this map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<property name="toolTip"> </property>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The section of the region map which the map is grouped under. This also determines the name of the map that is display when the player enters it.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <property name="editable">
</property> <bool>true</bool>
<property name="editable"> </property>
<bool>true</bool> </widget>
</property> </item>
</widget> <item row="1" column="0">
</item> <widget class="QLabel" name="label_4">
<item row="2" column="0"> <property name="text">
<widget class="QLabel" name="label_5"> <string>Location</string>
<property name="text"> </property>
<string>Requires Flash</string> </widget>
</property> </item>
</widget> <item row="1" column="1">
</item> <widget class="QComboBox" name="comboBox_Location">
<item row="2" column="1"> <property name="toolTip">
<widget class="QCheckBox" name="checkBox_Visibility"> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The section of the region map which the map is grouped under. This also determines the name of the map that is display when the player enters it.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<property name="toolTip"> </property>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Whether or not the map is dark and requires Flash to illuminate.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <property name="editable">
</property> <bool>true</bool>
<property name="text"> </property>
<string/> </widget>
</property> </item>
</widget> <item row="2" column="0">
</item> <widget class="QLabel" name="label_5">
<item row="3" column="0"> <property name="text">
<widget class="QLabel" name="label_6"> <string>Requires Flash</string>
<property name="text"> </property>
<string>Weather</string> </widget>
</property> </item>
</widget> <item row="2" column="1">
</item> <widget class="QCheckBox" name="checkBox_Visibility">
<item row="3" column="1"> <property name="toolTip">
<widget class="QComboBox" name="comboBox_Weather"> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Whether or not the map is dark and requires Flash to illuminate.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<property name="toolTip"> </property>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The default weather for this map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <property name="text">
</property> <string/>
<property name="editable"> </property>
<bool>true</bool> </widget>
</property> </item>
</widget> <item row="3" column="0">
</item> <widget class="QLabel" name="label_6">
<item row="4" column="0"> <property name="text">
<widget class="QLabel" name="label_7"> <string>Weather</string>
<property name="text"> </property>
<string>Type</string> </widget>
</property> </item>
</widget> <item row="3" column="1">
</item> <widget class="QComboBox" name="comboBox_Weather">
<item row="4" column="1"> <property name="toolTip">
<widget class="QComboBox" name="comboBox_Type"> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The default weather for this map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<property name="toolTip"> </property>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The map type is a general attribute, which is used for many different things. For example. it determines whether biking or running is allowed.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <property name="editable">
</property> <bool>true</bool>
<property name="editable"> </property>
<bool>true</bool> </widget>
</property> </item>
</widget> <item row="4" column="0">
</item> <widget class="QLabel" name="label_7">
<item row="6" column="0"> <property name="text">
<widget class="QLabel" name="label_9"> <string>Type</string>
<property name="text"> </property>
<string>Battle scene</string> </widget>
</property> </item>
</widget> <item row="4" column="1">
</item> <widget class="QComboBox" name="comboBox_Type">
<item row="6" column="1"> <property name="toolTip">
<widget class="QComboBox" name="comboBox_BattleScene"> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The map type is a general attribute, which is used for many different things. For example. it determines whether biking or running is allowed.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<property name="toolTip"> </property>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Determines the type of battle scene graphics to use.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <property name="editable">
</property> <bool>true</bool>
<property name="editable"> </property>
<bool>true</bool> </widget>
</property> </item>
</widget> <item row="6" column="0">
</item> <widget class="QLabel" name="label_9">
<item row="7" column="0"> <property name="text">
<widget class="QLabel" name="label_8"> <string>Battle scene</string>
<property name="text"> </property>
<string>Show Location Name</string> </widget>
</property> </item>
</widget> <item row="6" column="1">
</item> <widget class="QComboBox" name="comboBox_BattleScene">
<item row="7" column="1"> <property name="toolTip">
<widget class="QCheckBox" name="checkBox_ShowLocation"> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Determines the type of battle scene graphics to use.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<property name="toolTip"> </property>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Whether or not to display the location name when the player enters the map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <property name="editable">
</property> <bool>true</bool>
<property name="text"> </property>
<string/> </widget>
</property> </item>
</widget> <item row="7" column="0">
</item> <widget class="QLabel" name="label_8">
<item row="8" column="0"> <property name="text">
<widget class="QLabel" name="label_AllowRunning"> <string>Show Location Name</string>
<property name="text"> </property>
<string>Allow Running</string> </widget>
</property> </item>
</widget> <item row="7" column="1">
</item> <widget class="QCheckBox" name="checkBox_ShowLocation">
<item row="8" column="1"> <property name="toolTip">
<widget class="QCheckBox" name="checkBox_AllowRunning"> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Whether or not to display the location name when the player enters the map.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<property name="toolTip"> </property>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Allows the player to use Running Shoes&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <property name="text">
</property> <string/>
<property name="text"> </property>
<string/> </widget>
</property> </item>
</widget> <item row="8" column="0">
</item> <widget class="QLabel" name="label_AllowRunning">
<item row="9" column="0"> <property name="text">
<widget class="QLabel" name="label_AllowBiking"> <string>Allow Running</string>
<property name="text"> </property>
<string>Allow Biking</string> </widget>
</property> </item>
</widget> <item row="8" column="1">
</item> <widget class="QCheckBox" name="checkBox_AllowRunning">
<item row="9" column="1"> <property name="toolTip">
<widget class="QCheckBox" name="checkBox_AllowBiking"> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Allows the player to use Running Shoes&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<property name="toolTip"> </property>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Allows the player to use a Bike&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <property name="text">
</property> <string/>
<property name="text"> </property>
<string/> </widget>
</property> </item>
</widget> <item row="9" column="0">
</item> <widget class="QLabel" name="label_AllowBiking">
<item row="10" column="0"> <property name="text">
<widget class="QLabel" name="label_AllowEscapeRope"> <string>Allow Biking</string>
<property name="text"> </property>
<string>Allow Dig &amp; Escape Rope</string> </widget>
</property> </item>
</widget> <item row="9" column="1">
</item> <widget class="QCheckBox" name="checkBox_AllowBiking">
<item row="10" column="1"> <property name="toolTip">
<widget class="QCheckBox" name="checkBox_AllowEscapeRope"> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Allows the player to use a Bike&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<property name="toolTip"> </property>
<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 name="text">
</property> <string/>
<property name="text"> </property>
<string/> </widget>
</property> </item>
</widget> <item row="10" column="0">
</item> <widget class="QLabel" name="label_AllowEscapeRope">
</layout> <property name="text">
</widget> <string>Allow Dig &amp; Escape Rope</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QCheckBox" name="checkBox_AllowEscapeRope">
<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>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_keyValue">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Custom Fields</string>
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="pushButton_AddCustomHeaderField">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_DeleteCustomHeaderField">
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tableWidget_CustomHeaderFields">
<property name="toolTip">
<string>Custom fields will be added to the map.json file for the current map.</string>
</property>
<attribute name="horizontalHeaderVisible">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderCascadingSectionResizes">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderHighlightSections">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Key</string>
</property>
</column>
<column>
<property name="text">
<string>Value</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget> </widget>
<widget class="QWidget" name="tab_Connections"> <widget class="QWidget" name="tab_Connections">
<attribute name="title"> <attribute name="title">

View file

@ -38,6 +38,7 @@ public:
QString battle_scene; QString battle_scene;
QString sharedEventsMap = ""; QString sharedEventsMap = "";
QString sharedScriptsMap = ""; QString sharedScriptsMap = "";
QMap<QString, QString> customHeaders;
MapLayout *layout; MapLayout *layout;
bool isPersistedToFile = true; bool isPersistedToFile = true;
bool needsLayoutDir = true; bool needsLayoutDir = true;

View file

@ -74,6 +74,7 @@ public:
void updatePrimaryTileset(QString tilesetLabel, bool forceLoad = false); void updatePrimaryTileset(QString tilesetLabel, bool forceLoad = false);
void updateSecondaryTileset(QString tilesetLabel, bool forceLoad = false); void updateSecondaryTileset(QString tilesetLabel, bool forceLoad = false);
void toggleBorderVisibility(bool visible); void toggleBorderVisibility(bool visible);
void updateCustomMapHeaderValues(QTableWidget *);
Tileset *getCurrentMapPrimaryTileset(); Tileset *getCurrentMapPrimaryTileset();
DraggablePixmapItem *addMapEvent(Event *event); DraggablePixmapItem *addMapEvent(Event *event);

View file

@ -152,12 +152,12 @@ private slots:
void selectedEventIndexChanged(int index); void selectedEventIndexChanged(int index);
void on_horizontalSlider_CollisionTransparency_valueChanged(int value); void on_horizontalSlider_CollisionTransparency_valueChanged(int value);
void on_toolButton_ExpandAll_clicked(); void on_toolButton_ExpandAll_clicked();
void on_toolButton_CollapseAll_clicked(); void on_toolButton_CollapseAll_clicked();
void on_actionAbout_Porymap_triggered(); void on_actionAbout_Porymap_triggered();
void on_pushButton_AddCustomHeaderField_clicked();
void on_pushButton_DeleteCustomHeaderField_clicked();
void on_tableWidget_CustomHeaderFields_cellChanged(int row, int column);
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;

View file

@ -70,6 +70,7 @@ public:
QList<QStringList>* getLabelMacros(QList<QStringList>*, QString); QList<QStringList>* getLabelMacros(QList<QStringList>*, QString);
QStringList* getLabelValues(QList<QStringList>*, QString); QStringList* getLabelValues(QList<QStringList>*, QString);
QMap<QString, bool> getTopLevelMapFields();
bool loadMapData(Map*); bool loadMapData(Map*);
void readMapLayouts(); void readMapLayouts();
void loadMapLayout(Map*); void loadMapLayout(Map*);

View file

@ -1109,6 +1109,21 @@ void Editor::toggleBorderVisibility(bool visible)
this->setConnectionsVisibility(visible); this->setConnectionsVisibility(visible);
} }
void Editor::updateCustomMapHeaderValues(QTableWidget *table)
{
QMap<QString, QString> fields;
for (int row = 0; row < table->rowCount(); row++) {
QString keyStr = "";
QString valueStr = "";
QTableWidgetItem *key = table->item(row, 0);
QTableWidgetItem *value = table->item(row, 1);
if (key) keyStr = key->text();
if (value) valueStr = value->text();
fields[keyStr] = valueStr;
}
map->customHeaders = fields;
}
Tileset* Editor::getCurrentMapPrimaryTileset() Tileset* Editor::getCurrentMapPrimaryTileset()
{ {
QString tilesetLabel = map->layout->tileset_primary_label; QString tilesetLabel = map->layout->tileset_primary_label;

View file

@ -486,6 +486,17 @@ void MainWindow::displayMapProperties() {
ui->checkBox_AllowRunning->setChecked(map->allowRunning.toInt() > 0 || map->allowRunning == "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_AllowBiking->setChecked(map->allowBiking.toInt() > 0 || map->allowBiking == "TRUE");
ui->checkBox_AllowEscapeRope->setChecked(map->allowEscapeRope.toInt() > 0 || map->allowEscapeRope == "TRUE"); ui->checkBox_AllowEscapeRope->setChecked(map->allowEscapeRope.toInt() > 0 || map->allowEscapeRope == "TRUE");
// Custom fields table.
ui->tableWidget_CustomHeaderFields->blockSignals(true);
ui->tableWidget_CustomHeaderFields->setRowCount(0);
for (auto it = map->customHeaders.begin(); it != map->customHeaders.end(); it++) {
int rowIndex = ui->tableWidget_CustomHeaderFields->rowCount();
ui->tableWidget_CustomHeaderFields->insertRow(rowIndex);
ui->tableWidget_CustomHeaderFields->setItem(rowIndex, 0, new QTableWidgetItem(it.key()));
ui->tableWidget_CustomHeaderFields->setItem(rowIndex, 1, new QTableWidgetItem(it.value()));
}
ui->tableWidget_CustomHeaderFields->blockSignals(false);
} }
void MainWindow::on_comboBox_Song_activated(const QString &song) void MainWindow::on_comboBox_Song_activated(const QString &song)
@ -1903,6 +1914,42 @@ void MainWindow::on_actionAbout_Porymap_triggered()
window->show(); window->show();
} }
void MainWindow::on_pushButton_AddCustomHeaderField_clicked()
{
int rowIndex = this->ui->tableWidget_CustomHeaderFields->rowCount();
this->ui->tableWidget_CustomHeaderFields->insertRow(rowIndex);
this->ui->tableWidget_CustomHeaderFields->selectRow(rowIndex);
this->editor->updateCustomMapHeaderValues(this->ui->tableWidget_CustomHeaderFields);
}
void MainWindow::on_pushButton_DeleteCustomHeaderField_clicked()
{
int rowCount = this->ui->tableWidget_CustomHeaderFields->rowCount();
if (rowCount > 0) {
QModelIndexList indexList = ui->tableWidget_CustomHeaderFields->selectionModel()->selectedIndexes();
QList<QPersistentModelIndex> persistentIndexes;
for (QModelIndex index : indexList) {
QPersistentModelIndex persistentIndex(index);
persistentIndexes.append(persistentIndex);
}
for (QPersistentModelIndex index : persistentIndexes) {
this->ui->tableWidget_CustomHeaderFields->removeRow(index.row());
}
if (this->ui->tableWidget_CustomHeaderFields->rowCount() > 0) {
this->ui->tableWidget_CustomHeaderFields->selectRow(0);
}
this->editor->updateCustomMapHeaderValues(this->ui->tableWidget_CustomHeaderFields);
}
}
void MainWindow::on_tableWidget_CustomHeaderFields_cellChanged(int row, int column)
{
this->editor->updateCustomMapHeaderValues(this->ui->tableWidget_CustomHeaderFields);
}
void MainWindow::closeEvent(QCloseEvent *event) { void MainWindow::closeEvent(QCloseEvent *event) {
porymapConfig.setGeometry( porymapConfig.setGeometry(
this->saveGeometry(), this->saveGeometry(),

View file

@ -128,6 +128,58 @@ QStringList* Project::getLabelValues(QList<QStringList> *list, QString label) {
return values; return values;
} }
QMap<QString, bool> Project::getTopLevelMapFields() {
if (projectConfig.getBaseGameVersion() == BaseGameVersion::pokeemerald) {
return QMap<QString, bool>
{
{"id", true},
{"name", true},
{"layout", true},
{"music", true},
{"region_map_section", true},
{"requires_flash", true},
{"weather", true},
{"map_type", true},
{"allow_bike", true},
{"allow_escape_rope", true},
{"allow_running", true},
{"show_map_name", 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<QString, bool>
{
{"id", true},
{"name", true},
{"layout", true},
{"music", true},
{"region_map_section", true},
{"requires_flash", true},
{"weather", true},
{"map_type", true},
{"show_map_name", 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 {
logError("Invalid game version");
return QMap<QString, bool>();
}
}
bool Project::loadMapData(Map* map) { bool Project::loadMapData(Map* map) {
if (!map->isPersistedToFile) { if (!map->isPersistedToFile) {
return true; return true;
@ -322,6 +374,14 @@ bool Project::loadMapData(Map* map) {
} }
} }
// Check for custom fields
QMap<QString, bool> baseFields = this->getTopLevelMapFields();
for (QString key : mapObj.keys()) {
if (!baseFields.contains(key)) {
map->customHeaders.insert(key, mapObj[key].toString());
}
}
return true; return true;
} }
@ -954,6 +1014,11 @@ void Project::saveMap(Map *map) {
mapObj["shared_scripts_map"] = map->sharedScriptsMap; mapObj["shared_scripts_map"] = map->sharedScriptsMap;
} }
// Custom header fields.
for (QString key : map->customHeaders.keys()) {
mapObj[key] = map->customHeaders[key];
}
QJsonDocument mapDoc(mapObj); QJsonDocument mapDoc(mapObj);
mapFile.write(mapDoc.toJson()); mapFile.write(mapDoc.toJson());