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" Spanish:"Vino"
Simplified_Chinese:"红酒" Simplified_Chinese:"红酒"
Portuguese:"Vinho" Portuguese:"Vinho"
Korean:"" Korean:"와인"
} }
"Sugar":{ "Sugar":{

View File

@ -21,8 +21,8 @@ android {
applicationId "com.unciv.app" applicationId "com.unciv.app"
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 29 targetSdkVersion 29
versionCode 309 versionCode 310
versionName "3.1.6" versionName "3.1.7"
} }
// Had to add this crap for Travis to build, it wanted to sign the app // 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.ScrollPane
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.badlogic.gdx.scenes.scene2d.ui.TextButton
import com.unciv.Constants
import com.unciv.UnCivGame import com.unciv.UnCivGame
import com.unciv.logic.map.RoadStatus import com.unciv.logic.map.RoadStatus
import com.unciv.logic.map.TileInfo import com.unciv.logic.map.TileInfo
@ -100,44 +101,46 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
editorPickTable.add(ScrollPane(nationsTable)).height(mapEditorScreen.stage.height*0.7f) editorPickTable.add(ScrollPane(nationsTable)).height(mapEditorScreen.stage.height*0.7f)
} }
fun setTerrainsAndResources(){ fun setTerrainsAndResources(){
val baseTerrains = ArrayList<Actor>() val baseTerrainTable = Table().apply { defaults().pad(20f) }
val terrainFeatures=ArrayList<Actor>() val terrainFeaturesTable = Table().apply { defaults().pad(20f) }
terrainFeatures.add(getHex(Color.WHITE).apply {
terrainFeaturesTable.add(getHex(Color.WHITE).apply {
onClick { onClick {
clearSelection() clearSelection()
clearTerrainFeature = true clearTerrainFeature = true
setCurrentHex(getHex(Color.WHITE), "Clear terrain features") setCurrentHex(getHex(Color.WHITE), "Clear terrain features")
} }
}) }).row()
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() addTerrainOptions(terrainFeaturesTable, baseTerrainTable)
val group = TileGroup(tileInfo, TileSetStrings()) // addRiverToggleOptions(baseTerrainTable)
group.showEntireMap=true
group.forMapEditorIcon=true
group.update()
group.onClick {
clearSelection() val resources = getResourceActors()
selectedTerrain = terrain
setCurrentHex(tileInfo,terrain.name.tr()+"\n"+terrain.clone().toString()) 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)
} }
if (terrain.type == TerrainType.TerrainFeature) private fun getResourceActors(): ArrayList<Actor> {
terrainFeatures.add(group)
else baseTerrains.add(group)
}
val resources = ArrayList<Actor>() val resources = ArrayList<Actor>()
resources.add(getHex(Color.WHITE).apply { resources.add(getHex(Color.WHITE).apply {
onClick { onClick {
@ -159,8 +162,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
if (terrainObject.type == TerrainType.TerrainFeature) { if (terrainObject.type == TerrainType.TerrainFeature) {
tileInfo.baseTerrain = terrainObject.occursOn!!.first() tileInfo.baseTerrain = terrainObject.occursOn!!.first()
tileInfo.terrainFeature = terrain tileInfo.terrainFeature = terrain
} } else tileInfo.baseTerrain = terrain
else tileInfo.baseTerrain=terrain
tileInfo.resource = resource.name tileInfo.resource = resource.name
tileInfo.setTransients() tileInfo.setTransients()
@ -168,29 +170,84 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
} }
resources.add(resourceHex) 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() 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() terrainFeaturesTable.pack()
terrainsAndResourcesTable.add(ScrollPane(terrainFeaturesTable).apply { setScrollingDisabled(true,false) }).height(mapEditorScreen.stage.height*0.7f) }
val resourcesTable = Table() private fun addRiverToggleOptions(baseTerrainTable: Table) {
for(resource in resources) resourcesTable.add(resource).row() baseTerrainTable.addSeparator()
resourcesTable.pack()
terrainsAndResourcesTable.add(ScrollPane(resourcesTable).apply { setScrollingDisabled(true,false) }).height(mapEditorScreen.stage.height*0.7f).row()
terrainsAndResourcesTable.pack()
editorPickTable.clear() val tileInfoBottomRightRiver = TileInfo()
editorPickTable.add(terrainsAndResourcesTable) 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 selectedResource=null
clearImprovement=false clearImprovement=false
selectedImprovement=null selectedImprovement=null
toggleBottomLeftRiver = false
toggleBottomRightRiver = false
toggleBottomRiver = false
} }
fun updateTileWhenClicked(tileInfo: TileInfo) { fun updateTileWhenClicked(tileInfo: TileInfo) {
@ -242,6 +302,9 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
else if (improvement.name == "Railroad") tileInfo.roadStatus = RoadStatus.Railroad else if (improvement.name == "Railroad") tileInfo.roadStatus = RoadStatus.Railroad
else tileInfo.improvement = improvement.name else tileInfo.improvement = improvement.name
} }
toggleBottomLeftRiver -> tileInfo.hasBottomLeftRiver = !tileInfo.hasBottomLeftRiver
toggleBottomRiver -> tileInfo.hasBottomRiver = !tileInfo.hasBottomRiver
toggleBottomRightRiver -> tileInfo.hasBottomRightRiver = !tileInfo.hasBottomRightRiver
} }
} }