[Editor] Move map settings (size) from Settings dialog to map parameters
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package com.bartlomiejpluta.base.editor.common.parameter.model
|
package com.bartlomiejpluta.base.editor.common.parameter.model
|
||||||
|
|
||||||
import com.bartlomiejpluta.base.editor.util.fx.TextFieldUtil
|
import com.bartlomiejpluta.base.editor.util.fx.TextFieldUtil
|
||||||
|
import javafx.beans.property.IntegerProperty
|
||||||
import javafx.beans.property.Property
|
import javafx.beans.property.Property
|
||||||
import javafx.scene.control.Spinner
|
import javafx.scene.control.Spinner
|
||||||
|
|
||||||
@@ -32,4 +33,8 @@ class IntegerParameter(
|
|||||||
init {
|
init {
|
||||||
super.init()
|
super.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun bindBidirectional(other: IntegerProperty) {
|
||||||
|
super.bindBidirectional(other.asObject())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -19,6 +19,7 @@ class MapFragment : Fragment() {
|
|||||||
private val toolbarView = find<MapToolbarView>()
|
private val toolbarView = find<MapToolbarView>()
|
||||||
private val statusBarView = find<MapStatusBarView>()
|
private val statusBarView = find<MapStatusBarView>()
|
||||||
private val layerParameters = find<MapLayerParameters>()
|
private val layerParameters = find<MapLayerParameters>()
|
||||||
|
private val mapParameters = find<MapParameters>()
|
||||||
|
|
||||||
private val isTileLayerSelected = Bindings.createBooleanBinding(
|
private val isTileLayerSelected = Bindings.createBooleanBinding(
|
||||||
{ editorStateVM.selectedLayer is TileLayer },
|
{ editorStateVM.selectedLayer is TileLayer },
|
||||||
@@ -48,6 +49,10 @@ class MapFragment : Fragment() {
|
|||||||
item("Layer Parameters", expanded = false) {
|
item("Layer Parameters", expanded = false) {
|
||||||
this += layerParameters
|
this += layerParameters
|
||||||
}
|
}
|
||||||
|
|
||||||
|
item("Map Parameters", expanded = false) {
|
||||||
|
this += mapParameters
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bottom = statusBarView.root
|
bottom = statusBarView.root
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.bartlomiejpluta.base.editor.map.view.editor
|
||||||
|
|
||||||
|
import com.bartlomiejpluta.base.editor.common.parameter.model.IntegerParameter
|
||||||
|
import com.bartlomiejpluta.base.editor.common.parameter.view.ParametersTableFragment
|
||||||
|
import com.bartlomiejpluta.base.editor.map.viewmodel.GameMapVM
|
||||||
|
import tornadofx.View
|
||||||
|
import tornadofx.observableListOf
|
||||||
|
|
||||||
|
class MapParameters : View() {
|
||||||
|
private val mapVM = find<GameMapVM>()
|
||||||
|
|
||||||
|
private val parameters = observableListOf(
|
||||||
|
IntegerParameter("rows", mapVM.rows, 1, 100).apply { bindBidirectional(mapVM.item.rowsProperty) },
|
||||||
|
IntegerParameter("columns", mapVM.columns, 1, 100).apply { bindBidirectional(mapVM.item.columnsProperty) },
|
||||||
|
)
|
||||||
|
|
||||||
|
override val root = find<ParametersTableFragment>(ParametersTableFragment::parameters to parameters).root
|
||||||
|
}
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
package com.bartlomiejpluta.base.editor.map.view.editor
|
|
||||||
|
|
||||||
import com.bartlomiejpluta.base.editor.command.context.UndoableScope
|
|
||||||
import com.bartlomiejpluta.base.editor.command.service.UndoRedoService
|
|
||||||
import com.bartlomiejpluta.base.editor.map.viewmodel.GameMapVM
|
|
||||||
import com.bartlomiejpluta.base.editor.util.fx.TextFieldUtil
|
|
||||||
import tornadofx.*
|
|
||||||
|
|
||||||
class MapSettingsFragment : Fragment("Map Settings") {
|
|
||||||
override val scope = super.scope as UndoableScope
|
|
||||||
private val undoRedoService: UndoRedoService by di()
|
|
||||||
|
|
||||||
private val mapVM = find<GameMapVM>()
|
|
||||||
|
|
||||||
var result = false
|
|
||||||
private set
|
|
||||||
|
|
||||||
override val root = form {
|
|
||||||
fieldset("Map Settings") {
|
|
||||||
field("Rows") {
|
|
||||||
|
|
||||||
spinner(min = 1, max = 100, property = mapVM.rowsProperty, editable = true) {
|
|
||||||
required()
|
|
||||||
editor.textFormatter = TextFieldUtil.integerFormatter(mapVM.rows)
|
|
||||||
|
|
||||||
validator {
|
|
||||||
when (it?.toInt()) {
|
|
||||||
in 1..50 -> null
|
|
||||||
in 50..100 -> warning("The map sizes over 50 can impact game performance")
|
|
||||||
else -> error("The map size must be between 1 and 100")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
field("Columns") {
|
|
||||||
spinner(min = 1, max = 100, property = mapVM.columnsProperty, editable = true) {
|
|
||||||
required()
|
|
||||||
editor.textFormatter = TextFieldUtil.integerFormatter(mapVM.columns)
|
|
||||||
|
|
||||||
validator {
|
|
||||||
when (it?.toInt()) {
|
|
||||||
in 1..50 -> null
|
|
||||||
in 50..100 -> warning("The map sizes over 50 can impact game performance")
|
|
||||||
else -> error("The map size must be between 1 and 100")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
label("Warning: Submitting the form will clear related undo/redo stacks!")
|
|
||||||
}
|
|
||||||
|
|
||||||
buttonbar {
|
|
||||||
button("Ok") {
|
|
||||||
shortcut("Enter")
|
|
||||||
|
|
||||||
action {
|
|
||||||
mapVM.commit {
|
|
||||||
result = true
|
|
||||||
undoRedoService.clear(scope)
|
|
||||||
close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
button("Reset") {
|
|
||||||
action { mapVM.rollback() }
|
|
||||||
}
|
|
||||||
|
|
||||||
button("Cancel") {
|
|
||||||
action { close() }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -123,11 +123,5 @@ class MapToolbarView : View() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this += FontIcon("fa-paint-brush").apply { iconSize = 15 }
|
this += FontIcon("fa-paint-brush").apply { iconSize = 15 }
|
||||||
|
|
||||||
button(graphic = FontIcon("fa-sliders")) {
|
|
||||||
action {
|
|
||||||
find<MapSettingsFragment>().openModal(block = true, resizable = false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user