Custom collision/event graphics cleanup
This commit is contained in:
parent
4f0e8716f2
commit
61b1789d4b
5 changed files with 31 additions and 24 deletions
|
@ -225,6 +225,7 @@ public:
|
||||||
this->enableTripleLayerMetatiles = false;
|
this->enableTripleLayerMetatiles = false;
|
||||||
this->newMapMetatileId = 1;
|
this->newMapMetatileId = 1;
|
||||||
this->newMapElevation = 3;
|
this->newMapElevation = 3;
|
||||||
|
this->newMapCollision = 0;
|
||||||
this->defaultPrimaryTileset = "gTileset_General";
|
this->defaultPrimaryTileset = "gTileset_General";
|
||||||
this->prefabFilepath = QString();
|
this->prefabFilepath = QString();
|
||||||
this->prefabImportPrompted = false;
|
this->prefabImportPrompted = false;
|
||||||
|
@ -275,6 +276,8 @@ public:
|
||||||
uint16_t getNewMapMetatileId();
|
uint16_t getNewMapMetatileId();
|
||||||
void setNewMapElevation(int elevation);
|
void setNewMapElevation(int elevation);
|
||||||
int getNewMapElevation();
|
int getNewMapElevation();
|
||||||
|
void setNewMapCollision(int collision);
|
||||||
|
int getNewMapCollision();
|
||||||
void setNewMapBorderMetatileIds(QList<uint16_t> metatileIds);
|
void setNewMapBorderMetatileIds(QList<uint16_t> metatileIds);
|
||||||
QList<uint16_t> getNewMapBorderMetatileIds();
|
QList<uint16_t> getNewMapBorderMetatileIds();
|
||||||
QString getDefaultPrimaryTileset();
|
QString getDefaultPrimaryTileset();
|
||||||
|
@ -307,8 +310,6 @@ public:
|
||||||
void setMapAllowFlagsEnabled(bool enabled);
|
void setMapAllowFlagsEnabled(bool enabled);
|
||||||
void setEventIconPath(Event::Group group, const QString &path);
|
void setEventIconPath(Event::Group group, const QString &path);
|
||||||
QString getEventIconPath(Event::Group group);
|
QString getEventIconPath(Event::Group group);
|
||||||
void setCollisionIconPath(int collision, const QString &path);
|
|
||||||
QString getCollisionIconPath(int collision);
|
|
||||||
void setCollisionSheetPath(const QString &path);
|
void setCollisionSheetPath(const QString &path);
|
||||||
QString getCollisionSheetPath();
|
QString getCollisionSheetPath();
|
||||||
void setCollisionSheetWidth(int width);
|
void setCollisionSheetWidth(int width);
|
||||||
|
@ -339,6 +340,7 @@ private:
|
||||||
bool enableTripleLayerMetatiles;
|
bool enableTripleLayerMetatiles;
|
||||||
uint16_t newMapMetatileId;
|
uint16_t newMapMetatileId;
|
||||||
int newMapElevation;
|
int newMapElevation;
|
||||||
|
int newMapCollision;
|
||||||
QList<uint16_t> newMapBorderMetatileIds;
|
QList<uint16_t> newMapBorderMetatileIds;
|
||||||
QString defaultPrimaryTileset;
|
QString defaultPrimaryTileset;
|
||||||
QString defaultSecondaryTileset;
|
QString defaultSecondaryTileset;
|
||||||
|
|
|
@ -640,17 +640,19 @@ void ProjectConfig::parseConfigKeyValue(QString key, QString 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 == "new_map_metatile") {
|
||||||
// TODO: Update max
|
// TODO: Update max once Block layout can be edited
|
||||||
this->newMapMetatileId = getConfigUint32(key, value, 0, 1023, 0);
|
this->newMapMetatileId = getConfigUint32(key, value, 0, 1023, 0);
|
||||||
} else if (key == "new_map_elevation") {
|
} else if (key == "new_map_elevation") {
|
||||||
// TODO: Update max
|
// TODO: Update max once Block layout can be edited
|
||||||
this->newMapElevation = getConfigInteger(key, value, 0, 15, 3);
|
this->newMapElevation = getConfigInteger(key, value, 0, 15, 3);
|
||||||
|
} 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: The max of 1023 here should eventually reflect Project::num_metatiles_total-1,
|
// TODO: Update max once Block layout can be edited
|
||||||
// but the config is parsed well before that constant is.
|
|
||||||
int metatileId = getConfigUint32(key, metatileIds.at(i), 0, 1023, 0);
|
int metatileId = getConfigUint32(key, metatileIds.at(i), 0, 1023, 0);
|
||||||
this->newMapBorderMetatileIds.append(metatileId);
|
this->newMapBorderMetatileIds.append(metatileId);
|
||||||
}
|
}
|
||||||
|
@ -712,7 +714,6 @@ void ProjectConfig::parseConfigKeyValue(QString key, QString value) {
|
||||||
this->collisionSheetPath = value;
|
this->collisionSheetPath = value;
|
||||||
} else if (key == "collision_sheet_width") {
|
} else if (key == "collision_sheet_width") {
|
||||||
// Max for these two keys is if a user specifies blocks with 1 bit for metatile ID and 15 bits for collision or elevation
|
// Max for these two keys is if a user specifies blocks with 1 bit for metatile ID and 15 bits for collision or elevation
|
||||||
// TODO: Test to make sure there shouldn't be a stricter limit given the UI
|
|
||||||
this->collisionSheetWidth = getConfigInteger(key, value, 1, 0x7FFF, 2);
|
this->collisionSheetWidth = getConfigInteger(key, value, 1, 0x7FFF, 2);
|
||||||
} else if (key == "collision_sheet_height") {
|
} else if (key == "collision_sheet_height") {
|
||||||
this->collisionSheetHeight = getConfigInteger(key, value, 1, 0x7FFF, 16);
|
this->collisionSheetHeight = getConfigInteger(key, value, 1, 0x7FFF, 16);
|
||||||
|
@ -767,6 +768,7 @@ QMap<QString, QString> ProjectConfig::getKeyValueMap() {
|
||||||
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("new_map_metatile", Metatile::getMetatileIdString(this->newMapMetatileId));
|
||||||
map.insert("new_map_elevation", QString::number(this->newMapElevation));
|
map.insert("new_map_elevation", QString::number(this->newMapElevation));
|
||||||
|
map.insert("new_map_collision", QString::number(this->newMapCollision));
|
||||||
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);
|
||||||
|
@ -1014,6 +1016,15 @@ int ProjectConfig::getNewMapElevation() {
|
||||||
return this->newMapElevation;
|
return this->newMapElevation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProjectConfig::setNewMapCollision(int collision) {
|
||||||
|
this->newMapCollision = collision;
|
||||||
|
this->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ProjectConfig::getNewMapCollision() {
|
||||||
|
return this->newMapCollision;
|
||||||
|
}
|
||||||
|
|
||||||
void ProjectConfig::setNewMapBorderMetatileIds(QList<uint16_t> metatileIds) {
|
void ProjectConfig::setNewMapBorderMetatileIds(QList<uint16_t> metatileIds) {
|
||||||
this->newMapBorderMetatileIds = metatileIds;
|
this->newMapBorderMetatileIds = metatileIds;
|
||||||
this->save();
|
this->save();
|
||||||
|
@ -1131,7 +1142,6 @@ void ProjectConfig::setMapAllowFlagsEnabled(bool enabled) {
|
||||||
this->save();
|
this->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Expose to project settings editor
|
|
||||||
void ProjectConfig::setEventIconPath(Event::Group group, const QString &path) {
|
void ProjectConfig::setEventIconPath(Event::Group group, const QString &path) {
|
||||||
this->eventIconPaths[group] = path;
|
this->eventIconPaths[group] = path;
|
||||||
this->save();
|
this->save();
|
||||||
|
@ -1141,7 +1151,6 @@ QString ProjectConfig::getEventIconPath(Event::Group group) {
|
||||||
return this->eventIconPaths.value(group);
|
return this->eventIconPaths.value(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Expose to project settings editor
|
|
||||||
void ProjectConfig::setCollisionSheetPath(const QString &path) {
|
void ProjectConfig::setCollisionSheetPath(const QString &path) {
|
||||||
this->collisionSheetPath = path;
|
this->collisionSheetPath = path;
|
||||||
this->save();
|
this->save();
|
||||||
|
|
|
@ -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(0, projectConfig.getNewMapElevation()); // TODO: New map collision config?
|
movement_permissions_selector_item->select(projectConfig.getNewMapCollision(), projectConfig.getNewMapElevation());
|
||||||
}
|
}
|
||||||
|
|
||||||
scene_collision_metatiles->addItem(movement_permissions_selector_item);
|
scene_collision_metatiles->addItem(movement_permissions_selector_item);
|
||||||
|
@ -2243,13 +2243,15 @@ void Editor::setCollisionTabSpinBoxes(uint16_t collision, uint16_t elevation) {
|
||||||
ui->spinBox_SelectedElevation->setValue(elevation);
|
ui->spinBox_SelectedElevation->setValue(elevation);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Bug--Images with transparency allow users to paint metatiles on the Collision tab
|
|
||||||
// Custom collision graphics may be provided by the user.
|
// Custom collision graphics may be provided by the user.
|
||||||
void Editor::setCollisionGraphics() {
|
void Editor::setCollisionGraphics() {
|
||||||
QString customPath = projectConfig.getCollisionSheetPath();
|
QString customPath = projectConfig.getCollisionSheetPath();
|
||||||
|
|
||||||
QImage imgSheet;
|
QImage imgSheet;
|
||||||
if (!customPath.isEmpty()) {
|
if (customPath.isEmpty()) {
|
||||||
|
// No custom collision image specified, use the default.
|
||||||
|
imgSheet = this->defaultCollisionImgSheet;
|
||||||
|
} else {
|
||||||
// Try to load custom collision image
|
// Try to load custom collision image
|
||||||
QFileInfo info(customPath);
|
QFileInfo info(customPath);
|
||||||
if (info.isRelative()) {
|
if (info.isRelative()) {
|
||||||
|
@ -2261,12 +2263,9 @@ void Editor::setCollisionGraphics() {
|
||||||
logWarn(QString("Failed to load custom collision image '%1', using default.").arg(customPath));
|
logWarn(QString("Failed to load custom collision image '%1', using default.").arg(customPath));
|
||||||
imgSheet = this->defaultCollisionImgSheet;
|
imgSheet = this->defaultCollisionImgSheet;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// No custom collision image specified, use the default.
|
|
||||||
imgSheet = this->defaultCollisionImgSheet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Like the vanilla collision image, users are not required to provide an image that gives an icon for every elevation/collision combination.
|
// Users are not required to provide an image that gives an icon for every elevation/collision combination.
|
||||||
// Instead they tell us how many are provided in their image by specifying the number of columns and rows.
|
// Instead they tell us how many are provided in their image by specifying the number of columns and rows.
|
||||||
const int imgColumns = projectConfig.getCollisionSheetWidth();
|
const int imgColumns = projectConfig.getCollisionSheetWidth();
|
||||||
const int imgRows = projectConfig.getCollisionSheetHeight();
|
const int imgRows = projectConfig.getCollisionSheetHeight();
|
||||||
|
@ -2286,7 +2285,6 @@ void Editor::setCollisionGraphics() {
|
||||||
const int w = 16, h = 16;
|
const int w = 16, h = 16;
|
||||||
imgSheet = imgSheet.scaled(w * imgColumns, h * imgRows);
|
imgSheet = imgSheet.scaled(w * imgColumns, h * imgRows);
|
||||||
for (int collision = 0; collision <= Project::getMaxCollision(); collision++) {
|
for (int collision = 0; collision <= Project::getMaxCollision(); collision++) {
|
||||||
|
|
||||||
// If (collision >= imgColumns) here, it's a valid collision value, but it is not represented with an icon on the image sheet.
|
// If (collision >= imgColumns) here, it's a valid collision value, but it is not represented with an icon on the image sheet.
|
||||||
// In this case we just use the rightmost collision icon. This is mostly to support the vanilla case, where technically 0-3
|
// In this case we just use the rightmost collision icon. This is mostly to support the vanilla case, where technically 0-3
|
||||||
// are valid collision values, but 1-3 have the same meaning, so the vanilla collision selector image only has 2 columns.
|
// are valid collision values, but 1-3 have the same meaning, so the vanilla collision selector image only has 2 columns.
|
||||||
|
|
|
@ -2820,14 +2820,12 @@ void MainWindow::on_horizontalSlider_CollisionZoom_valueChanged(int value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_spinBox_SelectedCollision_valueChanged(int collision) {
|
void MainWindow::on_spinBox_SelectedCollision_valueChanged(int collision) {
|
||||||
if (!this->editor || !this->editor->movement_permissions_selector_item)
|
if (this->editor && this->editor->movement_permissions_selector_item)
|
||||||
return;
|
|
||||||
this->editor->movement_permissions_selector_item->select(collision, ui->spinBox_SelectedElevation->value());
|
this->editor->movement_permissions_selector_item->select(collision, ui->spinBox_SelectedElevation->value());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_spinBox_SelectedElevation_valueChanged(int elevation) {
|
void MainWindow::on_spinBox_SelectedElevation_valueChanged(int elevation) {
|
||||||
if (!this->editor || !this->editor->movement_permissions_selector_item)
|
if (this->editor && this->editor->movement_permissions_selector_item)
|
||||||
return;
|
|
||||||
this->editor->movement_permissions_selector_item->select(ui->spinBox_SelectedCollision->value(), elevation);
|
this->editor->movement_permissions_selector_item->select(ui->spinBox_SelectedCollision->value(), elevation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1114,7 +1114,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(), 0, projectConfig.getNewMapElevation());
|
Block block(projectConfig.getNewMapMetatileId(), projectConfig.getNewMapCollision(), projectConfig.getNewMapElevation());
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue