diff --git a/editor/CHANGES b/editor/CHANGES index fe0da984c..ce63474bc 100644 --- a/editor/CHANGES +++ b/editor/CHANGES @@ -12,6 +12,7 @@ - Fix reset import model dialog on close - Change scene camera to be base camera class - Duplicate materials from inspector +- Show brush selection [0.4.2] ~ 10/24/2022 - Fix shader compilation error for Terrain when using normal maps diff --git a/editor/src/main/com/mbrlabs/mundus/editor/ui/modules/inspector/components/terrain/BaseBrushTab.kt b/editor/src/main/com/mbrlabs/mundus/editor/ui/modules/inspector/components/terrain/BaseBrushTab.kt new file mode 100644 index 000000000..b3117c9f4 --- /dev/null +++ b/editor/src/main/com/mbrlabs/mundus/editor/ui/modules/inspector/components/terrain/BaseBrushTab.kt @@ -0,0 +1,20 @@ +package com.mbrlabs.mundus.editor.ui.modules.inspector.components.terrain + +import com.kotcrab.vis.ui.widget.tabbedpane.Tab +import com.mbrlabs.mundus.editor.tools.brushes.TerrainBrush + +abstract class BaseBrushTab(private val parent: TerrainComponentWidget, + private val mode: TerrainBrush.BrushMode) + : Tab(false, false) { + + protected val terrainBrushGrid: TerrainBrushGrid = TerrainBrushGrid(parent, mode); + + /** + * Clears selection. + */ + override fun onHide() { + super.onHide() + terrainBrushGrid.clearSelection() + } + +} diff --git a/editor/src/main/com/mbrlabs/mundus/editor/ui/modules/inspector/components/terrain/TerrainBrushGrid.kt b/editor/src/main/com/mbrlabs/mundus/editor/ui/modules/inspector/components/terrain/TerrainBrushGrid.kt index cb61d6bf1..d1c742583 100644 --- a/editor/src/main/com/mbrlabs/mundus/editor/ui/modules/inspector/components/terrain/TerrainBrushGrid.kt +++ b/editor/src/main/com/mbrlabs/mundus/editor/ui/modules/inspector/components/terrain/TerrainBrushGrid.kt @@ -45,6 +45,7 @@ class TerrainBrushGrid(private val parent: TerrainComponentWidget, private val strengthSlider = ImprovedSlider(0f, 1f, 0.1f) private val toolManager: ToolManager = Mundus.inject() + private val buttons: ArrayList = arrayListOf() init { Mundus.registerEventListener(this) @@ -75,6 +76,11 @@ class TerrainBrushGrid(private val parent: TerrainComponentWidget, add(settingsTable).expand().fill().padLeft(5f).padRight(5f).padTop(5f).row() } + fun clearSelection() { + toolManager.deactivateTool() + buttons.forEach { it.style = FaTextButton.styleNoBg } + } + fun activateBrush(brush: TerrainBrush) { try { brush.mode = brushMode @@ -95,10 +101,14 @@ class TerrainBrushGrid(private val parent: TerrainComponentWidget, */ private inner class BrushItem(brush: TerrainBrush) : VisTable() { init { - add(FaTextButton(brush.iconFont)) + val button = FaTextButton(brush.iconFont) + add(button) + buttons.add(button) addListener(object : ClickListener() { override fun clicked(event: InputEvent?, x: Float, y: Float) { + clearSelection() activateBrush(brush) + button.style = FaTextButton.styleActive } }) } diff --git a/editor/src/main/com/mbrlabs/mundus/editor/ui/modules/inspector/components/terrain/TerrainFlattenTab.kt b/editor/src/main/com/mbrlabs/mundus/editor/ui/modules/inspector/components/terrain/TerrainFlattenTab.kt index 25c885212..2e4f14d22 100644 --- a/editor/src/main/com/mbrlabs/mundus/editor/ui/modules/inspector/components/terrain/TerrainFlattenTab.kt +++ b/editor/src/main/com/mbrlabs/mundus/editor/ui/modules/inspector/components/terrain/TerrainFlattenTab.kt @@ -20,24 +20,21 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.utils.Align import com.kotcrab.vis.ui.widget.VisLabel import com.kotcrab.vis.ui.widget.VisTable -import com.kotcrab.vis.ui.widget.tabbedpane.Tab import com.mbrlabs.mundus.editor.tools.brushes.TerrainBrush /** * @author Marcus Brummer * @version 30-01-2016 */ -class TerrainFlattenTab(parent: TerrainComponentWidget) : Tab(false, false) { +class TerrainFlattenTab(parent: TerrainComponentWidget) : BaseBrushTab(parent, TerrainBrush.BrushMode.FLATTEN) { private val table = VisTable() - private val brushGrid: TerrainBrushGrid init { table.align(Align.left) table.add(VisLabel("Hold shift to sample a height")).center().row() - brushGrid = TerrainBrushGrid(parent, TerrainBrush.BrushMode.FLATTEN) - table.add(brushGrid).expand().fill().row() + table.add(terrainBrushGrid).expand().fill().row() } override fun getTabTitle(): String { diff --git a/editor/src/main/com/mbrlabs/mundus/editor/ui/modules/inspector/components/terrain/TerrainPaintTab.kt b/editor/src/main/com/mbrlabs/mundus/editor/ui/modules/inspector/components/terrain/TerrainPaintTab.kt index 6240d8d7d..f460ce9e3 100644 --- a/editor/src/main/com/mbrlabs/mundus/editor/ui/modules/inspector/components/terrain/TerrainPaintTab.kt +++ b/editor/src/main/com/mbrlabs/mundus/editor/ui/modules/inspector/components/terrain/TerrainPaintTab.kt @@ -24,7 +24,6 @@ import com.badlogic.gdx.utils.Align import com.kotcrab.vis.ui.VisUI import com.kotcrab.vis.ui.util.dialog.Dialogs import com.kotcrab.vis.ui.widget.* -import com.kotcrab.vis.ui.widget.tabbedpane.Tab import com.mbrlabs.mundus.commons.assets.Asset import com.mbrlabs.mundus.commons.assets.TextureAsset import com.mbrlabs.mundus.commons.terrain.SplatTexture @@ -45,7 +44,7 @@ import java.io.IOException * @author Marcus Brummer * @version 30-01-2016 */ -class TerrainPaintTab(private val parentWidget: TerrainComponentWidget) : Tab(false, false) { +class TerrainPaintTab(private val parentWidget: TerrainComponentWidget) : BaseBrushTab(parentWidget, TerrainBrush.BrushMode.PAINT) { companion object { private val TAG = TerrainPaintTab::class.java.simpleName @@ -63,7 +62,7 @@ class TerrainPaintTab(private val parentWidget: TerrainComponentWidget) : Tab(fa root.align(Align.left) // brushes - root.add(TerrainBrushGrid(parentWidget, TerrainBrush.BrushMode.PAINT)).expand().fill().padBottom(5f).row() + root.add(terrainBrushGrid).expand().fill().padBottom(5f).row() // textures root.add(VisLabel("Textures:")).padLeft(5f).left().row() diff --git a/editor/src/main/com/mbrlabs/mundus/editor/ui/modules/inspector/components/terrain/TerrainSmoothTab.kt b/editor/src/main/com/mbrlabs/mundus/editor/ui/modules/inspector/components/terrain/TerrainSmoothTab.kt index c07d74fbd..1ab7e191b 100644 --- a/editor/src/main/com/mbrlabs/mundus/editor/ui/modules/inspector/components/terrain/TerrainSmoothTab.kt +++ b/editor/src/main/com/mbrlabs/mundus/editor/ui/modules/inspector/components/terrain/TerrainSmoothTab.kt @@ -3,23 +3,20 @@ package com.mbrlabs.mundus.editor.ui.modules.inspector.components.terrain import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.utils.Align import com.kotcrab.vis.ui.widget.VisTable -import com.kotcrab.vis.ui.widget.tabbedpane.Tab import com.mbrlabs.mundus.editor.tools.brushes.TerrainBrush /** * @author JamesTKhan * @version July 17, 2022 */ -class TerrainSmoothTab(parent: TerrainComponentWidget) : Tab(false, false) { +class TerrainSmoothTab(parent: TerrainComponentWidget) : BaseBrushTab(parent, TerrainBrush.BrushMode.SMOOTH) { private val table = VisTable() - private val brushGrid: TerrainBrushGrid init { table.align(Align.left) - brushGrid = TerrainBrushGrid(parent, TerrainBrush.BrushMode.SMOOTH) - table.add(brushGrid).expand().fill().row() + table.add(terrainBrushGrid).expand().fill().row() } override fun getTabTitle(): String { diff --git a/editor/src/main/com/mbrlabs/mundus/editor/ui/modules/inspector/components/terrain/TerrainUpDownTab.kt b/editor/src/main/com/mbrlabs/mundus/editor/ui/modules/inspector/components/terrain/TerrainUpDownTab.kt index 34ccebf40..8ca66c9ea 100644 --- a/editor/src/main/com/mbrlabs/mundus/editor/ui/modules/inspector/components/terrain/TerrainUpDownTab.kt +++ b/editor/src/main/com/mbrlabs/mundus/editor/ui/modules/inspector/components/terrain/TerrainUpDownTab.kt @@ -20,20 +20,19 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.utils.Align import com.kotcrab.vis.ui.widget.VisLabel import com.kotcrab.vis.ui.widget.VisTable -import com.kotcrab.vis.ui.widget.tabbedpane.Tab import com.mbrlabs.mundus.editor.tools.brushes.TerrainBrush /** * @author Marcus Brummer * @version 30-01-2016 */ -class TerrainUpDownTab(private val parent: TerrainComponentWidget) : Tab(false, false) { +class TerrainUpDownTab(private val parent: TerrainComponentWidget) : BaseBrushTab(parent, TerrainBrush.BrushMode.RAISE_LOWER) { private val table = VisTable() init { table.align(Align.left) table.add(VisLabel("Hold shift to lower")).center().row() - table.add(TerrainBrushGrid(this.parent, TerrainBrush.BrushMode.RAISE_LOWER)).expandX().fillX().row() + table.add(terrainBrushGrid).expandX().fillX().row() } override fun getTabTitle(): String {