Compare commits
3 commits
Author | SHA1 | Date | |
---|---|---|---|
|
ffccb75860 | ||
|
51c3126a9a | ||
|
7183e089db |
7 changed files with 108 additions and 22 deletions
|
@ -18,6 +18,7 @@ import com.unciv.models.translations.TranslationFileReader
|
||||||
import com.unciv.models.translations.Translations
|
import com.unciv.models.translations.Translations
|
||||||
import com.unciv.ui.LanguagePickerScreen
|
import com.unciv.ui.LanguagePickerScreen
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
|
import com.unciv.ui.worldscreen.TotemWorldScreen
|
||||||
import com.unciv.ui.worldscreen.WorldScreen
|
import com.unciv.ui.worldscreen.WorldScreen
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.concurrent.thread
|
import kotlin.concurrent.thread
|
||||||
|
@ -103,6 +104,7 @@ class UncivGame(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun autoLoadGame(){
|
fun autoLoadGame(){
|
||||||
|
return setScreen(TotemWorldScreen())
|
||||||
if (!GameSaver().getSave("Autosave").exists())
|
if (!GameSaver().getSave("Autosave").exists())
|
||||||
return setScreen(LanguagePickerScreen())
|
return setScreen(LanguagePickerScreen())
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -288,10 +288,10 @@ open class TileInfo {
|
||||||
|
|
||||||
fun isRoughTerrain() = getBaseTerrain().rough || getTerrainFeature()?.rough == true
|
fun isRoughTerrain() = getBaseTerrain().rough || getTerrainFeature()?.rough == true
|
||||||
|
|
||||||
override fun toString(): String {
|
fun toString(viewingCiv: CivilizationInfo): String {
|
||||||
val lineList = ArrayList<String>() // more readable than StringBuilder, with same performance for our use-case
|
val lineList = ArrayList<String>() // more readable than StringBuilder, with same performance for our use-case
|
||||||
val isViewableToPlayer = UncivGame.Current.viewEntireMapForDebug
|
val isViewableToPlayer = UncivGame.Current.viewEntireMapForDebug
|
||||||
|| UncivGame.Current.gameInfo.getCurrentPlayerCivilization().viewableTiles.contains(this)
|
|| viewingCiv.viewableTiles.contains(this)
|
||||||
|
|
||||||
if (isCityCenter()) {
|
if (isCityCenter()) {
|
||||||
val city = getCity()!!
|
val city = getCity()!!
|
||||||
|
|
|
@ -32,7 +32,7 @@ class CityScreenTileTable(val city: CityInfo): Table(){
|
||||||
val stats = selectedTile.getTileStats(city, city.civInfo)
|
val stats = selectedTile.getTileStats(city, city.civInfo)
|
||||||
innerTable.pad(20f)
|
innerTable.pad(20f)
|
||||||
|
|
||||||
innerTable.add(selectedTile.toString().toLabel()).colspan(2)
|
innerTable.add(selectedTile.toString(city.civInfo).toLabel()).colspan(2)
|
||||||
innerTable.row()
|
innerTable.row()
|
||||||
innerTable.add(getTileStatsTable(stats)).row()
|
innerTable.add(getTileStatsTable(stats)).row()
|
||||||
|
|
||||||
|
|
|
@ -277,7 +277,7 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings)
|
||||||
updatePixelMilitaryUnit(tileIsViewable && showMilitaryUnit)
|
updatePixelMilitaryUnit(tileIsViewable && showMilitaryUnit)
|
||||||
updatePixelCivilianUnit(tileIsViewable)
|
updatePixelCivilianUnit(tileIsViewable)
|
||||||
|
|
||||||
icons.update(showResourcesAndImprovements, tileIsViewable, showMilitaryUnit)
|
icons.update(viewingCiv,showResourcesAndImprovements, tileIsViewable, showMilitaryUnit)
|
||||||
|
|
||||||
updateCityImage()
|
updateCityImage()
|
||||||
updateNaturalWonderImage()
|
updateNaturalWonderImage()
|
||||||
|
|
|
@ -6,8 +6,12 @@ import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.utils.Align
|
import com.badlogic.gdx.utils.Align
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
import com.unciv.logic.map.MapUnit
|
import com.unciv.logic.map.MapUnit
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.ImageGetter
|
||||||
|
import com.unciv.ui.utils.UnitGroup
|
||||||
|
import com.unciv.ui.utils.center
|
||||||
|
import com.unciv.ui.utils.toLabel
|
||||||
|
|
||||||
/** Helper class for TileGroup, which was getting too full */
|
/** Helper class for TileGroup, which was getting too full */
|
||||||
class TileGroupIcons(val tileGroup: TileGroup){
|
class TileGroupIcons(val tileGroup: TileGroup){
|
||||||
|
@ -18,12 +22,14 @@ class TileGroupIcons(val tileGroup: TileGroup){
|
||||||
var civilianUnitIcon: UnitGroup? = null
|
var civilianUnitIcon: UnitGroup? = null
|
||||||
var militaryUnitIcon: UnitGroup? = null
|
var militaryUnitIcon: UnitGroup? = null
|
||||||
|
|
||||||
fun update(showResourcesAndImprovements: Boolean, tileIsViewable: Boolean, showMilitaryUnit: Boolean) {
|
fun update(viewingCiv:CivilizationInfo?,showResourcesAndImprovements: Boolean, tileIsViewable: Boolean, showMilitaryUnit: Boolean) {
|
||||||
updateResourceIcon(showResourcesAndImprovements)
|
updateResourceIcon(showResourcesAndImprovements,viewingCiv)
|
||||||
updateImprovementIcon(showResourcesAndImprovements)
|
updateImprovementIcon(showResourcesAndImprovements)
|
||||||
|
|
||||||
civilianUnitIcon = newUnitIcon(tileGroup.tileInfo.civilianUnit, civilianUnitIcon, tileIsViewable, -20f)
|
civilianUnitIcon = newUnitIcon(tileGroup.tileInfo.civilianUnit, civilianUnitIcon,
|
||||||
militaryUnitIcon = newUnitIcon(tileGroup.tileInfo.militaryUnit, militaryUnitIcon, tileIsViewable && showMilitaryUnit, 20f)
|
tileIsViewable, -20f, viewingCiv)
|
||||||
|
militaryUnitIcon = newUnitIcon(tileGroup.tileInfo.militaryUnit, militaryUnitIcon,
|
||||||
|
tileIsViewable && showMilitaryUnit, 20f, viewingCiv)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addPopulationIcon() {
|
fun addPopulationIcon() {
|
||||||
|
@ -43,7 +49,7 @@ class TileGroupIcons(val tileGroup: TileGroup){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun newUnitIcon(unit: MapUnit?, oldUnitGroup: UnitGroup?, isViewable: Boolean, yFromCenter: Float): UnitGroup? {
|
fun newUnitIcon(unit: MapUnit?, oldUnitGroup: UnitGroup?, isViewable: Boolean, yFromCenter: Float, viewingCiv: CivilizationInfo?): UnitGroup? {
|
||||||
var newImage: UnitGroup? = null
|
var newImage: UnitGroup? = null
|
||||||
// The unit can change within one update - for instance, when attacking, the attacker replaces the defender!
|
// The unit can change within one update - for instance, when attacking, the attacker replaces the defender!
|
||||||
oldUnitGroup?.remove()
|
oldUnitGroup?.remove()
|
||||||
|
@ -77,7 +83,7 @@ class TileGroupIcons(val tileGroup: TileGroup){
|
||||||
|
|
||||||
// Instead of fading out the entire unit with its background, we just fade out its central icon,
|
// Instead of fading out the entire unit with its background, we just fade out its central icon,
|
||||||
// that way it remains much more visible on the map
|
// that way it remains much more visible on the map
|
||||||
if (!unit.isIdle() && unit.civInfo == UncivGame.Current.worldScreen.viewingCiv)
|
if (!unit.isIdle() && unit.civInfo == viewingCiv)
|
||||||
newImage.unitBaseImage.color.a = 0.5f
|
newImage.unitBaseImage.color.a = 0.5f
|
||||||
}
|
}
|
||||||
return newImage
|
return newImage
|
||||||
|
@ -104,7 +110,7 @@ class TileGroupIcons(val tileGroup: TileGroup){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateResourceIcon(showResourcesAndImprovements: Boolean) {
|
fun updateResourceIcon(showResourcesAndImprovements: Boolean, viewingCiv: CivilizationInfo?) {
|
||||||
if (tileGroup.resource != tileGroup.tileInfo.resource) {
|
if (tileGroup.resource != tileGroup.tileInfo.resource) {
|
||||||
tileGroup.resource = tileGroup.tileInfo.resource
|
tileGroup.resource = tileGroup.tileInfo.resource
|
||||||
tileGroup.resourceImage?.remove()
|
tileGroup.resourceImage?.remove()
|
||||||
|
@ -121,9 +127,12 @@ class TileGroupIcons(val tileGroup: TileGroup){
|
||||||
|
|
||||||
if (tileGroup.resourceImage != null) { // This could happen on any turn, since resources need certain techs to reveal them
|
if (tileGroup.resourceImage != null) { // This could happen on any turn, since resources need certain techs to reveal them
|
||||||
val shouldDisplayResource =
|
val shouldDisplayResource =
|
||||||
if (tileGroup.showEntireMap) tileGroup.tileInfo.resource != null
|
when {
|
||||||
else showResourcesAndImprovements
|
viewingCiv == null -> false
|
||||||
&& tileGroup.tileInfo.hasViewableResource(UncivGame.Current.worldScreen.viewingCiv)
|
tileGroup.showEntireMap -> tileGroup.tileInfo.resource != null
|
||||||
|
else -> showResourcesAndImprovements
|
||||||
|
&& tileGroup.tileInfo.hasViewableResource(viewingCiv)
|
||||||
|
}
|
||||||
tileGroup.resourceImage!!.isVisible = shouldDisplayResource
|
tileGroup.resourceImage!!.isVisible = shouldDisplayResource
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,25 +7,36 @@ import com.badlogic.gdx.scenes.scene2d.InputListener
|
||||||
import com.badlogic.gdx.scenes.scene2d.Touchable
|
import com.badlogic.gdx.scenes.scene2d.Touchable
|
||||||
import com.badlogic.gdx.scenes.scene2d.actions.Actions
|
import com.badlogic.gdx.scenes.scene2d.actions.Actions
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Button
|
import com.badlogic.gdx.scenes.scene2d.ui.Button
|
||||||
|
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.badlogic.gdx.utils.Align
|
import com.badlogic.gdx.utils.Align
|
||||||
import com.unciv.Constants
|
import com.unciv.Constants
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
|
import com.unciv.logic.GameInfo
|
||||||
import com.unciv.logic.GameSaver
|
import com.unciv.logic.GameSaver
|
||||||
import com.unciv.logic.civilization.CivilizationInfo
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
|
import com.unciv.logic.civilization.PlayerType
|
||||||
import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
|
import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
|
||||||
|
import com.unciv.logic.map.MapGenerator
|
||||||
|
import com.unciv.logic.map.MapParameters
|
||||||
|
import com.unciv.logic.map.MapUnit
|
||||||
|
import com.unciv.logic.map.TileInfo
|
||||||
import com.unciv.models.Tutorial
|
import com.unciv.models.Tutorial
|
||||||
import com.unciv.models.UncivSound
|
import com.unciv.models.UncivSound
|
||||||
|
import com.unciv.models.ruleset.RulesetCache
|
||||||
import com.unciv.models.ruleset.tile.ResourceType
|
import com.unciv.models.ruleset.tile.ResourceType
|
||||||
import com.unciv.models.ruleset.unit.UnitType
|
import com.unciv.models.ruleset.unit.UnitType
|
||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
import com.unciv.ui.VictoryScreen
|
import com.unciv.ui.VictoryScreen
|
||||||
import com.unciv.ui.cityscreen.CityScreen
|
import com.unciv.ui.cityscreen.CityScreen
|
||||||
|
import com.unciv.ui.map.TileGroupMap
|
||||||
import com.unciv.ui.pickerscreens.GreatPersonPickerScreen
|
import com.unciv.ui.pickerscreens.GreatPersonPickerScreen
|
||||||
import com.unciv.ui.pickerscreens.PolicyPickerScreen
|
import com.unciv.ui.pickerscreens.PolicyPickerScreen
|
||||||
import com.unciv.ui.pickerscreens.TechButton
|
import com.unciv.ui.pickerscreens.TechButton
|
||||||
import com.unciv.ui.pickerscreens.TechPickerScreen
|
import com.unciv.ui.pickerscreens.TechPickerScreen
|
||||||
|
import com.unciv.ui.tilegroups.TileGroup
|
||||||
|
import com.unciv.ui.tilegroups.TileSetStrings
|
||||||
import com.unciv.ui.trade.DiplomacyScreen
|
import com.unciv.ui.trade.DiplomacyScreen
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
import com.unciv.ui.worldscreen.bottombar.BattleTable
|
import com.unciv.ui.worldscreen.bottombar.BattleTable
|
||||||
|
@ -45,7 +56,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||||
|
|
||||||
private val topBar = WorldScreenTopBar(this)
|
private val topBar = WorldScreenTopBar(this)
|
||||||
val bottomUnitTable = UnitTable(this)
|
val bottomUnitTable = UnitTable(this)
|
||||||
val bottomTileInfoTable = TileInfoTable(this)
|
val bottomTileInfoTable = TileInfoTable(viewingCiv)
|
||||||
val battleTable = BattleTable(this)
|
val battleTable = BattleTable(this)
|
||||||
val unitActionsTable = UnitActionsTable(this)
|
val unitActionsTable = UnitActionsTable(this)
|
||||||
|
|
||||||
|
@ -531,3 +542,68 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class TotemWorldScreen : CameraStageBaseScreen(){
|
||||||
|
val tileMap = MapGenerator().generateMap(MapParameters(),RulesetCache.getBaseRuleset())
|
||||||
|
val tileSetStrings = TileSetStrings()
|
||||||
|
val tileMapHolder = TileGroupMap(tileMap.values.map { TileGroup(it,tileSetStrings) },500f)
|
||||||
|
val newCiv = CivilizationInfo("Babylon")
|
||||||
|
var selectedUnit : MapUnit? = null
|
||||||
|
val gameInfo = GameInfo()
|
||||||
|
val tileInfoTable = TileInfoTable(newCiv)
|
||||||
|
var selectedTile: TileInfo?=null
|
||||||
|
|
||||||
|
init{
|
||||||
|
newCiv.playerType=PlayerType.Human
|
||||||
|
gameInfo.tileMap = tileMap
|
||||||
|
gameInfo.civilizations.add(newCiv)
|
||||||
|
gameInfo.setTransients()
|
||||||
|
ImageGetter.ruleset = RulesetCache.getBaseRuleset()
|
||||||
|
val scrollPane = ScrollPane(tileMapHolder)
|
||||||
|
for(tileGroup in tileMapHolder.tileGroups)
|
||||||
|
tileGroup.onClick {
|
||||||
|
val tileInfo = tileGroup.tileInfo
|
||||||
|
selectedTile=tileInfo
|
||||||
|
if(tileInfo.civilianUnit!=null){
|
||||||
|
selectedUnit = tileInfo.civilianUnit
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(selectedUnit!=null
|
||||||
|
&& selectedUnit!!.movement.getDistanceToTiles().containsKey(tileInfo)
|
||||||
|
&& selectedUnit!!.movement.canMoveTo(tileInfo)){
|
||||||
|
selectedUnit!!.movement.moveToTile(tileInfo)
|
||||||
|
}
|
||||||
|
update()
|
||||||
|
}
|
||||||
|
scrollPane.setSize(stage.width,stage.height)
|
||||||
|
scrollPane.center(stage)
|
||||||
|
scrollPane.scrollPercentX=0.5f
|
||||||
|
scrollPane.scrollPercentY=0.5f
|
||||||
|
stage.addActor(scrollPane)
|
||||||
|
newCiv.placeUnitNearTile(Vector2.Zero, Constants.worker)
|
||||||
|
update()
|
||||||
|
|
||||||
|
stage.addActor(tileInfoTable)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun update() {
|
||||||
|
if(newCiv.getIdleUnits().none()) gameInfo.nextTurn()
|
||||||
|
for (tileGroup in tileMapHolder.tileGroups) {
|
||||||
|
tileGroup.update(newCiv)
|
||||||
|
tileGroup.hideCircle()
|
||||||
|
if (tileGroup.tileInfo.civilianUnit == selectedUnit) {
|
||||||
|
tileGroup.icons.civilianUnitIcon?.selectUnit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(selectedUnit!=null) {
|
||||||
|
for (tile in selectedUnit!!.movement.getDistanceToTiles().keys){
|
||||||
|
val tileGroup = tileMapHolder.tileGroups.first{it.tileInfo==tile}
|
||||||
|
tileGroup.showCircle(Color.WHITE)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(selectedTile!=null) tileInfoTable.updateTileTable(selectedTile!!)
|
||||||
|
tileInfoTable.setPosition(stage.width,0f,Align.bottomRight)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,24 +4,23 @@ import com.badlogic.gdx.graphics.Color
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.badlogic.gdx.utils.Align
|
import com.badlogic.gdx.utils.Align
|
||||||
import com.unciv.UncivGame
|
import com.unciv.UncivGame
|
||||||
|
import com.unciv.logic.civilization.CivilizationInfo
|
||||||
import com.unciv.logic.map.TileInfo
|
import com.unciv.logic.map.TileInfo
|
||||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||||
import com.unciv.ui.utils.ImageGetter
|
import com.unciv.ui.utils.ImageGetter
|
||||||
import com.unciv.ui.utils.toLabel
|
import com.unciv.ui.utils.toLabel
|
||||||
import com.unciv.ui.worldscreen.WorldScreen
|
|
||||||
|
|
||||||
class TileInfoTable(private val worldScreen: WorldScreen) : Table(CameraStageBaseScreen.skin) {
|
class TileInfoTable(private val viewingCiv :CivilizationInfo) : Table(CameraStageBaseScreen.skin) {
|
||||||
init {
|
init {
|
||||||
background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
|
background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun updateTileTable(tile: TileInfo) {
|
internal fun updateTileTable(tile: TileInfo) {
|
||||||
clearChildren()
|
clearChildren()
|
||||||
val civInfo = worldScreen.viewingCiv
|
|
||||||
|
|
||||||
if (UncivGame.Current.viewEntireMapForDebug || civInfo.exploredTiles.contains(tile.position)) {
|
if (UncivGame.Current.viewEntireMapForDebug || viewingCiv.exploredTiles.contains(tile.position)) {
|
||||||
add(getStatsTable(tile))
|
add(getStatsTable(tile))
|
||||||
add(tile.toString().toLabel()).colspan(2).pad(10f)
|
add(tile.toString(viewingCiv).toLabel()).colspan(2).pad(10f)
|
||||||
}
|
}
|
||||||
|
|
||||||
pack()
|
pack()
|
||||||
|
@ -31,7 +30,7 @@ class TileInfoTable(private val worldScreen: WorldScreen) : Table(CameraStageBas
|
||||||
val table = Table()
|
val table = Table()
|
||||||
table.defaults().pad(2f)
|
table.defaults().pad(2f)
|
||||||
|
|
||||||
for (entry in tile.getTileStats(worldScreen.viewingCiv).toHashMap()
|
for (entry in tile.getTileStats(viewingCiv).toHashMap()
|
||||||
.filterNot { it.value == 0f || it.key.toString() == "" }) {
|
.filterNot { it.value == 0f || it.key.toString() == "" }) {
|
||||||
table.add(ImageGetter.getStatIcon(entry.key.toString())).size(20f).align(Align.right)
|
table.add(ImageGetter.getStatIcon(entry.key.toString())).size(20f).align(Align.right)
|
||||||
table.add(entry.value.toInt().toString().toLabel()).align(Align.left).padRight(10f)
|
table.add(entry.value.toInt().toString().toLabel()).align(Align.left).padRight(10f)
|
||||||
|
|
Loading…
Reference in a new issue