Automatically adjust metatile ID strings
This commit is contained in:
parent
513e63193e
commit
59f0d9fe11
5 changed files with 22 additions and 13 deletions
|
@ -9,6 +9,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
|
|||
## [Unreleased]
|
||||
### Changed
|
||||
- The API functions `addImage` and `createImage` now support project-relative paths.
|
||||
- Metatile ID strings are now padded to their current max, not the overall max.
|
||||
|
||||
### Fixed
|
||||
- Fix API error reporting
|
||||
|
|
|
@ -74,15 +74,8 @@ public:
|
|||
static uint32_t getMaxAttributesMask();
|
||||
static int getDefaultAttributesSize(BaseGameVersion version);
|
||||
static void setLayout(Project*);
|
||||
static QString getMetatileIdString(uint16_t metatileId) {
|
||||
return "0x" + QString("%1").arg(metatileId, 4, 16, QChar('0')).toUpper();
|
||||
};
|
||||
static QString getMetatileIdStringList(const QList<uint16_t> metatileIds) {
|
||||
QStringList metatiles;
|
||||
for (auto metatileId : metatileIds)
|
||||
metatiles << Metatile::getMetatileIdString(metatileId);
|
||||
return metatiles.join(",");
|
||||
};
|
||||
static QString getMetatileIdString(uint16_t metatileId);
|
||||
static QString getMetatileIdStrings(const QList<uint16_t> metatileIds);
|
||||
|
||||
inline bool operator==(const Metatile &other) {
|
||||
return this->tiles == other.tiles && this->attributes == other.attributes;
|
||||
|
@ -94,8 +87,6 @@ public:
|
|||
|
||||
private:
|
||||
QMap<Metatile::Attr, uint32_t> attributes;
|
||||
|
||||
static bool doMasksOverlap(QList<uint32_t>);
|
||||
};
|
||||
|
||||
#endif // METATILE_H
|
||||
|
|
|
@ -965,7 +965,7 @@ QMap<QString, QString> ProjectConfig::getKeyValueMap() {
|
|||
map.insert("default_metatile", Metatile::getMetatileIdString(this->defaultMetatileId));
|
||||
map.insert("default_elevation", QString::number(this->defaultElevation));
|
||||
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::getMetatileIdStrings(this->newMapBorderMetatileIds));
|
||||
map.insert("default_primary_tileset", this->defaultPrimaryTileset);
|
||||
map.insert("default_secondary_tileset", this->defaultSecondaryTileset);
|
||||
map.insert("prefabs_filepath", this->prefabFilepath);
|
||||
|
|
|
@ -40,6 +40,18 @@ QPoint Metatile::coordFromPixmapCoord(const QPointF &pixelCoord) {
|
|||
return QPoint(x, y);
|
||||
}
|
||||
|
||||
static int numMetatileIdChars = 4;
|
||||
QString Metatile::getMetatileIdString(uint16_t metatileId) {
|
||||
return "0x" + QString("%1").arg(metatileId, numMetatileIdChars, 16, QChar('0')).toUpper();
|
||||
};
|
||||
|
||||
QString Metatile::getMetatileIdStrings(const QList<uint16_t> metatileIds) {
|
||||
QStringList metatiles;
|
||||
for (auto metatileId : metatileIds)
|
||||
metatiles << Metatile::getMetatileIdString(metatileId);
|
||||
return metatiles.join(",");
|
||||
};
|
||||
|
||||
// Read and pack together this metatile's attributes.
|
||||
uint32_t Metatile::getAttributes() const {
|
||||
uint32_t data = 0;
|
||||
|
@ -92,6 +104,11 @@ uint32_t Metatile::getMaxAttributesMask() {
|
|||
}
|
||||
|
||||
void Metatile::setLayout(Project * project) {
|
||||
// Calculate the number of hex characters needed to display a metatile ID.
|
||||
numMetatileIdChars = 0;
|
||||
for (uint16_t i = Block::getMaxMetatileId(); i > 1; i /= 0xF)
|
||||
numMetatileIdChars++;
|
||||
|
||||
uint32_t behaviorMask = projectConfig.getMetatileBehaviorMask();
|
||||
uint32_t terrainTypeMask = projectConfig.getMetatileTerrainTypeMask();
|
||||
uint32_t encounterTypeMask = projectConfig.getMetatileEncounterTypeMask();
|
||||
|
|
|
@ -198,7 +198,7 @@ void ProjectSettingsEditor::setBorderMetatilesUi(bool customSize) {
|
|||
|
||||
void ProjectSettingsEditor::setBorderMetatileIds(bool customSize, QList<uint16_t> metatileIds) {
|
||||
if (customSize) {
|
||||
ui->lineEdit_BorderMetatiles->setText(Metatile::getMetatileIdStringList(metatileIds));
|
||||
ui->lineEdit_BorderMetatiles->setText(Metatile::getMetatileIdStrings(metatileIds));
|
||||
} else {
|
||||
ui->spinBox_BorderMetatile1->setValue(metatileIds.value(0, 0x0));
|
||||
ui->spinBox_BorderMetatile2->setValue(metatileIds.value(1, 0x0));
|
||||
|
|
Loading…
Reference in a new issue