mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-23 06:08:46 +07:00
Map Editor UI improvements (#2462)
* Better icons for "clear" tools * Map editor layout is reworked
This commit is contained in:
@ -6,7 +6,6 @@ import com.badlogic.gdx.scenes.scene2d.Actor
|
|||||||
import com.badlogic.gdx.scenes.scene2d.Group
|
import com.badlogic.gdx.scenes.scene2d.Group
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Slider
|
import com.badlogic.gdx.scenes.scene2d.ui.Slider
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
|
||||||
import com.unciv.Constants
|
import com.unciv.Constants
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
import com.unciv.logic.map.RoadStatus
|
import com.unciv.logic.map.RoadStatus
|
||||||
@ -22,7 +21,7 @@ import com.unciv.ui.utils.*
|
|||||||
|
|
||||||
|
|
||||||
class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(CameraStageBaseScreen.skin){
|
class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(CameraStageBaseScreen.skin){
|
||||||
val tileSetLocation = "TileSets/"+ UncivGame.Current.settings.tileSet +"/"
|
private val tileSetLocation = "TileSets/"+ UncivGame.Current.settings.tileSet +"/"
|
||||||
|
|
||||||
var clearTerrainFeature=false
|
var clearTerrainFeature=false
|
||||||
var selectedTerrain : Terrain?=null
|
var selectedTerrain : Terrain?=null
|
||||||
@ -37,12 +36,14 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
var toggleBottomRiver=false
|
var toggleBottomRiver=false
|
||||||
var toggleBottomLeftRiver=false
|
var toggleBottomLeftRiver=false
|
||||||
|
|
||||||
val editorPickTable = Table()
|
private val editorPickTable = Table()
|
||||||
|
|
||||||
var brushSize = 1
|
var brushSize = 1
|
||||||
private var currentHex: Actor = Group()
|
private var currentHex: Actor = Group()
|
||||||
|
|
||||||
val ruleset = mapEditorScreen.ruleset
|
private val ruleset = mapEditorScreen.ruleset
|
||||||
|
|
||||||
|
private val scrollPanelHeight = mapEditorScreen.stage.height*0.7f - 100f // -100 reserved for currentHex table
|
||||||
|
|
||||||
init{
|
init{
|
||||||
height = mapEditorScreen.stage.height
|
height = mapEditorScreen.stage.height
|
||||||
@ -104,7 +105,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
}
|
}
|
||||||
improvementsTable.add(improvementImage).row()
|
improvementsTable.add(improvementImage).row()
|
||||||
}
|
}
|
||||||
editorPickTable.add(ScrollPane(improvementsTable)).height(mapEditorScreen.stage.height*0.7f)
|
editorPickTable.add(ScrollPane(improvementsTable)).height(scrollPanelHeight)
|
||||||
|
|
||||||
val nationsTable = Table()
|
val nationsTable = Table()
|
||||||
for(nation in ruleset.nations.values){
|
for(nation in ruleset.nations.values){
|
||||||
@ -118,20 +119,26 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
nationsTable.add(nationImage).row()
|
nationsTable.add(nationImage).row()
|
||||||
}
|
}
|
||||||
|
|
||||||
editorPickTable.add(ScrollPane(nationsTable)).height(mapEditorScreen.stage.height*0.7f)
|
editorPickTable.add(ScrollPane(nationsTable)).height(scrollPanelHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getRedCross(size: Float, alpha: Float): Actor {
|
||||||
|
val redCross = ImageGetter.getImage("OtherIcons/Close")
|
||||||
|
redCross.setSize( size, size)
|
||||||
|
redCross.color = Color.RED.cpy().apply { a = alpha }
|
||||||
|
return redCross
|
||||||
|
}
|
||||||
|
|
||||||
fun setTerrainsAndResources(){
|
private fun setTerrainsAndResources(){
|
||||||
|
|
||||||
val baseTerrainTable = Table().apply { defaults().pad(20f) }
|
val baseTerrainTable = Table().apply { defaults().pad(20f) }
|
||||||
val terrainFeaturesTable = Table().apply { defaults().pad(20f) }
|
val terrainFeaturesTable = Table().apply { defaults().pad(20f) }
|
||||||
|
|
||||||
terrainFeaturesTable.add(getHex(Color.WHITE).apply {
|
terrainFeaturesTable.add(getHex(Color.WHITE, getRedCross(50f, 0.6f)).apply {
|
||||||
onClick {
|
onClick {
|
||||||
clearSelection()
|
clearSelection()
|
||||||
clearTerrainFeature = true
|
clearTerrainFeature = true
|
||||||
setCurrentHex(getHex(Color.WHITE), "Clear terrain features")
|
setCurrentHex(getHex(Color.WHITE, getRedCross(40f, 0.6f)), "Clear terrain features")
|
||||||
}
|
}
|
||||||
}).row()
|
}).row()
|
||||||
|
|
||||||
@ -145,14 +152,14 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
background = ImageGetter.getBackground(Color.GRAY.cpy().apply { a = 0.7f })
|
background = ImageGetter.getBackground(Color.GRAY.cpy().apply { a = 0.7f })
|
||||||
|
|
||||||
val terrainsAndResourcesTable = Table()
|
val terrainsAndResourcesTable = Table()
|
||||||
terrainsAndResourcesTable.add(ScrollPane(baseTerrainTable).apply { setScrollingDisabled(true,false) }).height(mapEditorScreen.stage.height*0.7f)
|
terrainsAndResourcesTable.add(ScrollPane(baseTerrainTable).apply { setScrollingDisabled(true,false) }).height(scrollPanelHeight)
|
||||||
|
|
||||||
terrainsAndResourcesTable.add(ScrollPane(terrainFeaturesTable).apply { setScrollingDisabled(true,false) }).height(mapEditorScreen.stage.height*0.7f)
|
terrainsAndResourcesTable.add(ScrollPane(terrainFeaturesTable).apply { setScrollingDisabled(true,false) }).height(scrollPanelHeight)
|
||||||
|
|
||||||
val resourcesTable = Table()
|
val resourcesTable = Table()
|
||||||
for(resource in resources) resourcesTable.add(resource).row()
|
for(resource in resources) resourcesTable.add(resource).row()
|
||||||
resourcesTable.pack()
|
resourcesTable.pack()
|
||||||
terrainsAndResourcesTable.add(ScrollPane(resourcesTable).apply { setScrollingDisabled(true,false) }).height(mapEditorScreen.stage.height*0.7f).row()
|
terrainsAndResourcesTable.add(ScrollPane(resourcesTable).apply { setScrollingDisabled(true,false) }).height(scrollPanelHeight).row()
|
||||||
|
|
||||||
terrainsAndResourcesTable.pack()
|
terrainsAndResourcesTable.pack()
|
||||||
|
|
||||||
@ -160,13 +167,21 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
editorPickTable.add(terrainsAndResourcesTable)
|
editorPickTable.add(terrainsAndResourcesTable)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getCrossedResource() : Actor {
|
||||||
|
val redCross = getRedCross(45f, 0.5f)
|
||||||
|
val group = IconCircleGroup(40f, redCross, false)
|
||||||
|
group.circle.color = ImageGetter.foodCircleColor
|
||||||
|
return group
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun getResourceActors(): ArrayList<Actor> {
|
private fun getResourceActors(): ArrayList<Actor> {
|
||||||
val resources = ArrayList<Actor>()
|
val resources = ArrayList<Actor>()
|
||||||
resources.add(getHex(Color.WHITE).apply {
|
resources.add(getHex(Color.WHITE, getCrossedResource()).apply {
|
||||||
onClick {
|
onClick {
|
||||||
clearSelection()
|
clearSelection()
|
||||||
clearResource = true
|
clearResource = true
|
||||||
setCurrentHex(getHex(Color.WHITE), "Clear resource")
|
setCurrentHex(getHex(Color.WHITE, getCrossedResource()), "Clear resource")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -278,7 +293,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun getHex(color: Color, image: Actor?=null): Group {
|
private fun getHex(color: Color, image: Actor?=null): Group {
|
||||||
val hex = ImageGetter.getImage(tileSetLocation + "Hexagon")
|
val hex = ImageGetter.getImage(tileSetLocation + "Hexagon")
|
||||||
hex.color = color
|
hex.color = color
|
||||||
hex.width*=0.3f
|
hex.width*=0.3f
|
||||||
@ -297,7 +312,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun clearSelection(){
|
private fun clearSelection(){
|
||||||
clearTerrainFeature=false
|
clearTerrainFeature=false
|
||||||
selectedTerrain=null
|
selectedTerrain=null
|
||||||
clearResource=false
|
clearResource=false
|
||||||
@ -392,21 +407,22 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun setCurrentHex(tileInfo: TileInfo, text:String){
|
private fun setCurrentHex(tileInfo: TileInfo, text:String){
|
||||||
val tileGroup = TileGroup(tileInfo,TileSetStrings())
|
val tileGroup = TileGroup(tileInfo,TileSetStrings())
|
||||||
.apply {
|
.apply {
|
||||||
showEntireMap=true
|
showEntireMap=true
|
||||||
forMapEditorIcon=true
|
forMapEditorIcon=true
|
||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
|
tileGroup.baseLayerGroup.moveBy(-10f, 10f)
|
||||||
setCurrentHex(tileGroup,text)
|
setCurrentHex(tileGroup,text)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setCurrentHex(actor:Actor, text:String){
|
private fun setCurrentHex(actor:Actor, text:String){
|
||||||
currentHex.remove()
|
currentHex.remove()
|
||||||
val currentHexTable = Table()
|
val currentHexTable = Table()
|
||||||
currentHexTable.add(text.toLabel()).padRight(20f)
|
currentHexTable.add(text.toLabel()).padRight(30f)
|
||||||
currentHexTable.add(actor).pad(10f)
|
currentHexTable.add(actor)
|
||||||
currentHexTable.pack()
|
currentHexTable.pack()
|
||||||
currentHex=currentHexTable
|
currentHex=currentHexTable
|
||||||
currentHex.setPosition(stage.width - currentHex.width-10, 10f)
|
currentHex.setPosition(stage.width - currentHex.width-10, 10f)
|
||||||
|
Reference in New Issue
Block a user