[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.model.map.map.GameMap
|
||||||
import com.bartlomiejpluta.base.editor.view.component.map.MapPane
|
import com.bartlomiejpluta.base.editor.view.component.map.MapPane
|
||||||
import tornadofx.Fragment
|
import javafx.beans.property.SimpleDoubleProperty
|
||||||
import tornadofx.group
|
import javafx.scene.transform.Scale
|
||||||
import tornadofx.plusAssign
|
import tornadofx.*
|
||||||
import tornadofx.scrollpane
|
|
||||||
|
|
||||||
class MapFragment : Fragment() {
|
class MapFragment : Fragment() {
|
||||||
private val pane = MapPane()
|
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) {
|
fun updateMap(map: GameMap) {
|
||||||
pane.updateMap(map)
|
pane.updateMap(map)
|
||||||
@@ -21,6 +26,7 @@ class MapFragment : Fragment() {
|
|||||||
group {
|
group {
|
||||||
group {
|
group {
|
||||||
this += pane
|
this += pane
|
||||||
|
transforms += transformation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,20 @@ class MainView : View() {
|
|||||||
mapFragment.updateMap(mapController.getMap(2))
|
mapFragment.updateMap(mapController.getMap(2))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button("+") {
|
||||||
|
action {
|
||||||
|
mapFragment.scaleProperty.value += 0.1
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
button("-") {
|
||||||
|
action {
|
||||||
|
mapFragment.scaleProperty.value -= 0.1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
center = mapFragment.root
|
center = mapFragment.root
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,6 @@ class Renderer(
|
|||||||
override fun handle(now: Long) {
|
override fun handle(now: Long) {
|
||||||
val dt = (now - previous) / 1000000000.0
|
val dt = (now - previous) / 1000000000.0
|
||||||
previous = now
|
previous = now
|
||||||
gc.isImageSmoothing = false
|
|
||||||
|
|
||||||
render()
|
render()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user