mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-22 22:00:24 +07:00
Code cleanup
This commit is contained in:
@ -16,7 +16,7 @@ import kotlin.random.Random
|
|||||||
|
|
||||||
|
|
||||||
class MapGenerator(val ruleset: Ruleset) {
|
class MapGenerator(val ruleset: Ruleset) {
|
||||||
var randomness = MapGenerationRandomness()
|
private var randomness = MapGenerationRandomness()
|
||||||
|
|
||||||
fun generateMap(mapParameters: MapParameters, seed: Long = System.currentTimeMillis()): TileMap {
|
fun generateMap(mapParameters: MapParameters, seed: Long = System.currentTimeMillis()): TileMap {
|
||||||
val mapRadius = mapParameters.size.radius
|
val mapRadius = mapParameters.size.radius
|
||||||
@ -185,9 +185,11 @@ class MapGenerator(val ruleset: Ruleset) {
|
|||||||
var elevation = randomness.getPerlinNoise(tile, elevationSeed, scale = 2.0)
|
var elevation = randomness.getPerlinNoise(tile, elevationSeed, scale = 2.0)
|
||||||
elevation = abs(elevation).pow(1.0 - tileMap.mapParameters.elevationExponent.toDouble()) * elevation.sign
|
elevation = abs(elevation).pow(1.0 - tileMap.mapParameters.elevationExponent.toDouble()) * elevation.sign
|
||||||
|
|
||||||
if (elevation <= 0.5) tile.baseTerrain = Constants.plains
|
when {
|
||||||
else if (elevation <= 0.7) tile.baseTerrain = Constants.hill
|
elevation <= 0.5 -> tile.baseTerrain = Constants.plains
|
||||||
else if (elevation <= 1.0) tile.baseTerrain = Constants.mountain
|
elevation <= 0.7 -> tile.baseTerrain = Constants.hill
|
||||||
|
elevation <= 1.0 -> tile.baseTerrain = Constants.mountain
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,6 +348,7 @@ class RiverCoordinate(val position: Vector2, val bottomRightOrLeft: BottomRightO
|
|||||||
enum class BottomRightOrLeft {
|
enum class BottomRightOrLeft {
|
||||||
/** 7 O'Clock of the tile */
|
/** 7 O'Clock of the tile */
|
||||||
BottomLeft,
|
BottomLeft,
|
||||||
|
|
||||||
/** 5 O'Clock of the tile */
|
/** 5 O'Clock of the tile */
|
||||||
BottomRight
|
BottomRight
|
||||||
}
|
}
|
||||||
@ -366,4 +369,3 @@ class RiverCoordinate(val position: Vector2, val bottomRightOrLeft: BottomRightO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ class MapLandmassGenerator(val randomness: MapGenerationRandomness) {
|
|||||||
private fun createPerlin(tileMap: TileMap) {
|
private fun createPerlin(tileMap: TileMap) {
|
||||||
val elevationSeed = randomness.RNG.nextInt().toDouble()
|
val elevationSeed = randomness.RNG.nextInt().toDouble()
|
||||||
for (tile in tileMap.values) {
|
for (tile in tileMap.values) {
|
||||||
var elevation = randomness.getPerlinNoise(tile, elevationSeed)
|
val elevation = randomness.getPerlinNoise(tile, elevationSeed)
|
||||||
spawnLandOrWater(tile, elevation, tileMap.mapParameters.waterThreshold.toDouble())
|
spawnLandOrWater(tile, elevation, tileMap.mapParameters.waterThreshold.toDouble())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ class MapLandmassGenerator(val randomness: MapGenerationRandomness) {
|
|||||||
private fun createArchipelago(tileMap: TileMap) {
|
private fun createArchipelago(tileMap: TileMap) {
|
||||||
val elevationSeed = randomness.RNG.nextInt().toDouble()
|
val elevationSeed = randomness.RNG.nextInt().toDouble()
|
||||||
for (tile in tileMap.values) {
|
for (tile in tileMap.values) {
|
||||||
var elevation = getRidgedPerlinNoise(tile, elevationSeed)
|
val elevation = getRidgedPerlinNoise(tile, elevationSeed)
|
||||||
spawnLandOrWater(tile, elevation, 0.25 + tileMap.mapParameters.waterThreshold.toDouble())
|
spawnLandOrWater(tile, elevation, 0.25 + tileMap.mapParameters.waterThreshold.toDouble())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,8 +120,6 @@ class MapLandmassGenerator(val randomness: MapGenerationRandomness) {
|
|||||||
|
|
||||||
// region Cellular automata
|
// region Cellular automata
|
||||||
private fun generateLandCellularAutomata(tileMap: TileMap) {
|
private fun generateLandCellularAutomata(tileMap: TileMap) {
|
||||||
val mapRadius = tileMap.mapParameters.size.radius
|
|
||||||
val mapType = tileMap.mapParameters.type
|
|
||||||
val numSmooth = 4
|
val numSmooth = 4
|
||||||
|
|
||||||
//init
|
//init
|
||||||
|
@ -78,7 +78,8 @@ class NaturalWonderGenerator(val ruleset: Ruleset){
|
|||||||
*/
|
*/
|
||||||
private fun spawnBarringerCrater(tileMap: TileMap) {
|
private fun spawnBarringerCrater(tileMap: TileMap) {
|
||||||
val wonder = ruleset.terrains[Constants.barringerCrater]!!
|
val wonder = ruleset.terrains[Constants.barringerCrater]!!
|
||||||
val suitableLocations = tileMap.values.filter { it.resource == null && it.improvement == null
|
val suitableLocations = tileMap.values.filter {
|
||||||
|
it.resource == null && it.improvement == null
|
||||||
&& wonder.occursOn.contains(it.getLastTerrain().name)
|
&& wonder.occursOn.contains(it.getLastTerrain().name)
|
||||||
&& it.neighbors.none { neighbor -> neighbor.getBaseTerrain().name == Constants.grassland }
|
&& it.neighbors.none { neighbor -> neighbor.getBaseTerrain().name == Constants.grassland }
|
||||||
&& it.neighbors.count { neighbor -> neighbor.getBaseTerrain().name == Constants.mountain } <= 2
|
&& it.neighbors.count { neighbor -> neighbor.getBaseTerrain().name == Constants.mountain } <= 2
|
||||||
@ -94,7 +95,8 @@ class NaturalWonderGenerator(val ruleset: Ruleset){
|
|||||||
*/
|
*/
|
||||||
private fun spawnMountFuji(tileMap: TileMap) {
|
private fun spawnMountFuji(tileMap: TileMap) {
|
||||||
val wonder = ruleset.terrains[Constants.mountFuji]!!
|
val wonder = ruleset.terrains[Constants.mountFuji]!!
|
||||||
val suitableLocations = tileMap.values.filter { it.resource == null && it.improvement == null
|
val suitableLocations = tileMap.values.filter {
|
||||||
|
it.resource == null && it.improvement == null
|
||||||
&& wonder.occursOn.contains(it.getLastTerrain().name)
|
&& wonder.occursOn.contains(it.getLastTerrain().name)
|
||||||
&& it.neighbors.none { neighbor -> neighbor.getBaseTerrain().name == Constants.tundra }
|
&& it.neighbors.none { neighbor -> neighbor.getBaseTerrain().name == Constants.tundra }
|
||||||
&& it.neighbors.none { neighbor -> neighbor.getBaseTerrain().name == Constants.desert }
|
&& it.neighbors.none { neighbor -> neighbor.getBaseTerrain().name == Constants.desert }
|
||||||
@ -112,7 +114,8 @@ class NaturalWonderGenerator(val ruleset: Ruleset){
|
|||||||
*/
|
*/
|
||||||
private fun spawnGrandMesa(tileMap: TileMap) {
|
private fun spawnGrandMesa(tileMap: TileMap) {
|
||||||
val wonder = ruleset.terrains[Constants.grandMesa]!!
|
val wonder = ruleset.terrains[Constants.grandMesa]!!
|
||||||
val suitableLocations = tileMap.values.filter { it.resource == null && it.improvement == null
|
val suitableLocations = tileMap.values.filter {
|
||||||
|
it.resource == null && it.improvement == null
|
||||||
&& wonder.occursOn.contains(it.getLastTerrain().name)
|
&& wonder.occursOn.contains(it.getLastTerrain().name)
|
||||||
&& it.neighbors.count { neighbor -> neighbor.isHill() } >= 2
|
&& it.neighbors.count { neighbor -> neighbor.isHill() } >= 2
|
||||||
&& it.neighbors.none { neighbor -> neighbor.getBaseTerrain().name == Constants.grassland }
|
&& it.neighbors.none { neighbor -> neighbor.getBaseTerrain().name == Constants.grassland }
|
||||||
@ -128,7 +131,8 @@ class NaturalWonderGenerator(val ruleset: Ruleset){
|
|||||||
*/
|
*/
|
||||||
private fun spawnGreatBarrierReef(tileMap: TileMap) {
|
private fun spawnGreatBarrierReef(tileMap: TileMap) {
|
||||||
val wonder = ruleset.terrains[Constants.greatBarrierReef]!!
|
val wonder = ruleset.terrains[Constants.greatBarrierReef]!!
|
||||||
val suitableLocations = tileMap.values.filter { it.resource == null && it.improvement == null
|
val suitableLocations = tileMap.values.filter {
|
||||||
|
it.resource == null && it.improvement == null
|
||||||
&& wonder.occursOn.contains(it.getLastTerrain().name)
|
&& wonder.occursOn.contains(it.getLastTerrain().name)
|
||||||
&& abs(it.latitude) > tileMap.maxLatitude * 0.1
|
&& abs(it.latitude) > tileMap.maxLatitude * 0.1
|
||||||
&& abs(it.latitude) < tileMap.maxLatitude * 0.7
|
&& abs(it.latitude) < tileMap.maxLatitude * 0.7
|
||||||
@ -136,15 +140,18 @@ class NaturalWonderGenerator(val ruleset: Ruleset){
|
|||||||
&& it.neighbors.any { neighbor ->
|
&& it.neighbors.any { neighbor ->
|
||||||
neighbor.resource == null && neighbor.improvement == null
|
neighbor.resource == null && neighbor.improvement == null
|
||||||
&& wonder.occursOn.contains(neighbor.getLastTerrain().name)
|
&& wonder.occursOn.contains(neighbor.getLastTerrain().name)
|
||||||
&& neighbor.neighbors.all{ it.isWater } }
|
&& neighbor.neighbors.all { it.isWater }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val location = trySpawnOnSuitableLocation(suitableLocations, wonder)
|
val location = trySpawnOnSuitableLocation(suitableLocations, wonder)
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
val location2 = location.neighbors
|
val location2 = location.neighbors
|
||||||
.filter { it.resource == null && it.improvement == null
|
.filter {
|
||||||
|
it.resource == null && it.improvement == null
|
||||||
&& wonder.occursOn.contains(it.getLastTerrain().name)
|
&& wonder.occursOn.contains(it.getLastTerrain().name)
|
||||||
&& it.neighbors.all{ it.isWater } }
|
&& it.neighbors.all { it.isWater }
|
||||||
|
}
|
||||||
.toList().random()
|
.toList().random()
|
||||||
|
|
||||||
location2.naturalWonder = wonder.name
|
location2.naturalWonder = wonder.name
|
||||||
@ -159,7 +166,8 @@ class NaturalWonderGenerator(val ruleset: Ruleset){
|
|||||||
*/
|
*/
|
||||||
private fun spawnKrakatoa(tileMap: TileMap) {
|
private fun spawnKrakatoa(tileMap: TileMap) {
|
||||||
val wonder = ruleset.terrains[Constants.krakatoa]!!
|
val wonder = ruleset.terrains[Constants.krakatoa]!!
|
||||||
val suitableLocations = tileMap.values.filter { it.resource == null && it.improvement == null
|
val suitableLocations = tileMap.values.filter {
|
||||||
|
it.resource == null && it.improvement == null
|
||||||
&& wonder.occursOn.contains(it.getLastTerrain().name)
|
&& wonder.occursOn.contains(it.getLastTerrain().name)
|
||||||
&& it.neighbors.any { neighbor -> neighbor.getBaseTerrain().name == Constants.coast }
|
&& it.neighbors.any { neighbor -> neighbor.getBaseTerrain().name == Constants.coast }
|
||||||
&& it.neighbors.none { neighbor -> neighbor.getLastTerrain().name == Constants.ice }
|
&& it.neighbors.none { neighbor -> neighbor.getLastTerrain().name == Constants.ice }
|
||||||
@ -185,7 +193,8 @@ class NaturalWonderGenerator(val ruleset: Ruleset){
|
|||||||
*/
|
*/
|
||||||
private fun spawnRockOfGibraltar(tileMap: TileMap) {
|
private fun spawnRockOfGibraltar(tileMap: TileMap) {
|
||||||
val wonder = ruleset.terrains[Constants.rockOfGibraltar]!!
|
val wonder = ruleset.terrains[Constants.rockOfGibraltar]!!
|
||||||
val suitableLocations = tileMap.values.filter { it.resource == null && it.improvement == null
|
val suitableLocations = tileMap.values.filter {
|
||||||
|
it.resource == null && it.improvement == null
|
||||||
&& wonder.occursOn.contains(it.getLastTerrain().name)
|
&& wonder.occursOn.contains(it.getLastTerrain().name)
|
||||||
&& it.neighbors.any { neighbor -> neighbor.getBaseTerrain().name == Constants.coast }
|
&& it.neighbors.any { neighbor -> neighbor.getBaseTerrain().name == Constants.coast }
|
||||||
&& it.neighbors.count { neighbor -> neighbor.getBaseTerrain().name == Constants.mountain } == 1
|
&& it.neighbors.count { neighbor -> neighbor.getBaseTerrain().name == Constants.mountain } == 1
|
||||||
@ -220,10 +229,12 @@ class NaturalWonderGenerator(val ruleset: Ruleset){
|
|||||||
*/
|
*/
|
||||||
private fun spawnOldFaithful(tileMap: TileMap) {
|
private fun spawnOldFaithful(tileMap: TileMap) {
|
||||||
val wonder = ruleset.terrains[Constants.oldFaithful]!!
|
val wonder = ruleset.terrains[Constants.oldFaithful]!!
|
||||||
val suitableLocations = tileMap.values.filter { it.resource == null && it.improvement == null
|
val suitableLocations = tileMap.values.filter {
|
||||||
|
it.resource == null && it.improvement == null
|
||||||
&& wonder.occursOn.contains(it.getLastTerrain().name)
|
&& wonder.occursOn.contains(it.getLastTerrain().name)
|
||||||
&& it.neighbors.count { neighbor -> neighbor.getBaseTerrain().name == Constants.mountain } <= 4
|
&& it.neighbors.count { neighbor -> neighbor.getBaseTerrain().name == Constants.mountain } <= 4
|
||||||
&& it.neighbors.count { neighbor -> neighbor.getBaseTerrain().name == Constants.mountain ||
|
&& it.neighbors.count { neighbor ->
|
||||||
|
neighbor.getBaseTerrain().name == Constants.mountain ||
|
||||||
neighbor.isHill()
|
neighbor.isHill()
|
||||||
} >= 3
|
} >= 3
|
||||||
&& it.neighbors.count { neighbor -> neighbor.getBaseTerrain().name == Constants.desert } <= 3
|
&& it.neighbors.count { neighbor -> neighbor.getBaseTerrain().name == Constants.desert } <= 3
|
||||||
@ -238,7 +249,8 @@ class NaturalWonderGenerator(val ruleset: Ruleset){
|
|||||||
*/
|
*/
|
||||||
private fun spawnCerroDePotosi(tileMap: TileMap) {
|
private fun spawnCerroDePotosi(tileMap: TileMap) {
|
||||||
val wonder = ruleset.terrains[Constants.cerroDePotosi]!!
|
val wonder = ruleset.terrains[Constants.cerroDePotosi]!!
|
||||||
val suitableLocations = tileMap.values.filter { it.resource == null && it.improvement == null
|
val suitableLocations = tileMap.values.filter {
|
||||||
|
it.resource == null && it.improvement == null
|
||||||
&& wonder.occursOn.contains(it.getLastTerrain().name)
|
&& wonder.occursOn.contains(it.getLastTerrain().name)
|
||||||
&& it.neighbors.any { neighbor -> neighbor.isHill() }
|
&& it.neighbors.any { neighbor -> neighbor.isHill() }
|
||||||
}
|
}
|
||||||
@ -251,7 +263,8 @@ class NaturalWonderGenerator(val ruleset: Ruleset){
|
|||||||
*/
|
*/
|
||||||
private fun spawnElDorado(tileMap: TileMap) {
|
private fun spawnElDorado(tileMap: TileMap) {
|
||||||
val wonder = ruleset.terrains[Constants.elDorado]!!
|
val wonder = ruleset.terrains[Constants.elDorado]!!
|
||||||
val suitableLocations = tileMap.values.filter { it.resource == null && it.improvement == null
|
val suitableLocations = tileMap.values.filter {
|
||||||
|
it.resource == null && it.improvement == null
|
||||||
&& wonder.occursOn.contains(it.getLastTerrain().name)
|
&& wonder.occursOn.contains(it.getLastTerrain().name)
|
||||||
&& it.neighbors.any { neighbor -> neighbor.getLastTerrain().name == Constants.jungle }
|
&& it.neighbors.any { neighbor -> neighbor.getLastTerrain().name == Constants.jungle }
|
||||||
}
|
}
|
||||||
@ -264,8 +277,10 @@ class NaturalWonderGenerator(val ruleset: Ruleset){
|
|||||||
*/
|
*/
|
||||||
private fun spawnFountainOfYouth(tileMap: TileMap) {
|
private fun spawnFountainOfYouth(tileMap: TileMap) {
|
||||||
val wonder = ruleset.terrains[Constants.fountainOfYouth]!!
|
val wonder = ruleset.terrains[Constants.fountainOfYouth]!!
|
||||||
val suitableLocations = tileMap.values.filter { it.resource == null && it.improvement == null
|
val suitableLocations = tileMap.values.filter {
|
||||||
&& wonder.occursOn.contains(it.getLastTerrain().name) }
|
it.resource == null && it.improvement == null
|
||||||
|
&& wonder.occursOn.contains(it.getLastTerrain().name)
|
||||||
|
}
|
||||||
|
|
||||||
trySpawnOnSuitableLocation(suitableLocations, wonder)
|
trySpawnOnSuitableLocation(suitableLocations, wonder)
|
||||||
}
|
}
|
||||||
|
@ -119,19 +119,20 @@ class BaseUnit : INamed, IConstruction {
|
|||||||
|| rejectionReason.startsWith("Consumes")
|
|| rejectionReason.startsWith("Consumes")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getRejectionReason(construction: CityConstructions): String {
|
fun getRejectionReason(cityConstructions: CityConstructions): String {
|
||||||
if (unitType.isWaterUnit() && !construction.cityInfo.getCenterTile().isCoastalTile())
|
if (unitType.isWaterUnit() && !cityConstructions.cityInfo.getCenterTile().isCoastalTile())
|
||||||
return "Can only build water units in coastal cities"
|
return "Can only build water units in coastal cities"
|
||||||
|
val civInfo = cityConstructions.cityInfo.civInfo
|
||||||
for (unique in uniqueObjects.filter { it.placeholderText == "Not displayed as an available construction without []" }) {
|
for (unique in uniqueObjects.filter { it.placeholderText == "Not displayed as an available construction without []" }) {
|
||||||
val filter = unique.params[0]
|
val filter = unique.params[0]
|
||||||
if (filter in construction.cityInfo.civInfo.gameInfo.ruleSet.tileResources && !construction.cityInfo.civInfo.hasResource(filter)
|
if (filter in civInfo.gameInfo.ruleSet.tileResources && !civInfo.hasResource(filter)
|
||||||
|| filter in construction.cityInfo.civInfo.gameInfo.ruleSet.buildings && !construction.containsBuildingOrEquivalent(filter))
|
|| filter in civInfo.gameInfo.ruleSet.buildings && !cityConstructions.containsBuildingOrEquivalent(filter))
|
||||||
return "Should not be displayed"
|
return "Should not be displayed"
|
||||||
}
|
}
|
||||||
val civRejectionReason = getRejectionReason(construction.cityInfo.civInfo)
|
val civRejectionReason = getRejectionReason(civInfo)
|
||||||
if (civRejectionReason != "") return civRejectionReason
|
if (civRejectionReason != "") return civRejectionReason
|
||||||
for (unique in uniqueObjects.filter { it.placeholderText == "Requires at least [] population" })
|
for (unique in uniqueObjects.filter { it.placeholderText == "Requires at least [] population" })
|
||||||
if (unique.params[0].toInt() > construction.cityInfo.population.population)
|
if (unique.params[0].toInt() > cityConstructions.cityInfo.population.population)
|
||||||
return unique.text
|
return unique.text
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,15 @@
|
|||||||
package com.unciv.ui.mapeditor
|
package com.unciv.ui.mapeditor
|
||||||
|
|
||||||
import com.badlogic.gdx.files.FileHandle
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.math.Vector2
|
import com.badlogic.gdx.math.Vector2
|
||||||
import com.badlogic.gdx.scenes.scene2d.InputEvent
|
import com.badlogic.gdx.scenes.scene2d.InputEvent
|
||||||
import com.badlogic.gdx.scenes.scene2d.InputListener
|
import com.badlogic.gdx.scenes.scene2d.InputListener
|
||||||
import com.badlogic.gdx.scenes.scene2d.actions.Actions
|
import com.badlogic.gdx.scenes.scene2d.actions.Actions
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin
|
|
||||||
import com.badlogic.gdx.utils.Array
|
|
||||||
import com.unciv.logic.MapSaver
|
|
||||||
import com.unciv.logic.map.ScenarioMap
|
import com.unciv.logic.map.ScenarioMap
|
||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
import com.unciv.logic.map.TileMap
|
import com.unciv.logic.map.TileMap
|
||||||
import com.unciv.models.ruleset.Ruleset
|
import com.unciv.models.ruleset.Ruleset
|
||||||
import com.unciv.models.ruleset.RulesetCache
|
import com.unciv.models.ruleset.RulesetCache
|
||||||
import com.unciv.models.translations.tr
|
|
||||||
import com.unciv.ui.newgamescreen.GameSetupInfo
|
import com.unciv.ui.newgamescreen.GameSetupInfo
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
|
|
||||||
@ -34,25 +28,6 @@ class MapEditorScreen(): CameraStageBaseScreen() {
|
|||||||
private val showHideEditorOptionsButton = ">".toTextButton()
|
private val showHideEditorOptionsButton = ">".toTextButton()
|
||||||
|
|
||||||
|
|
||||||
constructor(mapNameToLoad: String?) : this() {
|
|
||||||
var mapToLoad = mapNameToLoad
|
|
||||||
if (mapToLoad == null) {
|
|
||||||
val existingSaves = MapSaver.getMaps()
|
|
||||||
if (existingSaves.isNotEmpty())
|
|
||||||
mapToLoad = existingSaves.first().name()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mapToLoad != null) {
|
|
||||||
mapName = mapToLoad
|
|
||||||
scenarioName = mapToLoad
|
|
||||||
tileMap = MapSaver.loadMap(mapName)
|
|
||||||
}
|
|
||||||
|
|
||||||
initialize()
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(mapFile:FileHandle):this()
|
|
||||||
|
|
||||||
constructor(map: TileMap) : this() {
|
constructor(map: TileMap) : this() {
|
||||||
tileMap = map
|
tileMap = map
|
||||||
initialize()
|
initialize()
|
||||||
@ -178,24 +153,7 @@ class MapEditorScreen(): CameraStageBaseScreen() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hasScenario(): Boolean {
|
fun hasScenario() = this.scenarioMap != null
|
||||||
return this.scenarioMap != null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class TranslatedSelectBox(values : Collection<String>, default:String, skin: Skin) : SelectBox<TranslatedSelectBox.TranslatedString>(skin) {
|
|
||||||
class TranslatedString(val value: String) {
|
|
||||||
val translation = value.tr()
|
|
||||||
override fun toString() = translation
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
|
||||||
val array = Array<TranslatedString>()
|
|
||||||
values.forEach { array.add(TranslatedString(it)) }
|
|
||||||
items = array
|
|
||||||
val defaultItem = array.firstOrNull { it.value == default }
|
|
||||||
selected = if (defaultItem != null) defaultItem else array.first()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user