diff --git a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/autotile/asset/AutoTileAsset.kt b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/autotile/asset/AutoTileAsset.kt index 516d8d43..bdd70179 100644 --- a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/autotile/asset/AutoTileAsset.kt +++ b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/autotile/asset/AutoTileAsset.kt @@ -1,8 +1,15 @@ package com.bartlomiejpluta.base.editor.autotile.asset import com.bartlomiejpluta.base.editor.asset.model.GraphicAsset -import com.bartlomiejpluta.base.editor.autotile.model.AutoTile +import com.bartlomiejpluta.base.editor.autotile.model.AutoTileLayout import com.bartlomiejpluta.base.editor.project.model.Project -class AutoTileAsset(project: Project, uid: String, source: String, name: String, rows: Int, columns: Int) : - GraphicAsset(project.autoTilesDirectoryProperty, uid, source, name, rows, columns) \ No newline at end of file +class AutoTileAsset( + project: Project, + uid: String, + source: String, + name: String, + rows: Int, + columns: Int, + val layout: AutoTileLayout +) : GraphicAsset(project.autoTilesDirectoryProperty, uid, source, name, rows, columns) \ No newline at end of file diff --git a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/autotile/asset/AutoTileAssetData.kt b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/autotile/asset/AutoTileAssetData.kt index 4c070bf4..3159b7ed 100644 --- a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/autotile/asset/AutoTileAssetData.kt +++ b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/autotile/asset/AutoTileAssetData.kt @@ -1,6 +1,7 @@ package com.bartlomiejpluta.base.editor.autotile.asset import com.bartlomiejpluta.base.editor.autotile.model.AutoTile +import com.bartlomiejpluta.base.editor.autotile.model.AutoTileLayout import javafx.beans.property.SimpleIntegerProperty import javafx.beans.property.SimpleObjectProperty import javafx.beans.property.SimpleStringProperty @@ -26,4 +27,7 @@ class AutoTileAssetData { val fileProperty = SimpleObjectProperty() var file by fileProperty + + val layoutProperty = SimpleObjectProperty(AutoTileLayout.LAYOUT_2X2) + var layout by layoutProperty } \ No newline at end of file diff --git a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/autotile/model/AutoTile.kt b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/autotile/model/AutoTile.kt index a01c45e4..a9f67d86 100644 --- a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/autotile/model/AutoTile.kt +++ b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/autotile/model/AutoTile.kt @@ -11,7 +11,7 @@ import tornadofx.div import tornadofx.getValue // Algorithm source: https://love2d.org/forums/viewtopic.php?t=7826 -class AutoTile(uid: String, name: String, image: Image, rows: Int, columns: Int) { +class AutoTile(uid: String, name: String, image: Image, rows: Int, columns: Int, layout: AutoTileLayout) { val uidProperty = ReadOnlyStringWrapper(uid) val uid by uidProperty @@ -33,10 +33,10 @@ class AutoTile(uid: String, name: String, image: Image, rows: Int, columns: Int) val tileSetHeightProperty = SimpleIntegerProperty(image.height.toInt() / rows) val tileSetHeight by tileSetHeightProperty - val tileWidthProperty = tileSetWidthProperty.div(COLUMNS) + val tileWidthProperty = tileSetWidthProperty.div(layout.columns) val tileWidth by tileWidthProperty - val tileHeightProperty = tileSetHeightProperty.div(ROWS) + val tileHeightProperty = tileSetHeightProperty.div(layout.rows) val tileHeight by tileHeightProperty val widthProperty = SimpleIntegerProperty(image.width.toInt()) @@ -44,15 +44,34 @@ class AutoTile(uid: String, name: String, image: Image, rows: Int, columns: Int) val heightProperty = SimpleIntegerProperty(image.height.toInt() ) val height by heightProperty + + val layoutProperty = SimpleObjectProperty(layout) + val layout by layoutProperty - val islandSubTiles: Array> - val topLeftSubTiles: Array> - val topRightSubTiles: Array> - val bottomLeftSubTiles: Array> - val bottomRightSubTiles: Array> + lateinit var islandSubTiles: Array> + private set + + lateinit var topLeftSubTiles: Array> + private set + + lateinit var topRightSubTiles: Array> + private set + + lateinit var bottomLeftSubTiles: Array> + private set + + lateinit var bottomRightSubTiles: Array> + private set init { + when(layout) { + AutoTileLayout.LAYOUT_2X3 -> init2x3() + AutoTileLayout.LAYOUT_2X2 -> init2x2() + } + } + + private fun init2x3() { val islandSubTiles: MutableList> = mutableListOf() val topLeftSubTiles: MutableList> = mutableListOf() val topRightSubTiles: MutableList> = mutableListOf() @@ -88,6 +107,7 @@ class AutoTile(uid: String, name: String, image: Image, rows: Int, columns: Int) bottomLeftSubTiles += arrayOf(bl0, bl1, bl2, bl3, bl4) bottomRightSubTiles += arrayOf(br0, br1, br2, br3, br4) } + this.islandSubTiles = islandSubTiles.toTypedArray() this.topLeftSubTiles = topLeftSubTiles.toTypedArray() this.topRightSubTiles = topRightSubTiles.toTypedArray() @@ -95,7 +115,56 @@ class AutoTile(uid: String, name: String, image: Image, rows: Int, columns: Int) this.bottomRightSubTiles = bottomRightSubTiles.toTypedArray() } - fun getTile(layer: AutoTileLayer, row: Int, column: Int): Array { + private fun init2x2() { + val topLeftSubTiles: MutableList> = mutableListOf() + val topRightSubTiles: MutableList> = mutableListOf() + val bottomLeftSubTiles: MutableList> = mutableListOf() + val bottomRightSubTiles: MutableList> = mutableListOf() + + for (i in 0 until columns * rows) { + val tileSet = cropTileSet(i) + val topLeftCornerTile = cropTile(tileSet, 0, 0) + val topRightCornerTile = cropTile(tileSet, 1, 0) + val bottomLeftCornerTile = cropTile(tileSet, 0, 1) + val bottomRightCornerTile = cropTile(tileSet, 1, 1) + + /* + * Indexes: + * 0 - No connected tiles + * 1 - Left tile is connected + * 2 - Right tile is connected + * 3 - Left, Right, and Center tiles are connected. + */ + val (tl0, tr2, bl1, br3) = cutSubTiles(topLeftCornerTile) + val (tl1, tr0, bl3, br2) = cutSubTiles(topRightCornerTile) + val (tl2, tr3, bl0, br1) = cutSubTiles(bottomLeftCornerTile) + val (tl3, tr1, bl2, br0) = cutSubTiles(bottomRightCornerTile) + + topLeftSubTiles += arrayOf(tl0, tl1, tl2, tl3) + topRightSubTiles += arrayOf(tr0, tr1, tr2, tr3) + bottomLeftSubTiles += arrayOf(bl0, bl1, bl2, bl3) + bottomRightSubTiles += arrayOf(br0, br1, br2, br3) + } + + this.topLeftSubTiles = topLeftSubTiles.toTypedArray() + this.topRightSubTiles = topRightSubTiles.toTypedArray() + this.bottomLeftSubTiles = bottomLeftSubTiles.toTypedArray() + this.bottomRightSubTiles = bottomRightSubTiles.toTypedArray() + + this.islandSubTiles = this.topLeftSubTiles + } + + fun getTile(layer: AutoTileLayer, row: Int, column: Int, connect: Boolean) = when(layout!!) { + AutoTileLayout.LAYOUT_2X3 -> getTile2x3(layer, row, column, connect) + AutoTileLayout.LAYOUT_2X2 -> getTile2x2(layer, row, column, connect) + } + + private fun isAdjacent(currentId: Int, centerId: Int, connect: Boolean) = when (connect) { + true -> currentId > 0 + false -> currentId == centerId + } + + private fun getTile2x3(layer: AutoTileLayer, row: Int, column: Int, connect: Boolean): Array { var topLeft = 0 var topRight = 0 var bottomLeft = 0 @@ -104,51 +173,91 @@ class AutoTile(uid: String, name: String, image: Image, rows: Int, columns: Int) val id = layer.layer[row][column] // Top - if (row > 0 && layer.layer[row - 1][column] > 0) { + if (row > 0 && isAdjacent(layer.layer[row - 1][column] , id, connect)) { topLeft += 2 topRight += 1 } // Bottom - if (row < layer.rows - 1 && layer.layer[row + 1][column] > 0) { + if (row < layer.rows - 1 && isAdjacent(layer.layer[row + 1][column] , id, connect)) { bottomLeft += 1 bottomRight += 2 } // Left - if (column > 0 && layer.layer[row][column - 1] > 0) { + if (column > 0 && isAdjacent(layer.layer[row][column - 1] , id, connect)) { topLeft += 1 bottomLeft += 2 } // Right - if (column < layer.columns - 1 && layer.layer[row][column + 1] > 0) { + if (column < layer.columns - 1 && isAdjacent(layer.layer[row][column + 1] , id, connect)) { topRight += 2 bottomRight += 1 } // Top left - if (row > 0 && column > 0 && layer.layer[row - 1][column - 1] > 0 && topLeft == 3) { + if (row > 0 && column > 0 && isAdjacent(layer.layer[row - 1][column - 1] , id, connect) && topLeft == 3) { topLeft = 4 } // Top right - if (row > 0 && column < layer.columns - 1 && layer.layer[row - 1][column + 1] > 0 && topRight == 3) { + if (row > 0 && column < layer.columns - 1 && isAdjacent(layer.layer[row - 1][column + 1] , id, connect) && topRight == 3) { topRight = 4 } // Bottom left - if (row < layer.rows - 1 && column > 0 && layer.layer[row + 1][column - 1] > 0 && bottomLeft == 3) { + if (row < layer.rows - 1 && column > 0 && isAdjacent(layer.layer[row + 1][column - 1] , id, connect) && bottomLeft == 3) { bottomLeft = 4 } // Bottom right - if (row < layer.rows - 1 && column < layer.columns - 1 && layer.layer[row + 1][column + 1] > 0 && bottomRight == 3) { + if (row < layer.rows - 1 && column < layer.columns - 1 && isAdjacent(layer.layer[row + 1][column + 1] , id, connect) && bottomRight == 3) { bottomRight = 4 } if (topLeft == 0 && topRight == 0 && bottomLeft == 0 && bottomRight == 0) { - return islandSubTiles[id - 1] + return islandSubTiles!![id - 1] + } + + return arrayOf( + topLeftSubTiles[id - 1][topLeft], + topRightSubTiles[id - 1][topRight], + bottomLeftSubTiles[id - 1][bottomLeft], + bottomRightSubTiles[id - 1][bottomRight] + ) + } + + private fun getTile2x2(layer: AutoTileLayer, row: Int, column: Int, connect: Boolean): Array { + var topLeft = 0 + var topRight = 0 + var bottomLeft = 0 + var bottomRight = 0 + + val id = layer.layer[row][column] + + // Top + if (row > 0 && isAdjacent(layer.layer[row - 1][column] , id, connect)) { + topLeft += 2 + topRight += 1 + } + + // Bottom + if (row < layer.rows - 1 && isAdjacent(layer.layer[row + 1][column] , id, connect)) { + bottomLeft += 1 + bottomRight += 2 + } + + // Left + if (column > 0 && isAdjacent(layer.layer[row][column - 1] , id, connect)) { + topLeft += 1 + bottomLeft += 2 + } + + // Right + if (column < layer.columns - 1 && isAdjacent(layer.layer[row][column + 1] , id, connect)) { + topRight += 2 + bottomRight += 1 } return arrayOf( @@ -177,9 +286,4 @@ class AutoTile(uid: String, name: String, image: Image, rows: Int, columns: Int) return arrayOf(topLeft, topRight, bottomLeft, bottomRight) } - - companion object { - const val ROWS = 3 - const val COLUMNS = 2 - } } \ No newline at end of file diff --git a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/autotile/model/AutoTileLayout.kt b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/autotile/model/AutoTileLayout.kt new file mode 100644 index 00000000..93cef9b3 --- /dev/null +++ b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/autotile/model/AutoTileLayout.kt @@ -0,0 +1,8 @@ +package com.bartlomiejpluta.base.editor.autotile.model + +enum class AutoTileLayout(val columns: Int, val rows: Int) { + LAYOUT_2X2(2, 2), + LAYOUT_2X3(2, 3); + + override fun toString() = "$columns x $rows" +} \ No newline at end of file diff --git a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/autotile/view/importing/ImportAutoTileFragment.kt b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/autotile/view/importing/ImportAutoTileFragment.kt index 7f8fb258..e8b71dab 100644 --- a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/autotile/view/importing/ImportAutoTileFragment.kt +++ b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/autotile/view/importing/ImportAutoTileFragment.kt @@ -3,6 +3,7 @@ package com.bartlomiejpluta.base.editor.autotile.view.importing import com.bartlomiejpluta.base.editor.asset.component.GraphicAssetViewCanvas import com.bartlomiejpluta.base.editor.asset.viewmodel.GraphicAssetVM import com.bartlomiejpluta.base.editor.autotile.asset.AutoTileAssetData +import com.bartlomiejpluta.base.editor.autotile.model.AutoTileLayout import com.bartlomiejpluta.base.editor.autotile.viewmodel.AutoTileAssetDataVM import com.bartlomiejpluta.base.editor.util.fx.TextFieldUtil import javafx.beans.property.SimpleObjectProperty @@ -95,6 +96,12 @@ class ImportAutoTileFragment : Fragment("Import Auto Tile") { } } + field("Auto Tile Layout") { + combobox(values = AutoTileLayout.values().asList(), property = dataVM.layoutProperty) { + required() + } + } + field("Auto Tile Rows") { enableWhen(imagePreview.isNotNull) spinner(min = 1, max = Integer.MAX_VALUE, property = dataVM.rowsProperty, editable = true) { diff --git a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/autotile/viewmodel/AutoTileAssetDataVM.kt b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/autotile/viewmodel/AutoTileAssetDataVM.kt index d2f14e8b..214ff541 100644 --- a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/autotile/viewmodel/AutoTileAssetDataVM.kt +++ b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/autotile/viewmodel/AutoTileAssetDataVM.kt @@ -1,6 +1,8 @@ package com.bartlomiejpluta.base.editor.autotile.viewmodel import com.bartlomiejpluta.base.editor.autotile.asset.AutoTileAssetData +import com.bartlomiejpluta.base.editor.autotile.model.AutoTileLayout +import javafx.beans.property.SimpleObjectProperty import tornadofx.* class AutoTileAssetDataVM : ItemViewModel(AutoTileAssetData()) { @@ -21,4 +23,7 @@ class AutoTileAssetDataVM : ItemViewModel(AutoTileAssetData() val fileProperty = bind(AutoTileAssetData::fileProperty) var file by fileProperty + + val layoutProperty = bind(AutoTileAssetData::layoutProperty) + var layout by layoutProperty } \ No newline at end of file diff --git a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/canvas/MapCanvas.kt b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/canvas/MapCanvas.kt index d1456f63..db4e8fbf 100644 --- a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/canvas/MapCanvas.kt +++ b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/canvas/MapCanvas.kt @@ -133,7 +133,7 @@ class MapCanvas(val map: GameMapVM, private val editorStateVM: EditorStateVM, pr } private fun renderAutoTile(gc: GraphicsContext, autoTile: AutoTile, layer: AutoTileLayer, column: Int, row: Int) { - val (topLeft, topRight, bottomLeft, bottomRight) = autoTile.getTile(layer, row, column) + val (topLeft, topRight, bottomLeft, bottomRight) = autoTile.getTile(layer, row, column, layer.connect) val x = column * tileWidth val y = row * tileHeight gc.drawImage(topLeft, x, y) diff --git a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/model/layer/AutoTileLayer.kt b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/model/layer/AutoTileLayer.kt index b0b6c57e..a492bfdf 100644 --- a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/model/layer/AutoTileLayer.kt +++ b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/model/layer/AutoTileLayer.kt @@ -16,6 +16,7 @@ class AutoTileLayer( autoTileAsset: AutoTileAsset, animated: Boolean, animationDuration: Double, + connect: Boolean, layer: Array> = Array(rows) { Array(columns) { 0 } } ) : Layer { var layer = layer @@ -36,6 +37,9 @@ class AutoTileLayer( val animationDurationProperty = animationDuration.toProperty() var animationDuration by animationDurationProperty + val connectProperty = connect.toProperty() + var connect by connectProperty + val autoTileProperty = Bindings.createObjectBinding({ autoTileAsset.file.inputStream().use { fis -> AutoTile( @@ -43,7 +47,8 @@ class AutoTileLayer( autoTileAsset.name, Image(fis), autoTileAsset.rows, - autoTileAsset.columns + autoTileAsset.columns, + autoTileAsset.layout ) } }, autoTileAssetProperty) diff --git a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/parameter/layer/AutoTileLayerParametersBinder.kt b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/parameter/layer/AutoTileLayerParametersBinder.kt index ce973432..dc024e2c 100644 --- a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/parameter/layer/AutoTileLayerParametersBinder.kt +++ b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/parameter/layer/AutoTileLayerParametersBinder.kt @@ -33,10 +33,16 @@ class AutoTileLayerParametersBinder : LayerParametersBinder { submit() } + val connect = BooleanParameter("connect", layer.connect) { _, _, submit -> + onCommit() + submit() + } + autoTile.bindBidirectional(layer.autoTileAssetProperty) animated.bindBidirectional(layer.animatedProperty) animationDuration.bindBidirectional(layer.animationDurationProperty) + connect.bindBidirectional(layer.connectProperty) - parameters.addAll(autoTile, animated, animationDuration) + parameters.addAll(autoTile, animated, animationDuration, connect) } } \ No newline at end of file diff --git a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/serial/ProtobufMapDeserializer.kt b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/serial/ProtobufMapDeserializer.kt index e96b483b..18536b15 100644 --- a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/serial/ProtobufMapDeserializer.kt +++ b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/serial/ProtobufMapDeserializer.kt @@ -102,6 +102,7 @@ class ProtobufMapDeserializer : MapDeserializer { autoTile, proto.autoTileLayer.animated, proto.autoTileLayer.animationDuration, + proto.autoTileLayer.connect, layer ) } diff --git a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/serial/ProtobufMapSerializer.kt b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/serial/ProtobufMapSerializer.kt index 3afde373..5ebf3ece 100644 --- a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/serial/ProtobufMapSerializer.kt +++ b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/serial/ProtobufMapSerializer.kt @@ -38,6 +38,7 @@ class ProtobufMapSerializer : MapSerializer { .setAutotileUID(layer.autoTileAsset.uid) .setAnimated(layer.animated) .setAnimationDuration(layer.animationDuration) + .setConnect(layer.connect) .build() .let { GameMapProto.Layer.newBuilder().setName(layer.name).setAutoTileLayer(it).build() } diff --git a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/view/editor/MapLayersView.kt b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/view/editor/MapLayersView.kt index 5fbcf333..81712b8e 100644 --- a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/view/editor/MapLayersView.kt +++ b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/map/view/editor/MapLayersView.kt @@ -81,7 +81,7 @@ class MapLayersView : View() { find>(scope, SelectGraphicAssetFragment::assets to projectContext.project?.autoTiles!!).apply { onComplete { val layer = - AutoTileLayer("Layer ${mapVM.layers.size + 1}", mapVM.rows, mapVM.columns, it, false, 1.0) + AutoTileLayer("Layer ${mapVM.layers.size + 1}", mapVM.rows, mapVM.columns, it, false, 1.0, false) val command = CreateLayerCommand(mapVM.item, layer) command.execute() layersPane.selectionModel.select(mapVM.layers.size - 1) diff --git a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/project/context/DefaultProjectContext.kt b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/project/context/DefaultProjectContext.kt index df20601f..5a937512 100644 --- a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/project/context/DefaultProjectContext.kt +++ b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/project/context/DefaultProjectContext.kt @@ -188,7 +188,7 @@ class DefaultProjectContext : ProjectContext { val source = "$uid.${data.file.extension}" val targetFile = File(it.autoTilesDirectory, source) data.file.copyTo(targetFile) - it.autoTiles += AutoTileAsset(it, uid, source, data.name, data.rows, data.columns) + it.autoTiles += AutoTileAsset(it, uid, source, data.name, data.rows, data.columns, data.layout) save() } @@ -202,7 +202,7 @@ class DefaultProjectContext : ProjectContext { val image = File(it.autoTilesDirectory, asset.source).inputStream().use { fis -> Image(fis) } - AutoTile(uid, asset.name, image, asset.rows, asset.columns) + AutoTile(uid, asset.name, image, asset.rows, asset.columns, asset.layout) } ?: throw IllegalStateException("There is no open project in the context") } diff --git a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/project/serial/ProtobufProjectDeserializer.kt b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/project/serial/ProtobufProjectDeserializer.kt index 7a981636..d0e15835 100644 --- a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/project/serial/ProtobufProjectDeserializer.kt +++ b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/project/serial/ProtobufProjectDeserializer.kt @@ -3,6 +3,7 @@ package com.bartlomiejpluta.base.editor.project.serial import com.bartlomiejpluta.base.editor.animation.asset.AnimationAsset import com.bartlomiejpluta.base.editor.audio.asset.SoundAsset import com.bartlomiejpluta.base.editor.autotile.asset.AutoTileAsset +import com.bartlomiejpluta.base.editor.autotile.model.AutoTileLayout import com.bartlomiejpluta.base.editor.characterset.asset.CharacterSetAsset import com.bartlomiejpluta.base.editor.gui.font.asset.FontAsset import com.bartlomiejpluta.base.editor.gui.widget.asset.WidgetAsset @@ -58,7 +59,8 @@ class ProtobufProjectDeserializer : ProjectDeserializer { source = autoTile.source, name = autoTile.name, rows = autoTile.rows, - columns = autoTile.columns + columns = autoTile.columns, + layout = AutoTileLayout.valueOf(autoTile.layout.name) ) private fun deserializeImage(project: Project, image: ProjectProto.ImageAsset) = ImageAsset( diff --git a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/project/serial/ProtobufProjectSerializer.kt b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/project/serial/ProtobufProjectSerializer.kt index 812ae43b..5d98d904 100644 --- a/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/project/serial/ProtobufProjectSerializer.kt +++ b/editor/src/main/kotlin/com/bartlomiejpluta/base/editor/project/serial/ProtobufProjectSerializer.kt @@ -55,6 +55,7 @@ class ProtobufProjectSerializer : ProjectSerializer { .setName(autoTile.name) .setRows(autoTile.rows) .setColumns(autoTile.columns) + .setLayout(ProjectProto.AutoTileLayout.valueOf(autoTile.layout.name)) .build() private fun serializeImage(image: ImageAsset) = ProjectProto.ImageAsset.newBuilder() diff --git a/engine/src/main/java/com/bartlomiejpluta/base/engine/world/autotile/model/AutoTileLayout.java b/engine/src/main/java/com/bartlomiejpluta/base/engine/world/autotile/model/AutoTileLayout.java new file mode 100644 index 00000000..109402cf --- /dev/null +++ b/engine/src/main/java/com/bartlomiejpluta/base/engine/world/autotile/model/AutoTileLayout.java @@ -0,0 +1,2 @@ +package com.bartlomiejpluta.base.engine.world.autotile.model;public enum AutoTileLayout { +}