Changed placement of notifications and unit commands in world screen for an unobstructed central view

This commit is contained in:
Yair Morgenstern 2018-03-21 21:10:28 +02:00
parent c8c1ecc4da
commit 3959706ab9
6 changed files with 69 additions and 52 deletions

View File

@ -160,7 +160,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
// Borders // Borders
if(tileInfo.owner!=null){ if(tileInfo.owner!=null){
for(border in borderImages) border.remove() for (border in borderImages) border.remove()
for (neighbor in tileInfo.neighbors.filter { it.owner!=tileInfo.owner }){ for (neighbor in tileInfo.neighbors.filter { it.owner!=tileInfo.owner }){
val image = ImageGetter.getImage(ImageGetter.WhiteDot) val image = ImageGetter.getImage(ImageGetter.WhiteDot)

View File

@ -16,7 +16,7 @@ class WorldTileGroup(tileInfo: TileInfo) : TileGroup(tileInfo) {
tileInfo.explored = true tileInfo.explored = true
update() update()
} else } else
setColor(0f, 0f, 0f, 0.5f) setColor(0f, 0f, 0f, 0.6f)
} }

View File

@ -9,59 +9,70 @@ import com.unciv.ui.cityscreen.addClickListener
import com.unciv.ui.utils.CameraStageBaseScreen import com.unciv.ui.utils.CameraStageBaseScreen
import com.unciv.ui.utils.ImageGetter import com.unciv.ui.utils.ImageGetter
class CivStatsTable internal constructor() : Table() { class CivStatsTable : Table {
init {
private val turnsLabel = Label("Turns: 0/400", CameraStageBaseScreen.skin)
private val goldLabel = Label("Gold:",CameraStageBaseScreen.skin)
private val scienceLabel = Label("Science:",CameraStageBaseScreen.skin)
private val happinessLabel = Label("Happiness:",CameraStageBaseScreen.skin)
private val cultureLabel = Label("Culture:",CameraStageBaseScreen.skin)
internal constructor(screen: WorldScreen){
val civBackground = ImageGetter.getDrawable("skin/civTableBackground.png") val civBackground = ImageGetter.getDrawable("skin/civTableBackground.png")
background = civBackground.tint(Color(0x004085bf)) background = civBackground.tint(Color(0x004085bf))
} addCivilopediaButton(screen)
add(turnsLabel)
internal fun update(screen: WorldScreen) { add(goldLabel)
val civInfo = screen.civInfo
val skin = CameraStageBaseScreen.skin
clear()
row().pad(15f)
val civilopediaButton = TextButton("Menu", skin)
civilopediaButton.addClickListener {
screen.optionsTable.isVisible = !screen.optionsTable.isVisible
}
civilopediaButton.label.setFontScale(screen.buttonScale)
add(civilopediaButton)
.size(civilopediaButton.width * screen.buttonScale, civilopediaButton.height * screen.buttonScale)
add(Label("Turns: " + civInfo.gameInfo.turns + "/400", skin))
val nextTurnStats = civInfo.getStatsForNextTurn()
add(Label("Gold: " + Math.round(civInfo.gold.toFloat())
+ "(" + (if (nextTurnStats.gold > 0) "+" else "") + Math.round(nextTurnStats.gold) + ")", skin))
val scienceLabel = Label("Science: +" + Math.round(nextTurnStats.science)
+ "\r\n" + civInfo.tech.getAmountResearchedText(), skin)
scienceLabel.setAlignment(Align.center) scienceLabel.setAlignment(Align.center)
add(scienceLabel) add(scienceLabel)
var happinessText = "Happiness: " + civInfo.happiness
if (civInfo.goldenAges.isGoldenAge())
happinessText += "\r\n GOLDEN AGE (" + civInfo.goldenAges.turnsLeftForCurrentGoldenAge + ")"
else
happinessText += ("\r\n (" + civInfo.goldenAges.storedHappiness + "/"
+ civInfo.goldenAges.happinessRequiredForNextGoldenAge() + ")")
val happinessLabel = Label(happinessText, skin)
happinessLabel.setAlignment(Align.center) happinessLabel.setAlignment(Align.center)
add(happinessLabel) add(happinessLabel)
val cultureString = ("Culture: " + "+" + Math.round(nextTurnStats.culture) + "\r\n"
+ "(" + civInfo.policies.storedCulture + "/" + civInfo.policies.getCultureNeededForNextPolicy() + ")")
val cultureLabel = Label(cultureString, skin)
cultureLabel.setAlignment(Align.center) cultureLabel.setAlignment(Align.center)
add(cultureLabel) add(cultureLabel)
pack() pack()
setPosition(10f, screen.stage.height - 10f - height)
width = screen.stage.width - 20 width = screen.stage.width - 20
}
internal fun addCivilopediaButton(screen: WorldScreen){
row().pad(15f)
val civilopediaButton = TextButton("Menu", CameraStageBaseScreen.skin)
civilopediaButton.addClickListener {
screen.optionsTable.isVisible = !screen.optionsTable.isVisible
}
civilopediaButton.label.setFontScale(screen.buttonScale)
add(civilopediaButton)
.size(civilopediaButton.width * screen.buttonScale, civilopediaButton.height * screen.buttonScale)
}
internal fun update(screen: WorldScreen) {
val civInfo = screen.civInfo
turnsLabel.setText("Turns: " + civInfo.gameInfo.turns + "/400")
val nextTurnStats = civInfo.getStatsForNextTurn()
val goldPerTurn = "(" + (if (nextTurnStats.gold > 0) "+" else "") + Math.round(nextTurnStats.gold) + ")"
goldLabel.setText("Gold: " + Math.round(civInfo.gold.toFloat()) + goldPerTurn)
scienceLabel.setText("Science: +" + Math.round(nextTurnStats.science)
+ "\r\n" + civInfo.tech.getAmountResearchedText())
var happinessText = "Happiness: " + civInfo.happiness+"\r\n"
if (civInfo.goldenAges.isGoldenAge())
happinessText += "GOLDEN AGE (${civInfo.goldenAges.turnsLeftForCurrentGoldenAge})"
else
happinessText += ("(" + civInfo.goldenAges.storedHappiness + "/"
+ civInfo.goldenAges.happinessRequiredForNextGoldenAge() + ")")
happinessLabel.setText(happinessText)
val cultureString = "Culture: " + "+" + Math.round(nextTurnStats.culture) + "\r\n" +
"(" + civInfo.policies.storedCulture + "/" + civInfo.policies.getCultureNeededForNextPolicy() + ")"
cultureLabel.setText(cultureString)
} }
} }

View File

@ -39,8 +39,6 @@ class NotificationsScroll(private val notifications: List<Notification>, interna
} }
notificationsTable.pack() notificationsTable.pack()
setSize(worldScreen.stage.width / 3,
Math.min(notificationsTable.height, worldScreen.stage.height / 3))
} }
} }

View File

@ -18,9 +18,9 @@ class WorldScreen : CameraStageBaseScreen() {
internal var buttonScale = game.settings.buttonScale internal var buttonScale = game.settings.buttonScale
private val tileInfoTable: TileInfoTable private val tileInfoTable: TileInfoTable
private val civTable = CivStatsTable() private val civTable = CivStatsTable(this)
private val techButton = TextButton("", CameraStageBaseScreen.skin) private val techButton = TextButton("", CameraStageBaseScreen.skin)
private val nextTurnButton = createNextTurnButton()
internal val optionsTable: WorldScreenOptionsTable internal val optionsTable: WorldScreenOptionsTable
private val notificationsScroll: NotificationsScroll private val notificationsScroll: NotificationsScroll
@ -29,19 +29,30 @@ class WorldScreen : CameraStageBaseScreen() {
init { init {
val gameInfo = game.gameInfo val gameInfo = game.gameInfo
this.civInfo = gameInfo.getPlayerCivilization() this.civInfo = gameInfo.getPlayerCivilization()
unitTable.setPosition(5f, 5f)
tileMapHolder = TileMapHolder(this, gameInfo.tileMap, civInfo) tileMapHolder = TileMapHolder(this, gameInfo.tileMap, civInfo)
tileInfoTable = TileInfoTable(this, civInfo) tileInfoTable = TileInfoTable(this, civInfo)
civTable.setPosition(10f, stage.height - civTable.height - 10f )
nextTurnButton.setPosition(stage.width - nextTurnButton.width - 10f,
civTable.y - nextTurnButton.height - 10f)
notificationsScroll = NotificationsScroll(gameInfo.notifications, this) notificationsScroll = NotificationsScroll(gameInfo.notifications, this)
notificationsScroll.setSize(stage.width/3,stage.height/4)
notificationsScroll.setPosition(stage.width - notificationsScroll.width - 5f,
nextTurnButton.y - notificationsScroll.height - 5f)
optionsTable = WorldScreenOptionsTable(this, civInfo) optionsTable = WorldScreenOptionsTable(this, civInfo)
Label("", CameraStageBaseScreen.skin).style.font.data.setScale(game.settings.labelScale) Label("", CameraStageBaseScreen.skin).style.font.data.setScale(game.settings.labelScale)
tileMapHolder.addTiles() tileMapHolder.addTiles()
stage.addActor(tileMapHolder) stage.addActor(tileMapHolder)
stage.addActor(tileInfoTable) stage.addActor(tileInfoTable)
stage.addActor(civTable) stage.addActor(civTable)
stage.addActor(nextTurnButton)
stage.addActor(techButton) stage.addActor(techButton)
stage.addActor(notificationsScroll) stage.addActor(notificationsScroll)
stage.addActor(unitTable) stage.addActor(unitTable)
update() update()
tileMapHolder.setCenterPosition(Vector2.Zero) tileMapHolder.setCenterPosition(Vector2.Zero)
@ -81,7 +92,7 @@ class WorldScreen : CameraStageBaseScreen() {
techButton.setPosition(10f, civTable.y - techButton.height - 5f) techButton.setPosition(10f, civTable.y - techButton.height - 5f)
} }
private fun createNextTurnButton() { private fun createNextTurnButton(): TextButton {
val nextTurnButton = TextButton("Next turn", CameraStageBaseScreen.skin) val nextTurnButton = TextButton("Next turn", CameraStageBaseScreen.skin)
nextTurnButton.addClickListener { nextTurnButton.addClickListener {
if (civInfo.tech.freeTechs != 0) { if (civInfo.tech.freeTechs != 0) {
@ -105,9 +116,7 @@ class WorldScreen : CameraStageBaseScreen() {
displayTutorials("NextTurn") displayTutorials("NextTurn")
} }
nextTurnButton.setPosition(stage.width - nextTurnButton.width - 10f, return nextTurnButton
civTable.y - nextTurnButton.height - 10f)
stage.addActor(nextTurnButton)
} }
override fun resize(width: Int, height: Int) { override fun resize(width: Int, height: Int) {

View File

@ -50,7 +50,6 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
unitActionsTable.pack() unitActionsTable.pack()
pack() pack()
setPosition(worldScreen.stage.width / 2 - width / 2, 5f)
} }
fun tileSelected(selectedTile: TileInfo) { fun tileSelected(selectedTile: TileInfo) {