mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 06:16:37 -04:00
Code cleanup
This commit is contained in:
parent
931f485a8e
commit
68c2763ea7
@ -158,23 +158,4 @@ class WorkerAutomation(val unit: MapUnit) {
|
|||||||
return GameBasics.TileImprovements[improvementString]!!
|
return GameBasics.TileImprovements[improvementString]!!
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: is this neccesary? Worker automation does something else to build roads.
|
|
||||||
// Either generalize or delete
|
|
||||||
fun constructRoadTo(destination:TileInfo) {
|
|
||||||
val currentTile = unit.getTile()
|
|
||||||
if (currentTile.roadStatus == RoadStatus.None)
|
|
||||||
return currentTile.startWorkingOnImprovement(GameBasics.TileImprovements["Road"]!!, unit.civInfo)
|
|
||||||
|
|
||||||
val pathToDestination = unit.movementAlgs().getShortestPath(destination)
|
|
||||||
val destinationThisTurn = pathToDestination.first()
|
|
||||||
val fullPathToCurrentDestination = unit.movementAlgs().getFullPathToCloseTile(destinationThisTurn)
|
|
||||||
val firstTileWithoutRoad = fullPathToCurrentDestination.firstOrNull { it.roadStatus == RoadStatus.None && unit.canMoveTo(it) }
|
|
||||||
if (firstTileWithoutRoad == null)
|
|
||||||
return unit.moveToTile(destinationThisTurn)
|
|
||||||
|
|
||||||
unit.moveToTile(firstTileWithoutRoad)
|
|
||||||
if (unit.currentMovement > 0)
|
|
||||||
firstTileWithoutRoad.startWorkingOnImprovement(GameBasics.TileImprovements["Road"]!!, unit.civInfo)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -36,8 +36,7 @@ enum class PlayerType{
|
|||||||
|
|
||||||
class TradeRequest(val requestingCiv:String,
|
class TradeRequest(val requestingCiv:String,
|
||||||
/** Their offers are what they offer us, and our offers are what they want in return */
|
/** Their offers are what they offer us, and our offers are what they want in return */
|
||||||
val trade: Trade){
|
val trade: Trade)
|
||||||
}
|
|
||||||
|
|
||||||
class CivilizationInfo {
|
class CivilizationInfo {
|
||||||
@Transient lateinit var gameInfo: GameInfo
|
@Transient lateinit var gameInfo: GameInfo
|
||||||
|
@ -21,7 +21,7 @@ class CivilopediaScreen : CameraStageBaseScreen() {
|
|||||||
val buttonTable = Table()
|
val buttonTable = Table()
|
||||||
buttonTable.pad(15f)
|
buttonTable.pad(15f)
|
||||||
val entryTable = Table()
|
val entryTable = Table()
|
||||||
val splitPane = SplitPane(buttonTable, entryTable, true, CameraStageBaseScreen.skin)
|
val splitPane = SplitPane(buttonTable, entryTable, true, skin)
|
||||||
splitPane.splitAmount = 0.2f
|
splitPane.splitAmount = 0.2f
|
||||||
splitPane.setFillParent(true)
|
splitPane.setFillParent(true)
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ class CivilopediaScreen : CameraStageBaseScreen() {
|
|||||||
val label = "".toLabel()
|
val label = "".toLabel()
|
||||||
label.setWrap(true)
|
label.setWrap(true)
|
||||||
|
|
||||||
val goToGameButton = TextButton("Close".tr(), CameraStageBaseScreen.skin)
|
val goToGameButton = TextButton("Close".tr(), skin)
|
||||||
goToGameButton.onClick {
|
goToGameButton.onClick {
|
||||||
game.setWorldScreen()
|
game.setWorldScreen()
|
||||||
dispose()
|
dispose()
|
||||||
@ -51,7 +51,7 @@ class CivilopediaScreen : CameraStageBaseScreen() {
|
|||||||
categoryToInfos["Units"] = GameBasics.Units.values
|
categoryToInfos["Units"] = GameBasics.Units.values
|
||||||
categoryToInfos["Technologies"] = GameBasics.Technologies.values
|
categoryToInfos["Technologies"] = GameBasics.Technologies.values
|
||||||
|
|
||||||
val nameList = List<ICivilopedia>(CameraStageBaseScreen.skin)
|
val nameList = List<ICivilopedia>(skin)
|
||||||
|
|
||||||
val nameListClickListener = {
|
val nameListClickListener = {
|
||||||
if(nameList.selected!=null) label.setText(nameList.selected.description)
|
if(nameList.selected!=null) label.setText(nameList.selected.description)
|
||||||
@ -64,7 +64,7 @@ class CivilopediaScreen : CameraStageBaseScreen() {
|
|||||||
val buttons = ArrayList<Button>()
|
val buttons = ArrayList<Button>()
|
||||||
var first = true
|
var first = true
|
||||||
for (str in categoryToInfos.keys) {
|
for (str in categoryToInfos.keys) {
|
||||||
val button = TextButton(str.tr(), CameraStageBaseScreen.skin)
|
val button = TextButton(str.tr(), skin)
|
||||||
button.style = TextButton.TextButtonStyle(button.style)
|
button.style = TextButton.TextButtonStyle(button.style)
|
||||||
button.style.checkedFontColor = Color.BLACK
|
button.style.checkedFontColor = Color.BLACK
|
||||||
buttons.add(button)
|
buttons.add(button)
|
||||||
|
@ -175,8 +175,8 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
|||||||
greatPeopleTable.add(greatPersonPoints[entry.key]!!.toInt().toString()+"/"+pointsToGreatPerson)
|
greatPeopleTable.add(greatPersonPoints[entry.key]!!.toInt().toString()+"/"+pointsToGreatPerson)
|
||||||
greatPeopleTable.add(greatPersonPointsPerTurn[entry.key]!!.toInt().toString()).row()
|
greatPeopleTable.add(greatPersonPointsPerTurn[entry.key]!!.toInt().toString()).row()
|
||||||
}
|
}
|
||||||
val pointsForGreatGeneral = currentPlayerCivInfo.greatPeople.greatGeneralPoints.toInt().toString()
|
val pointsForGreatGeneral = currentPlayerCivInfo.greatPeople.greatGeneralPoints.toString()
|
||||||
val pointsForNextGreatGeneral = currentPlayerCivInfo.greatPeople.pointsForNextGreatGeneral.toInt().toString()
|
val pointsForNextGreatGeneral = currentPlayerCivInfo.greatPeople.pointsForNextGreatGeneral.toString()
|
||||||
greatPeopleTable.add("Great General".tr())
|
greatPeopleTable.add("Great General".tr())
|
||||||
greatPeopleTable.add("$pointsForGreatGeneral/$pointsForNextGreatGeneral").row()
|
greatPeopleTable.add("$pointsForGreatGeneral/$pointsForNextGreatGeneral").row()
|
||||||
greatPeopleTable.pack()
|
greatPeopleTable.pack()
|
||||||
|
@ -101,7 +101,7 @@ class LanguagePickerScreen: PickerScreen(){
|
|||||||
fun pickLanguage(){
|
fun pickLanguage(){
|
||||||
UnCivGame.Current.settings.language = chosenLanguage
|
UnCivGame.Current.settings.language = chosenLanguage
|
||||||
UnCivGame.Current.settings.save()
|
UnCivGame.Current.settings.save()
|
||||||
CameraStageBaseScreen.resetFonts()
|
resetFonts()
|
||||||
UnCivGame.Current.startNewGame()
|
UnCivGame.Current.startNewGame()
|
||||||
dispose()
|
dispose()
|
||||||
}
|
}
|
||||||
|
@ -28,13 +28,12 @@ class CityScreenTileTable(val city: CityInfo): Table(){
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
isVisible=true
|
isVisible=true
|
||||||
val tile = selectedTile
|
|
||||||
innerTable.clearChildren()
|
innerTable.clearChildren()
|
||||||
|
|
||||||
val stats = tile.getTileStats(city, city.civInfo)
|
val stats = selectedTile.getTileStats(city, city.civInfo)
|
||||||
innerTable.pad(20f)
|
innerTable.pad(20f)
|
||||||
|
|
||||||
innerTable.add(Label(tile.toString(), CameraStageBaseScreen.skin)).colspan(2)
|
innerTable.add(Label(selectedTile.toString(), CameraStageBaseScreen.skin)).colspan(2)
|
||||||
innerTable.row()
|
innerTable.row()
|
||||||
|
|
||||||
val statsTable = Table()
|
val statsTable = Table()
|
||||||
@ -46,16 +45,16 @@ class CityScreenTileTable(val city: CityInfo): Table(){
|
|||||||
}
|
}
|
||||||
innerTable.add(statsTable).row()
|
innerTable.add(statsTable).row()
|
||||||
|
|
||||||
if(tile.getOwner()==null && tile.neighbors.any{it.getCity()==city}){
|
if(selectedTile.getOwner()==null && selectedTile.neighbors.any{it.getCity()==city}){
|
||||||
val goldCostOfTile = city.expansion.getGoldCostOfTile(tile)
|
val goldCostOfTile = city.expansion.getGoldCostOfTile(selectedTile)
|
||||||
val buyTileButton = TextButton("Buy for [$goldCostOfTile] gold".tr(), CameraStageBaseScreen.skin)
|
val buyTileButton = TextButton("Buy for [$goldCostOfTile] gold".tr(), CameraStageBaseScreen.skin)
|
||||||
buyTileButton.onClick("coin") { city.expansion.buyTile(tile); UnCivGame.Current.screen = CityScreen(city) }
|
buyTileButton.onClick("coin") { city.expansion.buyTile(selectedTile); UnCivGame.Current.screen = CityScreen(city) }
|
||||||
if(goldCostOfTile>city.civInfo.gold) buyTileButton.disable()
|
if(goldCostOfTile>city.civInfo.gold) buyTileButton.disable()
|
||||||
innerTable.add(buyTileButton)
|
innerTable.add(buyTileButton)
|
||||||
}
|
}
|
||||||
if(city.canAcquireTile(tile)){
|
if(city.canAcquireTile(selectedTile)){
|
||||||
val acquireTileButton = TextButton("Acquire".tr(), CameraStageBaseScreen.skin)
|
val acquireTileButton = TextButton("Acquire".tr(), CameraStageBaseScreen.skin)
|
||||||
acquireTileButton.onClick { city.expansion.takeOwnership(tile); UnCivGame.Current.screen = CityScreen(city) }
|
acquireTileButton.onClick { city.expansion.takeOwnership(selectedTile); UnCivGame.Current.screen = CityScreen(city) }
|
||||||
innerTable.add(acquireTileButton)
|
innerTable.add(acquireTileButton)
|
||||||
}
|
}
|
||||||
innerTable.pack()
|
innerTable.pack()
|
||||||
|
@ -15,7 +15,6 @@ import com.unciv.models.gamebasics.tile.Terrain
|
|||||||
import com.unciv.models.gamebasics.tile.TerrainType
|
import com.unciv.models.gamebasics.tile.TerrainType
|
||||||
import com.unciv.models.gamebasics.tile.TileResource
|
import com.unciv.models.gamebasics.tile.TileResource
|
||||||
import com.unciv.models.gamebasics.tr
|
import com.unciv.models.gamebasics.tr
|
||||||
import com.unciv.ui.pickerscreens.PickerScreen
|
|
||||||
import com.unciv.ui.tilegroups.TileGroup
|
import com.unciv.ui.tilegroups.TileGroup
|
||||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||||
import com.unciv.ui.utils.ImageGetter
|
import com.unciv.ui.utils.ImageGetter
|
||||||
@ -198,10 +197,4 @@ class MapEditorScreen(): CameraStageBaseScreen(){
|
|||||||
scrollTable.setPosition(0f, stage.height - scrollTable.height)
|
scrollTable.setPosition(0f, stage.height - scrollTable.height)
|
||||||
return scrollTable
|
return scrollTable
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
class NewMapScreen:PickerScreen(){
|
|
||||||
init{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -7,7 +7,7 @@ import com.unciv.ui.utils.*
|
|||||||
|
|
||||||
open class PickerScreen : CameraStageBaseScreen() {
|
open class PickerScreen : CameraStageBaseScreen() {
|
||||||
|
|
||||||
internal var closeButton: TextButton = TextButton("Close".tr(), CameraStageBaseScreen.skin)
|
internal var closeButton: TextButton = TextButton("Close".tr(), skin)
|
||||||
protected var descriptionLabel: Label
|
protected var descriptionLabel: Label
|
||||||
protected var rightSideGroup = VerticalGroup()
|
protected var rightSideGroup = VerticalGroup()
|
||||||
protected var rightSideButton: TextButton
|
protected var rightSideButton: TextButton
|
||||||
@ -24,7 +24,7 @@ open class PickerScreen : CameraStageBaseScreen() {
|
|||||||
val labelScroll = ScrollPane(descriptionLabel)
|
val labelScroll = ScrollPane(descriptionLabel)
|
||||||
bottomTable.add(labelScroll).pad(5f).width(stage.width / 2)
|
bottomTable.add(labelScroll).pad(5f).width(stage.width / 2)
|
||||||
|
|
||||||
rightSideButton = TextButton("", CameraStageBaseScreen.skin)
|
rightSideButton = TextButton("", skin)
|
||||||
rightSideButton.disable()
|
rightSideButton.disable()
|
||||||
rightSideGroup.addActor(rightSideButton)
|
rightSideGroup.addActor(rightSideButton)
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ open class PickerScreen : CameraStageBaseScreen() {
|
|||||||
|
|
||||||
scrollPane.setSize(stage.width, stage.height * screenSplit)
|
scrollPane.setSize(stage.width, stage.height * screenSplit)
|
||||||
|
|
||||||
splitPane = SplitPane(scrollPane, bottomTable, true, CameraStageBaseScreen.skin)
|
splitPane = SplitPane(scrollPane, bottomTable, true, skin)
|
||||||
splitPane.splitAmount = screenSplit
|
splitPane.splitAmount = screenSplit
|
||||||
splitPane.setFillParent(true)
|
splitPane.setFillParent(true)
|
||||||
stage.addActor(splitPane)
|
stage.addActor(splitPane)
|
||||||
|
@ -93,12 +93,12 @@ class PolicyPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getPolicyButton(policy: Policy, image: Boolean): Button {
|
private fun getPolicyButton(policy: Policy, image: Boolean): Button {
|
||||||
var policyButton = Button(CameraStageBaseScreen.skin)
|
var policyButton = Button(skin)
|
||||||
if (image) {
|
if (image) {
|
||||||
val policyImage = ImageGetter.getImage("PolicyIcons/" + policy.name)
|
val policyImage = ImageGetter.getImage("PolicyIcons/" + policy.name)
|
||||||
policyButton.add(policyImage).size(30f)
|
policyButton.add(policyImage).size(30f)
|
||||||
} else {
|
} else {
|
||||||
policyButton = TextButton(policy.name.tr(), CameraStageBaseScreen.skin)
|
policyButton = TextButton(policy.name.tr(), skin)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (civInfo.policies.isAdopted(policy.name)) { // existing
|
if (civInfo.policies.isAdopted(policy.name)) { // existing
|
||||||
|
@ -22,7 +22,7 @@ class LoadScreen : PickerScreen() {
|
|||||||
setDefaultCloseAction()
|
setDefaultCloseAction()
|
||||||
val saveTable = Table()
|
val saveTable = Table()
|
||||||
|
|
||||||
val deleteSaveButton = TextButton("Delete save".tr(), CameraStageBaseScreen.skin)
|
val deleteSaveButton = TextButton("Delete save".tr(), skin)
|
||||||
deleteSaveButton .onClick {
|
deleteSaveButton .onClick {
|
||||||
GameSaver().deleteSave(selectedSave)
|
GameSaver().deleteSave(selectedSave)
|
||||||
UnCivGame.Current.screen = LoadScreen()
|
UnCivGame.Current.screen = LoadScreen()
|
||||||
|
@ -62,7 +62,7 @@ object ImageGetter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getStatIcon(statName: String): Image {
|
fun getStatIcon(statName: String): Image {
|
||||||
return ImageGetter.getImage("StatIcons/$statName")
|
return getImage("StatIcons/$statName")
|
||||||
.apply { setSize(20f,20f)}
|
.apply { setSize(20f,20f)}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,13 +152,13 @@ object ImageGetter {
|
|||||||
fun getHealthBar(currentHealth: Float, maxHealth: Float, healthBarSize: Float): Table {
|
fun getHealthBar(currentHealth: Float, maxHealth: Float, healthBarSize: Float): Table {
|
||||||
val healthPercent = currentHealth / maxHealth
|
val healthPercent = currentHealth / maxHealth
|
||||||
val healthBar = Table()
|
val healthBar = Table()
|
||||||
val healthPartOfBar = ImageGetter.getWhiteDot()
|
val healthPartOfBar = getWhiteDot()
|
||||||
healthPartOfBar.color = when {
|
healthPartOfBar.color = when {
|
||||||
healthPercent > 2 / 3f -> Color.GREEN
|
healthPercent > 2 / 3f -> Color.GREEN
|
||||||
healthPercent > 1 / 3f -> Color.ORANGE
|
healthPercent > 1 / 3f -> Color.ORANGE
|
||||||
else -> Color.RED
|
else -> Color.RED
|
||||||
}
|
}
|
||||||
val emptyPartOfBar = ImageGetter.getDot(Color.BLACK)
|
val emptyPartOfBar = getDot(Color.BLACK)
|
||||||
healthBar.add(healthPartOfBar).width(healthBarSize * healthPercent).height(5f)
|
healthBar.add(healthPartOfBar).width(healthBarSize * healthPercent).height(5f)
|
||||||
healthBar.add(emptyPartOfBar).width(healthBarSize * (1 - healthPercent)).height(5f)
|
healthBar.add(emptyPartOfBar).width(healthBarSize * (1 - healthPercent)).height(5f)
|
||||||
healthBar.pack()
|
healthBar.pack()
|
||||||
|
@ -9,7 +9,7 @@ object Sounds{
|
|||||||
|
|
||||||
fun get(name:String):Sound{
|
fun get(name:String):Sound{
|
||||||
if(!soundMap.containsKey(name))
|
if(!soundMap.containsKey(name))
|
||||||
soundMap[name] = Gdx.audio.newSound(Gdx.files.internal("sounds/$name.mp3"));
|
soundMap[name] = Gdx.audio.newSound(Gdx.files.internal("sounds/$name.mp3"))
|
||||||
return soundMap[name]!!
|
return soundMap[name]!!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,8 +21,6 @@ import kotlin.math.ceil
|
|||||||
|
|
||||||
class WorldScreenTopBar(val screen: WorldScreen) : Table() {
|
class WorldScreenTopBar(val screen: WorldScreen) : Table() {
|
||||||
|
|
||||||
val labelSkin = CameraStageBaseScreen.skin
|
|
||||||
|
|
||||||
private val turnsLabel = "Turns: 0/400".toLabel().setFontColor(Color.WHITE)
|
private val turnsLabel = "Turns: 0/400".toLabel().setFontColor(Color.WHITE)
|
||||||
private val goldLabel = "Gold:".toLabel().setFontColor(colorFromRGB(225, 217, 71) )
|
private val goldLabel = "Gold:".toLabel().setFontColor(colorFromRGB(225, 217, 71) )
|
||||||
private val scienceLabel = "Science:".toLabel().setFontColor(colorFromRGB(78, 140, 151) )
|
private val scienceLabel = "Science:".toLabel().setFontColor(colorFromRGB(78, 140, 151) )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user