[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.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") {
|
||||
@@ -18,11 +19,12 @@ class MapSettingsFragment : Fragment("Map Settings") {
|
||||
fieldset("Map Settings") {
|
||||
field("Rows") {
|
||||
|
||||
textfield(mapVM.rowsProperty) {
|
||||
stripNonInteger()
|
||||
spinner(min = 1, max = 100, property = mapVM.rowsProperty, editable = true) {
|
||||
required()
|
||||
editor.textFormatter = TextFieldUtil.integerFormatter(mapVM.rows)
|
||||
|
||||
validator {
|
||||
when (it?.toIntOrNull()) {
|
||||
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")
|
||||
@@ -32,11 +34,12 @@ class MapSettingsFragment : Fragment("Map Settings") {
|
||||
}
|
||||
|
||||
field("Columns") {
|
||||
textfield(mapVM.columnsProperty) {
|
||||
stripNonInteger()
|
||||
spinner(min = 1, max = 100, property = mapVM.columnsProperty, editable = true) {
|
||||
required()
|
||||
editor.textFormatter = TextFieldUtil.integerFormatter(mapVM.columns)
|
||||
|
||||
validator {
|
||||
when (it?.toIntOrNull()) {
|
||||
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")
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.bartlomiejpluta.base.editor.map.view.wizard
|
||||
|
||||
import com.bartlomiejpluta.base.editor.map.viewmodel.GameMapBuilderVM
|
||||
import com.bartlomiejpluta.base.editor.util.fx.TextFieldUtil
|
||||
import tornadofx.*
|
||||
|
||||
class MapCreationBasicDataView : View("Basic Data") {
|
||||
@@ -18,12 +19,12 @@ class MapCreationBasicDataView : View("Basic Data") {
|
||||
}
|
||||
|
||||
field("Rows") {
|
||||
|
||||
textfield(mapBuilderVM.rowsProperty) {
|
||||
stripNonInteger()
|
||||
spinner(min = 1, max = 100, property = mapBuilderVM.rowsProperty, editable = true) {
|
||||
required()
|
||||
editor.textFormatter = TextFieldUtil.integerFormatter(mapBuilderVM.rows)
|
||||
|
||||
validator {
|
||||
when (it?.toIntOrNull()) {
|
||||
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")
|
||||
@@ -33,11 +34,12 @@ class MapCreationBasicDataView : View("Basic Data") {
|
||||
}
|
||||
|
||||
field("Columns") {
|
||||
textfield(mapBuilderVM.columnsProperty) {
|
||||
stripNonInteger()
|
||||
spinner(min = 1, max = 100, property = mapBuilderVM.columnsProperty, editable = true) {
|
||||
required()
|
||||
editor.textFormatter = TextFieldUtil.integerFormatter(mapBuilderVM.columns)
|
||||
|
||||
validator {
|
||||
when (it?.toIntOrNull()) {
|
||||
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")
|
||||
|
||||
@@ -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.viewmodel.TileSetAssetDataVM
|
||||
import com.bartlomiejpluta.base.editor.util.fx.TextFieldUtil
|
||||
import javafx.beans.property.SimpleObjectProperty
|
||||
import javafx.scene.Cursor
|
||||
import javafx.scene.image.Image
|
||||
@@ -68,36 +69,16 @@ class ImportTileSetFragment : Fragment("Import Tile Set") {
|
||||
}
|
||||
|
||||
field("Tile Set Rows") {
|
||||
textfield(dataVM.rowsProperty) {
|
||||
stripNonInteger()
|
||||
spinner(min = 1, max = Integer.MAX_VALUE, property = dataVM.rowsProperty, editable = true) {
|
||||
required()
|
||||
trimWhitespace()
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
editor.textFormatter = TextFieldUtil.integerFormatter(dataVM.rows)
|
||||
}
|
||||
}
|
||||
|
||||
field("Tile Set Columns") {
|
||||
textfield(dataVM.columnsProperty) {
|
||||
stripNonInteger()
|
||||
spinner(min = 1, max = Integer.MAX_VALUE, property = dataVM.columnsProperty, editable = true) {
|
||||
required()
|
||||
trimWhitespace()
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
editor.textFormatter = TextFieldUtil.integerFormatter(dataVM.columns)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user