Added river toggles to map editor to see how it looks. Not good, btw - can't see rivers behind mountain/forest/hill tiles...

Disabled for now, until we find a better way to display rivers.
This commit is contained in:
Yair Morgenstern
2019-10-18 16:39:23 +03:00
parent 6d1edd67e0
commit 77f479e39b
3 changed files with 124 additions and 61 deletions

View File

@ -518,7 +518,7 @@
Spanish:"Vino"
Simplified_Chinese:"红酒"
Portuguese:"Vinho"
Korean:""
Korean:"와인"
}
"Sugar":{

View File

@ -21,8 +21,8 @@ android {
applicationId "com.unciv.app"
minSdkVersion 14
targetSdkVersion 29
versionCode 309
versionName "3.1.6"
versionCode 310
versionName "3.1.7"
}
// Had to add this crap for Travis to build, it wanted to sign the app

View File

@ -6,6 +6,7 @@ import com.badlogic.gdx.scenes.scene2d.Group
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
import com.unciv.Constants
import com.unciv.UnCivGame
import com.unciv.logic.map.RoadStatus
import com.unciv.logic.map.TileInfo
@ -100,50 +101,52 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
editorPickTable.add(ScrollPane(nationsTable)).height(mapEditorScreen.stage.height*0.7f)
}
fun setTerrainsAndResources(){
val baseTerrains = ArrayList<Actor>()
val terrainFeatures=ArrayList<Actor>()
terrainFeatures.add(getHex(Color.WHITE).apply {
val baseTerrainTable = Table().apply { defaults().pad(20f) }
val terrainFeaturesTable = Table().apply { defaults().pad(20f) }
terrainFeaturesTable.add(getHex(Color.WHITE).apply {
onClick {
clearSelection()
clearTerrainFeature = true
setCurrentHex(getHex(Color.WHITE), "Clear terrain features")
}
})
for (terrain in GameBasics.Terrains.values) {
val tileInfo = TileInfo()
if (terrain.type == TerrainType.TerrainFeature) {
tileInfo.baseTerrain = terrain.occursOn!!.first()
tileInfo.terrainFeature=terrain.name
}
else tileInfo.baseTerrain=terrain.name
tileInfo.setTransients()
val group = TileGroup(tileInfo, TileSetStrings())
group.showEntireMap=true
group.forMapEditorIcon=true
group.update()
group.onClick {
clearSelection()
selectedTerrain = terrain
setCurrentHex(tileInfo,terrain.name.tr()+"\n"+terrain.clone().toString())
}
if (terrain.type == TerrainType.TerrainFeature)
terrainFeatures.add(group)
else baseTerrains.add(group)
}
}).row()
addTerrainOptions(terrainFeaturesTable, baseTerrainTable)
// addRiverToggleOptions(baseTerrainTable)
val resources = getResourceActors()
background = ImageGetter.getBackground(Color.GRAY.cpy().apply { a = 0.7f })
val terrainsAndResourcesTable = Table()
terrainsAndResourcesTable.add(ScrollPane(baseTerrainTable).apply { setScrollingDisabled(true,false) }).height(mapEditorScreen.stage.height*0.7f)
terrainsAndResourcesTable.add(ScrollPane(terrainFeaturesTable).apply { setScrollingDisabled(true,false) }).height(mapEditorScreen.stage.height*0.7f)
val resourcesTable = Table()
for(resource in resources) resourcesTable.add(resource).row()
resourcesTable.pack()
terrainsAndResourcesTable.add(ScrollPane(resourcesTable).apply { setScrollingDisabled(true,false) }).height(mapEditorScreen.stage.height*0.7f).row()
terrainsAndResourcesTable.pack()
editorPickTable.clear()
editorPickTable.add(terrainsAndResourcesTable)
}
private fun getResourceActors(): ArrayList<Actor> {
val resources = ArrayList<Actor>()
resources.add(getHex(Color.WHITE).apply {
onClick {
clearSelection()
clearResource = true
setCurrentHex(getHex(Color.WHITE),"Clear resource")
setCurrentHex(getHex(Color.WHITE), "Clear resource")
}
})
@ -156,41 +159,95 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
val terrain = resource.terrainsCanBeFoundOn.first()
val terrainObject = GameBasics.Terrains[terrain]!!
if(terrainObject.type== TerrainType.TerrainFeature){
tileInfo.baseTerrain=terrainObject.occursOn!!.first()
tileInfo.terrainFeature=terrain
}
else tileInfo.baseTerrain=terrain
if (terrainObject.type == TerrainType.TerrainFeature) {
tileInfo.baseTerrain = terrainObject.occursOn!!.first()
tileInfo.terrainFeature = terrain
} else tileInfo.baseTerrain = terrain
tileInfo.resource = resource.name
tileInfo.setTransients()
setCurrentHex(tileInfo,resource.name.tr()+"\n"+resource.clone().toString())
setCurrentHex(tileInfo, resource.name.tr() + "\n" + resource.clone().toString())
}
resources.add(resourceHex)
}
return resources
}
private fun addTerrainOptions(terrainFeaturesTable: Table, baseTerrainTable: Table) {
for (terrain in GameBasics.Terrains.values) {
val tileInfo = TileInfo()
if (terrain.type == TerrainType.TerrainFeature) {
tileInfo.baseTerrain = terrain.occursOn!!.first()
tileInfo.terrainFeature = terrain.name
} else tileInfo.baseTerrain = terrain.name
val group = makeTileGroup(tileInfo)
group.onClick {
clearSelection()
selectedTerrain = terrain
setCurrentHex(tileInfo, terrain.name.tr() + "\n" + terrain.clone().toString())
}
if (terrain.type == TerrainType.TerrainFeature)
terrainFeaturesTable.add(group).row()
else baseTerrainTable.add(group).row()
}
background = ImageGetter.getBackground(Color.GRAY.cpy().apply { a = 0.7f })
val terrainsAndResourcesTable = Table()
val baseTerrainTable = Table().apply { defaults().pad(20f) }
for(baseTerrain in baseTerrains) baseTerrainTable.add(baseTerrain).row()
baseTerrainTable.pack()
terrainsAndResourcesTable.add(ScrollPane(baseTerrainTable).apply { setScrollingDisabled(true,false) }).height(mapEditorScreen.stage.height*0.7f)
val terrainFeaturesTable = Table().apply { defaults().pad(20f) }
for(terrainFeature in terrainFeatures) terrainFeaturesTable.add(terrainFeature).row()
terrainFeaturesTable.pack()
terrainsAndResourcesTable.add(ScrollPane(terrainFeaturesTable).apply { setScrollingDisabled(true,false) }).height(mapEditorScreen.stage.height*0.7f)
}
val resourcesTable = Table()
for(resource in resources) resourcesTable.add(resource).row()
resourcesTable.pack()
terrainsAndResourcesTable.add(ScrollPane(resourcesTable).apply { setScrollingDisabled(true,false) }).height(mapEditorScreen.stage.height*0.7f).row()
private fun addRiverToggleOptions(baseTerrainTable: Table) {
baseTerrainTable.addSeparator()
terrainsAndResourcesTable.pack()
editorPickTable.clear()
editorPickTable.add(terrainsAndResourcesTable)
val tileInfoBottomRightRiver = TileInfo()
tileInfoBottomRightRiver.baseTerrain = Constants.plains
tileInfoBottomRightRiver.hasBottomRightRiver = true
val tileGroupBottomRightRiver = makeTileGroup(tileInfoBottomRightRiver)
tileGroupBottomRightRiver.onClick {
clearSelection()
toggleBottomRightRiver = true
setCurrentHex(tileInfoBottomRightRiver, "Bottom right river")
}
baseTerrainTable.add(tileGroupBottomRightRiver).row()
val tileInfoBottomRiver = TileInfo()
tileInfoBottomRiver.baseTerrain = Constants.plains
tileInfoBottomRiver.hasBottomRiver = true
val tileGroupBottomRiver = makeTileGroup(tileInfoBottomRiver)
tileGroupBottomRiver.onClick {
clearSelection()
toggleBottomRiver = true
setCurrentHex(tileInfoBottomRiver, "Bottom river")
}
baseTerrainTable.add(tileGroupBottomRiver).row()
val tileInfoBottomLeftRiver = TileInfo()
tileInfoBottomLeftRiver.hasBottomLeftRiver = true
tileInfoBottomLeftRiver.baseTerrain = Constants.plains
val tileGroupBottomLeftRiver = makeTileGroup(tileInfoBottomLeftRiver)
tileGroupBottomLeftRiver.onClick {
clearSelection()
toggleBottomLeftRiver = true
setCurrentHex(tileInfoBottomLeftRiver, "Bottom left river")
}
baseTerrainTable.add(tileGroupBottomLeftRiver).row()
baseTerrainTable.pack()
}
private fun makeTileGroup(tileInfo: TileInfo): TileGroup {
tileInfo.setTransients()
val group = TileGroup(tileInfo, TileSetStrings())
group.showEntireMap = true
group.forMapEditorIcon = true
group.update()
return group
}
@ -220,6 +277,9 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
selectedResource=null
clearImprovement=false
selectedImprovement=null
toggleBottomLeftRiver = false
toggleBottomRightRiver = false
toggleBottomRiver = false
}
fun updateTileWhenClicked(tileInfo: TileInfo) {
@ -233,15 +293,18 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
else tileInfo.baseTerrain = selectedTerrain!!.name
}
clearImprovement -> {
tileInfo.improvement=null
tileInfo.roadStatus=RoadStatus.None
tileInfo.improvement = null
tileInfo.roadStatus = RoadStatus.None
}
selectedImprovement!=null -> {
selectedImprovement != null -> {
val improvement = selectedImprovement!!
if(improvement.name=="Road") tileInfo.roadStatus=RoadStatus.Road
else if(improvement.name=="Railroad") tileInfo.roadStatus=RoadStatus.Railroad
else tileInfo.improvement=improvement.name
if (improvement.name == "Road") tileInfo.roadStatus = RoadStatus.Road
else if (improvement.name == "Railroad") tileInfo.roadStatus = RoadStatus.Railroad
else tileInfo.improvement = improvement.name
}
toggleBottomLeftRiver -> tileInfo.hasBottomLeftRiver = !tileInfo.hasBottomLeftRiver
toggleBottomRiver -> tileInfo.hasBottomRiver = !tileInfo.hasBottomRiver
toggleBottomRightRiver -> tileInfo.hasBottomRightRiver = !tileInfo.hasBottomRightRiver
}
}