[Editor] Add support for importing and storing images in :editor
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package com.bartlomiejpluta.base.editor.image.asset
|
||||
|
||||
import com.bartlomiejpluta.base.editor.asset.model.Asset
|
||||
import com.bartlomiejpluta.base.editor.project.model.Project
|
||||
|
||||
class ImageAsset(project: Project, uid: String, source: String, name: String) :
|
||||
Asset(project.imagesDirectoryProperty, uid, source, name)
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.bartlomiejpluta.base.editor.image.asset
|
||||
|
||||
import javafx.beans.property.SimpleObjectProperty
|
||||
import javafx.beans.property.SimpleStringProperty
|
||||
import tornadofx.getValue
|
||||
import tornadofx.setValue
|
||||
import java.io.File
|
||||
|
||||
class ImageAssetData {
|
||||
val nameProperty = SimpleStringProperty()
|
||||
var name by nameProperty
|
||||
|
||||
val fileProperty = SimpleObjectProperty<File>()
|
||||
var file by fileProperty
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.bartlomiejpluta.base.editor.image.view.importing
|
||||
|
||||
import com.bartlomiejpluta.base.editor.image.asset.ImageAssetData
|
||||
import com.bartlomiejpluta.base.editor.image.viewmodel.ImageAssetDataVM
|
||||
import javafx.beans.property.SimpleObjectProperty
|
||||
import javafx.scene.Cursor
|
||||
import javafx.scene.image.Image
|
||||
import javafx.stage.FileChooser
|
||||
import tornadofx.*
|
||||
|
||||
class ImportImageFragment : Fragment("Import Image") {
|
||||
private val dataVM = find<ImageAssetDataVM>()
|
||||
private val imagePreview = SimpleObjectProperty<Image?>()
|
||||
|
||||
private var onCompleteConsumer: ((ImageAssetData) -> Unit)? = null
|
||||
|
||||
init {
|
||||
dataVM.fileProperty.addListener { _, _, file ->
|
||||
when (file) {
|
||||
null -> imagePreview.value = null
|
||||
else -> file.inputStream().use { imagePreview.value = Image(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onComplete(consumer: (ImageAssetData) -> Unit) {
|
||||
this.onCompleteConsumer = consumer
|
||||
}
|
||||
|
||||
override val root = form {
|
||||
prefHeight = 480.0
|
||||
|
||||
fieldset("Import Image") {
|
||||
hbox {
|
||||
vbox {
|
||||
scrollpane {
|
||||
prefWidth = 300.0
|
||||
prefHeightProperty().bind(this@form.heightProperty())
|
||||
imageview(imagePreview)
|
||||
tooltip = tooltip("Click to choose image file")
|
||||
cursor = Cursor.HAND
|
||||
|
||||
setOnMouseClicked {
|
||||
dataVM.file = chooseFile(
|
||||
title = "Select Image",
|
||||
filters = arrayOf(FileChooser.ExtensionFilter("PNG Images (*.png)", "*.png"))
|
||||
).getOrNull(0)
|
||||
}
|
||||
|
||||
dataVM.validationContext.addValidator(this@vbox, dataVM.fileProperty) {
|
||||
when {
|
||||
it == null -> error("This field is required")
|
||||
!it.exists() -> error("The file must exist")
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vbox {
|
||||
paddingLeft = 20.0
|
||||
|
||||
field("Image Name") {
|
||||
textfield(dataVM.nameProperty) {
|
||||
required()
|
||||
trimWhitespace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buttonbar {
|
||||
button("Import") {
|
||||
action {
|
||||
if (dataVM.commit()) {
|
||||
onCompleteConsumer?.let { it(dataVM.item) }
|
||||
close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
button("Reset") {
|
||||
action { dataVM.rollback() }
|
||||
}
|
||||
|
||||
|
||||
button("Cancel") {
|
||||
action { close() }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.bartlomiejpluta.base.editor.image.viewmodel
|
||||
|
||||
import com.bartlomiejpluta.base.editor.image.asset.ImageAssetData
|
||||
import tornadofx.ItemViewModel
|
||||
import tornadofx.getValue
|
||||
import tornadofx.setValue
|
||||
|
||||
class ImageAssetDataVM : ItemViewModel<ImageAssetData>(ImageAssetData()) {
|
||||
val nameProperty = bind(ImageAssetData::nameProperty)
|
||||
var name by nameProperty
|
||||
|
||||
val fileProperty = bind(ImageAssetData::fileProperty)
|
||||
var file by fileProperty
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.bartlomiejpluta.base.editor.main.controller
|
||||
|
||||
import com.bartlomiejpluta.base.editor.command.context.UndoableScope
|
||||
import com.bartlomiejpluta.base.editor.image.view.importing.ImportImageFragment
|
||||
import com.bartlomiejpluta.base.editor.image.viewmodel.ImageAssetDataVM
|
||||
import com.bartlomiejpluta.base.editor.map.model.map.GameMap
|
||||
import com.bartlomiejpluta.base.editor.map.view.wizard.MapCreationWizard
|
||||
import com.bartlomiejpluta.base.editor.map.viewmodel.GameMapBuilderVM
|
||||
@@ -10,7 +12,7 @@ import com.bartlomiejpluta.base.editor.project.model.Project
|
||||
import com.bartlomiejpluta.base.editor.project.view.ProjectSettingsFragment
|
||||
import com.bartlomiejpluta.base.editor.project.viewmodel.ProjectVM
|
||||
import com.bartlomiejpluta.base.editor.tileset.view.importing.ImportTileSetFragment
|
||||
import com.bartlomiejpluta.base.editor.tileset.viewmodel.TileSetAssetBuilderVM
|
||||
import com.bartlomiejpluta.base.editor.tileset.viewmodel.TileSetAssetDataVM
|
||||
import javafx.stage.FileChooser
|
||||
import org.springframework.stereotype.Component
|
||||
import tornadofx.*
|
||||
@@ -76,7 +78,7 @@ class MainController : Controller() {
|
||||
}
|
||||
|
||||
fun importTileSet() {
|
||||
val vm = TileSetAssetBuilderVM()
|
||||
val vm = TileSetAssetDataVM()
|
||||
val scope = Scope()
|
||||
setInScope(vm, scope)
|
||||
|
||||
@@ -88,4 +90,18 @@ class MainController : Controller() {
|
||||
openModal(block = true, resizable = false)
|
||||
}
|
||||
}
|
||||
|
||||
fun importImage() {
|
||||
val vm = ImageAssetDataVM()
|
||||
val scope = Scope()
|
||||
setInScope(vm, scope)
|
||||
|
||||
find<ImportImageFragment>(scope).apply {
|
||||
onComplete {
|
||||
projectContext.importImage(it)
|
||||
}
|
||||
|
||||
openModal(block = true, resizable = false)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,14 @@ class MainMenuView : View() {
|
||||
mainController.importTileSet()
|
||||
}
|
||||
}
|
||||
|
||||
item("Import Image...") {
|
||||
enableWhen(projectContext.projectProperty.isNotNull)
|
||||
|
||||
action {
|
||||
mainController.importImage()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
menu("Edit") {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.bartlomiejpluta.base.editor.main.view
|
||||
|
||||
import com.bartlomiejpluta.base.editor.asset.model.Asset
|
||||
import com.bartlomiejpluta.base.editor.image.asset.ImageAsset
|
||||
import com.bartlomiejpluta.base.editor.main.controller.MainController
|
||||
import com.bartlomiejpluta.base.editor.map.asset.GameMapAsset
|
||||
import com.bartlomiejpluta.base.editor.project.context.ProjectContext
|
||||
@@ -19,10 +20,12 @@ class ProjectStructureView : View() {
|
||||
|
||||
private val structureMaps = StructureCategory("Maps")
|
||||
private val structureTileSets = StructureCategory("Tile Sets")
|
||||
private val structureImages = StructureCategory("Images")
|
||||
|
||||
private val structureRoot = StructureCategory(name = "Project", items = observableListOf(
|
||||
structureMaps,
|
||||
structureTileSets
|
||||
structureTileSets,
|
||||
structureImages
|
||||
))
|
||||
|
||||
init {
|
||||
@@ -31,6 +34,7 @@ class ProjectStructureView : View() {
|
||||
structureRoot.nameProperty.bind(it.nameProperty)
|
||||
Bindings.bindContent(structureMaps.items, it.maps)
|
||||
Bindings.bindContent(structureTileSets.items, it.tileSets)
|
||||
Bindings.bindContent(structureImages.items, it.images)
|
||||
root.root.expandAll()
|
||||
root.refresh()
|
||||
}
|
||||
@@ -46,6 +50,7 @@ class ProjectStructureView : View() {
|
||||
is StructureCategory -> FontIcon("fa-folder")
|
||||
is GameMapAsset -> FontIcon("fa-map")
|
||||
is TileSetAsset -> FontIcon("fa-th")
|
||||
is ImageAsset -> FontIcon("fa-image")
|
||||
else -> null
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.bartlomiejpluta.base.editor.project.context
|
||||
|
||||
import com.bartlomiejpluta.base.editor.asset.model.Asset
|
||||
import com.bartlomiejpluta.base.editor.image.asset.ImageAsset
|
||||
import com.bartlomiejpluta.base.editor.image.asset.ImageAssetData
|
||||
import com.bartlomiejpluta.base.editor.map.asset.GameMapAsset
|
||||
import com.bartlomiejpluta.base.editor.map.model.map.GameMap
|
||||
import com.bartlomiejpluta.base.editor.map.serial.MapDeserializer
|
||||
@@ -9,7 +11,7 @@ import com.bartlomiejpluta.base.editor.project.model.Project
|
||||
import com.bartlomiejpluta.base.editor.project.serial.ProjectDeserializer
|
||||
import com.bartlomiejpluta.base.editor.project.serial.ProjectSerializer
|
||||
import com.bartlomiejpluta.base.editor.tileset.asset.TileSetAsset
|
||||
import com.bartlomiejpluta.base.editor.tileset.asset.TileSetAssetBuilder
|
||||
import com.bartlomiejpluta.base.editor.tileset.asset.TileSetAssetData
|
||||
import com.bartlomiejpluta.base.editor.tileset.model.TileSet
|
||||
import com.bartlomiejpluta.base.editor.util.uid.UID
|
||||
import javafx.beans.property.ObjectProperty
|
||||
@@ -95,13 +97,13 @@ class DefaultProjectContext : ProjectContext {
|
||||
}
|
||||
}
|
||||
|
||||
override fun importTileSet(builder: TileSetAssetBuilder) {
|
||||
override fun importTileSet(data: TileSetAssetData) {
|
||||
project?.let {
|
||||
UID.next(it.tileSets.map(Asset::uid)).let { uid ->
|
||||
val source = "$uid.${builder.file.extension}"
|
||||
val source = "$uid.${data.file.extension}"
|
||||
val targetFile = File(it.tileSetsDirectory, source)
|
||||
builder.file.copyTo(targetFile)
|
||||
it.tileSets += TileSetAsset(it, uid, source, builder.name, builder.rows, builder.columns)
|
||||
data.file.copyTo(targetFile)
|
||||
it.tileSets += TileSetAsset(it, uid, source, data.name, data.rows, data.columns)
|
||||
|
||||
save()
|
||||
}
|
||||
@@ -118,4 +120,25 @@ class DefaultProjectContext : ProjectContext {
|
||||
TileSet(uid, asset.name, image, asset.rows, asset.columns)
|
||||
} ?: throw IllegalStateException("There is no open project in the context")
|
||||
}
|
||||
|
||||
override fun importImage(data: ImageAssetData) {
|
||||
project?.let {
|
||||
UID.next(it.images.map(Asset::uid)).let { uid ->
|
||||
val source = "$uid.${data.file.extension}"
|
||||
val targetFile = File(it.imagesDirectory, source)
|
||||
data.file.copyTo(targetFile)
|
||||
it.images += ImageAsset(it, uid, source, data.name)
|
||||
|
||||
save()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun loadImage(uid: String) = project?.let {
|
||||
val asset = it.images.firstOrNull { image -> image.uid == uid }
|
||||
?: throw IllegalStateException("The Image with uid [$uid] does not exist ")
|
||||
|
||||
File(it.imagesDirectory, asset.source).inputStream().use { fis -> Image(fis) }
|
||||
} ?: throw IllegalStateException("There is no open project in the context")
|
||||
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.bartlomiejpluta.base.editor.project.context
|
||||
|
||||
import com.bartlomiejpluta.base.editor.image.asset.ImageAssetData
|
||||
import com.bartlomiejpluta.base.editor.map.model.map.GameMap
|
||||
import com.bartlomiejpluta.base.editor.project.model.Project
|
||||
import com.bartlomiejpluta.base.editor.tileset.asset.TileSetAssetBuilder
|
||||
import com.bartlomiejpluta.base.editor.tileset.asset.TileSetAssetData
|
||||
import com.bartlomiejpluta.base.editor.tileset.model.TileSet
|
||||
import javafx.beans.property.ObjectProperty
|
||||
import javafx.scene.image.Image
|
||||
import java.io.File
|
||||
|
||||
interface ProjectContext {
|
||||
@@ -18,6 +20,9 @@ interface ProjectContext {
|
||||
fun loadMap(uid: String): GameMap
|
||||
fun saveMap(map: GameMap)
|
||||
|
||||
fun importTileSet(builder: TileSetAssetBuilder)
|
||||
fun importTileSet(data: TileSetAssetData)
|
||||
fun loadTileSet(uid: String): TileSet
|
||||
|
||||
fun importImage(data: ImageAssetData)
|
||||
fun loadImage(uid: String): Image
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.bartlomiejpluta.base.editor.project.model
|
||||
|
||||
import com.bartlomiejpluta.base.editor.image.asset.ImageAsset
|
||||
import com.bartlomiejpluta.base.editor.map.asset.GameMapAsset
|
||||
import com.bartlomiejpluta.base.editor.project.context.DefaultProjectContext
|
||||
import com.bartlomiejpluta.base.editor.tileset.asset.TileSetAsset
|
||||
import javafx.beans.property.SimpleObjectProperty
|
||||
import javafx.beans.property.SimpleStringProperty
|
||||
@@ -19,6 +19,7 @@ class Project {
|
||||
|
||||
val maps = observableListOf<GameMapAsset>()
|
||||
val tileSets = observableListOf<TileSetAsset>()
|
||||
val images = observableListOf<ImageAsset>()
|
||||
|
||||
val mapsDirectoryProperty = SimpleObjectProperty<File>()
|
||||
var mapsDirectory by mapsDirectoryProperty
|
||||
@@ -26,12 +27,18 @@ class Project {
|
||||
|
||||
val tileSetsDirectoryProperty = SimpleObjectProperty<File>()
|
||||
var tileSetsDirectory by tileSetsDirectoryProperty
|
||||
private set
|
||||
|
||||
val imagesDirectoryProperty = SimpleObjectProperty<File>()
|
||||
var imagesDirectory by imagesDirectoryProperty
|
||||
private set
|
||||
|
||||
init {
|
||||
sourceDirectoryProperty.addListener { _, _, dir ->
|
||||
dir?.let {
|
||||
mapsDirectory = File(it, MAPS_DIR)
|
||||
tileSetsDirectory = File(it, TILESETS_DIR)
|
||||
imagesDirectory = File(it, IMAGES_DIR)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,10 +47,12 @@ class Project {
|
||||
sourceDirectory?.mkdirs()
|
||||
mapsDirectory?.mkdirs()
|
||||
tileSetsDirectory?.mkdirs()
|
||||
imagesDirectory?.mkdirs()
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val MAPS_DIR = "maps"
|
||||
const val TILESETS_DIR = "tilesets"
|
||||
const val IMAGES_DIR = "images"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.bartlomiejpluta.base.editor.project.serial
|
||||
|
||||
import com.bartlomiejpluta.base.editor.image.asset.ImageAsset
|
||||
import com.bartlomiejpluta.base.editor.map.asset.GameMapAsset
|
||||
import com.bartlomiejpluta.base.editor.project.model.Project
|
||||
import com.bartlomiejpluta.base.editor.tileset.asset.TileSetAsset
|
||||
@@ -16,6 +17,7 @@ class ProtobufProjectDeserializer : ProjectDeserializer {
|
||||
project.name = proto.name
|
||||
project.maps.addAll(proto.mapsList.map { deserializeMap(project, it) })
|
||||
project.tileSets.addAll(proto.tileSetsList.map { deserializeTileSet(project, it) })
|
||||
project.images.addAll(proto.imagesList.map { deserializeImage(project, it) })
|
||||
|
||||
return project
|
||||
}
|
||||
@@ -34,4 +36,11 @@ class ProtobufProjectDeserializer : ProjectDeserializer {
|
||||
rows = tileSet.rows,
|
||||
columns = tileSet.columns
|
||||
)
|
||||
|
||||
private fun deserializeImage(project: Project, image: ProjectProto.ImageAsset) = ImageAsset(
|
||||
project = project,
|
||||
uid = image.uid,
|
||||
source = image.source,
|
||||
name = image.name
|
||||
)
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.bartlomiejpluta.base.editor.project.serial
|
||||
|
||||
import com.bartlomiejpluta.base.editor.image.asset.ImageAsset
|
||||
import com.bartlomiejpluta.base.editor.map.asset.GameMapAsset
|
||||
import com.bartlomiejpluta.base.editor.project.model.Project
|
||||
import com.bartlomiejpluta.base.editor.tileset.asset.TileSetAsset
|
||||
@@ -15,6 +16,7 @@ class ProtobufProjectSerializer : ProjectSerializer {
|
||||
proto.name = item.name
|
||||
proto.addAllMaps(item.maps.map(this::serializeMap))
|
||||
proto.addAllTileSets(item.tileSets.map(this::serializeTileSet))
|
||||
proto.addAllImages(item.images.map(this::serializeImage))
|
||||
proto.build().writeTo(output)
|
||||
}
|
||||
|
||||
@@ -31,4 +33,10 @@ class ProtobufProjectSerializer : ProjectSerializer {
|
||||
.setRows(tileSet.rows)
|
||||
.setColumns(tileSet.columns)
|
||||
.build()
|
||||
|
||||
private fun serializeImage(image: ImageAsset) = ProjectProto.ImageAsset.newBuilder()
|
||||
.setUid(image.uid)
|
||||
.setSource(image.source)
|
||||
.setName(image.name)
|
||||
.build()
|
||||
}
|
||||
@@ -3,10 +3,11 @@ package com.bartlomiejpluta.base.editor.tileset.asset
|
||||
import javafx.beans.property.SimpleIntegerProperty
|
||||
import javafx.beans.property.SimpleObjectProperty
|
||||
import javafx.beans.property.SimpleStringProperty
|
||||
import tornadofx.getValue
|
||||
import tornadofx.setValue
|
||||
import java.io.File
|
||||
import tornadofx.*
|
||||
|
||||
class TileSetAssetBuilder {
|
||||
class TileSetAssetData {
|
||||
val nameProperty = SimpleStringProperty()
|
||||
var name by nameProperty
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.bartlomiejpluta.base.editor.tileset.view.importing
|
||||
|
||||
import com.bartlomiejpluta.base.editor.tileset.asset.TileSetAssetBuilder
|
||||
import com.bartlomiejpluta.base.editor.tileset.viewmodel.TileSetAssetBuilderVM
|
||||
import com.bartlomiejpluta.base.editor.tileset.asset.TileSetAssetData
|
||||
import com.bartlomiejpluta.base.editor.tileset.viewmodel.TileSetAssetDataVM
|
||||
import javafx.beans.property.SimpleObjectProperty
|
||||
import javafx.scene.Cursor
|
||||
import javafx.scene.image.Image
|
||||
@@ -9,21 +9,21 @@ import javafx.stage.FileChooser
|
||||
import tornadofx.*
|
||||
|
||||
class ImportTileSetFragment : Fragment("Import Tile Set") {
|
||||
private val builderVM = find<TileSetAssetBuilderVM>()
|
||||
private val dataVM = find<TileSetAssetDataVM>()
|
||||
private val imagePreview = SimpleObjectProperty<Image?>()
|
||||
|
||||
private var onCompleteConsumer: ((TileSetAssetBuilder) -> Unit)? = null
|
||||
private var onCompleteConsumer: ((TileSetAssetData) -> Unit)? = null
|
||||
|
||||
init {
|
||||
builderVM.fileProperty.addListener { _, _, file ->
|
||||
when(file) {
|
||||
dataVM.fileProperty.addListener { _, _, file ->
|
||||
when (file) {
|
||||
null -> imagePreview.value = null
|
||||
else -> file.inputStream().use { imagePreview.value = Image(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onComplete(consumer: (TileSetAssetBuilder) -> Unit) {
|
||||
fun onComplete(consumer: (TileSetAssetData) -> Unit) {
|
||||
this.onCompleteConsumer = consumer
|
||||
}
|
||||
|
||||
@@ -41,13 +41,13 @@ class ImportTileSetFragment : Fragment("Import Tile Set") {
|
||||
cursor = Cursor.HAND
|
||||
|
||||
setOnMouseClicked {
|
||||
builderVM.file = chooseFile(
|
||||
dataVM.file = chooseFile(
|
||||
title = "Select Sprite",
|
||||
filters = arrayOf(FileChooser.ExtensionFilter("PNG Images (*.png)", "*.png"))
|
||||
).getOrNull(0)
|
||||
}
|
||||
|
||||
builderVM.validationContext.addValidator(this@vbox, builderVM.fileProperty) {
|
||||
dataVM.validationContext.addValidator(this@vbox, dataVM.fileProperty) {
|
||||
when {
|
||||
it == null -> error("This field is required")
|
||||
!it.exists() -> error("The file must exist")
|
||||
@@ -61,14 +61,14 @@ class ImportTileSetFragment : Fragment("Import Tile Set") {
|
||||
paddingLeft = 20.0
|
||||
|
||||
field("Tile Set Name") {
|
||||
textfield(builderVM.nameProperty) {
|
||||
textfield(dataVM.nameProperty) {
|
||||
required()
|
||||
trimWhitespace()
|
||||
}
|
||||
}
|
||||
|
||||
field("Tile Set Rows") {
|
||||
textfield(builderVM.rowsProperty) {
|
||||
textfield(dataVM.rowsProperty) {
|
||||
stripNonInteger()
|
||||
required()
|
||||
trimWhitespace()
|
||||
@@ -85,7 +85,7 @@ class ImportTileSetFragment : Fragment("Import Tile Set") {
|
||||
}
|
||||
|
||||
field("Tile Set Columns") {
|
||||
textfield(builderVM.columnsProperty) {
|
||||
textfield(dataVM.columnsProperty) {
|
||||
stripNonInteger()
|
||||
required()
|
||||
trimWhitespace()
|
||||
@@ -107,15 +107,15 @@ class ImportTileSetFragment : Fragment("Import Tile Set") {
|
||||
buttonbar {
|
||||
button("Import") {
|
||||
action {
|
||||
if(builderVM.commit()) {
|
||||
onCompleteConsumer?.let { it(builderVM.item) }
|
||||
if (dataVM.commit()) {
|
||||
onCompleteConsumer?.let { it(dataVM.item) }
|
||||
close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
button("Reset") {
|
||||
action { builderVM.rollback() }
|
||||
action { dataVM.rollback() }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.bartlomiejpluta.base.editor.tileset.viewmodel
|
||||
|
||||
import com.bartlomiejpluta.base.editor.tileset.asset.TileSetAssetBuilder
|
||||
import tornadofx.ItemViewModel
|
||||
import tornadofx.getValue
|
||||
import tornadofx.setValue
|
||||
|
||||
class TileSetAssetBuilderVM : ItemViewModel<TileSetAssetBuilder>(TileSetAssetBuilder()) {
|
||||
val nameProperty = bind(TileSetAssetBuilder::nameProperty)
|
||||
var name by nameProperty
|
||||
|
||||
val rowsProperty = bind(TileSetAssetBuilder::rowsProperty)
|
||||
var rows by rowsProperty
|
||||
|
||||
val columnsProperty = bind(TileSetAssetBuilder::columnsProperty)
|
||||
var columns by columnsProperty
|
||||
|
||||
val fileProperty = bind(TileSetAssetBuilder::fileProperty)
|
||||
var file by fileProperty
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.bartlomiejpluta.base.editor.tileset.viewmodel
|
||||
|
||||
import com.bartlomiejpluta.base.editor.tileset.asset.TileSetAssetData
|
||||
import tornadofx.ItemViewModel
|
||||
import tornadofx.getValue
|
||||
import tornadofx.setValue
|
||||
|
||||
class TileSetAssetDataVM : ItemViewModel<TileSetAssetData>(TileSetAssetData()) {
|
||||
val nameProperty = bind(TileSetAssetData::nameProperty)
|
||||
var name by nameProperty
|
||||
|
||||
val rowsProperty = bind(TileSetAssetData::rowsProperty)
|
||||
var rows by rowsProperty
|
||||
|
||||
val columnsProperty = bind(TileSetAssetData::columnsProperty)
|
||||
var columns by columnsProperty
|
||||
|
||||
val fileProperty = bind(TileSetAssetData::fileProperty)
|
||||
var file by fileProperty
|
||||
}
|
||||
@@ -7,6 +7,7 @@ message Project {
|
||||
required string name = 1;
|
||||
repeated GameMapAsset maps = 2;
|
||||
repeated TileSetAsset tileSets = 3;
|
||||
repeated ImageAsset images = 4;
|
||||
}
|
||||
|
||||
message GameMapAsset {
|
||||
@@ -21,4 +22,10 @@ message TileSetAsset {
|
||||
required string name = 3;
|
||||
required uint32 rows = 4;
|
||||
required uint32 columns = 5;
|
||||
}
|
||||
|
||||
message ImageAsset {
|
||||
required string uid = 1;
|
||||
required string source = 2;
|
||||
required string name = 3;
|
||||
}
|
||||
Reference in New Issue
Block a user