Use Block masks to update value limits, parse fieldmap.c
This commit is contained in:
parent
f0310d4a63
commit
5a3907bf56
15 changed files with 431 additions and 301 deletions
|
@ -21,7 +21,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="mainTabs">
|
<widget class="QTabWidget" name="mainTabs">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab_General">
|
<widget class="QWidget" name="tab_General">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
|
@ -370,138 +370,17 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>531</width>
|
<width>531</width>
|
||||||
<height>566</height>
|
<height>545</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_16">
|
<layout class="QVBoxLayout" name="verticalLayout_16">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_NewMapDefaults">
|
<widget class="QGroupBox" name="groupBox_MapDataDefaults">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>New Map Defaults</string>
|
<string>Map Data Defaults</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
<item row="2" column="0">
|
<item row="1" column="1" colspan="3">
|
||||||
<widget class="QLabel" name="label_FillMetatile">
|
|
||||||
<property name="text">
|
|
||||||
<string>Fill Metatile</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0" colspan="5">
|
|
||||||
<widget class="QWidget" name="widget_DefaultSizeBorderMetatiles" native="true">
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<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="QLabel" name="label_BorderMetatiles">
|
|
||||||
<property name="text">
|
|
||||||
<string>Border Metatiles</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="NoScrollSpinBox" name="spinBox_BorderMetatile1">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>The default metatile value that will be used for the top-left border metatile on new maps.</string>
|
|
||||||
</property>
|
|
||||||
<property name="prefix">
|
|
||||||
<string>0x</string>
|
|
||||||
</property>
|
|
||||||
<property name="displayIntegerBase">
|
|
||||||
<number>16</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="NoScrollSpinBox" name="spinBox_BorderMetatile2">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>The default metatile value that will be used for the top-right border metatile on new maps.</string>
|
|
||||||
</property>
|
|
||||||
<property name="prefix">
|
|
||||||
<string>0x</string>
|
|
||||||
</property>
|
|
||||||
<property name="displayIntegerBase">
|
|
||||||
<number>16</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="NoScrollSpinBox" name="spinBox_BorderMetatile3">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>The default metatile value that will be used for the bottom-left border metatile on new maps.</string>
|
|
||||||
</property>
|
|
||||||
<property name="prefix">
|
|
||||||
<string>0x</string>
|
|
||||||
</property>
|
|
||||||
<property name="displayIntegerBase">
|
|
||||||
<number>16</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="NoScrollSpinBox" name="spinBox_BorderMetatile4">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>The default metatile value that will be used for the bottom-right border metatile on new maps.</string>
|
|
||||||
</property>
|
|
||||||
<property name="prefix">
|
|
||||||
<string>0x</string>
|
|
||||||
</property>
|
|
||||||
<property name="displayIntegerBase">
|
|
||||||
<number>16</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="NoScrollSpinBox" name="spinBox_FillMetatile">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>The default metatile value that will be used to fill new maps</string>
|
|
||||||
</property>
|
|
||||||
<property name="prefix">
|
|
||||||
<string>0x</string>
|
|
||||||
</property>
|
|
||||||
<property name="displayIntegerBase">
|
|
||||||
<number>16</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1">
|
|
||||||
<widget class="NoScrollSpinBox" name="spinBox_Elevation">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>The default elevation that will be used to fill new maps</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="0" colspan="6">
|
|
||||||
<widget class="QCheckBox" name="checkBox_CreateTextFile">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Whether a separate text.inc or text.pory file will be created for new maps, alongside the scripts file</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Create separate text file</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0">
|
|
||||||
<widget class="QLabel" name="label_Collision">
|
|
||||||
<property name="text">
|
|
||||||
<string>Collision</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0" colspan="6">
|
|
||||||
<widget class="QWidget" name="widget_CustomSizeBorderMetatiles" native="true">
|
<widget class="QWidget" name="widget_CustomSizeBorderMetatiles" native="true">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
|
@ -516,34 +395,166 @@
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_BorderMetatiles_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Border Metatiles</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="lineEdit_BorderMetatiles">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>A comma-separated list of metatile values that will be used to fill new map borders</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_BorderMetatiles">
|
||||||
|
<property name="text">
|
||||||
|
<string>Border Metatiles</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1" colspan="3">
|
||||||
|
<widget class="QStackedWidget" name="stackedWidget_BorderMetatiles">
|
||||||
|
<widget class="QWidget" name="page_CustomBorderSize">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<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="QLineEdit" name="lineEdit_BorderMetatiles">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>A comma-separated list of metatile values that will be used to fill new map borders</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="page_DefaultBorderSize">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
|
<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="NoScrollSpinBox" name="spinBox_BorderMetatile1">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>The default metatile value that will be used for the top-left border metatile on new maps.</string>
|
||||||
|
</property>
|
||||||
|
<property name="prefix">
|
||||||
|
<string>0x</string>
|
||||||
|
</property>
|
||||||
|
<property name="displayIntegerBase">
|
||||||
|
<number>16</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="NoScrollSpinBox" name="spinBox_BorderMetatile2">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>The default metatile value that will be used for the top-right border metatile on new maps.</string>
|
||||||
|
</property>
|
||||||
|
<property name="prefix">
|
||||||
|
<string>0x</string>
|
||||||
|
</property>
|
||||||
|
<property name="displayIntegerBase">
|
||||||
|
<number>16</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="NoScrollSpinBox" name="spinBox_BorderMetatile3">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>The default metatile value that will be used for the bottom-left border metatile on new maps.</string>
|
||||||
|
</property>
|
||||||
|
<property name="prefix">
|
||||||
|
<string>0x</string>
|
||||||
|
</property>
|
||||||
|
<property name="displayIntegerBase">
|
||||||
|
<number>16</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="NoScrollSpinBox" name="spinBox_BorderMetatile4">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>The default metatile value that will be used for the bottom-right border metatile on new maps.</string>
|
||||||
|
</property>
|
||||||
|
<property name="prefix">
|
||||||
|
<string>0x</string>
|
||||||
|
</property>
|
||||||
|
<property name="displayIntegerBase">
|
||||||
|
<number>16</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="label_FillMetatile">
|
||||||
|
<property name="text">
|
||||||
|
<string>Fill Metatile</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="label_Elevation">
|
||||||
|
<property name="text">
|
||||||
|
<string>Elevation</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QLabel" name="label_Collision">
|
||||||
|
<property name="text">
|
||||||
|
<string>Collision</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="NoScrollSpinBox" name="spinBox_FillMetatile">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>The default metatile value that will be used to fill new maps</string>
|
||||||
|
</property>
|
||||||
|
<property name="prefix">
|
||||||
|
<string>0x</string>
|
||||||
|
</property>
|
||||||
|
<property name="displayIntegerBase">
|
||||||
|
<number>16</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="4" column="1">
|
||||||
|
<widget class="NoScrollSpinBox" name="spinBox_Elevation">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>The default elevation that will be used to fill new maps</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
<widget class="NoScrollSpinBox" name="spinBox_Collision">
|
<widget class="NoScrollSpinBox" name="spinBox_Collision">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>The default collision that will be used to fill new maps</string>
|
<string>The default collision that will be used to fill new maps</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="6" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label_Elevation">
|
<widget class="QCheckBox" name="checkBox_CreateTextFile">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Whether a separate text.inc or text.pory file will be created for new maps, alongside the scripts file</string>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Elevation</string>
|
<string>Create separate text file</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -214,6 +214,7 @@ enum ProjectFilePath {
|
||||||
constants_species,
|
constants_species,
|
||||||
constants_fieldmap,
|
constants_fieldmap,
|
||||||
global_fieldmap,
|
global_fieldmap,
|
||||||
|
fieldmap,
|
||||||
initial_facing_table,
|
initial_facing_table,
|
||||||
pokemon_icon_table,
|
pokemon_icon_table,
|
||||||
pokemon_gfx,
|
pokemon_gfx,
|
||||||
|
@ -230,9 +231,9 @@ public:
|
||||||
// Reset non-version-specific settings
|
// Reset non-version-specific settings
|
||||||
this->usePoryScript = false;
|
this->usePoryScript = false;
|
||||||
this->enableTripleLayerMetatiles = false;
|
this->enableTripleLayerMetatiles = false;
|
||||||
this->newMapMetatileId = 1;
|
this->defaultMetatileId = 1;
|
||||||
this->newMapElevation = 3;
|
this->defaultElevation = 3;
|
||||||
this->newMapCollision = 0;
|
this->defaultCollision = 0;
|
||||||
this->defaultPrimaryTileset = "gTileset_General";
|
this->defaultPrimaryTileset = "gTileset_General";
|
||||||
this->prefabFilepath = QString();
|
this->prefabFilepath = QString();
|
||||||
this->prefabImportPrompted = false;
|
this->prefabImportPrompted = false;
|
||||||
|
@ -283,12 +284,12 @@ public:
|
||||||
bool getTripleLayerMetatilesEnabled();
|
bool getTripleLayerMetatilesEnabled();
|
||||||
int getNumLayersInMetatile();
|
int getNumLayersInMetatile();
|
||||||
int getNumTilesInMetatile();
|
int getNumTilesInMetatile();
|
||||||
void setNewMapMetatileId(uint16_t metatileId);
|
void setDefaultMetatileId(uint16_t metatileId);
|
||||||
uint16_t getNewMapMetatileId();
|
uint16_t getDefaultMetatileId();
|
||||||
void setNewMapElevation(int elevation);
|
void setDefaultElevation(int elevation);
|
||||||
int getNewMapElevation();
|
int getDefaultElevation();
|
||||||
void setNewMapCollision(int collision);
|
void setDefaultCollision(int collision);
|
||||||
int getNewMapCollision();
|
int getDefaultCollision();
|
||||||
void setNewMapBorderMetatileIds(QList<uint16_t> metatileIds);
|
void setNewMapBorderMetatileIds(QList<uint16_t> metatileIds);
|
||||||
QList<uint16_t> getNewMapBorderMetatileIds();
|
QList<uint16_t> getNewMapBorderMetatileIds();
|
||||||
QString getDefaultPrimaryTileset();
|
QString getDefaultPrimaryTileset();
|
||||||
|
@ -337,6 +338,18 @@ public:
|
||||||
void setCollisionSheetHeight(int height);
|
void setCollisionSheetHeight(int height);
|
||||||
int getCollisionSheetHeight();
|
int getCollisionSheetHeight();
|
||||||
|
|
||||||
|
// TODO: Replace these once there's generic support for editing project names
|
||||||
|
static const QString metatileIdMaskName;
|
||||||
|
static const QString collisionMaskName;
|
||||||
|
static const QString elevationMaskName;
|
||||||
|
static const QString behaviorMaskName;
|
||||||
|
static const QString layerTypeMaskName;
|
||||||
|
static const QString behaviorTableName;
|
||||||
|
static const QString layerTypeTableName;
|
||||||
|
static const QString terrainTypeTableName;
|
||||||
|
static const QString encounterTypeTableName;
|
||||||
|
static const QString attrTableName;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual QString getConfigFilepath() override;
|
virtual QString getConfigFilepath() override;
|
||||||
virtual void parseConfigKeyValue(QString key, QString value) override;
|
virtual void parseConfigKeyValue(QString key, QString value) override;
|
||||||
|
@ -358,9 +371,9 @@ private:
|
||||||
bool enableFloorNumber;
|
bool enableFloorNumber;
|
||||||
bool createMapTextFile;
|
bool createMapTextFile;
|
||||||
bool enableTripleLayerMetatiles;
|
bool enableTripleLayerMetatiles;
|
||||||
uint16_t newMapMetatileId;
|
uint16_t defaultMetatileId;
|
||||||
int newMapElevation;
|
uint16_t defaultElevation;
|
||||||
int newMapCollision;
|
uint16_t defaultCollision;
|
||||||
QList<uint16_t> newMapBorderMetatileIds;
|
QList<uint16_t> newMapBorderMetatileIds;
|
||||||
QString defaultPrimaryTileset;
|
QString defaultPrimaryTileset;
|
||||||
QString defaultSecondaryTileset;
|
QString defaultSecondaryTileset;
|
||||||
|
|
|
@ -26,10 +26,12 @@ public:
|
||||||
static uint16_t getMaxCollision();
|
static uint16_t getMaxCollision();
|
||||||
static uint16_t getMaxElevation();
|
static uint16_t getMaxElevation();
|
||||||
|
|
||||||
|
static const uint16_t maxValue;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint16_t m_metatileId; // 10
|
uint16_t m_metatileId;
|
||||||
uint16_t m_collision; // 2
|
uint16_t m_collision;
|
||||||
uint16_t m_elevation; // 4
|
uint16_t m_elevation;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BLOCK_H
|
#endif // BLOCK_H
|
||||||
|
|
|
@ -350,7 +350,7 @@ private:
|
||||||
void openSubWindow(QWidget * window);
|
void openSubWindow(QWidget * window);
|
||||||
QString getExistingDirectory(QString);
|
QString getExistingDirectory(QString);
|
||||||
bool openProject(QString dir);
|
bool openProject(QString dir);
|
||||||
QString getDefaultMap();
|
bool setInitialMap();
|
||||||
void setRecentMap(QString map_name);
|
void setRecentMap(QString map_name);
|
||||||
QStandardItem* createMapItem(QString mapName, int groupNum, int inGroupNum);
|
QStandardItem* createMapItem(QString mapName, int groupNum, int inGroupNum);
|
||||||
|
|
||||||
|
@ -372,7 +372,7 @@ private:
|
||||||
void initMapSortOrder();
|
void initMapSortOrder();
|
||||||
void initShortcuts();
|
void initShortcuts();
|
||||||
void initExtraShortcuts();
|
void initExtraShortcuts();
|
||||||
void setProjectSpecificUI();
|
bool setProjectSpecificUI();
|
||||||
void setWildEncountersUIEnabled(bool enabled);
|
void setWildEncountersUIEnabled(bool enabled);
|
||||||
void loadUserSettings();
|
void loadUserSettings();
|
||||||
void applyMapListFilter(QString filterText);
|
void applyMapListFilter(QString filterText);
|
||||||
|
|
|
@ -85,11 +85,7 @@ public:
|
||||||
QMap<QString, qint64> modifiedFileTimestamps;
|
QMap<QString, qint64> modifiedFileTimestamps;
|
||||||
bool usingAsmTilesets;
|
bool usingAsmTilesets;
|
||||||
QString importExportPath;
|
QString importExportPath;
|
||||||
bool parsedMetatileIdMask;
|
QSet<QString> disabledSettingsNames;
|
||||||
bool parsedCollisionMask;
|
|
||||||
bool parsedElevationMask;
|
|
||||||
bool parsedBehaviorMask;
|
|
||||||
bool parsedLayerTypeMask;
|
|
||||||
|
|
||||||
void set_root(QString);
|
void set_root(QString);
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ private:
|
||||||
void chooseImageFile(QLineEdit * filepathEdit);
|
void chooseImageFile(QLineEdit * filepathEdit);
|
||||||
void chooseFile(QLineEdit * filepathEdit, const QString &description, const QString &extensions);
|
void chooseFile(QLineEdit * filepathEdit, const QString &description, const QString &extensions);
|
||||||
QString stripProjectDir(QString s);
|
QString stripProjectDir(QString s);
|
||||||
|
void disableParsedSetting(QWidget * widget, const QString &name, const QString &filepath);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void dialogButtonClicked(QAbstractButton *button);
|
void dialogButtonClicked(QAbstractButton *button);
|
||||||
|
|
|
@ -16,6 +16,17 @@
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QAbstractButton>
|
#include <QAbstractButton>
|
||||||
|
|
||||||
|
const QString ProjectConfig::metatileIdMaskName = "MAPGRID_METATILE_ID_MASK";
|
||||||
|
const QString ProjectConfig::collisionMaskName = "MAPGRID_COLLISION_MASK";
|
||||||
|
const QString ProjectConfig::elevationMaskName = "MAPGRID_ELEVATION_MASK";
|
||||||
|
const QString ProjectConfig::behaviorMaskName = "METATILE_ATTR_BEHAVIOR_MASK";
|
||||||
|
const QString ProjectConfig::layerTypeMaskName = "METATILE_ATTR_LAYER_MASK";
|
||||||
|
const QString ProjectConfig::behaviorTableName = "METATILE_ATTRIBUTE_BEHAVIOR";
|
||||||
|
const QString ProjectConfig::layerTypeTableName = "METATILE_ATTRIBUTE_LAYER_TYPE";
|
||||||
|
const QString ProjectConfig::terrainTypeTableName = "METATILE_ATTRIBUTE_TERRAIN";
|
||||||
|
const QString ProjectConfig::encounterTypeTableName = "METATILE_ATTRIBUTE_ENCOUNTER_TYPE";
|
||||||
|
const QString ProjectConfig::attrTableName = "sMetatileAttrMasks";
|
||||||
|
|
||||||
const QMap<ProjectFilePath, std::pair<QString, QString>> ProjectConfig::defaultPaths = {
|
const QMap<ProjectFilePath, std::pair<QString, QString>> ProjectConfig::defaultPaths = {
|
||||||
{ProjectFilePath::data_map_folders, { "data_map_folders", "data/maps/"}},
|
{ProjectFilePath::data_map_folders, { "data_map_folders", "data/maps/"}},
|
||||||
{ProjectFilePath::data_scripts_folders, { "data_scripts_folders", "data/scripts/"}},
|
{ProjectFilePath::data_scripts_folders, { "data_scripts_folders", "data/scripts/"}},
|
||||||
|
@ -60,6 +71,7 @@ const QMap<ProjectFilePath, std::pair<QString, QString>> ProjectConfig::defaultP
|
||||||
{ProjectFilePath::constants_species, { "constants_species", "include/constants/species.h"}},
|
{ProjectFilePath::constants_species, { "constants_species", "include/constants/species.h"}},
|
||||||
{ProjectFilePath::constants_fieldmap, { "constants_fieldmap", "include/fieldmap.h"}},
|
{ProjectFilePath::constants_fieldmap, { "constants_fieldmap", "include/fieldmap.h"}},
|
||||||
{ProjectFilePath::global_fieldmap, { "global_fieldmap", "include/global.fieldmap.h"}},
|
{ProjectFilePath::global_fieldmap, { "global_fieldmap", "include/global.fieldmap.h"}},
|
||||||
|
{ProjectFilePath::fieldmap, { "fieldmap", "src/fieldmap.c"}},
|
||||||
{ProjectFilePath::pokemon_icon_table, { "pokemon_icon_table", "src/pokemon_icon.c"}},
|
{ProjectFilePath::pokemon_icon_table, { "pokemon_icon_table", "src/pokemon_icon.c"}},
|
||||||
{ProjectFilePath::initial_facing_table, { "initial_facing_table", "src/event_object_movement.c"}},
|
{ProjectFilePath::initial_facing_table, { "initial_facing_table", "src/event_object_movement.c"}},
|
||||||
{ProjectFilePath::pokemon_gfx, { "pokemon_gfx", "graphics/pokemon/"}},
|
{ProjectFilePath::pokemon_gfx, { "pokemon_gfx", "graphics/pokemon/"}},
|
||||||
|
@ -653,21 +665,17 @@ void ProjectConfig::parseConfigKeyValue(QString key, QString value) {
|
||||||
this->createMapTextFile = getConfigBool(key, value);
|
this->createMapTextFile = getConfigBool(key, value);
|
||||||
} else if (key == "enable_triple_layer_metatiles") {
|
} else if (key == "enable_triple_layer_metatiles") {
|
||||||
this->enableTripleLayerMetatiles = getConfigBool(key, value);
|
this->enableTripleLayerMetatiles = getConfigBool(key, value);
|
||||||
} else if (key == "new_map_metatile") {
|
} else if (key == "default_metatile") {
|
||||||
// TODO: Update max once Block layout can be edited
|
this->defaultMetatileId = getConfigUint32(key, value, 0, Block::maxValue);
|
||||||
this->newMapMetatileId = getConfigUint32(key, value, 0, 1023, 0);
|
} else if (key == "default_elevation") {
|
||||||
} else if (key == "new_map_elevation") {
|
this->defaultElevation = getConfigUint32(key, value, 0, Block::maxValue);
|
||||||
// TODO: Update max once Block layout can be edited
|
} else if (key == "default_collision") {
|
||||||
this->newMapElevation = getConfigInteger(key, value, 0, 15, 3);
|
this->defaultCollision = getConfigUint32(key, value, 0, Block::maxValue);
|
||||||
} else if (key == "new_map_collision") {
|
|
||||||
// TODO: Update max once Block layout can be edited
|
|
||||||
this->newMapCollision = getConfigInteger(key, value, 0, 3, 0);
|
|
||||||
} else if (key == "new_map_border_metatiles") {
|
} else if (key == "new_map_border_metatiles") {
|
||||||
this->newMapBorderMetatileIds.clear();
|
this->newMapBorderMetatileIds.clear();
|
||||||
QList<QString> metatileIds = value.split(",");
|
QList<QString> metatileIds = value.split(",");
|
||||||
for (int i = 0; i < metatileIds.size(); i++) {
|
for (int i = 0; i < metatileIds.size(); i++) {
|
||||||
// TODO: Update max once Block layout can be edited
|
int metatileId = getConfigUint32(key, metatileIds.at(i), 0, Block::maxValue);
|
||||||
int metatileId = getConfigUint32(key, metatileIds.at(i), 0, 1023, 0);
|
|
||||||
this->newMapBorderMetatileIds.append(metatileId);
|
this->newMapBorderMetatileIds.append(metatileId);
|
||||||
}
|
}
|
||||||
} else if (key == "default_primary_tileset") {
|
} else if (key == "default_primary_tileset") {
|
||||||
|
@ -690,11 +698,11 @@ void ProjectConfig::parseConfigKeyValue(QString key, QString value) {
|
||||||
} else if (key == "metatile_layer_type_mask") {
|
} else if (key == "metatile_layer_type_mask") {
|
||||||
this->metatileLayerTypeMask = getConfigUint32(key, value);
|
this->metatileLayerTypeMask = getConfigUint32(key, value);
|
||||||
} else if (key == "block_metatile_id_mask") {
|
} else if (key == "block_metatile_id_mask") {
|
||||||
this->blockMetatileIdMask = getConfigUint32(key, value, 1, 0xFFFF);
|
this->blockMetatileIdMask = getConfigUint32(key, value, 0, Block::maxValue);
|
||||||
} else if (key == "block_collision_mask") {
|
} else if (key == "block_collision_mask") {
|
||||||
this->blockCollisionMask = getConfigUint32(key, value, 0, 0xFFFE);
|
this->blockCollisionMask = getConfigUint32(key, value, 0, Block::maxValue);
|
||||||
} else if (key == "block_elevation_mask") {
|
} else if (key == "block_elevation_mask") {
|
||||||
this->blockElevationMask = getConfigUint32(key, value, 0, 0xFFFE);
|
this->blockElevationMask = getConfigUint32(key, value, 0, Block::maxValue);
|
||||||
} else if (key == "enable_map_allow_flags") {
|
} else if (key == "enable_map_allow_flags") {
|
||||||
this->enableMapAllowFlags = getConfigBool(key, value);
|
this->enableMapAllowFlags = getConfigBool(key, value);
|
||||||
#ifdef CONFIG_BACKWARDS_COMPATABILITY
|
#ifdef CONFIG_BACKWARDS_COMPATABILITY
|
||||||
|
@ -735,10 +743,9 @@ void ProjectConfig::parseConfigKeyValue(QString key, QString value) {
|
||||||
} else if (key == "collision_sheet_path") {
|
} else if (key == "collision_sheet_path") {
|
||||||
this->collisionSheetPath = value;
|
this->collisionSheetPath = value;
|
||||||
} else if (key == "collision_sheet_width") {
|
} else if (key == "collision_sheet_width") {
|
||||||
// TODO: Update max once Block layout can be edited (0x7FFF for 15 bits)
|
this->collisionSheetWidth = getConfigUint32(key, value, 1, Block::maxValue);
|
||||||
this->collisionSheetWidth = getConfigInteger(key, value, 1, 4, 2);
|
|
||||||
} else if (key == "collision_sheet_height") {
|
} else if (key == "collision_sheet_height") {
|
||||||
this->collisionSheetHeight = getConfigInteger(key, value, 1, 16, 16);
|
this->collisionSheetHeight = getConfigUint32(key, value, 1, Block::maxValue);
|
||||||
} else {
|
} else {
|
||||||
logWarn(QString("Invalid config key found in config file %1: '%2'").arg(this->getConfigFilepath()).arg(key));
|
logWarn(QString("Invalid config key found in config file %1: '%2'").arg(this->getConfigFilepath()).arg(key));
|
||||||
}
|
}
|
||||||
|
@ -788,9 +795,9 @@ QMap<QString, QString> ProjectConfig::getKeyValueMap() {
|
||||||
map.insert("enable_floor_number", QString::number(this->enableFloorNumber));
|
map.insert("enable_floor_number", QString::number(this->enableFloorNumber));
|
||||||
map.insert("create_map_text_file", QString::number(this->createMapTextFile));
|
map.insert("create_map_text_file", QString::number(this->createMapTextFile));
|
||||||
map.insert("enable_triple_layer_metatiles", QString::number(this->enableTripleLayerMetatiles));
|
map.insert("enable_triple_layer_metatiles", QString::number(this->enableTripleLayerMetatiles));
|
||||||
map.insert("new_map_metatile", Metatile::getMetatileIdString(this->newMapMetatileId));
|
map.insert("default_metatile", Metatile::getMetatileIdString(this->defaultMetatileId));
|
||||||
map.insert("new_map_elevation", QString::number(this->newMapElevation));
|
map.insert("default_elevation", QString::number(this->defaultElevation));
|
||||||
map.insert("new_map_collision", QString::number(this->newMapCollision));
|
map.insert("default_collision", QString::number(this->defaultCollision));
|
||||||
map.insert("new_map_border_metatiles", Metatile::getMetatileIdStringList(this->newMapBorderMetatileIds));
|
map.insert("new_map_border_metatiles", Metatile::getMetatileIdStringList(this->newMapBorderMetatileIds));
|
||||||
map.insert("default_primary_tileset", this->defaultPrimaryTileset);
|
map.insert("default_primary_tileset", this->defaultPrimaryTileset);
|
||||||
map.insert("default_secondary_tileset", this->defaultSecondaryTileset);
|
map.insert("default_secondary_tileset", this->defaultSecondaryTileset);
|
||||||
|
@ -1027,31 +1034,31 @@ int ProjectConfig::getNumTilesInMetatile() {
|
||||||
return this->enableTripleLayerMetatiles ? 12 : 8;
|
return this->enableTripleLayerMetatiles ? 12 : 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectConfig::setNewMapMetatileId(uint16_t metatileId) {
|
void ProjectConfig::setDefaultMetatileId(uint16_t metatileId) {
|
||||||
this->newMapMetatileId = metatileId;
|
this->defaultMetatileId = metatileId;
|
||||||
this->save();
|
this->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t ProjectConfig::getNewMapMetatileId() {
|
uint16_t ProjectConfig::getDefaultMetatileId() {
|
||||||
return this->newMapMetatileId;
|
return this->defaultMetatileId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectConfig::setNewMapElevation(int elevation) {
|
void ProjectConfig::setDefaultElevation(int elevation) {
|
||||||
this->newMapElevation = elevation;
|
this->defaultElevation = elevation;
|
||||||
this->save();
|
this->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ProjectConfig::getNewMapElevation() {
|
int ProjectConfig::getDefaultElevation() {
|
||||||
return this->newMapElevation;
|
return this->defaultElevation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectConfig::setNewMapCollision(int collision) {
|
void ProjectConfig::setDefaultCollision(int collision) {
|
||||||
this->newMapCollision = collision;
|
this->defaultCollision = collision;
|
||||||
this->save();
|
this->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ProjectConfig::getNewMapCollision() {
|
int ProjectConfig::getDefaultCollision() {
|
||||||
return this->newMapCollision;
|
return this->defaultCollision;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectConfig::setNewMapBorderMetatileIds(QList<uint16_t> metatileIds) {
|
void ProjectConfig::setNewMapBorderMetatileIds(QList<uint16_t> metatileIds) {
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
#include "bitpacker.h"
|
#include "bitpacker.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
// Upper limit for metatile ID, collision, and elevation masks. Used externally.
|
||||||
|
const uint16_t Block::maxValue = 0xFFFF;
|
||||||
|
|
||||||
static BitPacker bitsMetatileId = BitPacker(0x3FF);
|
static BitPacker bitsMetatileId = BitPacker(0x3FF);
|
||||||
static BitPacker bitsCollision = BitPacker(0xC00);
|
static BitPacker bitsCollision = BitPacker(0xC00);
|
||||||
static BitPacker bitsElevation = BitPacker(0xF000);
|
static BitPacker bitsElevation = BitPacker(0xF000);
|
||||||
|
@ -43,16 +46,32 @@ uint16_t Block::rawValue() const {
|
||||||
| bitsElevation.pack(m_elevation);
|
| bitsElevation.pack(m_elevation);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Resolve TODOs for max block limits, and disable collision tab if collision and elevation are 0
|
// TODO: After parsing, recalc config (or parsed!) values that depend on max collision/elevation
|
||||||
// TODO: After parsing, recalc max collision/elevation for selector image (in Metatile::setLayout?)
|
/* - newMapMetatileId
|
||||||
// TODO: More generous config limits
|
- newMapElevation
|
||||||
// TODO: Settings editor -- disable UI & restore after refresh, red flag overlapping masks
|
- newMapCollision
|
||||||
// TODO: Generalize API tab disabling, i.e. check if disabled before allowing selection
|
- newMapBorderMetatileIds
|
||||||
// TODO: Metatile selector looks like it's having a fit during group block select
|
- collisionSheetWidth
|
||||||
|
- collisionSheetHeight
|
||||||
|
- NUM_METATILES_IN_PRIMARY
|
||||||
|
- event elevations
|
||||||
|
- metatile labels?
|
||||||
|
|
||||||
|
*/
|
||||||
|
// TODO: Settings editor -- disable UI & restore after refresh
|
||||||
void Block::setLayout() {
|
void Block::setLayout() {
|
||||||
bitsMetatileId.setMask(projectConfig.getBlockMetatileIdMask());
|
bitsMetatileId.setMask(projectConfig.getBlockMetatileIdMask());
|
||||||
bitsCollision.setMask(projectConfig.getBlockCollisionMask());
|
bitsCollision.setMask(projectConfig.getBlockCollisionMask());
|
||||||
bitsElevation.setMask(projectConfig.getBlockElevationMask());
|
bitsElevation.setMask(projectConfig.getBlockElevationMask());
|
||||||
|
|
||||||
|
// Some settings may need to be reevaluated based on the layout
|
||||||
|
/*uint16_t metatileId = projectConfig.getNewMapMetatileId();
|
||||||
|
if (bitsMetatileId.clamp(metatileId) != metatileId)
|
||||||
|
projectConfig.setNewMapMetatileId(bitsMetatileId.clamp(metatileId));
|
||||||
|
uint16_t metatileId = projectConfig.getNewMapMetatileId();
|
||||||
|
if (bitsMetatileId.clamp(metatileId) != metatileId)
|
||||||
|
projectConfig.setNewMapMetatileId(bitsMetatileId.clamp(metatileId));*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Block::operator ==(Block other) const {
|
bool Block::operator ==(Block other) const {
|
||||||
|
|
|
@ -35,7 +35,7 @@ int Event::getEventIndex() {
|
||||||
void Event::setDefaultValues(Project *) {
|
void Event::setDefaultValues(Project *) {
|
||||||
this->setX(0);
|
this->setX(0);
|
||||||
this->setY(0);
|
this->setY(0);
|
||||||
this->setElevation(3);
|
this->setElevation(projectConfig.getDefaultElevation());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Event::readCustomValues(QJsonObject values) {
|
void Event::readCustomValues(QJsonObject values) {
|
||||||
|
|
|
@ -104,6 +104,7 @@ void Metatile::setLayout(Project * project) {
|
||||||
uint32_t encounterTypeMask = projectConfig.getMetatileEncounterTypeMask() & maxMask;
|
uint32_t encounterTypeMask = projectConfig.getMetatileEncounterTypeMask() & maxMask;
|
||||||
uint32_t layerTypeMask = projectConfig.getMetatileLayerTypeMask() & maxMask;
|
uint32_t layerTypeMask = projectConfig.getMetatileLayerTypeMask() & maxMask;
|
||||||
|
|
||||||
|
// TODO: Overlap handling to settings editor; set red text box with similar text warning if overlapping
|
||||||
// Overlapping masks are technically ok, but probably not intended.
|
// Overlapping masks are technically ok, but probably not intended.
|
||||||
// Additionally, Porymap will not properly reflect that the values are linked.
|
// Additionally, Porymap will not properly reflect that the values are linked.
|
||||||
if (doMasksOverlap({behaviorMask, terrainTypeMask, encounterTypeMask, layerTypeMask})) {
|
if (doMasksOverlap({behaviorMask, terrainTypeMask, encounterTypeMask, layerTypeMask})) {
|
||||||
|
|
|
@ -1080,16 +1080,16 @@ void Editor::onHoveredMapMovementPermissionCleared() {
|
||||||
|
|
||||||
QString Editor::getMovementPermissionText(uint16_t collision, uint16_t elevation) {
|
QString Editor::getMovementPermissionText(uint16_t collision, uint16_t elevation) {
|
||||||
QString message;
|
QString message;
|
||||||
if (collision == 0 && elevation == 0) {
|
if (collision != 0) {
|
||||||
message = "Collision: Transition between elevations";
|
|
||||||
} else if (collision == 0 && elevation == 15) {
|
|
||||||
message = "Collision: Multi-Level (Bridge)";
|
|
||||||
} else if (collision == 0 && elevation == 1) {
|
|
||||||
message = "Collision: Surf";
|
|
||||||
} else if (collision == 0) {
|
|
||||||
message = QString("Collision: Passable, Elevation: %1").arg(elevation);
|
|
||||||
} else {
|
|
||||||
message = QString("Collision: Impassable (%1), Elevation: %2").arg(collision).arg(elevation);
|
message = QString("Collision: Impassable (%1), Elevation: %2").arg(collision).arg(elevation);
|
||||||
|
} else if (elevation == 0) {
|
||||||
|
message = "Collision: Transition between elevations";
|
||||||
|
} else if (elevation == 15) {
|
||||||
|
message = "Collision: Multi-Level (Bridge)";
|
||||||
|
} else if (elevation == 1) {
|
||||||
|
message = "Collision: Surf";
|
||||||
|
} else {
|
||||||
|
message = QString("Collision: Passable, Elevation: %1").arg(elevation);
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
@ -1497,7 +1497,7 @@ void Editor::displayMovementPermissionSelector() {
|
||||||
connect(movement_permissions_selector_item, &SelectablePixmapItem::selectionChanged, [this](int x, int y, int, int) {
|
connect(movement_permissions_selector_item, &SelectablePixmapItem::selectionChanged, [this](int x, int y, int, int) {
|
||||||
this->setCollisionTabSpinBoxes(x, y);
|
this->setCollisionTabSpinBoxes(x, y);
|
||||||
});
|
});
|
||||||
movement_permissions_selector_item->select(projectConfig.getNewMapCollision(), projectConfig.getNewMapElevation());
|
movement_permissions_selector_item->select(projectConfig.getDefaultCollision(), projectConfig.getDefaultElevation());
|
||||||
}
|
}
|
||||||
|
|
||||||
scene_collision_metatiles->addItem(movement_permissions_selector_item);
|
scene_collision_metatiles->addItem(movement_permissions_selector_item);
|
||||||
|
|
|
@ -372,8 +372,8 @@ void MainWindow::setWildEncountersUIEnabled(bool enabled) {
|
||||||
ui->mainTabBar->setTabEnabled(4, enabled);
|
ui->mainTabBar->setTabEnabled(4, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the UI using information we've read from the user's project config file.
|
// Update the UI using information we've read from the user's project files.
|
||||||
void MainWindow::setProjectSpecificUI()
|
bool MainWindow::setProjectSpecificUI()
|
||||||
{
|
{
|
||||||
this->setWildEncountersUIEnabled(userConfig.getEncounterJsonActive());
|
this->setWildEncountersUIEnabled(userConfig.getEncounterJsonActive());
|
||||||
|
|
||||||
|
@ -397,6 +397,7 @@ void MainWindow::setProjectSpecificUI()
|
||||||
editor->setCollisionGraphics();
|
editor->setCollisionGraphics();
|
||||||
ui->spinBox_SelectedElevation->setMaximum(Block::getMaxElevation());
|
ui->spinBox_SelectedElevation->setMaximum(Block::getMaxElevation());
|
||||||
ui->spinBox_SelectedCollision->setMaximum(Block::getMaxCollision());
|
ui->spinBox_SelectedCollision->setMaximum(Block::getMaxCollision());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::mapSortOrder_changed(QAction *action)
|
void MainWindow::mapSortOrder_changed(QAction *action)
|
||||||
|
@ -513,14 +514,12 @@ bool MainWindow::openProject(QString dir) {
|
||||||
|
|
||||||
this->statusBar()->showMessage(QString("Opening project %1").arg(nativeDir));
|
this->statusBar()->showMessage(QString("Opening project %1").arg(nativeDir));
|
||||||
|
|
||||||
bool success = true;
|
|
||||||
userConfig.setProjectDir(dir);
|
userConfig.setProjectDir(dir);
|
||||||
userConfig.load();
|
userConfig.load();
|
||||||
projectConfig.setProjectDir(dir);
|
projectConfig.setProjectDir(dir);
|
||||||
projectConfig.load();
|
projectConfig.load();
|
||||||
|
|
||||||
this->closeSupplementaryWindows();
|
this->closeSupplementaryWindows();
|
||||||
this->setProjectSpecificUI();
|
|
||||||
this->newMapDefaultsSet = false;
|
this->newMapDefaultsSet = false;
|
||||||
|
|
||||||
Scripting::init(this);
|
Scripting::init(this);
|
||||||
|
@ -537,19 +536,18 @@ bool MainWindow::openProject(QString dir) {
|
||||||
this->preferenceEditor->updateFields();
|
this->preferenceEditor->updateFields();
|
||||||
});
|
});
|
||||||
editor->project->set_root(dir);
|
editor->project->set_root(dir);
|
||||||
success = loadDataStructures()
|
|
||||||
&& populateMapList()
|
|
||||||
&& setMap(getDefaultMap(), true);
|
|
||||||
} else {
|
} else {
|
||||||
QString open_map = editor->map->name;
|
|
||||||
editor->project->fileWatcher.removePaths(editor->project->fileWatcher.files());
|
editor->project->fileWatcher.removePaths(editor->project->fileWatcher.files());
|
||||||
editor->project->clearMapCache();
|
editor->project->clearMapCache();
|
||||||
editor->project->clearTilesetCache();
|
editor->project->clearTilesetCache();
|
||||||
success = loadDataStructures() && populateMapList() && setMap(open_map, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
projectOpenFailure = !success;
|
this->projectOpenFailure = !(loadDataStructures()
|
||||||
if (projectOpenFailure) {
|
&& setProjectSpecificUI()
|
||||||
|
&& populateMapList()
|
||||||
|
&& setInitialMap());
|
||||||
|
|
||||||
|
if (this->projectOpenFailure) {
|
||||||
this->statusBar()->showMessage(QString("Failed to open project %1").arg(nativeDir));
|
this->statusBar()->showMessage(QString("Failed to open project %1").arg(nativeDir));
|
||||||
QMessageBox msgBox(this);
|
QMessageBox msgBox(this);
|
||||||
QString errorMsg = QString("There was an error opening the project %1. Please see %2 for full error details.\n\n%3")
|
QString errorMsg = QString("There was an error opening the project %1. Please see %2 for full error details.\n\n%3")
|
||||||
|
@ -576,28 +574,31 @@ bool MainWindow::isProjectOpen() {
|
||||||
return !projectOpenFailure && editor && editor->project;
|
return !projectOpenFailure && editor && editor->project;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MainWindow::getDefaultMap() {
|
bool MainWindow::setInitialMap() {
|
||||||
if (editor && editor->project) {
|
QList<QStringList> names;
|
||||||
QList<QStringList> names = editor->project->groupedMapNames;
|
if (editor && editor->project)
|
||||||
if (!names.isEmpty()) {
|
names = editor->project->groupedMapNames;
|
||||||
QString recentMap = userConfig.getRecentMap();
|
|
||||||
if (!recentMap.isNull() && recentMap.length() > 0) {
|
QString recentMap = userConfig.getRecentMap();
|
||||||
for (int i = 0; i < names.length(); i++) {
|
if (!recentMap.isEmpty()) {
|
||||||
if (names.value(i).contains(recentMap)) {
|
// Make sure the recent map is still in the map list
|
||||||
return recentMap;
|
for (int i = 0; i < names.length(); i++) {
|
||||||
}
|
if (names.value(i).contains(recentMap)) {
|
||||||
}
|
return setMap(recentMap, true);
|
||||||
}
|
|
||||||
// Failing that, just get the first map in the list.
|
|
||||||
for (int i = 0; i < names.length(); i++) {
|
|
||||||
QStringList list = names.value(i);
|
|
||||||
if (list.length()) {
|
|
||||||
return list.value(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return QString();
|
|
||||||
|
// Failing that, just get the first map in the list.
|
||||||
|
for (int i = 0; i < names.length(); i++) {
|
||||||
|
QStringList list = names.value(i);
|
||||||
|
if (list.length()) {
|
||||||
|
return setMap(list.value(0), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logError("Failed to load any map names.");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::openSubWindow(QWidget * window) {
|
void MainWindow::openSubWindow(QWidget * window) {
|
||||||
|
@ -654,7 +655,7 @@ bool MainWindow::setMap(QString map_name, bool scrollTreeView) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!editor->setMap(map_name)) {
|
if (!editor || !editor->setMap(map_name)) {
|
||||||
logWarn(QString("Failed to set map to '%1'").arg(map_name));
|
logWarn(QString("Failed to set map to '%1'").arg(map_name));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1461,8 +1462,8 @@ void MainWindow::copy() {
|
||||||
collisions.clear();
|
collisions.clear();
|
||||||
for (int i = 0; i < metatiles.length(); i++) {
|
for (int i = 0; i < metatiles.length(); i++) {
|
||||||
OrderedJson::object collision;
|
OrderedJson::object collision;
|
||||||
collision["collision"] = 0;
|
collision["collision"] = projectConfig.getDefaultCollision();
|
||||||
collision["elevation"] = 3;
|
collision["elevation"] = projectConfig.getDefaultElevation();
|
||||||
collisions.append(collision);
|
collisions.append(collision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -297,7 +297,7 @@ bool Project::loadMapData(Map* map) {
|
||||||
heal->setMap(map);
|
heal->setMap(map);
|
||||||
heal->setX(loc.x);
|
heal->setX(loc.x);
|
||||||
heal->setY(loc.y);
|
heal->setY(loc.y);
|
||||||
heal->setElevation(3);
|
heal->setElevation(projectConfig.getDefaultElevation());
|
||||||
heal->setLocationName(loc.mapName);
|
heal->setLocationName(loc.mapName);
|
||||||
heal->setIdName(loc.idName);
|
heal->setIdName(loc.idName);
|
||||||
heal->setIndex(loc.index);
|
heal->setIndex(loc.index);
|
||||||
|
@ -1109,7 +1109,7 @@ void Project::setNewMapBlockdata(Map *map) {
|
||||||
map->layout->blockdata.clear();
|
map->layout->blockdata.clear();
|
||||||
int width = map->getWidth();
|
int width = map->getWidth();
|
||||||
int height = map->getHeight();
|
int height = map->getHeight();
|
||||||
Block block(projectConfig.getNewMapMetatileId(), projectConfig.getNewMapCollision(), projectConfig.getNewMapElevation());
|
Block block(projectConfig.getDefaultMetatileId(), projectConfig.getDefaultCollision(), projectConfig.getDefaultElevation());
|
||||||
for (int i = 0; i < width * height; i++) {
|
for (int i = 0; i < width * height; i++) {
|
||||||
map->layout->blockdata.append(block);
|
map->layout->blockdata.append(block);
|
||||||
}
|
}
|
||||||
|
@ -1914,37 +1914,78 @@ bool Project::readTilesetProperties() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read data masks for Blocks and metatile attributes.
|
// Read data masks for Blocks and metatile attributes.
|
||||||
// These settings are exposed in the settings window. If any are parsed from
|
|
||||||
// the project they'll be visible in the settings window but not editable.
|
|
||||||
bool Project::readFieldmapMasks() {
|
bool Project::readFieldmapMasks() {
|
||||||
// We're looking for the suffix "_MASK". Technically our "prefix" is the whole define.
|
// We're looking for the suffix "_MASK". Technically our "prefix" is the whole define.
|
||||||
static const QStringList definePrefixes{ "\\b\\w+_MASK" };
|
static const QStringList definePrefixes{ "\\b\\w+_MASK" };
|
||||||
QString filename = projectConfig.getFilePath(ProjectFilePath::global_fieldmap);
|
QString globalFieldmap = projectConfig.getFilePath(ProjectFilePath::global_fieldmap);
|
||||||
fileWatcher.addPath(root + "/" + filename);
|
fileWatcher.addPath(root + "/" + globalFieldmap);
|
||||||
QMap<QString, int> defines = parser.readCDefines(filename, definePrefixes);
|
QMap<QString, int> defines = parser.readCDefines(globalFieldmap, definePrefixes);
|
||||||
|
|
||||||
auto it = defines.find("MAPGRID_METATILE_ID_MASK");
|
// These mask values are accessible via the settings editor for users who don't have these defines.
|
||||||
if ((parsedMetatileIdMask = (it != defines.end())))
|
// If users do have the defines we disable them in the settings editor and direct them to their project files.
|
||||||
|
// Record the names we read so we know later which settings to disable.
|
||||||
|
const QStringList defineNames = defines.keys();
|
||||||
|
this->disabledSettingsNames = QSet<QString>(defineNames.constBegin(), defineNames.constEnd());
|
||||||
|
|
||||||
|
// Avoid repeatedly writing the config file
|
||||||
|
projectConfig.setSaveDisabled(true);
|
||||||
|
|
||||||
|
// Read Block masks
|
||||||
|
auto it = defines.find(ProjectConfig::metatileIdMaskName);
|
||||||
|
if (it != defines.end())
|
||||||
projectConfig.setBlockMetatileIdMask(static_cast<uint16_t>(it.value()));
|
projectConfig.setBlockMetatileIdMask(static_cast<uint16_t>(it.value()));
|
||||||
|
it = defines.find(ProjectConfig::collisionMaskName);
|
||||||
it = defines.find("MAPGRID_COLLISION_MASK");
|
if (it != defines.end())
|
||||||
if ((parsedCollisionMask = (it != defines.end())))
|
|
||||||
projectConfig.setBlockCollisionMask(static_cast<uint16_t>(it.value()));
|
projectConfig.setBlockCollisionMask(static_cast<uint16_t>(it.value()));
|
||||||
|
it = defines.find(ProjectConfig::elevationMaskName);
|
||||||
it = defines.find("MAPGRID_ELEVATION_MASK");
|
if (it != defines.end())
|
||||||
if ((parsedElevationMask = (it != defines.end())))
|
|
||||||
projectConfig.setBlockElevationMask(static_cast<uint16_t>(it.value()));
|
projectConfig.setBlockElevationMask(static_cast<uint16_t>(it.value()));
|
||||||
|
|
||||||
// TODO: For FRLG, parse from fieldmap.c?
|
// Read RSE metatile attribute masks
|
||||||
|
it = defines.find(ProjectConfig::behaviorMaskName);
|
||||||
it = defines.find("METATILE_ATTR_BEHAVIOR_MASK");
|
if (it != defines.end())
|
||||||
if ((parsedBehaviorMask = (it != defines.end())))
|
|
||||||
projectConfig.setMetatileBehaviorMask(static_cast<uint32_t>(it.value()));
|
projectConfig.setMetatileBehaviorMask(static_cast<uint32_t>(it.value()));
|
||||||
|
it = defines.find(ProjectConfig::layerTypeMaskName);
|
||||||
it = defines.find("METATILE_ATTR_LAYER_MASK");
|
if (it != defines.end())
|
||||||
if ((parsedLayerTypeMask = (it != defines.end())))
|
|
||||||
projectConfig.setMetatileLayerTypeMask(static_cast<uint32_t>(it.value()));
|
projectConfig.setMetatileLayerTypeMask(static_cast<uint32_t>(it.value()));
|
||||||
|
|
||||||
|
// pokefirered keeps its attribute masks in a separate table, parse this too.
|
||||||
|
QString srcFieldmap = projectConfig.getFilePath(ProjectFilePath::fieldmap);
|
||||||
|
const QMap<QString, QString> attrTable = parser.readNamedIndexCArray(srcFieldmap, ProjectConfig::attrTableName);
|
||||||
|
if (!attrTable.isEmpty()) {
|
||||||
|
fileWatcher.addPath(root + "/" + srcFieldmap);
|
||||||
|
bool ok;
|
||||||
|
// Read terrain type mask
|
||||||
|
uint32_t mask = attrTable.value(ProjectConfig::terrainTypeTableName).toUInt(&ok, 0);
|
||||||
|
if (ok) {
|
||||||
|
projectConfig.setMetatileTerrainTypeMask(mask);
|
||||||
|
this->disabledSettingsNames.insert(ProjectConfig::terrainTypeTableName);
|
||||||
|
}
|
||||||
|
// Read encounter type mask
|
||||||
|
mask = attrTable.value(ProjectConfig::encounterTypeTableName).toUInt(&ok, 0);
|
||||||
|
if (ok) {
|
||||||
|
projectConfig.setMetatileEncounterTypeMask(mask);
|
||||||
|
this->disabledSettingsNames.insert(ProjectConfig::encounterTypeTableName);
|
||||||
|
}
|
||||||
|
// If we haven't already parsed behavior and layer type then try those too
|
||||||
|
if (!this->disabledSettingsNames.contains(ProjectConfig::behaviorMaskName)) {
|
||||||
|
// Read behavior mask
|
||||||
|
mask = attrTable.value(ProjectConfig::behaviorTableName).toUInt(&ok, 0);
|
||||||
|
if (ok) {
|
||||||
|
projectConfig.setMetatileBehaviorMask(mask);
|
||||||
|
this->disabledSettingsNames.insert(ProjectConfig::behaviorTableName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!this->disabledSettingsNames.contains(ProjectConfig::layerTypeMaskName)) {
|
||||||
|
// Read layer type mask
|
||||||
|
mask = attrTable.value(ProjectConfig::layerTypeTableName).toUInt(&ok, 0);
|
||||||
|
if (ok) {
|
||||||
|
projectConfig.setMetatileLayerTypeMask(mask);
|
||||||
|
this->disabledSettingsNames.insert(ProjectConfig::layerTypeTableName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
projectConfig.setSaveDisabled(false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,6 @@ void ProjectSettingsEditor::initUi() {
|
||||||
ui->comboBox_DefaultPrimaryTileset->addItems(project->primaryTilesetLabels);
|
ui->comboBox_DefaultPrimaryTileset->addItems(project->primaryTilesetLabels);
|
||||||
ui->comboBox_DefaultSecondaryTileset->addItems(project->secondaryTilesetLabels);
|
ui->comboBox_DefaultSecondaryTileset->addItems(project->secondaryTilesetLabels);
|
||||||
ui->comboBox_IconSpecies->addItems(project->speciesToIconPath.keys());
|
ui->comboBox_IconSpecies->addItems(project->speciesToIconPath.keys());
|
||||||
ui->comboBox_IconSpecies->setEditable(false);
|
|
||||||
}
|
}
|
||||||
ui->comboBox_BaseGameVersion->addItems(ProjectConfig::versionStrings);
|
ui->comboBox_BaseGameVersion->addItems(ProjectConfig::versionStrings);
|
||||||
ui->comboBox_AttributesSize->addItems({"1", "2", "4"});
|
ui->comboBox_AttributesSize->addItems({"1", "2", "4"});
|
||||||
|
@ -96,14 +95,14 @@ void ProjectSettingsEditor::initUi() {
|
||||||
ui->mainTabs->setCurrentIndex(porymapConfig.getProjectSettingsTab());
|
ui->mainTabs->setCurrentIndex(porymapConfig.getProjectSettingsTab());
|
||||||
|
|
||||||
// Validate that the border metatiles text is a comma-separated list of metatile values
|
// Validate that the border metatiles text is a comma-separated list of metatile values
|
||||||
const QString regex_Hex = "(0[xX])?[A-Fa-f0-9]+";
|
static const QString regex_Hex = "(0[xX])?[A-Fa-f0-9]+";
|
||||||
static const QRegularExpression expression(QString("^(%1,)*%1$").arg(regex_Hex)); // Comma-separated list of hex values
|
static const QRegularExpression expression(QString("^(%1,)*%1$").arg(regex_Hex)); // Comma-separated list of hex values
|
||||||
QRegularExpressionValidator *validator = new QRegularExpressionValidator(expression);
|
QRegularExpressionValidator *validator = new QRegularExpressionValidator(expression);
|
||||||
ui->lineEdit_BorderMetatiles->setValidator(validator);
|
ui->lineEdit_BorderMetatiles->setValidator(validator);
|
||||||
this->setBorderMetatilesUi(projectConfig.getUseCustomBorderSize());
|
this->setBorderMetatilesUi(projectConfig.getUseCustomBorderSize());
|
||||||
|
|
||||||
// Set spin box limits
|
// Set spin box limits
|
||||||
int maxMetatileId = Block::getMaxMetatileId();
|
uint16_t maxMetatileId = Block::getMaxMetatileId();
|
||||||
ui->spinBox_FillMetatile->setMaximum(maxMetatileId);
|
ui->spinBox_FillMetatile->setMaximum(maxMetatileId);
|
||||||
ui->spinBox_BorderMetatile1->setMaximum(maxMetatileId);
|
ui->spinBox_BorderMetatile1->setMaximum(maxMetatileId);
|
||||||
ui->spinBox_BorderMetatile2->setMaximum(maxMetatileId);
|
ui->spinBox_BorderMetatile2->setMaximum(maxMetatileId);
|
||||||
|
@ -113,16 +112,52 @@ void ProjectSettingsEditor::initUi() {
|
||||||
ui->spinBox_Collision->setMaximum(Block::getMaxCollision());
|
ui->spinBox_Collision->setMaximum(Block::getMaxCollision());
|
||||||
ui->spinBox_MaxElevation->setMaximum(Block::getMaxElevation());
|
ui->spinBox_MaxElevation->setMaximum(Block::getMaxElevation());
|
||||||
ui->spinBox_MaxCollision->setMaximum(Block::getMaxCollision());
|
ui->spinBox_MaxCollision->setMaximum(Block::getMaxCollision());
|
||||||
// TODO: Move to a global
|
//ui->spinBox_MetatileIdMask->setMinimum(0x1);
|
||||||
ui->spinBox_MetatileIdMask->setMinimum(0x1);
|
ui->spinBox_MetatileIdMask->setMaximum(Block::maxValue);
|
||||||
ui->spinBox_MetatileIdMask->setMaximum(0xFFFF); // Metatile IDs can use all 16 bits of a block
|
ui->spinBox_CollisionMask->setMaximum(Block::maxValue);
|
||||||
ui->spinBox_CollisionMask->setMaximum(0xFFFE); // Collision/elevation can only use 15; metatile IDs must have at least 1 bit
|
ui->spinBox_ElevationMask->setMaximum(Block::maxValue);
|
||||||
ui->spinBox_ElevationMask->setMaximum(0xFFFE);
|
|
||||||
|
// Some settings can be determined by constants in the project.
|
||||||
|
// We reflect that here by disabling their UI elements.
|
||||||
|
if (project) {
|
||||||
|
const QString maskFilepath = projectConfig.getFilePath(ProjectFilePath::global_fieldmap);
|
||||||
|
const QString attrTableFilepath = projectConfig.getFilePath(ProjectFilePath::fieldmap);
|
||||||
|
|
||||||
|
// Block masks
|
||||||
|
if (project->disabledSettingsNames.contains(ProjectConfig::metatileIdMaskName))
|
||||||
|
this->disableParsedSetting(ui->spinBox_MetatileIdMask, ProjectConfig::metatileIdMaskName, maskFilepath);
|
||||||
|
if (project->disabledSettingsNames.contains(ProjectConfig::collisionMaskName))
|
||||||
|
this->disableParsedSetting(ui->spinBox_CollisionMask, ProjectConfig::collisionMaskName, maskFilepath);
|
||||||
|
if (project->disabledSettingsNames.contains(ProjectConfig::elevationMaskName))
|
||||||
|
this->disableParsedSetting(ui->spinBox_ElevationMask, ProjectConfig::elevationMaskName, maskFilepath);
|
||||||
|
|
||||||
|
// Behavior mask
|
||||||
|
if (project->disabledSettingsNames.contains(ProjectConfig::behaviorMaskName))
|
||||||
|
this->disableParsedSetting(ui->spinBox_BehaviorMask, ProjectConfig::behaviorMaskName, maskFilepath);
|
||||||
|
else if (project->disabledSettingsNames.contains(ProjectConfig::behaviorTableName))
|
||||||
|
this->disableParsedSetting(ui->spinBox_BehaviorMask, ProjectConfig::attrTableName, attrTableFilepath);
|
||||||
|
|
||||||
|
// Layer type mask
|
||||||
|
if (project->disabledSettingsNames.contains(ProjectConfig::layerTypeMaskName))
|
||||||
|
this->disableParsedSetting(ui->spinBox_LayerTypeMask, ProjectConfig::layerTypeMaskName, maskFilepath);
|
||||||
|
else if (project->disabledSettingsNames.contains(ProjectConfig::layerTypeTableName))
|
||||||
|
this->disableParsedSetting(ui->spinBox_LayerTypeMask, ProjectConfig::attrTableName, attrTableFilepath);
|
||||||
|
|
||||||
|
// Encounter and terrain type masks
|
||||||
|
if (project->disabledSettingsNames.contains(ProjectConfig::terrainTypeTableName))
|
||||||
|
this->disableParsedSetting(ui->spinBox_TerrainTypeMask, ProjectConfig::attrTableName, attrTableFilepath);
|
||||||
|
if (project->disabledSettingsNames.contains(ProjectConfig::encounterTypeTableName))
|
||||||
|
this->disableParsedSetting(ui->spinBox_EncounterTypeMask, ProjectConfig::attrTableName, attrTableFilepath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectSettingsEditor::disableParsedSetting(QWidget * widget, const QString &name, const QString &filepath) {
|
||||||
|
widget->setEnabled(false);
|
||||||
|
widget->setToolTip(QString("This value has been read from '%1' in %2").arg(name).arg(filepath));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectSettingsEditor::setBorderMetatilesUi(bool customSize) {
|
void ProjectSettingsEditor::setBorderMetatilesUi(bool customSize) {
|
||||||
ui->widget_DefaultSizeBorderMetatiles->setVisible(!customSize);
|
ui->stackedWidget_BorderMetatiles->setCurrentIndex(customSize ? 0 : 1);
|
||||||
ui->widget_CustomSizeBorderMetatiles->setVisible(customSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectSettingsEditor::setBorderMetatileIds(bool customSize, QList<uint16_t> metatileIds) {
|
void ProjectSettingsEditor::setBorderMetatileIds(bool customSize, QList<uint16_t> metatileIds) {
|
||||||
|
@ -155,7 +190,7 @@ QList<uint16_t> ProjectSettingsEditor::getBorderMetatileIds(bool customSize) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectSettingsEditor::updateAttributeLimits(const QString &attrSize) {
|
void ProjectSettingsEditor::updateAttributeLimits(const QString &attrSize) {
|
||||||
QMap<QString, uint32_t> limits {
|
static const QMap<QString, uint32_t> limits {
|
||||||
{"1", 0xFF},
|
{"1", 0xFF},
|
||||||
{"2", 0xFFFF},
|
{"2", 0xFFFF},
|
||||||
{"4", 0xFFFFFFFF},
|
{"4", 0xFFFFFFFF},
|
||||||
|
@ -170,20 +205,19 @@ void ProjectSettingsEditor::updateAttributeLimits(const QString &attrSize) {
|
||||||
// Only one icon path is displayed at a time, so we need to keep track of the rest,
|
// Only one icon path is displayed at a time, so we need to keep track of the rest,
|
||||||
// and update the path edit when the user changes the selected species.
|
// and update the path edit when the user changes the selected species.
|
||||||
// The existing icon path map in ProjectConfig is left alone to allow unsaved changes.
|
// The existing icon path map in ProjectConfig is left alone to allow unsaved changes.
|
||||||
void ProjectSettingsEditor::updatePokemonIconPath(const QString &species) {
|
void ProjectSettingsEditor::updatePokemonIconPath(const QString &newSpecies) {
|
||||||
if (!project) return;
|
if (!project) return;
|
||||||
|
|
||||||
// If user was editing a path for a valid species, record filepath text before we wipe it.
|
// If user was editing a path for a valid species, record filepath text before we wipe it.
|
||||||
if (!this->prevIconSpecies.isEmpty() && this->project->speciesToIconPath.contains(species)) {
|
if (!this->prevIconSpecies.isEmpty() && this->project->speciesToIconPath.contains(this->prevIconSpecies))
|
||||||
this->editedPokemonIconPaths[this->prevIconSpecies] = ui->lineEdit_PokemonIcon->text();
|
this->editedPokemonIconPaths[this->prevIconSpecies] = ui->lineEdit_PokemonIcon->text();
|
||||||
}
|
|
||||||
|
|
||||||
QString editedPath = this->editedPokemonIconPaths.value(species);
|
QString editedPath = this->editedPokemonIconPaths.value(newSpecies);
|
||||||
QString defaultPath = this->project->speciesToIconPath.value(species);
|
QString defaultPath = this->project->speciesToIconPath.value(newSpecies);
|
||||||
|
|
||||||
ui->lineEdit_PokemonIcon->setText(this->stripProjectDir(editedPath));
|
ui->lineEdit_PokemonIcon->setText(this->stripProjectDir(editedPath));
|
||||||
ui->lineEdit_PokemonIcon->setPlaceholderText(this->stripProjectDir(defaultPath));
|
ui->lineEdit_PokemonIcon->setPlaceholderText(this->stripProjectDir(defaultPath));
|
||||||
this->prevIconSpecies = species;
|
this->prevIconSpecies = newSpecies;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectSettingsEditor::createProjectPathsTable() {
|
void ProjectSettingsEditor::createProjectPathsTable() {
|
||||||
|
@ -282,18 +316,18 @@ void ProjectSettingsEditor::refresh() {
|
||||||
ui->checkBox_OutputIsCompressed->setChecked(projectConfig.getTilesetsHaveIsCompressed());
|
ui->checkBox_OutputIsCompressed->setChecked(projectConfig.getTilesetsHaveIsCompressed());
|
||||||
|
|
||||||
// Set spin box values
|
// Set spin box values
|
||||||
ui->spinBox_Elevation->setValue(projectConfig.getNewMapElevation());
|
ui->spinBox_Elevation->setValue(projectConfig.getDefaultElevation());
|
||||||
ui->spinBox_Collision->setValue(projectConfig.getNewMapCollision());
|
ui->spinBox_Collision->setValue(projectConfig.getDefaultCollision());
|
||||||
ui->spinBox_FillMetatile->setValue(projectConfig.getNewMapMetatileId());
|
ui->spinBox_FillMetatile->setValue(projectConfig.getDefaultMetatileId());
|
||||||
ui->spinBox_MaxElevation->setValue(projectConfig.getCollisionSheetHeight() - 1);
|
ui->spinBox_MaxElevation->setValue(projectConfig.getCollisionSheetHeight() - 1);
|
||||||
ui->spinBox_MaxCollision->setValue(projectConfig.getCollisionSheetWidth() - 1);
|
ui->spinBox_MaxCollision->setValue(projectConfig.getCollisionSheetWidth() - 1);
|
||||||
ui->spinBox_BehaviorMask->setValue(projectConfig.getMetatileBehaviorMask());
|
ui->spinBox_BehaviorMask->setValue(projectConfig.getMetatileBehaviorMask() & ui->spinBox_BehaviorMask->maximum());
|
||||||
ui->spinBox_EncounterTypeMask->setValue(projectConfig.getMetatileEncounterTypeMask());
|
ui->spinBox_EncounterTypeMask->setValue(projectConfig.getMetatileEncounterTypeMask() & ui->spinBox_EncounterTypeMask->maximum());
|
||||||
ui->spinBox_LayerTypeMask->setValue(projectConfig.getMetatileLayerTypeMask());
|
ui->spinBox_LayerTypeMask->setValue(projectConfig.getMetatileLayerTypeMask() & ui->spinBox_LayerTypeMask->maximum());
|
||||||
ui->spinBox_TerrainTypeMask->setValue(projectConfig.getMetatileTerrainTypeMask());
|
ui->spinBox_TerrainTypeMask->setValue(projectConfig.getMetatileTerrainTypeMask() & ui->spinBox_TerrainTypeMask->maximum());
|
||||||
ui->spinBox_MetatileIdMask->setValue(projectConfig.getBlockMetatileIdMask());
|
ui->spinBox_MetatileIdMask->setValue(projectConfig.getBlockMetatileIdMask() & ui->spinBox_MetatileIdMask->maximum());
|
||||||
ui->spinBox_CollisionMask->setValue(projectConfig.getBlockCollisionMask());
|
ui->spinBox_CollisionMask->setValue(projectConfig.getBlockCollisionMask() & ui->spinBox_CollisionMask->maximum());
|
||||||
ui->spinBox_ElevationMask->setValue(projectConfig.getBlockElevationMask());
|
ui->spinBox_ElevationMask->setValue(projectConfig.getBlockElevationMask() & ui->spinBox_ElevationMask->maximum());
|
||||||
|
|
||||||
// Set (and sync) border metatile IDs
|
// Set (and sync) border metatile IDs
|
||||||
auto metatileIds = projectConfig.getNewMapBorderMetatileIds();
|
auto metatileIds = projectConfig.getNewMapBorderMetatileIds();
|
||||||
|
@ -345,9 +379,9 @@ void ProjectSettingsEditor::save() {
|
||||||
projectConfig.setTilesetsHaveIsCompressed(ui->checkBox_OutputIsCompressed->isChecked());
|
projectConfig.setTilesetsHaveIsCompressed(ui->checkBox_OutputIsCompressed->isChecked());
|
||||||
|
|
||||||
// Save spin box settings
|
// Save spin box settings
|
||||||
projectConfig.setNewMapElevation(ui->spinBox_Elevation->value());
|
projectConfig.setDefaultElevation(ui->spinBox_Elevation->value());
|
||||||
projectConfig.setNewMapCollision(ui->spinBox_Collision->value());
|
projectConfig.setDefaultCollision(ui->spinBox_Collision->value());
|
||||||
projectConfig.setNewMapMetatileId(ui->spinBox_FillMetatile->value());
|
projectConfig.setDefaultMetatileId(ui->spinBox_FillMetatile->value());
|
||||||
projectConfig.setCollisionSheetHeight(ui->spinBox_MaxElevation->value() + 1);
|
projectConfig.setCollisionSheetHeight(ui->spinBox_MaxElevation->value() + 1);
|
||||||
projectConfig.setCollisionSheetWidth(ui->spinBox_MaxCollision->value() + 1);
|
projectConfig.setCollisionSheetWidth(ui->spinBox_MaxCollision->value() + 1);
|
||||||
projectConfig.setMetatileBehaviorMask(ui->spinBox_BehaviorMask->value());
|
projectConfig.setMetatileBehaviorMask(ui->spinBox_BehaviorMask->value());
|
||||||
|
@ -373,7 +407,9 @@ void ProjectSettingsEditor::save() {
|
||||||
projectConfig.setNewMapBorderMetatileIds(this->getBorderMetatileIds(ui->checkBox_EnableCustomBorderSize->isChecked()));
|
projectConfig.setNewMapBorderMetatileIds(this->getBorderMetatileIds(ui->checkBox_EnableCustomBorderSize->isChecked()));
|
||||||
|
|
||||||
// Save pokemon icon paths
|
// Save pokemon icon paths
|
||||||
this->editedPokemonIconPaths.insert(ui->comboBox_IconSpecies->currentText(), ui->lineEdit_PokemonIcon->text());
|
const QString species = ui->comboBox_IconSpecies->currentText();
|
||||||
|
if (this->project->speciesToIconPath.contains(species))
|
||||||
|
this->editedPokemonIconPaths.insert(species, ui->lineEdit_PokemonIcon->text());
|
||||||
for (auto i = this->editedPokemonIconPaths.cbegin(), end = this->editedPokemonIconPaths.cend(); i != end; i++)
|
for (auto i = this->editedPokemonIconPaths.cbegin(), end = this->editedPokemonIconPaths.cend(); i != end; i++)
|
||||||
projectConfig.setPokemonIconPath(i.key(), i.value());
|
projectConfig.setPokemonIconPath(i.key(), i.value());
|
||||||
|
|
||||||
|
@ -496,6 +532,7 @@ void ProjectSettingsEditor::closeEvent(QCloseEvent* event) {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this->projectNeedsReload) {
|
if (this->projectNeedsReload) {
|
||||||
|
// Note: Declining this prompt with changes that need a reload may cause problems
|
||||||
if (this->prompt("Settings changed, reload project to apply changes?") == QMessageBox::Yes){
|
if (this->prompt("Settings changed, reload project to apply changes?") == QMessageBox::Yes){
|
||||||
// Reloading the project will destroy this window, no other work should happen after this signal is emitted
|
// Reloading the project will destroy this window, no other work should happen after this signal is emitted
|
||||||
emit this->reloadProject();
|
emit this->reloadProject();
|
||||||
|
|
|
@ -18,6 +18,7 @@ UIntSpinBox::UIntSpinBox(QWidget *parent)
|
||||||
};
|
};
|
||||||
|
|
||||||
void UIntSpinBox::setValue(uint32_t val) {
|
void UIntSpinBox::setValue(uint32_t val) {
|
||||||
|
val = qMax(m_minimum, qMin(m_maximum, val));
|
||||||
if (m_value != val) {
|
if (m_value != val) {
|
||||||
m_value = val;
|
m_value = val;
|
||||||
emit valueChanged(m_value);
|
emit valueChanged(m_value);
|
||||||
|
|
Loading…
Reference in a new issue