Added Yes/No popup (we'll need it when we have diplomacy and you tell a unit to enter enemy territory)
Added opttion to disband unit (as a test for the popup)
This commit is contained in:
parent
c5787803f9
commit
e81df16317
9 changed files with 78 additions and 43 deletions
BIN
android/assets/OtherIcons/DisbandUnit.png
Normal file
BIN
android/assets/OtherIcons/DisbandUnit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
|
@ -142,6 +142,13 @@
|
|||
Romanian:"Sanatate"
|
||||
German:"Gesundheit"
|
||||
}
|
||||
|
||||
"Disband unit":{}
|
||||
|
||||
"Do you really want to disband this unit?":{}
|
||||
"Yes":{}
|
||||
"No":{}
|
||||
|
||||
|
||||
// Stats
|
||||
"Gold":{
|
||||
|
|
|
@ -33,6 +33,7 @@ class CivilizationInfo {
|
|||
var goldenAges = GoldenAgeManager()
|
||||
var greatPeople = GreatPersonManager()
|
||||
var scienceVictory = ScienceVictoryManager()
|
||||
@Transient var diplomacy = HashMap<String,DiplomacyManager>()
|
||||
|
||||
var cities = ArrayList<CityInfo>()
|
||||
var exploredTiles = HashSet<Vector2>()
|
||||
|
@ -65,12 +66,10 @@ class CivilizationInfo {
|
|||
statMap.put("Transportation upkeep",Stats().apply { gold=- getTransportationUpkeep().toFloat()})
|
||||
statMap.put("Unit upkeep",Stats().apply { gold=- getUnitUpkeep().toFloat()})
|
||||
|
||||
if (policies.isAdopted("Mandate Of Heaven"))
|
||||
|
||||
if (!statMap.containsKey("Policies")) {
|
||||
statMap["Policies"] = Stats()
|
||||
statMap["Policies"]!!.culture += statMap.values.map { it.happiness }.sum() / 2
|
||||
}
|
||||
if (policies.isAdopted("Mandate Of Heaven")) {
|
||||
if (!statMap.containsKey("Policies")) statMap["Policies"] = Stats()
|
||||
statMap["Policies"]!!.culture += statMap.values.map { it.happiness }.sum() / 2
|
||||
}
|
||||
|
||||
// if we have - or 0, then the techs will never be complete and the tech button
|
||||
// will show a negative number of turns and int.max, respectively
|
||||
|
@ -244,12 +243,19 @@ class CivilizationInfo {
|
|||
}
|
||||
}
|
||||
|
||||
//enum class DiplomaticStatus{
|
||||
// Peace,
|
||||
// War
|
||||
//}
|
||||
//
|
||||
//class DiplomacyManager {
|
||||
// lateinit var otherCivName:String
|
||||
// var status:DiplomaticStatus = DiplomaticStatus.Peace
|
||||
//}
|
||||
enum class DiplomaticStatus{
|
||||
Peace,
|
||||
War
|
||||
}
|
||||
|
||||
class DiplomacyManager {
|
||||
@Transient lateinit var civInfo:CivilizationInfo
|
||||
lateinit var otherCivName:String
|
||||
var status:DiplomaticStatus = DiplomaticStatus.Peace
|
||||
|
||||
fun otherCiv() = civInfo.gameInfo.civilizations.first{it.civName==otherCivName}
|
||||
fun declareWar(){
|
||||
status = DiplomaticStatus.War
|
||||
otherCiv().diplomacy[civInfo.civName]!!.status = DiplomaticStatus.War
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package com.unciv.ui.worldscreen.optionstable
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
import com.unciv.ui.utils.addClickListener
|
||||
import com.unciv.ui.utils.tr
|
||||
|
||||
open class OptionsTable: Table(){
|
||||
init {
|
||||
val tileTableBackground = ImageGetter.getDrawable("skin/whiteDot.png")
|
||||
.tint(Color(0x004085bf))
|
||||
background = tileTableBackground
|
||||
|
||||
this.pad(20f)
|
||||
this.defaults().pad(5f)
|
||||
}
|
||||
|
||||
fun addButton(text:String, action:()->Unit){
|
||||
val button = TextButton(text.tr(), CameraStageBaseScreen.skin).apply { color= ImageGetter.getBlue() }
|
||||
button.addClickListener(action)
|
||||
add(button).row()
|
||||
}
|
||||
}
|
39
core/src/com/unciv/ui/worldscreen/optionstable/PopupTable.kt
Normal file
39
core/src/com/unciv/ui/worldscreen/optionstable/PopupTable.kt
Normal file
|
@ -0,0 +1,39 @@
|
|||
package com.unciv.ui.worldscreen.optionstable
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
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.unciv.UnCivGame
|
||||
import com.unciv.ui.utils.*
|
||||
|
||||
open class PopupTable: Table(){
|
||||
init {
|
||||
val tileTableBackground = ImageGetter.getDrawable("skin/whiteDot.png")
|
||||
.tint(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
|
||||
background = tileTableBackground
|
||||
|
||||
this.pad(20f)
|
||||
this.defaults().pad(5f)
|
||||
}
|
||||
|
||||
fun addButton(text:String, action:()->Unit){
|
||||
val button = TextButton(text.tr(), CameraStageBaseScreen.skin).apply { color= ImageGetter.getBlue() }
|
||||
button.addClickListener(action)
|
||||
add(button).row()
|
||||
}
|
||||
}
|
||||
|
||||
class YesNoPopupTable(question:String, action:()->Unit,
|
||||
screen: CameraStageBaseScreen = UnCivGame.Current.worldScreen) : PopupTable(){
|
||||
init{
|
||||
val skin = CameraStageBaseScreen.skin
|
||||
add(Label(question,skin)).colspan(2).row()
|
||||
|
||||
add(TextButton("No",skin).apply { addClickListener { this@YesNoPopupTable.remove() } })
|
||||
add(TextButton("Yes",skin).apply { addClickListener { this@YesNoPopupTable.remove(); action() } })
|
||||
pack()
|
||||
center(screen.stage)
|
||||
screen.stage.addActor(this)
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ import com.unciv.ui.utils.CameraStageBaseScreen
|
|||
import com.unciv.ui.utils.center
|
||||
import com.unciv.ui.worldscreen.WorldScreen
|
||||
|
||||
class WorldScreenDisplayOptionsTable() : OptionsTable(){
|
||||
class WorldScreenDisplayOptionsTable() : PopupTable(){
|
||||
init {
|
||||
update()
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.unciv.ui.pickerscreens.PolicyPickerScreen
|
|||
import com.unciv.ui.utils.center
|
||||
import com.unciv.ui.utils.tr
|
||||
|
||||
class WorldScreenOptionsTable internal constructor() : OptionsTable() {
|
||||
class WorldScreenOptionsTable internal constructor() : PopupTable() {
|
||||
|
||||
init {
|
||||
addButton("Civilopedia".tr()){
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.unciv.ui.pickerscreens.ImprovementPickerScreen
|
|||
import com.unciv.ui.pickerscreens.PromotionPickerScreen
|
||||
import com.unciv.ui.pickerscreens.TechPickerScreen
|
||||
import com.unciv.ui.worldscreen.WorldScreen
|
||||
import com.unciv.ui.worldscreen.optionstable.YesNoPopupTable
|
||||
import java.util.*
|
||||
import kotlin.math.max
|
||||
|
||||
|
@ -36,6 +37,7 @@ class UnitActions {
|
|||
unitTable.currentlyExecutingAction = "moveTo"
|
||||
}, unit.currentMovement != 0f )
|
||||
}
|
||||
|
||||
else {
|
||||
actionList +=
|
||||
UnitAction("Stop movement", {
|
||||
|
@ -162,6 +164,12 @@ class UnitActions {
|
|||
unit.currentMovement != 0f)
|
||||
}
|
||||
|
||||
actionList += UnitAction("Disband unit",
|
||||
{
|
||||
YesNoPopupTable("Do you really want to disband this unit?",
|
||||
{unit.removeFromTile(); worldScreen.update()} )
|
||||
},unit.currentMovement != 0f)
|
||||
|
||||
return actionList
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ class UnitActionsTable(val worldScreen: WorldScreen) : Table(){
|
|||
"Conduct Trade Mission" -> return ImageGetter.getUnitIcon("Great Merchant")
|
||||
"Construct Customs House" -> return ImageGetter.getImprovementIcon("Customs house")
|
||||
"Set up" -> return ImageGetter.getUnitIcon("Catapult")
|
||||
"Disband unit" -> return ImageGetter.getImage("OtherIcons/DisbandUnit.png")
|
||||
else -> return ImageGetter.getImage("OtherIcons/Star.png")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue