1. In PickTechScreen all the Techs have the same size. 2.The tech in different era has different color. 3.About global status in victory status screen, you can touch the icons of Civs to check its policy tree and tech tree, but close button may lead to worldscreen (#1096)

This commit is contained in:
lishaoxia1985 2019-09-24 22:09:19 +08:00 committed by Yair Morgenstern
parent 27b8cd5f1b
commit f6009c43ca
6 changed files with 63 additions and 23 deletions

View File

@ -42,7 +42,7 @@ data class LocationAction(var locations: ArrayList<Vector2> = ArrayList()) : Not
class TechAction(val techName: String = "") : NotificationAction { class TechAction(val techName: String = "") : NotificationAction {
override fun execute(worldScreen: WorldScreen) { override fun execute(worldScreen: WorldScreen) {
val tech = GameBasics.Technologies[techName] val tech = GameBasics.Technologies[techName]
worldScreen.game.screen = TechPickerScreen(worldScreen.viewingCiv, tech) worldScreen.game.screen = TechPickerScreen(worldScreen.viewingCiv, true, tech)
} }
} }

View File

@ -1,6 +1,7 @@
package com.unciv.ui package com.unciv.ui
import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.scenes.scene2d.Touchable
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.unciv.UnCivGame import com.unciv.UnCivGame
@ -10,10 +11,10 @@ import com.unciv.models.gamebasics.VictoryType
import com.unciv.models.gamebasics.tr import com.unciv.models.gamebasics.tr
import com.unciv.ui.newgamescreen.NewGameScreen import com.unciv.ui.newgamescreen.NewGameScreen
import com.unciv.ui.pickerscreens.PickerScreen import com.unciv.ui.pickerscreens.PickerScreen
import com.unciv.ui.utils.addSeparator import com.unciv.ui.pickerscreens.PolicyPickerScreen
import com.unciv.ui.utils.enable import com.unciv.ui.pickerscreens.TechPickerScreen
import com.unciv.ui.utils.onClick import com.unciv.ui.utils.*
import com.unciv.ui.utils.toLabel import com.unciv.ui.worldscreen.WorldScreen
class VictoryScreen : PickerScreen() { class VictoryScreen : PickerScreen() {
@ -199,7 +200,13 @@ class VictoryScreen : PickerScreen() {
.sortedByDescending { it.branchesCompleted } .sortedByDescending { it.branchesCompleted }
for (entry in civsToBranchesCompleted) { for (entry in civsToBranchesCompleted) {
policyVictoryColumn.add(EmpireOverviewScreen.getCivGroup(entry.civ, " - " + entry.branchesCompleted, playerCivInfo)).row() val civToBranchesHaveCompleted=EmpireOverviewScreen.getCivGroup(entry.civ, " - " + entry.branchesCompleted, playerCivInfo)
policyVictoryColumn.add(civToBranchesHaveCompleted).row()
civToBranchesHaveCompleted.touchable= Touchable.enabled
civToBranchesHaveCompleted.onClick {
game.screen = PolicyPickerScreen(UnCivGame.Current.worldScreen,entry.civ, false)
dispose()
}
} }
return policyVictoryColumn return policyVictoryColumn
} }
@ -217,7 +224,13 @@ class VictoryScreen : PickerScreen() {
} }
for (entry in civsToPartsRemaining) { for (entry in civsToPartsRemaining) {
scientificVictoryColumn.add(EmpireOverviewScreen.getCivGroup(entry.civ, " - " + entry.partsRemaining, playerCivInfo)).row() val civToPartsBeRemaining=(EmpireOverviewScreen.getCivGroup(entry.civ, " - " + entry.partsRemaining, playerCivInfo))
scientificVictoryColumn.add(civToPartsBeRemaining).row()
civToPartsBeRemaining.touchable= Touchable.enabled
civToPartsBeRemaining.onClick {
game.screen = TechPickerScreen(entry.civ, false)
dispose()
}
} }
return scientificVictoryColumn return scientificVictoryColumn
} }

View File

@ -13,8 +13,8 @@ import com.unciv.ui.utils.*
import com.unciv.ui.worldscreen.WorldScreen import com.unciv.ui.worldscreen.WorldScreen
class PolicyPickerScreen(val worldScreen: WorldScreen) : PickerScreen() { class PolicyPickerScreen(val worldScreen: WorldScreen, civInfo: CivilizationInfo = worldScreen.viewingCiv, switchfromWorldScreen: Boolean = true) : PickerScreen() {
internal val viewingCiv: CivilizationInfo = worldScreen.viewingCiv internal val viewingCiv: CivilizationInfo = civInfo
private var pickedPolicy: Policy? = null private var pickedPolicy: Policy? = null
init { init {
@ -42,6 +42,12 @@ class PolicyPickerScreen(val worldScreen: WorldScreen) : PickerScreen() {
} }
if(!UnCivGame.Current.worldScreen.isPlayersTurn) if(!UnCivGame.Current.worldScreen.isPlayersTurn)
rightSideButton.disable() rightSideButton.disable()
if (!switchfromWorldScreen){
rightSideButton.apply {
disable()
setText("Policy Tree Of [${viewingCiv.civName}]".tr())
}
}
topTable.row().pad(30f) topTable.row().pad(30f)

View File

@ -7,12 +7,10 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.utils.Align import com.badlogic.gdx.utils.Align
import com.unciv.logic.civilization.TechManager import com.unciv.logic.civilization.TechManager
import com.unciv.models.gamebasics.GameBasics import com.unciv.models.gamebasics.GameBasics
import com.unciv.ui.utils.CameraStageBaseScreen import com.unciv.ui.utils.*
import com.unciv.ui.utils.ImageGetter import com.unciv.ui.worldscreen.WorldScreen
import com.unciv.ui.utils.setFontColor
import com.unciv.ui.utils.surroundWithCircle
class TechButton(techName:String, val techManager: TechManager) : Table(CameraStageBaseScreen.skin) { class TechButton(techName:String, val techManager: TechManager, isWorldScreen: Boolean = true) : Table(CameraStageBaseScreen.skin) {
val text= Label("", skin).setFontColor(Color.WHITE).apply { setAlignment(Align.center) } val text= Label("", skin).setFontColor(Color.WHITE).apply { setAlignment(Align.center) }
init { init {
touchable = Touchable.enabled touchable = Touchable.enabled
@ -28,7 +26,10 @@ class TechButton(techName:String, val techManager: TechManager) : Table(CameraSt
val percentComplete = (techCost-remainingTech)/techCost.toFloat() val percentComplete = (techCost-remainingTech)/techCost.toFloat()
add(ImageGetter.getProgressBarVertical(2f, 50f, percentComplete, Color.BLUE, Color.WHITE)) add(ImageGetter.getProgressBarVertical(2f, 50f, percentComplete, Color.BLUE, Color.WHITE))
} }
rightSide.add(text).row() else add().width(2f)
if (isWorldScreen) rightSide.add(text).row()
else rightSide.add(text).height(25f).row()
// here we add little images of what the tech gives you // here we add little images of what the tech gives you
val techEnabledIcons = Table() val techEnabledIcons = Table()
@ -66,7 +67,8 @@ class TechButton(techName:String, val techManager: TechManager) : Table(CameraSt
techEnabledIcons.add(ImageGetter.getImage("OtherIcons/Star") techEnabledIcons.add(ImageGetter.getImage("OtherIcons/Star")
.apply { color= Color.BLACK }.surroundWithCircle(30f)) .apply { color= Color.BLACK }.surroundWithCircle(30f))
rightSide.add(techEnabledIcons) if (isWorldScreen) rightSide.add(techEnabledIcons)
else rightSide.add(techEnabledIcons).width(150f)
add(rightSide) add(rightSide)
pack() pack()

View File

@ -16,7 +16,7 @@ import java.util.*
import kotlin.collections.HashSet import kotlin.collections.HashSet
class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Technology? = null) : PickerScreen() { class TechPickerScreen(internal val civInfo: CivilizationInfo, switchfromWorldScreen: Boolean = true, centerOnTech: Technology? = null) : PickerScreen() {
private var techNameToButton = HashMap<String, TechButton>() private var techNameToButton = HashMap<String, TechButton>()
private var isFreeTechPick: Boolean = false private var isFreeTechPick: Boolean = false
@ -69,7 +69,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
topTable.add() // empty cell topTable.add() // empty cell
else { else {
val techButton = TechButton(tech.name,civTech) val techButton = TechButton(tech.name,civTech,false)
techNameToButton[tech.name] = techButton techNameToButton[tech.name] = techButton
techButton.onClick { selectTechnology(tech) } techButton.onClick { selectTechnology(tech) }
@ -93,8 +93,13 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
} }
setButtonsInfo() setButtonsInfo()
if (!switchfromWorldScreen){
rightSideButton.setText("Pick a tech".tr()) rightSideButton.apply {
disable()
setText("Tech Tree Of [${civInfo.civName}]".tr())
}
}
else rightSideButton.setText("Pick a tech".tr())
rightSideButton.onClick("paper") { rightSideButton.onClick("paper") {
if (isFreeTechPick) civTech.getFreeTechnology(selectedTech!!.name) if (isFreeTechPick) civTech.getFreeTechnology(selectedTech!!.name)
else civTech.techsToResearch = tempTechsToResearch else civTech.techsToResearch = tempTechsToResearch
@ -110,7 +115,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
// and possibly select it to show description, // and possibly select it to show description,
// which is very helpful when just discovered and clicking the notification // which is very helpful when just discovered and clicking the notification
val tech = if (centerOnTech != null) centerOnTech else civInfo.tech.currentTechnology() val tech = if (centerOnTech != null) centerOnTech else civInfo.tech.currentTechnology()
if (tech != null) { if (tech != null && switchfromWorldScreen) {
// select only if there it doesn't mess up tempTechsToResearch // select only if there it doesn't mess up tempTechsToResearch
if (civInfo.tech.isResearched(tech.name) || civInfo.tech.techsToResearch.size <= 1) if (civInfo.tech.isResearched(tech.name) || civInfo.tech.techsToResearch.size <= 1)
selectTechnology(tech, true) selectTechnology(tech, true)
@ -148,11 +153,14 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
} }
} }
private fun selectTechnology(tech: Technology?, center: Boolean = false) { private fun selectTechnology(tech: Technology?, center: Boolean = false, switchfromWorldScreen: Boolean = true) {
selectedTech = tech selectedTech = tech
descriptionLabel.setText(tech?.description) descriptionLabel.setText(tech?.description)
if (!switchfromWorldScreen)
return
if(tech==null) if(tech==null)
return return

View File

@ -185,7 +185,18 @@ object ImageGetter {
} }
fun getTechIconGroup(techName: String): Group { fun getTechIconGroup(techName: String): Group {
return getImage("TechIcons/$techName").surroundWithCircle(60f) var TechIconColor = Color.WHITE
when(GameBasics.Technologies[techName]!!.era().name){
"Ancient"-> TechIconColor = Color.FIREBRICK
"Classical"-> TechIconColor = Color.VIOLET
"Medieval"-> TechIconColor = Color.TAN
"Renaissance"-> TechIconColor = Color.BROWN
"Industrial"-> TechIconColor = Color.CHARTREUSE
"Modern"-> TechIconColor = Color.GOLD
"Information"-> TechIconColor = Color.CORAL
"Future"-> TechIconColor = Color.CYAN
}
return getImage("TechIcons/$techName").surroundWithCircle(60f).apply{ this.circle.color = TechIconColor }
} }
fun getProgressBarVertical(width:Float,height:Float,percentComplete:Float,progressColor:Color,backgroundColor:Color): Table { fun getProgressBarVertical(width:Float,height:Float,percentComplete:Float,progressColor:Color,backgroundColor:Color): Table {