[Editor] Add support for ColorLayer serialization
This commit is contained in:
@@ -5,21 +5,21 @@ import javafx.beans.property.SimpleStringProperty
|
|||||||
import tornadofx.getValue
|
import tornadofx.getValue
|
||||||
import tornadofx.setValue
|
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 val nameProperty = SimpleStringProperty(name)
|
||||||
|
|
||||||
override var name by nameProperty
|
override var name by nameProperty
|
||||||
|
|
||||||
val redProperty = SimpleObjectProperty(100)
|
val redProperty = SimpleObjectProperty(red)
|
||||||
var red by redProperty
|
var red by redProperty
|
||||||
|
|
||||||
val greenProperty = SimpleObjectProperty(100)
|
val greenProperty = SimpleObjectProperty(green)
|
||||||
var green by greenProperty
|
var green by greenProperty
|
||||||
|
|
||||||
val blueProperty = SimpleObjectProperty(100)
|
val blueProperty = SimpleObjectProperty(blue)
|
||||||
var blue by blueProperty
|
var blue by blueProperty
|
||||||
|
|
||||||
val alphaProperty = SimpleObjectProperty(100)
|
val alphaProperty = SimpleObjectProperty(alpha)
|
||||||
var alpha by alphaProperty
|
var alpha by alphaProperty
|
||||||
|
|
||||||
override fun resize(rows: Int, columns: Int) {
|
override fun resize(rows: Int, columns: Int) {
|
||||||
|
|||||||
@@ -77,6 +77,12 @@ class ProtobufMapDeserializer : MapDeserializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun deserializeColorLayer(proto: GameMapProto.Layer): Layer {
|
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
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,6 +49,10 @@ class ProtobufMapSerializer : MapSerializer {
|
|||||||
.let { GameMapProto.Layer.newBuilder().setName(layer.name).setObjectLayer(it).build() }
|
.let { GameMapProto.Layer.newBuilder().setName(layer.name).setObjectLayer(it).build() }
|
||||||
|
|
||||||
is ColorLayer -> GameMapProto.ColorLayer.newBuilder()
|
is ColorLayer -> GameMapProto.ColorLayer.newBuilder()
|
||||||
|
.setRed(layer.red)
|
||||||
|
.setGreen(layer.green)
|
||||||
|
.setBlue(layer.blue)
|
||||||
|
.setAlpha(layer.alpha)
|
||||||
.build()
|
.build()
|
||||||
.let { GameMapProto.Layer.newBuilder().setName(layer.name).setColorLayer(it).build() }
|
.let { GameMapProto.Layer.newBuilder().setName(layer.name).setColorLayer(it).build() }
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class MapLayersView : View() {
|
|||||||
|
|
||||||
item("Color Layer", graphic = FontIcon("fa-paint-brush")) {
|
item("Color Layer", graphic = FontIcon("fa-paint-brush")) {
|
||||||
action {
|
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)
|
val command = CreateLayerCommand(mapVM.item, layer)
|
||||||
command.execute()
|
command.execute()
|
||||||
layersPane.selectionModel.select(mapVM.layers.size - 1)
|
layersPane.selectionModel.select(mapVM.layers.size - 1)
|
||||||
|
|||||||
@@ -39,11 +39,14 @@ enum PassageAbility {
|
|||||||
RIGHT_ONLY = 5;
|
RIGHT_ONLY = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ImageLayer {
|
message ColorLayer {
|
||||||
// TODO r, g, b, alpha
|
required uint32 red = 1;
|
||||||
|
required uint32 green = 2;
|
||||||
|
required uint32 blue = 3;
|
||||||
|
required uint32 alpha = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
message ColorLayer {
|
message ImageLayer {
|
||||||
// TODO imageUID
|
// TODO imageUID
|
||||||
// TODO imageMode
|
// TODO imageMode
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user