[Editor] Replace text fields with spinners where appropriate
This commit is contained in:
@@ -3,6 +3,7 @@ package com.bartlomiejpluta.base.editor.map.view.editor
|
|||||||
import com.bartlomiejpluta.base.editor.command.context.UndoableScope
|
import com.bartlomiejpluta.base.editor.command.context.UndoableScope
|
||||||
import com.bartlomiejpluta.base.editor.command.service.UndoRedoService
|
import com.bartlomiejpluta.base.editor.command.service.UndoRedoService
|
||||||
import com.bartlomiejpluta.base.editor.map.viewmodel.GameMapVM
|
import com.bartlomiejpluta.base.editor.map.viewmodel.GameMapVM
|
||||||
|
import com.bartlomiejpluta.base.editor.util.fx.TextFieldUtil
|
||||||
import tornadofx.*
|
import tornadofx.*
|
||||||
|
|
||||||
class MapSettingsFragment : Fragment("Map Settings") {
|
class MapSettingsFragment : Fragment("Map Settings") {
|
||||||
@@ -18,11 +19,12 @@ class MapSettingsFragment : Fragment("Map Settings") {
|
|||||||
fieldset("Map Settings") {
|
fieldset("Map Settings") {
|
||||||
field("Rows") {
|
field("Rows") {
|
||||||
|
|
||||||
textfield(mapVM.rowsProperty) {
|
spinner(min = 1, max = 100, property = mapVM.rowsProperty, editable = true) {
|
||||||
stripNonInteger()
|
|
||||||
required()
|
required()
|
||||||
|
editor.textFormatter = TextFieldUtil.integerFormatter(mapVM.rows)
|
||||||
|
|
||||||
validator {
|
validator {
|
||||||
when (it?.toIntOrNull()) {
|
when (it?.toInt()) {
|
||||||
in 1..50 -> null
|
in 1..50 -> null
|
||||||
in 50..100 -> warning("The map sizes over 50 can impact game performance")
|
in 50..100 -> warning("The map sizes over 50 can impact game performance")
|
||||||
else -> error("The map size must be between 1 and 100")
|
else -> error("The map size must be between 1 and 100")
|
||||||
@@ -32,11 +34,12 @@ class MapSettingsFragment : Fragment("Map Settings") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
field("Columns") {
|
field("Columns") {
|
||||||
textfield(mapVM.columnsProperty) {
|
spinner(min = 1, max = 100, property = mapVM.columnsProperty, editable = true) {
|
||||||
stripNonInteger()
|
|
||||||
required()
|
required()
|
||||||
|
editor.textFormatter = TextFieldUtil.integerFormatter(mapVM.columns)
|
||||||
|
|
||||||
validator {
|
validator {
|
||||||
when (it?.toIntOrNull()) {
|
when (it?.toInt()) {
|
||||||
in 1..50 -> null
|
in 1..50 -> null
|
||||||
in 50..100 -> warning("The map sizes over 50 can impact game performance")
|
in 50..100 -> warning("The map sizes over 50 can impact game performance")
|
||||||
else -> error("The map size must be between 1 and 100")
|
else -> error("The map size must be between 1 and 100")
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.bartlomiejpluta.base.editor.map.view.wizard
|
package com.bartlomiejpluta.base.editor.map.view.wizard
|
||||||
|
|
||||||
import com.bartlomiejpluta.base.editor.map.viewmodel.GameMapBuilderVM
|
import com.bartlomiejpluta.base.editor.map.viewmodel.GameMapBuilderVM
|
||||||
|
import com.bartlomiejpluta.base.editor.util.fx.TextFieldUtil
|
||||||
import tornadofx.*
|
import tornadofx.*
|
||||||
|
|
||||||
class MapCreationBasicDataView : View("Basic Data") {
|
class MapCreationBasicDataView : View("Basic Data") {
|
||||||
@@ -18,12 +19,12 @@ class MapCreationBasicDataView : View("Basic Data") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
field("Rows") {
|
field("Rows") {
|
||||||
|
spinner(min = 1, max = 100, property = mapBuilderVM.rowsProperty, editable = true) {
|
||||||
textfield(mapBuilderVM.rowsProperty) {
|
|
||||||
stripNonInteger()
|
|
||||||
required()
|
required()
|
||||||
|
editor.textFormatter = TextFieldUtil.integerFormatter(mapBuilderVM.rows)
|
||||||
|
|
||||||
validator {
|
validator {
|
||||||
when (it?.toIntOrNull()) {
|
when (it?.toInt()) {
|
||||||
in 1..50 -> null
|
in 1..50 -> null
|
||||||
in 50..100 -> warning("The map sizes over 50 can impact game performance")
|
in 50..100 -> warning("The map sizes over 50 can impact game performance")
|
||||||
else -> error("The map size must be between 1 and 100")
|
else -> error("The map size must be between 1 and 100")
|
||||||
@@ -33,11 +34,12 @@ class MapCreationBasicDataView : View("Basic Data") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
field("Columns") {
|
field("Columns") {
|
||||||
textfield(mapBuilderVM.columnsProperty) {
|
spinner(min = 1, max = 100, property = mapBuilderVM.columnsProperty, editable = true) {
|
||||||
stripNonInteger()
|
|
||||||
required()
|
required()
|
||||||
|
editor.textFormatter = TextFieldUtil.integerFormatter(mapBuilderVM.columns)
|
||||||
|
|
||||||
validator {
|
validator {
|
||||||
when (it?.toIntOrNull()) {
|
when (it?.toInt()) {
|
||||||
in 1..50 -> null
|
in 1..50 -> null
|
||||||
in 50..100 -> warning("The map sizes over 50 can impact game performance")
|
in 50..100 -> warning("The map sizes over 50 can impact game performance")
|
||||||
else -> error("The map size must be between 1 and 100")
|
else -> error("The map size must be between 1 and 100")
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.bartlomiejpluta.base.editor.tileset.view.importing
|
|||||||
|
|
||||||
import com.bartlomiejpluta.base.editor.tileset.asset.TileSetAssetData
|
import com.bartlomiejpluta.base.editor.tileset.asset.TileSetAssetData
|
||||||
import com.bartlomiejpluta.base.editor.tileset.viewmodel.TileSetAssetDataVM
|
import com.bartlomiejpluta.base.editor.tileset.viewmodel.TileSetAssetDataVM
|
||||||
|
import com.bartlomiejpluta.base.editor.util.fx.TextFieldUtil
|
||||||
import javafx.beans.property.SimpleObjectProperty
|
import javafx.beans.property.SimpleObjectProperty
|
||||||
import javafx.scene.Cursor
|
import javafx.scene.Cursor
|
||||||
import javafx.scene.image.Image
|
import javafx.scene.image.Image
|
||||||
@@ -68,36 +69,16 @@ class ImportTileSetFragment : Fragment("Import Tile Set") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
field("Tile Set Rows") {
|
field("Tile Set Rows") {
|
||||||
textfield(dataVM.rowsProperty) {
|
spinner(min = 1, max = Integer.MAX_VALUE, property = dataVM.rowsProperty, editable = true) {
|
||||||
stripNonInteger()
|
|
||||||
required()
|
required()
|
||||||
trimWhitespace()
|
editor.textFormatter = TextFieldUtil.integerFormatter(dataVM.rows)
|
||||||
|
|
||||||
validator {
|
|
||||||
val value = it?.toIntOrNull()
|
|
||||||
when {
|
|
||||||
value == null -> error("This field is required")
|
|
||||||
value < 1 -> error("The value must not be lower than 1")
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
field("Tile Set Columns") {
|
field("Tile Set Columns") {
|
||||||
textfield(dataVM.columnsProperty) {
|
spinner(min = 1, max = Integer.MAX_VALUE, property = dataVM.columnsProperty, editable = true) {
|
||||||
stripNonInteger()
|
|
||||||
required()
|
required()
|
||||||
trimWhitespace()
|
editor.textFormatter = TextFieldUtil.integerFormatter(dataVM.columns)
|
||||||
|
|
||||||
validator {
|
|
||||||
val value = it?.toIntOrNull()
|
|
||||||
when {
|
|
||||||
value == null -> error("This field is required")
|
|
||||||
value < 1 -> error("The value must not be lower than 1")
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user