[Editor] Add support for ColorLayer serialization

This commit is contained in:
2021-02-18 21:24:01 +01:00
parent 8a41e50e6d
commit 162dac3aa6
5 changed files with 24 additions and 11 deletions

View File

@@ -5,21 +5,21 @@ import javafx.beans.property.SimpleStringProperty
import tornadofx.getValue
import tornadofx.setValue
class ColorLayer(name: String) : Layer {
class ColorLayer(name: String, red: Int, green: Int, blue: Int, alpha: Int) : Layer {
override val nameProperty = SimpleStringProperty(name)
override var name by nameProperty
val redProperty = SimpleObjectProperty(100)
val redProperty = SimpleObjectProperty(red)
var red by redProperty
val greenProperty = SimpleObjectProperty(100)
val greenProperty = SimpleObjectProperty(green)
var green by greenProperty
val blueProperty = SimpleObjectProperty(100)
val blueProperty = SimpleObjectProperty(blue)
var blue by blueProperty
val alphaProperty = SimpleObjectProperty(100)
val alphaProperty = SimpleObjectProperty(alpha)
var alpha by alphaProperty
override fun resize(rows: Int, columns: Int) {

View File

@@ -77,6 +77,12 @@ class ProtobufMapDeserializer : MapDeserializer {
}
private fun deserializeColorLayer(proto: GameMapProto.Layer): Layer {
return ColorLayer(proto.name)
return ColorLayer(
name = proto.name,
red = proto.colorLayer.red,
green = proto.colorLayer.green,
blue = proto.colorLayer.blue,
alpha = proto.colorLayer.alpha
)
}
}

View File

@@ -49,6 +49,10 @@ class ProtobufMapSerializer : MapSerializer {
.let { GameMapProto.Layer.newBuilder().setName(layer.name).setObjectLayer(it).build() }
is ColorLayer -> GameMapProto.ColorLayer.newBuilder()
.setRed(layer.red)
.setGreen(layer.green)
.setBlue(layer.blue)
.setAlpha(layer.alpha)
.build()
.let { GameMapProto.Layer.newBuilder().setName(layer.name).setColorLayer(it).build() }

View File

@@ -72,7 +72,7 @@ class MapLayersView : View() {
item("Color Layer", graphic = FontIcon("fa-paint-brush")) {
action {
val layer = ColorLayer("Layer ${mapVM.layers.size + 1}")
val layer = ColorLayer("Layer ${mapVM.layers.size + 1}", 100, 100, 100, 100)
val command = CreateLayerCommand(mapVM.item, layer)
command.execute()
layersPane.selectionModel.select(mapVM.layers.size - 1)

View File

@@ -39,11 +39,14 @@ enum PassageAbility {
RIGHT_ONLY = 5;
}
message ImageLayer {
// TODO r, g, b, alpha
message ColorLayer {
required uint32 red = 1;
required uint32 green = 2;
required uint32 blue = 3;
required uint32 alpha = 4;
}
message ColorLayer {
message ImageLayer {
// TODO imageUID
// TODO imageMode
}