mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 13:55:54 -04:00
Resolved #3289 - can place unbuildable improvements that can exist on tiles
This commit is contained in:
parent
f57955c8d5
commit
c1a717e4f8
@ -299,7 +299,7 @@ open class TileInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Without regards to what civinfo it is, a lot of the checks are ust for the improvement on the tile.
|
/** Without regards to what civinfo it is, a lot of the checks are just for the improvement on the tile.
|
||||||
* Doubles as a check for the map editor.
|
* Doubles as a check for the map editor.
|
||||||
*/
|
*/
|
||||||
fun canImprovementBeBuiltHere(improvement: TileImprovement, resourceIsVisible:Boolean = resource!=null): Boolean {
|
fun canImprovementBeBuiltHere(improvement: TileImprovement, resourceIsVisible:Boolean = resource!=null): Boolean {
|
||||||
|
@ -21,10 +21,10 @@ import com.unciv.ui.tilegroups.TileGroup
|
|||||||
import com.unciv.ui.tilegroups.TileSetStrings
|
import com.unciv.ui.tilegroups.TileSetStrings
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
|
|
||||||
class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(CameraStageBaseScreen.skin){
|
class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(CameraStageBaseScreen.skin) {
|
||||||
private val tileSetLocation = "TileSets/"+ UncivGame.Current.settings.tileSet +"/"
|
private val tileSetLocation = "TileSets/" + UncivGame.Current.settings.tileSet + "/"
|
||||||
|
|
||||||
var tileAction:(TileInfo)->Unit = {}
|
var tileAction: (TileInfo) -> Unit = {}
|
||||||
|
|
||||||
private val editorPickTable = Table()
|
private val editorPickTable = Table()
|
||||||
|
|
||||||
@ -34,16 +34,16 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
private val ruleset = mapEditorScreen.ruleset
|
private val ruleset = mapEditorScreen.ruleset
|
||||||
private val gameParameters = mapEditorScreen.gameSetupInfo.gameParameters
|
private val gameParameters = mapEditorScreen.gameSetupInfo.gameParameters
|
||||||
|
|
||||||
private val scrollPanelHeight = mapEditorScreen.stage.height*0.7f - 100f // -100 reserved for currentHex table
|
private val scrollPanelHeight = mapEditorScreen.stage.height * 0.7f - 100f // -100 reserved for currentHex table
|
||||||
|
|
||||||
init{
|
init {
|
||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun update() {
|
fun update() {
|
||||||
clear()
|
clear()
|
||||||
height = mapEditorScreen.stage.height
|
height = mapEditorScreen.stage.height
|
||||||
width = mapEditorScreen.stage.width/3
|
width = mapEditorScreen.stage.width / 3
|
||||||
|
|
||||||
setTerrainsAndResources()
|
setTerrainsAndResources()
|
||||||
|
|
||||||
@ -79,12 +79,12 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
sliderTab.add(slider)
|
sliderTab.add(slider)
|
||||||
|
|
||||||
add(sliderTab).row()
|
add(sliderTab).row()
|
||||||
add(AutoScrollPane(tabPickerTable).apply { this.width= mapEditorScreen.stage.width/3}).row()
|
add(AutoScrollPane(tabPickerTable).apply { this.width = mapEditorScreen.stage.width / 3 }).row()
|
||||||
|
|
||||||
add(editorPickTable).row()
|
add(editorPickTable).row()
|
||||||
}
|
}
|
||||||
|
|
||||||
private 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) }
|
||||||
@ -92,11 +92,11 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
terrainFeaturesTable.add(getHex(Color.WHITE, getRedCross(50f, 0.6f)).apply {
|
terrainFeaturesTable.add(getHex(Color.WHITE, getRedCross(50f, 0.6f)).apply {
|
||||||
onClick {
|
onClick {
|
||||||
tileAction = {
|
tileAction = {
|
||||||
it.terrainFeature=null
|
it.terrainFeature = null
|
||||||
it.naturalWonder = null
|
it.naturalWonder = null
|
||||||
it.hasBottomRiver=false
|
it.hasBottomRiver = false
|
||||||
it.hasBottomLeftRiver=false
|
it.hasBottomLeftRiver = false
|
||||||
it.hasBottomRightRiver=false
|
it.hasBottomRightRiver = false
|
||||||
}
|
}
|
||||||
setCurrentHex(getHex(Color.WHITE, getRedCross(40f, 0.6f)), "Clear terrain features")
|
setCurrentHex(getHex(Color.WHITE, getRedCross(40f, 0.6f)), "Clear terrain features")
|
||||||
}
|
}
|
||||||
@ -112,14 +112,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(AutoScrollPane(baseTerrainTable).apply { setScrollingDisabled(true,false) }).height(scrollPanelHeight)
|
terrainsAndResourcesTable.add(AutoScrollPane(baseTerrainTable).apply { setScrollingDisabled(true, false) }).height(scrollPanelHeight)
|
||||||
|
|
||||||
terrainsAndResourcesTable.add(AutoScrollPane(terrainFeaturesTable).apply { setScrollingDisabled(true,false) }).height(scrollPanelHeight)
|
terrainsAndResourcesTable.add(AutoScrollPane(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(AutoScrollPane(resourcesTable).apply { setScrollingDisabled(true,false) }).height(scrollPanelHeight).row()
|
terrainsAndResourcesTable.add(AutoScrollPane(resourcesTable).apply { setScrollingDisabled(true, false) }).height(scrollPanelHeight).row()
|
||||||
|
|
||||||
terrainsAndResourcesTable.pack()
|
terrainsAndResourcesTable.pack()
|
||||||
|
|
||||||
@ -134,12 +134,12 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
val improvementsTable = Table()
|
val improvementsTable = Table()
|
||||||
improvementsTable.add(getHex(Color.WHITE, getRedCross(40f, 0.6f)).apply {
|
improvementsTable.add(getHex(Color.WHITE, getRedCross(40f, 0.6f)).apply {
|
||||||
onClick {
|
onClick {
|
||||||
tileAction = {it.improvement=null}
|
tileAction = { it.improvement = null }
|
||||||
setCurrentHex(getHex(Color.WHITE, getRedCross(40f, 0.6f)), "Clear improvements")
|
setCurrentHex(getHex(Color.WHITE, getRedCross(40f, 0.6f)), "Clear improvements")
|
||||||
}
|
}
|
||||||
}).row()
|
}).row()
|
||||||
|
|
||||||
for(improvement in ruleset.tileImprovements.values){
|
for (improvement in ruleset.tileImprovements.values) {
|
||||||
if (improvement.name.startsWith("Remove")) continue
|
if (improvement.name.startsWith("Remove")) continue
|
||||||
if (improvement.name == Constants.cancelImprovementOrder) continue
|
if (improvement.name == Constants.cancelImprovementOrder) continue
|
||||||
val improvementImage = getHex(Color.WHITE, ImageGetter.getImprovementIcon(improvement.name, 40f))
|
val improvementImage = getHex(Color.WHITE, ImageGetter.getImprovementIcon(improvement.name, 40f))
|
||||||
@ -152,11 +152,11 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
val improvementIcon = getHex(Color.WHITE, ImageGetter.getImprovementIcon(improvement.name, 40f))
|
val improvementIcon = getHex(Color.WHITE, ImageGetter.getImprovementIcon(improvement.name, 40f))
|
||||||
setCurrentHex(improvementIcon, improvement.name.tr()+"\n"+improvement.clone().toString())
|
setCurrentHex(improvementIcon, improvement.name.tr() + "\n" + improvement.clone().toString())
|
||||||
}
|
}
|
||||||
improvementsTable.add(improvementImage).row()
|
improvementsTable.add(improvementImage).row()
|
||||||
}
|
}
|
||||||
editorPickTable.add(AutoScrollPane(improvementsTable).apply { setScrollingDisabled(true,false) }).height(scrollPanelHeight)
|
editorPickTable.add(AutoScrollPane(improvementsTable).apply { setScrollingDisabled(true, false) }).height(scrollPanelHeight)
|
||||||
|
|
||||||
val nationTable = Table()
|
val nationTable = Table()
|
||||||
|
|
||||||
@ -184,19 +184,19 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
}
|
}
|
||||||
|
|
||||||
val nationIcon = getHex(Color.WHITE, ImageGetter.getNationIndicator(nation, 40f))
|
val nationIcon = getHex(Color.WHITE, ImageGetter.getNationIndicator(nation, 40f))
|
||||||
setCurrentHex(nationIcon,"Player [$playerIndex] starting location")
|
setCurrentHex(nationIcon, "Player [$playerIndex] starting location")
|
||||||
}
|
}
|
||||||
nationTable.add(nationImage).row()
|
nationTable.add(nationImage).row()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/** old way improvements for all civs
|
/** old way improvements for all civs
|
||||||
* */
|
* */
|
||||||
for(nation in ruleset.nations.values){
|
for (nation in ruleset.nations.values) {
|
||||||
if (nation.isSpectator()) continue // no improvements for spectator
|
if (nation.isSpectator()) continue // no improvements for spectator
|
||||||
|
|
||||||
val nationImage = getHex(Color.WHITE, ImageGetter.getNationIndicator(nation, 40f))
|
val nationImage = getHex(Color.WHITE, ImageGetter.getNationIndicator(nation, 40f))
|
||||||
nationImage.onClick {
|
nationImage.onClick {
|
||||||
val improvementName = "StartingLocation "+nation.name
|
val improvementName = "StartingLocation " + nation.name
|
||||||
tileAction = {
|
tileAction = {
|
||||||
it.improvement = improvementName
|
it.improvement = improvementName
|
||||||
for (tileGroup in mapEditorScreen.mapHolder.tileGroups.values) {
|
for (tileGroup in mapEditorScreen.mapHolder.tileGroups.values) {
|
||||||
@ -215,34 +215,34 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
editorPickTable.add(AutoScrollPane(nationTable).apply { setScrollingDisabled(true,false) }).height(scrollPanelHeight)
|
editorPickTable.add(AutoScrollPane(nationTable).apply { setScrollingDisabled(true, false) }).height(scrollPanelHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setUnits(){
|
fun setUnits() {
|
||||||
editorPickTable.clear()
|
editorPickTable.clear()
|
||||||
|
|
||||||
val nationsTable = Table()
|
val nationsTable = Table()
|
||||||
|
|
||||||
// default player - first MajorCiv player
|
// default player - first MajorCiv player
|
||||||
val defaultPlayer = gameParameters.players.first{
|
val defaultPlayer = gameParameters.players.first {
|
||||||
it.chosenCiv != Constants.spectator && it.chosenCiv != Constants.random
|
it.chosenCiv != Constants.spectator && it.chosenCiv != Constants.random
|
||||||
}
|
}
|
||||||
var currentPlayer = getPlayerIndexString(defaultPlayer)
|
var currentPlayer = getPlayerIndexString(defaultPlayer)
|
||||||
var currentNation: Nation = ruleset.nations[defaultPlayer.chosenCiv]!!
|
var currentNation: Nation = ruleset.nations[defaultPlayer.chosenCiv]!!
|
||||||
var currentUnit = ruleset.units.values.first()
|
var currentUnit = ruleset.units.values.first()
|
||||||
|
|
||||||
fun setUnitTileAction(){
|
fun setUnitTileAction() {
|
||||||
val unitImage = ImageGetter.getUnitIcon(currentUnit.name, currentNation.getInnerColor())
|
val unitImage = ImageGetter.getUnitIcon(currentUnit.name, currentNation.getInnerColor())
|
||||||
.surroundWithCircle(40f*0.9f).apply { circle.color=currentNation.getOuterColor() }
|
.surroundWithCircle(40f * 0.9f).apply { circle.color = currentNation.getOuterColor() }
|
||||||
.surroundWithCircle(40f, false).apply { circle.color=currentNation.getInnerColor() }
|
.surroundWithCircle(40f, false).apply { circle.color = currentNation.getInnerColor() }
|
||||||
|
|
||||||
setCurrentHex(unitImage, currentUnit.name.tr()+ " - $currentPlayer ("+currentNation.name.tr()+")")
|
setCurrentHex(unitImage, currentUnit.name.tr() + " - $currentPlayer (" + currentNation.name.tr() + ")")
|
||||||
tileAction = {
|
tileAction = {
|
||||||
val unit = MapUnit()
|
val unit = MapUnit()
|
||||||
unit.baseUnit = currentUnit
|
unit.baseUnit = currentUnit
|
||||||
unit.name = currentUnit.name
|
unit.name = currentUnit.name
|
||||||
unit.owner = currentNation.name
|
unit.owner = currentNation.name
|
||||||
unit.civInfo = CivilizationInfo(currentNation.name).apply { nation=currentNation } // needed for the unit icon to render correctly
|
unit.civInfo = CivilizationInfo(currentNation.name).apply { nation = currentNation } // needed for the unit icon to render correctly
|
||||||
unit.updateUniques()
|
unit.updateUniques()
|
||||||
if (unit.movement.canMoveTo(it)) {
|
if (unit.movement.canMoveTo(it)) {
|
||||||
when {
|
when {
|
||||||
@ -250,18 +250,22 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
it.airUnits.add(unit)
|
it.airUnits.add(unit)
|
||||||
if (!it.isCityCenter()) unit.isTransported = true // if not city - air unit enters carrier
|
if (!it.isCityCenter()) unit.isTransported = true // if not city - air unit enters carrier
|
||||||
}
|
}
|
||||||
unit.type.isCivilian() -> { it.civilianUnit = unit }
|
unit.type.isCivilian() -> {
|
||||||
else -> { it.militaryUnit = unit }
|
it.civilianUnit = unit
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
it.militaryUnit = unit
|
||||||
|
}
|
||||||
}
|
}
|
||||||
unit.currentTile=it // needed for unit icon - unit needs to know if it's embarked or not...
|
unit.currentTile = it // needed for unit icon - unit needs to know if it's embarked or not...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete units icon
|
// delete units icon
|
||||||
nationsTable.add(getCrossedIcon().onClick {
|
nationsTable.add(getCrossedIcon().onClick {
|
||||||
tileAction = { it.stripUnits() }
|
tileAction = { it.stripUnits() }
|
||||||
setCurrentHex(getCrossedIcon(), "Remove units")
|
setCurrentHex(getCrossedIcon(), "Remove units")
|
||||||
}).row()
|
}).row()
|
||||||
|
|
||||||
// player icons
|
// player icons
|
||||||
@ -274,12 +278,13 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
nationImage.onClick {
|
nationImage.onClick {
|
||||||
currentNation = nation;
|
currentNation = nation;
|
||||||
currentPlayer = getPlayerIndexString(player)
|
currentPlayer = getPlayerIndexString(player)
|
||||||
setUnitTileAction() }
|
setUnitTileAction()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// barbarians icon
|
// barbarians icon
|
||||||
if (!gameParameters.noBarbarians) {
|
if (!gameParameters.noBarbarians) {
|
||||||
val barbarians = ruleset.nations.values.filter { it.isBarbarian()}
|
val barbarians = ruleset.nations.values.filter { it.isBarbarian() }
|
||||||
for (nation in barbarians) {
|
for (nation in barbarians) {
|
||||||
val nationImage = ImageGetter.getNationIndicator(nation, 40f)
|
val nationImage = ImageGetter.getNationIndicator(nation, 40f)
|
||||||
nationsTable.add(nationImage).row()
|
nationsTable.add(nationImage).row()
|
||||||
@ -294,7 +299,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
editorPickTable.add(AutoScrollPane(nationsTable)).height(scrollPanelHeight)
|
editorPickTable.add(AutoScrollPane(nationsTable)).height(scrollPanelHeight)
|
||||||
|
|
||||||
val unitsTable = Table()
|
val unitsTable = Table()
|
||||||
for(unit in ruleset.units.values){
|
for (unit in ruleset.units.values) {
|
||||||
val unitImage = ImageGetter.getUnitIcon(unit.name).surroundWithCircle(40f)
|
val unitImage = ImageGetter.getUnitIcon(unit.name).surroundWithCircle(40f)
|
||||||
unitsTable.add(unitImage).row()
|
unitsTable.add(unitImage).row()
|
||||||
unitImage.onClick { currentUnit = unit; setUnitTileAction() }
|
unitImage.onClick { currentUnit = unit; setUnitTileAction() }
|
||||||
@ -307,7 +312,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
.filter { it.improvement != null && it.improvement!!.startsWith("StartingLocation ") }
|
.filter { it.improvement != null && it.improvement!!.startsWith("StartingLocation ") }
|
||||||
var nations = ArrayList<Nation>()
|
var nations = ArrayList<Nation>()
|
||||||
for (tile in tilesWithStartingLocations) {
|
for (tile in tilesWithStartingLocations) {
|
||||||
var civName = tile.improvement!!.removePrefix("StartingLocation ")
|
var civName = tile.improvement!!.removePrefix("StartingLocation ")
|
||||||
nations.add(ruleset.nations[civName]!!)
|
nations.add(ruleset.nations[civName]!!)
|
||||||
}
|
}
|
||||||
return nations
|
return nations
|
||||||
@ -326,12 +331,12 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
|
|
||||||
private fun getRedCross(size: Float, alpha: Float): Actor {
|
private fun getRedCross(size: Float, alpha: Float): Actor {
|
||||||
val redCross = ImageGetter.getImage("OtherIcons/Close")
|
val redCross = ImageGetter.getImage("OtherIcons/Close")
|
||||||
redCross.setSize( size, size)
|
redCross.setSize(size, size)
|
||||||
redCross.color = Color.RED.cpy().apply { a = alpha }
|
redCross.color = Color.RED.cpy().apply { a = alpha }
|
||||||
return redCross
|
return redCross
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getCrossedResource() : Actor {
|
private fun getCrossedResource(): Actor {
|
||||||
val redCross = getRedCross(45f, 0.5f)
|
val redCross = getRedCross(45f, 0.5f)
|
||||||
val group = IconCircleGroup(40f, redCross, false)
|
val group = IconCircleGroup(40f, redCross, false)
|
||||||
group.circle.color = ImageGetter.foodCircleColor
|
group.circle.color = ImageGetter.foodCircleColor
|
||||||
@ -416,7 +421,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
tileInfoBottomRightRiver.hasBottomRightRiver = true
|
tileInfoBottomRightRiver.hasBottomRightRiver = true
|
||||||
val tileGroupBottomRightRiver = makeTileGroup(tileInfoBottomRightRiver)
|
val tileGroupBottomRightRiver = makeTileGroup(tileInfoBottomRightRiver)
|
||||||
tileGroupBottomRightRiver.onClick {
|
tileGroupBottomRightRiver.onClick {
|
||||||
tileAction = {it.hasBottomRightRiver = !it.hasBottomRightRiver}
|
tileAction = { it.hasBottomRightRiver = !it.hasBottomRightRiver }
|
||||||
|
|
||||||
setCurrentHex(tileInfoBottomRightRiver, "Bottom right river")
|
setCurrentHex(tileInfoBottomRightRiver, "Bottom right river")
|
||||||
}
|
}
|
||||||
@ -428,7 +433,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
tileInfoBottomRiver.hasBottomRiver = true
|
tileInfoBottomRiver.hasBottomRiver = true
|
||||||
val tileGroupBottomRiver = makeTileGroup(tileInfoBottomRiver)
|
val tileGroupBottomRiver = makeTileGroup(tileInfoBottomRiver)
|
||||||
tileGroupBottomRiver.onClick {
|
tileGroupBottomRiver.onClick {
|
||||||
tileAction = {it.hasBottomRiver = !it.hasBottomRiver}
|
tileAction = { it.hasBottomRiver = !it.hasBottomRiver }
|
||||||
setCurrentHex(tileInfoBottomRiver, "Bottom river")
|
setCurrentHex(tileInfoBottomRiver, "Bottom river")
|
||||||
}
|
}
|
||||||
baseTerrainTable.add(tileGroupBottomRiver).row()
|
baseTerrainTable.add(tileGroupBottomRiver).row()
|
||||||
@ -439,7 +444,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
tileInfoBottomLeftRiver.baseTerrain = Constants.plains
|
tileInfoBottomLeftRiver.baseTerrain = Constants.plains
|
||||||
val tileGroupBottomLeftRiver = makeTileGroup(tileInfoBottomLeftRiver)
|
val tileGroupBottomLeftRiver = makeTileGroup(tileInfoBottomLeftRiver)
|
||||||
tileGroupBottomLeftRiver.onClick {
|
tileGroupBottomLeftRiver.onClick {
|
||||||
tileAction = {it.hasBottomLeftRiver = !it.hasBottomLeftRiver}
|
tileAction = { it.hasBottomLeftRiver = !it.hasBottomLeftRiver }
|
||||||
setCurrentHex(tileInfoBottomLeftRiver, "Bottom left river")
|
setCurrentHex(tileInfoBottomLeftRiver, "Bottom left river")
|
||||||
}
|
}
|
||||||
baseTerrainTable.add(tileGroupBottomLeftRiver).row()
|
baseTerrainTable.add(tileGroupBottomLeftRiver).row()
|
||||||
@ -458,17 +463,17 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private 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
|
||||||
hex.height*=0.3f
|
hex.height *= 0.3f
|
||||||
val group = Group()
|
val group = Group()
|
||||||
group.setSize(hex.width,hex.height)
|
group.setSize(hex.width, hex.height)
|
||||||
hex.center(group)
|
hex.center(group)
|
||||||
group.addActor(hex)
|
group.addActor(hex)
|
||||||
|
|
||||||
if(image!=null) {
|
if (image != null) {
|
||||||
image.setSize(40f, 40f)
|
image.setSize(40f, 40f)
|
||||||
image.center(group)
|
image.center(group)
|
||||||
group.addActor(image)
|
group.addActor(image)
|
||||||
@ -482,7 +487,7 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
normalizeTile(tileInfo)
|
normalizeTile(tileInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun normalizeTile(tileInfo: TileInfo){
|
fun normalizeTile(tileInfo: TileInfo) {
|
||||||
/*Natural Wonder superpowers! */
|
/*Natural Wonder superpowers! */
|
||||||
if (tileInfo.naturalWonder != null) {
|
if (tileInfo.naturalWonder != null) {
|
||||||
val naturalWonder = tileInfo.getNaturalWonder()
|
val naturalWonder = tileInfo.getNaturalWonder()
|
||||||
@ -494,19 +499,19 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
|
|
||||||
if (tileInfo.terrainFeature != null) {
|
if (tileInfo.terrainFeature != null) {
|
||||||
val terrainFeature = tileInfo.getTerrainFeature()
|
val terrainFeature = tileInfo.getTerrainFeature()
|
||||||
if (terrainFeature==null || terrainFeature.occursOn.isNotEmpty() && !terrainFeature.occursOn.contains(tileInfo.baseTerrain))
|
if (terrainFeature == null || terrainFeature.occursOn.isNotEmpty() && !terrainFeature.occursOn.contains(tileInfo.baseTerrain))
|
||||||
tileInfo.terrainFeature = null
|
tileInfo.terrainFeature = null
|
||||||
}
|
}
|
||||||
if (tileInfo.resource != null) {
|
if (tileInfo.resource != null) {
|
||||||
val resource = tileInfo.getTileResource()
|
val resource = tileInfo.getTileResource()
|
||||||
if(resource.terrainsCanBeFoundOn.none { it==tileInfo.baseTerrain || it==tileInfo.terrainFeature })
|
if (resource.terrainsCanBeFoundOn.none { it == tileInfo.baseTerrain || it == tileInfo.terrainFeature })
|
||||||
tileInfo.resource=null
|
tileInfo.resource = null
|
||||||
}
|
}
|
||||||
if (tileInfo.improvement!=null) {
|
if (tileInfo.improvement != null) {
|
||||||
normalizeTileImprovement(tileInfo)
|
normalizeTileImprovement(tileInfo)
|
||||||
}
|
}
|
||||||
if (tileInfo.isWater || tileInfo.isImpassible())
|
if (tileInfo.isWater || tileInfo.isImpassible())
|
||||||
tileInfo.roadStatus= RoadStatus.None
|
tileInfo.roadStatus = RoadStatus.None
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun normalizeTileImprovement(tileInfo: TileInfo) {
|
private fun normalizeTileImprovement(tileInfo: TileInfo) {
|
||||||
@ -518,30 +523,33 @@ class TileEditorOptionsTable(val mapEditorScreen: MapEditorScreen): Table(Camera
|
|||||||
}
|
}
|
||||||
val improvement = tileInfo.getTileImprovement()!!
|
val improvement = tileInfo.getTileImprovement()!!
|
||||||
tileInfo.improvement = null // Unset, and check if it can be reset. If so, do it, if not, invalid.
|
tileInfo.improvement = null // Unset, and check if it can be reset. If so, do it, if not, invalid.
|
||||||
if (tileInfo.canImprovementBeBuiltHere(improvement))
|
if (tileInfo.canImprovementBeBuiltHere(improvement)
|
||||||
|
// Allow building 'other' improvements like city ruins, barb encampments, Great Improvements etc
|
||||||
|
|| (improvement.terrainsCanBeBuiltOn.isEmpty() && ruleset.tileResources.values.none { it.improvement==improvement.name }
|
||||||
|
&& !tileInfo.isImpassible() && tileInfo.isLand))
|
||||||
tileInfo.improvement = improvement.name
|
tileInfo.improvement = improvement.name
|
||||||
}
|
}
|
||||||
|
|
||||||
private 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)
|
tileGroup.baseLayerGroup.moveBy(-10f, 10f)
|
||||||
setCurrentHex(tileGroup,text)
|
setCurrentHex(tileGroup, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
private 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(30f)
|
currentHexTable.add(text.toLabel()).padRight(30f)
|
||||||
currentHexTable.add(actor)
|
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)
|
||||||
stage.addActor(currentHex)
|
stage.addActor(currentHex)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -85,9 +85,4 @@ class BasicTests {
|
|||||||
Assert.assertTrue(modCheck == "")
|
Assert.assertTrue(modCheck == "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// @Test // This should NOT run as part of the test suite!
|
|
||||||
// fun tryGetGithubTopicInfo(){
|
|
||||||
// println(Github.tryGetGithubReposWithTopic())
|
|
||||||
// }
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user