[Editor] Add support for map scaling

This commit is contained in:
2021-02-03 23:54:42 +01:00
parent c798cd7e5f
commit 7a5ba2c4e2
3 changed files with 23 additions and 5 deletions

View File

@@ -2,13 +2,18 @@ package com.bartlomiejpluta.base.editor.view.fragment
import com.bartlomiejpluta.base.editor.model.map.map.GameMap
import com.bartlomiejpluta.base.editor.view.component.map.MapPane
import tornadofx.Fragment
import tornadofx.group
import tornadofx.plusAssign
import tornadofx.scrollpane
import javafx.beans.property.SimpleDoubleProperty
import javafx.scene.transform.Scale
import tornadofx.*
class MapFragment : Fragment() {
private val pane = MapPane()
val scaleProperty = SimpleDoubleProperty(1.0)
private val transformation = Scale(1.0, 1.0, 0.0, 0.0).apply {
xProperty().bind(scaleProperty)
yProperty().bind(scaleProperty)
}
fun updateMap(map: GameMap) {
pane.updateMap(map)
@@ -21,6 +26,7 @@ class MapFragment : Fragment() {
group {
group {
this += pane
transforms += transformation
}
}
}

View File

@@ -21,7 +21,20 @@ class MainView : View() {
mapFragment.updateMap(mapController.getMap(2))
}
}
button("+") {
action {
mapFragment.scaleProperty.value += 0.1
}
}
button("-") {
action {
mapFragment.scaleProperty.value -= 0.1
}
}
}
center = mapFragment.root
}
}

View File

@@ -13,7 +13,6 @@ class Renderer(
override fun handle(now: Long) {
val dt = (now - previous) / 1000000000.0
previous = now
gc.isImageSmoothing = false
render()
}