[Editor] Add option to preview all layers in map canvas
This commit is contained in:
@@ -75,6 +75,9 @@ class MapCanvas(val map: GameMapVM, private val editorStateVM: EditorStateVM, pr
|
||||
renderUnderlyingLayers(gc)
|
||||
renderCover(gc)
|
||||
renderSelectedLayer(gc)
|
||||
if (editorStateVM.renderAllLayers) {
|
||||
renderOverlappingLayers(gc)
|
||||
}
|
||||
renderGrid(gc)
|
||||
painter.render(gc)
|
||||
}
|
||||
@@ -98,6 +101,12 @@ class MapCanvas(val map: GameMapVM, private val editorStateVM: EditorStateVM, pr
|
||||
}
|
||||
}
|
||||
|
||||
private fun renderOverlappingLayers(gc: GraphicsContext) {
|
||||
for (layer in map.layers.drop(editorStateVM.selectedLayerIndex + 1)) {
|
||||
dispatchLayerRender(gc, layer)
|
||||
}
|
||||
}
|
||||
|
||||
private fun dispatchLayerRender(gc: GraphicsContext, layer: Layer) {
|
||||
when (layer) {
|
||||
is TileLayer -> renderTileLayer(gc, layer)
|
||||
|
||||
@@ -37,6 +37,7 @@ class MapPane(
|
||||
editorStateVM.showGridProperty.addListener { _, _, _ -> render() }
|
||||
editorStateVM.selectedLayerIndexProperty.addListener { _, _, _ -> render() }
|
||||
editorStateVM.coverUnderlyingLayersProperty.addListener { _, _, _ -> render() }
|
||||
editorStateVM.renderAllLayersProperty.addListener { _, _, _ -> render() }
|
||||
|
||||
render()
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class MapToolbarView : View() {
|
||||
{ editorStateVM.selectedLayer is AutoTileLayer },
|
||||
editorStateVM.selectedLayerProperty
|
||||
)
|
||||
|
||||
|
||||
private val isObjectLayerSelected = Bindings.createBooleanBinding(
|
||||
{ editorStateVM.selectedLayer is ObjectLayer },
|
||||
editorStateVM.selectedLayerProperty
|
||||
@@ -82,18 +82,17 @@ class MapToolbarView : View() {
|
||||
|
||||
togglebutton {
|
||||
graphic = FontIcon("fa-window-restore")
|
||||
|
||||
action {
|
||||
editorStateVM.coverUnderlyingLayers = isSelected
|
||||
}
|
||||
editorStateVM.coverUnderlyingLayersProperty.bind(selectedProperty())
|
||||
}
|
||||
|
||||
togglebutton {
|
||||
graphic = FontIcon("fa-th")
|
||||
editorStateVM.showGridProperty.bind(selectedProperty())
|
||||
}
|
||||
|
||||
action {
|
||||
editorStateVM.showGrid = isSelected
|
||||
}
|
||||
togglebutton {
|
||||
graphic = FontIcon("fa-clone")
|
||||
editorStateVM.renderAllLayersProperty.bind(selectedProperty())
|
||||
}
|
||||
|
||||
separator()
|
||||
|
||||
@@ -30,4 +30,7 @@ class EditorStateVM : ViewModel() {
|
||||
|
||||
val cursorColumnProperty = SimpleIntegerProperty(-1)
|
||||
val cursorColumn by cursorColumnProperty
|
||||
|
||||
val renderAllLayersProperty = SimpleBooleanProperty(false)
|
||||
var renderAllLayers by renderAllLayersProperty
|
||||
}
|
||||
Reference in New Issue
Block a user