[Editor] Add support for map scaling
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ class Renderer(
|
||||
override fun handle(now: Long) {
|
||||
val dt = (now - previous) / 1000000000.0
|
||||
previous = now
|
||||
gc.isImageSmoothing = false
|
||||
|
||||
render()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user