mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-28 21:58:54 +07:00
Code cleanup
This commit is contained in:
@ -158,23 +158,4 @@ class WorkerAutomation(val unit: MapUnit) {
|
||||
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,
|
||||
/** Their offers are what they offer us, and our offers are what they want in return */
|
||||
val trade: Trade){
|
||||
}
|
||||
val trade: Trade)
|
||||
|
||||
class CivilizationInfo {
|
||||
@Transient lateinit var gameInfo: GameInfo
|
||||
|
@ -21,7 +21,7 @@ class CivilopediaScreen : CameraStageBaseScreen() {
|
||||
val buttonTable = Table()
|
||||
buttonTable.pad(15f)
|
||||
val entryTable = Table()
|
||||
val splitPane = SplitPane(buttonTable, entryTable, true, CameraStageBaseScreen.skin)
|
||||
val splitPane = SplitPane(buttonTable, entryTable, true, skin)
|
||||
splitPane.splitAmount = 0.2f
|
||||
splitPane.setFillParent(true)
|
||||
|
||||
@ -30,7 +30,7 @@ class CivilopediaScreen : CameraStageBaseScreen() {
|
||||
val label = "".toLabel()
|
||||
label.setWrap(true)
|
||||
|
||||
val goToGameButton = TextButton("Close".tr(), CameraStageBaseScreen.skin)
|
||||
val goToGameButton = TextButton("Close".tr(), skin)
|
||||
goToGameButton.onClick {
|
||||
game.setWorldScreen()
|
||||
dispose()
|
||||
@ -51,7 +51,7 @@ class CivilopediaScreen : CameraStageBaseScreen() {
|
||||
categoryToInfos["Units"] = GameBasics.Units.values
|
||||
categoryToInfos["Technologies"] = GameBasics.Technologies.values
|
||||
|
||||
val nameList = List<ICivilopedia>(CameraStageBaseScreen.skin)
|
||||
val nameList = List<ICivilopedia>(skin)
|
||||
|
||||
val nameListClickListener = {
|
||||
if(nameList.selected!=null) label.setText(nameList.selected.description)
|
||||
@ -64,7 +64,7 @@ class CivilopediaScreen : CameraStageBaseScreen() {
|
||||
val buttons = ArrayList<Button>()
|
||||
var first = true
|
||||
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.checkedFontColor = Color.BLACK
|
||||
buttons.add(button)
|
||||
|
@ -175,8 +175,8 @@ class EmpireOverviewScreen : CameraStageBaseScreen(){
|
||||
greatPeopleTable.add(greatPersonPoints[entry.key]!!.toInt().toString()+"/"+pointsToGreatPerson)
|
||||
greatPeopleTable.add(greatPersonPointsPerTurn[entry.key]!!.toInt().toString()).row()
|
||||
}
|
||||
val pointsForGreatGeneral = currentPlayerCivInfo.greatPeople.greatGeneralPoints.toInt().toString()
|
||||
val pointsForNextGreatGeneral = currentPlayerCivInfo.greatPeople.pointsForNextGreatGeneral.toInt().toString()
|
||||
val pointsForGreatGeneral = currentPlayerCivInfo.greatPeople.greatGeneralPoints.toString()
|
||||
val pointsForNextGreatGeneral = currentPlayerCivInfo.greatPeople.pointsForNextGreatGeneral.toString()
|
||||
greatPeopleTable.add("Great General".tr())
|
||||
greatPeopleTable.add("$pointsForGreatGeneral/$pointsForNextGreatGeneral").row()
|
||||
greatPeopleTable.pack()
|
||||
|
@ -101,7 +101,7 @@ class LanguagePickerScreen: PickerScreen(){
|
||||
fun pickLanguage(){
|
||||
UnCivGame.Current.settings.language = chosenLanguage
|
||||
UnCivGame.Current.settings.save()
|
||||
CameraStageBaseScreen.resetFonts()
|
||||
resetFonts()
|
||||
UnCivGame.Current.startNewGame()
|
||||
dispose()
|
||||
}
|
||||
|
@ -28,13 +28,12 @@ class CityScreenTileTable(val city: CityInfo): Table(){
|
||||
return
|
||||
}
|
||||
isVisible=true
|
||||
val tile = selectedTile
|
||||
innerTable.clearChildren()
|
||||
|
||||
val stats = tile.getTileStats(city, city.civInfo)
|
||||
val stats = selectedTile.getTileStats(city, city.civInfo)
|
||||
innerTable.pad(20f)
|
||||
|
||||
innerTable.add(Label(tile.toString(), CameraStageBaseScreen.skin)).colspan(2)
|
||||
innerTable.add(Label(selectedTile.toString(), CameraStageBaseScreen.skin)).colspan(2)
|
||||
innerTable.row()
|
||||
|
||||
val statsTable = Table()
|
||||
@ -46,16 +45,16 @@ class CityScreenTileTable(val city: CityInfo): Table(){
|
||||
}
|
||||
innerTable.add(statsTable).row()
|
||||
|
||||
if(tile.getOwner()==null && tile.neighbors.any{it.getCity()==city}){
|
||||
val goldCostOfTile = city.expansion.getGoldCostOfTile(tile)
|
||||
if(selectedTile.getOwner()==null && selectedTile.neighbors.any{it.getCity()==city}){
|
||||
val goldCostOfTile = city.expansion.getGoldCostOfTile(selectedTile)
|
||||
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()
|
||||
innerTable.add(buyTileButton)
|
||||
}
|
||||
if(city.canAcquireTile(tile)){
|
||||
if(city.canAcquireTile(selectedTile)){
|
||||
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.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.TileResource
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.ui.pickerscreens.PickerScreen
|
||||
import com.unciv.ui.tilegroups.TileGroup
|
||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
@ -198,10 +197,4 @@ class MapEditorScreen(): CameraStageBaseScreen(){
|
||||
scrollTable.setPosition(0f, stage.height - scrollTable.height)
|
||||
return scrollTable
|
||||
}
|
||||
}
|
||||
|
||||
class NewMapScreen:PickerScreen(){
|
||||
init{
|
||||
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ import com.unciv.ui.utils.*
|
||||
|
||||
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 rightSideGroup = VerticalGroup()
|
||||
protected var rightSideButton: TextButton
|
||||
@ -24,7 +24,7 @@ open class PickerScreen : CameraStageBaseScreen() {
|
||||
val labelScroll = ScrollPane(descriptionLabel)
|
||||
bottomTable.add(labelScroll).pad(5f).width(stage.width / 2)
|
||||
|
||||
rightSideButton = TextButton("", CameraStageBaseScreen.skin)
|
||||
rightSideButton = TextButton("", skin)
|
||||
rightSideButton.disable()
|
||||
rightSideGroup.addActor(rightSideButton)
|
||||
|
||||
@ -37,7 +37,7 @@ open class PickerScreen : CameraStageBaseScreen() {
|
||||
|
||||
scrollPane.setSize(stage.width, stage.height * screenSplit)
|
||||
|
||||
splitPane = SplitPane(scrollPane, bottomTable, true, CameraStageBaseScreen.skin)
|
||||
splitPane = SplitPane(scrollPane, bottomTable, true, skin)
|
||||
splitPane.splitAmount = screenSplit
|
||||
splitPane.setFillParent(true)
|
||||
stage.addActor(splitPane)
|
||||
|
@ -93,12 +93,12 @@ class PolicyPickerScreen(internal val civInfo: CivilizationInfo) : PickerScreen(
|
||||
}
|
||||
|
||||
private fun getPolicyButton(policy: Policy, image: Boolean): Button {
|
||||
var policyButton = Button(CameraStageBaseScreen.skin)
|
||||
var policyButton = Button(skin)
|
||||
if (image) {
|
||||
val policyImage = ImageGetter.getImage("PolicyIcons/" + policy.name)
|
||||
policyButton.add(policyImage).size(30f)
|
||||
} else {
|
||||
policyButton = TextButton(policy.name.tr(), CameraStageBaseScreen.skin)
|
||||
policyButton = TextButton(policy.name.tr(), skin)
|
||||
}
|
||||
|
||||
if (civInfo.policies.isAdopted(policy.name)) { // existing
|
||||
|
@ -22,7 +22,7 @@ class LoadScreen : PickerScreen() {
|
||||
setDefaultCloseAction()
|
||||
val saveTable = Table()
|
||||
|
||||
val deleteSaveButton = TextButton("Delete save".tr(), CameraStageBaseScreen.skin)
|
||||
val deleteSaveButton = TextButton("Delete save".tr(), skin)
|
||||
deleteSaveButton .onClick {
|
||||
GameSaver().deleteSave(selectedSave)
|
||||
UnCivGame.Current.screen = LoadScreen()
|
||||
|
@ -62,7 +62,7 @@ object ImageGetter {
|
||||
}
|
||||
|
||||
fun getStatIcon(statName: String): Image {
|
||||
return ImageGetter.getImage("StatIcons/$statName")
|
||||
return getImage("StatIcons/$statName")
|
||||
.apply { setSize(20f,20f)}
|
||||
}
|
||||
|
||||
@ -152,13 +152,13 @@ object ImageGetter {
|
||||
fun getHealthBar(currentHealth: Float, maxHealth: Float, healthBarSize: Float): Table {
|
||||
val healthPercent = currentHealth / maxHealth
|
||||
val healthBar = Table()
|
||||
val healthPartOfBar = ImageGetter.getWhiteDot()
|
||||
val healthPartOfBar = getWhiteDot()
|
||||
healthPartOfBar.color = when {
|
||||
healthPercent > 2 / 3f -> Color.GREEN
|
||||
healthPercent > 1 / 3f -> Color.ORANGE
|
||||
else -> Color.RED
|
||||
}
|
||||
val emptyPartOfBar = ImageGetter.getDot(Color.BLACK)
|
||||
val emptyPartOfBar = getDot(Color.BLACK)
|
||||
healthBar.add(healthPartOfBar).width(healthBarSize * healthPercent).height(5f)
|
||||
healthBar.add(emptyPartOfBar).width(healthBarSize * (1 - healthPercent)).height(5f)
|
||||
healthBar.pack()
|
||||
|
@ -9,7 +9,7 @@ object Sounds{
|
||||
|
||||
fun get(name:String):Sound{
|
||||
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]!!
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,6 @@ import kotlin.math.ceil
|
||||
|
||||
class WorldScreenTopBar(val screen: WorldScreen) : Table() {
|
||||
|
||||
val labelSkin = CameraStageBaseScreen.skin
|
||||
|
||||
private val turnsLabel = "Turns: 0/400".toLabel().setFontColor(Color.WHITE)
|
||||
private val goldLabel = "Gold:".toLabel().setFontColor(colorFromRGB(225, 217, 71) )
|
||||
private val scienceLabel = "Science:".toLabel().setFontColor(colorFromRGB(78, 140, 151) )
|
||||
|
Reference in New Issue
Block a user