mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 23:40:01 +07:00
UI revamp to the top bar
This commit is contained in:
@ -80,6 +80,17 @@
|
||||
uniques:["Bonus vs City 200%","No defensive terrain bonus","Must set up to ranged attack"],
|
||||
hurryCostModifier:20
|
||||
},
|
||||
{
|
||||
name:"Swordsman",
|
||||
baseDescription: "",
|
||||
unitType:"Melee",
|
||||
movement:2,
|
||||
strength:14,
|
||||
cost: 75,
|
||||
requiredTech:"Iron Working",
|
||||
requiredResource:"Iron",
|
||||
hurryCostModifier:20
|
||||
},
|
||||
{
|
||||
name:"Horseman",
|
||||
baseDescription:"",
|
||||
|
BIN
android/assets/skin/menuIcon.png
Normal file
BIN
android/assets/skin/menuIcon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 35 KiB |
@ -64,7 +64,8 @@ class Automation {
|
||||
private fun trainCombatUnit(city: CityInfo) {
|
||||
val buildableUnits = city.cityConstructions.getConstructableUnits()
|
||||
val chosenUnit:Unit
|
||||
if(city.getCenterTile().unit==null && buildableUnits.any { it.unitType==UnitType.Archery }) // this is for defence so get an archery if we can
|
||||
if(city.civInfo.cities.any { it.getCenterTile().unit==null}
|
||||
&& buildableUnits.any { it.unitType==UnitType.Archery }) // this is for city defence so get an archery unit if we can
|
||||
chosenUnit = buildableUnits.filter { it.unitType==UnitType.Archery }.maxBy { it.cost }!!
|
||||
else chosenUnit = buildableUnits.maxBy { it.cost }!!
|
||||
|
||||
|
@ -84,4 +84,5 @@ class PolicyManager {
|
||||
if (!couldAdoptPolicyBefore && canAdoptPolicy())
|
||||
shouldOpenPolicyPicker = true
|
||||
}
|
||||
|
||||
}
|
@ -2,12 +2,13 @@ package com.unciv.models.gamebasics
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.unciv.models.stats.INamed
|
||||
import com.unciv.ui.utils.fromRGB
|
||||
|
||||
class Civilization : INamed {
|
||||
override lateinit var name: String
|
||||
lateinit var RGB: List<Int>
|
||||
fun getColor(): Color {
|
||||
return Color(RGB[0]/256f, RGB[1]/256f, RGB[2]/256f, 1f)
|
||||
return Color().fromRGB(RGB[0],RGB[1],RGB[2])
|
||||
}
|
||||
lateinit var cities: List<String>
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import com.unciv.logic.map.RoadStatus
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.ui.utils.HexMath
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
import com.unciv.ui.utils.fromRGB
|
||||
|
||||
open class TileGroup(var tileInfo: TileInfo) : Group() {
|
||||
|
||||
@ -146,7 +147,7 @@ open class TileGroup(var tileInfo: TileInfo) : Group() {
|
||||
|
||||
private fun updateTileColor(isViewable: Boolean) {
|
||||
val RGB = tileInfo.getBaseTerrain().RGB!!
|
||||
hexagon.color = Color(RGB[0] / 255f, RGB[1] / 255f, RGB[2] / 255f, 1f)
|
||||
hexagon.color = Color().fromRGB(RGB[0], RGB[1],RGB[2])
|
||||
if (!isViewable) hexagon.color = hexagon.color.lerp(Color.BLACK, 0.6f)
|
||||
}
|
||||
|
||||
|
@ -102,4 +102,9 @@ fun Button.enable() {
|
||||
color = Color.WHITE
|
||||
touchable = Touchable.enabled
|
||||
}
|
||||
fun <E> List<E>.getRandom(): E = if (size == 0) throw Exception() else get((Math.random() * size).toInt())
|
||||
fun <E> List<E>.getRandom(): E = if (size == 0) throw Exception() else get((Math.random() * size).toInt())
|
||||
|
||||
|
||||
fun Color.fromRGB(r:Int,g:Int,b:Int): Color {
|
||||
return Color(r/255f, g/255f, b/255f, 1f)
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package com.unciv.ui.utils
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||
@ -25,11 +26,10 @@ object ImageGetter {
|
||||
private fun getTextureRegion(fileName: String): TextureRegion {
|
||||
try {
|
||||
if (!textureRegionByFileName.containsKey(fileName)) {
|
||||
val texture = Texture(Gdx.files.internal(fileName))
|
||||
texture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear)
|
||||
val texture = Texture(Gdx.files.internal(fileName),true)
|
||||
texture.setFilter(Texture.TextureFilter.MipMapLinearLinear, Texture.TextureFilter.MipMapLinearLinear)
|
||||
textureRegionByFileName[fileName] = TextureRegion(texture)
|
||||
}
|
||||
|
||||
} catch (ex: Exception) {
|
||||
print("File $fileName not found!")
|
||||
throw ex
|
||||
@ -42,4 +42,5 @@ object ImageGetter {
|
||||
return getImage("StatIcons/20x" + name + "5.png")
|
||||
}
|
||||
|
||||
fun getBlue() = Color(0x004085bf)
|
||||
}
|
||||
|
@ -4,66 +4,87 @@ import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.ResourceType
|
||||
import com.unciv.ui.cityscreen.addClickListener
|
||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
import com.unciv.ui.utils.fromRGB
|
||||
import kotlin.math.ceil
|
||||
|
||||
class CivStatsTable(val screen: WorldScreen) : Table() {
|
||||
|
||||
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)
|
||||
val labelStyle = Label.LabelStyle(Label("",CameraStageBaseScreen.skin).style)
|
||||
.apply { fontColor = Color.valueOf("f5f5f5ff") }
|
||||
|
||||
private val turnsLabel = Label("Turns: 0/400", labelStyle)
|
||||
private val goldLabel = Label("Gold:",labelStyle).apply { color = Color().fromRGB(225,217,71) }
|
||||
private val scienceLabel = Label("Science:",labelStyle).apply { color = Color().fromRGB(78,140,151) }
|
||||
private val happinessLabel = Label("Happiness:",labelStyle).apply { color = Color().fromRGB(92,194,77) }
|
||||
private val cultureLabel = Label("Culture:",labelStyle).apply { color = Color().fromRGB(200,60,200) }
|
||||
private val resourceLabels = HashMap<String, Label>()
|
||||
private val resourceImages = HashMap<String, Image>()
|
||||
|
||||
init{
|
||||
val civBackground = ImageGetter.getDrawable("skin/civTableBackground.png")
|
||||
background = civBackground.tint(Color(0x004085e0))
|
||||
background = ImageGetter.getDrawable("skin/whiteDot.png").tint(ImageGetter.getBlue().lerp(Color.BLACK,0.5f))
|
||||
|
||||
//add(Table().apply {
|
||||
add(getStatsTable()).row()
|
||||
add(getResourceTable())
|
||||
// pack()
|
||||
// })
|
||||
|
||||
pad(5f)
|
||||
pack()
|
||||
addActor(getMenuButton()) // needs to be after pack
|
||||
}
|
||||
|
||||
private fun getResourceTable(): Table {
|
||||
val resourceTable = Table()
|
||||
resourceTable.defaults().pad(5f)
|
||||
val revealedStrategicResources = GameBasics.TileResources.values
|
||||
.filter { it.resourceType== ResourceType.Strategic} // && civInfo.tech.isResearched(it.revealedBy!!) }
|
||||
for(resource in revealedStrategicResources){
|
||||
.filter { it.resourceType == ResourceType.Strategic } // && civInfo.tech.isResearched(it.revealedBy!!) }
|
||||
for (resource in revealedStrategicResources) {
|
||||
val fileName = "ResourceIcons/${resource.name}_(Civ5).png"
|
||||
val resourceImage = ImageGetter.getImage(fileName)
|
||||
resourceImages.put(resource.name,resourceImage)
|
||||
resourceImages.put(resource.name, resourceImage)
|
||||
resourceTable.add(resourceImage).size(20f)
|
||||
val resourceLabel = Label("0",CameraStageBaseScreen.skin)
|
||||
val resourceLabel = Label("0", labelStyle)
|
||||
resourceLabels.put(resource.name, resourceLabel)
|
||||
resourceTable.add(resourceLabel)
|
||||
}
|
||||
resourceTable.pack()
|
||||
add(resourceTable).row()
|
||||
|
||||
|
||||
val statsTable = Table()
|
||||
statsTable.defaults().padRight(20f).padBottom(10f)
|
||||
statsTable.add(getMenuButton())
|
||||
statsTable.add(turnsLabel)
|
||||
statsTable.add(goldLabel)
|
||||
statsTable.add(scienceLabel.apply { setAlignment(Align.center) })
|
||||
statsTable.add(happinessLabel.apply { setAlignment(Align.center) })
|
||||
statsTable.add(cultureLabel.apply { setAlignment(Align.center) })
|
||||
|
||||
statsTable.pack()
|
||||
statsTable.width = screen.stage.width - 20
|
||||
add(statsTable)
|
||||
pack()
|
||||
width = screen.stage.width - 20
|
||||
return resourceTable
|
||||
}
|
||||
|
||||
internal fun getMenuButton(): TextButton {
|
||||
val menuButton = TextButton("Menu", CameraStageBaseScreen.skin)
|
||||
private fun getStatsTable(): Table {
|
||||
val statsTable = Table()
|
||||
statsTable.defaults().pad(3f)//.align(Align.top)
|
||||
statsTable.add(turnsLabel).padRight(20f)
|
||||
statsTable.add(goldLabel)
|
||||
statsTable.add(ImageGetter.getStatIcon("Gold")).padRight(20f)
|
||||
statsTable.add(scienceLabel) //.apply { setAlignment(Align.center) }).align(Align.top)
|
||||
statsTable.add(ImageGetter.getStatIcon("Science")).padRight(20f)
|
||||
|
||||
statsTable.add(ImageGetter.getStatIcon("Happiness"))
|
||||
statsTable.add(happinessLabel).padRight(20f)//.apply { setAlignment(Align.center) }).align(Align.top)
|
||||
|
||||
statsTable.add(cultureLabel)//.apply { setAlignment(Align.center) }).align(Align.top)
|
||||
statsTable.add(ImageGetter.getStatIcon("Culture"))
|
||||
statsTable.pack()
|
||||
statsTable.width = screen.stage.width - 20
|
||||
return statsTable
|
||||
}
|
||||
|
||||
internal fun getMenuButton(): Image {
|
||||
val menuButton = ImageGetter.getImage("skin/menuIcon.png")
|
||||
.apply { setSize(50f,50f) }
|
||||
menuButton.color = Color.WHITE
|
||||
menuButton.addClickListener {
|
||||
screen.optionsTable.isVisible = !screen.optionsTable.isVisible
|
||||
}
|
||||
menuButton.y = this.height/2-menuButton.height/2
|
||||
menuButton.x = menuButton.y
|
||||
return menuButton
|
||||
}
|
||||
|
||||
@ -87,23 +108,22 @@ class CivStatsTable(val screen: WorldScreen) : Table() {
|
||||
val nextTurnStats = civInfo.getStatsForNextTurn()
|
||||
|
||||
val goldPerTurn = "(" + (if (nextTurnStats.gold > 0) "+" else "") + Math.round(nextTurnStats.gold) + ")"
|
||||
goldLabel.setText("Gold: " + Math.round(civInfo.gold.toFloat()) + goldPerTurn)
|
||||
goldLabel.setText("" + Math.round(civInfo.gold.toFloat()) + goldPerTurn)
|
||||
|
||||
scienceLabel.setText("Science: +" + Math.round(nextTurnStats.science)
|
||||
+ "\r\n" + civInfo.tech.getAmountResearchedText())
|
||||
scienceLabel.setText("+" + Math.round(nextTurnStats.science))
|
||||
|
||||
var happinessText = "Happiness: " + civInfo.happiness+"\r\n"
|
||||
var happinessText = civInfo.happiness.toString()
|
||||
if (civInfo.goldenAges.isGoldenAge())
|
||||
happinessText += "GOLDEN AGE (${civInfo.goldenAges.turnsLeftForCurrentGoldenAge})"
|
||||
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() + ")"
|
||||
|
||||
val turnsToNextPolicy = (civInfo.policies.getCultureNeededForNextPolicy() - civInfo.policies.storedCulture) / nextTurnStats.culture
|
||||
var cultureString = "+" + Math.round(nextTurnStats.culture)
|
||||
if(turnsToNextPolicy>0) cultureString+= " ("+ ceil(turnsToNextPolicy)+")"
|
||||
else cultureString += " (!)"
|
||||
cultureLabel.setText(cultureString)
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,10 @@ class WorldScreen : CameraStageBaseScreen() {
|
||||
unitTable.setPosition(5f, 5f)
|
||||
tileMapHolder = TileMapHolder(this, gameInfo.tileMap, civInfo)
|
||||
tileInfoTable = TileInfoTable(this, civInfo)
|
||||
civTable.setPosition(10f, stage.height - civTable.height - 10f )
|
||||
|
||||
civTable.setPosition(0f, stage.height - civTable.height)
|
||||
civTable.width = stage.width
|
||||
|
||||
nextTurnButton.setPosition(stage.width - nextTurnButton.width - 10f,
|
||||
civTable.y - nextTurnButton.height - 10f)
|
||||
notificationsScroll = NotificationsScroll(gameInfo.notifications, this)
|
||||
|
@ -16,51 +16,55 @@ import com.unciv.ui.utils.ImageGetter
|
||||
class WorldScreenOptionsTable internal constructor(worldScreen: WorldScreen, private val civInfo: CivilizationInfo) : Table() {
|
||||
|
||||
init {
|
||||
val tileTableBackground = ImageGetter.getDrawable("skin/tileTableBackground.png")
|
||||
val tileTableBackground = ImageGetter.getDrawable("skin/whiteDot.png")
|
||||
.tint(Color(0x004085bf))
|
||||
background = tileTableBackground
|
||||
isVisible = false
|
||||
|
||||
val openCivilopediaButton = TextButton("Civilopedia", CameraStageBaseScreen.skin)
|
||||
pad(20f)
|
||||
defaults().pad(5f)
|
||||
|
||||
val openCivilopediaButton = TextButton("Civilopedia", CameraStageBaseScreen.skin).apply { color=ImageGetter.getBlue(); background=null }
|
||||
openCivilopediaButton.addClickListener {
|
||||
worldScreen.game.screen = CivilopediaScreen()
|
||||
isVisible = false
|
||||
}
|
||||
add(openCivilopediaButton).pad(10f).row()
|
||||
add(openCivilopediaButton).row()
|
||||
|
||||
val loadGameButton = TextButton("Load game", CameraStageBaseScreen.skin)
|
||||
val loadGameButton = TextButton("Load game", CameraStageBaseScreen.skin).apply { color=ImageGetter.getBlue() }
|
||||
loadGameButton .addClickListener {
|
||||
worldScreen.game.screen = LoadScreen()
|
||||
isVisible=false
|
||||
}
|
||||
add(loadGameButton ).pad(10f).row()
|
||||
add(loadGameButton ).row()
|
||||
|
||||
|
||||
val saveGameButton = TextButton("Save game", CameraStageBaseScreen.skin)
|
||||
val saveGameButton = TextButton("Save game", CameraStageBaseScreen.skin).apply { color=ImageGetter.getBlue() }
|
||||
saveGameButton .addClickListener {
|
||||
worldScreen.game.screen = SaveScreen()
|
||||
isVisible=false
|
||||
}
|
||||
add(saveGameButton ).pad(10f).row()
|
||||
val startNewGameButton = TextButton("Start new game", CameraStageBaseScreen.skin)
|
||||
startNewGameButton.addClickListener { worldScreen.game.startNewGame(true) }
|
||||
add(startNewGameButton).pad(10f).row()
|
||||
add(saveGameButton ).row()
|
||||
|
||||
val openVictoryScreen = TextButton("Victory status", CameraStageBaseScreen.skin)
|
||||
val startNewGameButton = TextButton("Start new game", CameraStageBaseScreen.skin).apply { color=ImageGetter.getBlue() }
|
||||
startNewGameButton.addClickListener { worldScreen.game.startNewGame(true) }
|
||||
add(startNewGameButton).row()
|
||||
|
||||
val openVictoryScreen = TextButton("Victory status", CameraStageBaseScreen.skin).apply { color=ImageGetter.getBlue() }
|
||||
openVictoryScreen.addClickListener {
|
||||
worldScreen.game.screen = VictoryScreen()
|
||||
}
|
||||
add(openVictoryScreen).pad(10f).row()
|
||||
add(openVictoryScreen).row()
|
||||
|
||||
val openPolicyPickerScreen = TextButton("Social Policies", CameraStageBaseScreen.skin)
|
||||
val openPolicyPickerScreen = TextButton("Social Policies", CameraStageBaseScreen.skin).apply { color=ImageGetter.getBlue() }
|
||||
openPolicyPickerScreen.addClickListener {
|
||||
worldScreen.game.screen = PolicyPickerScreen(this@WorldScreenOptionsTable.civInfo)
|
||||
}
|
||||
add(openPolicyPickerScreen).pad(10f).row()
|
||||
add(openPolicyPickerScreen).row()
|
||||
|
||||
val closeButton = TextButton("Close", CameraStageBaseScreen.skin)
|
||||
val closeButton = TextButton("Close", CameraStageBaseScreen.skin).apply { color=ImageGetter.getBlue() }
|
||||
closeButton.addClickListener { isVisible = false }
|
||||
add(closeButton).pad(10f)
|
||||
add(closeButton)
|
||||
|
||||
pack() // Needed to show the background.
|
||||
setPosition(worldScreen.stage.width / 2 - width / 2,
|
||||
|
@ -22,7 +22,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
||||
val tileTableBackground = ImageGetter.getDrawable("skin/tileTableBackground.png")
|
||||
.tint(Color(0x004085bf))
|
||||
pad(20f)
|
||||
background = tileTableBackground
|
||||
//background = tileTableBackground
|
||||
add(unitLabel).pad(10f)
|
||||
add(unitActionsTable)
|
||||
row()
|
||||
|
Reference in New Issue
Block a user