mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 14:24:43 -04:00
Added "deselect" button to unit & city display
This commit is contained in:
parent
d2a48fae38
commit
3feb231620
@ -12,6 +12,7 @@ import java.util.*
|
||||
*/
|
||||
class Battle(val gameInfo:GameInfo) {
|
||||
fun attack(attacker: ICombatant, defender: ICombatant) {
|
||||
println(attacker.getCivInfo().civName+" "+attacker.getName()+" attacked "+defender.getCivInfo().civName+" "+defender.getName())
|
||||
val attackedTile = defender.getTile()
|
||||
|
||||
var damageToDefender = BattleDamage().calculateDamageToDefender(attacker,defender)
|
||||
|
@ -27,6 +27,7 @@ class NewGameScreen: PickerScreen(){
|
||||
val nationTables = ArrayList<NationTable>()
|
||||
|
||||
val civPickerTable = Table().apply { defaults().pad(15f) }
|
||||
|
||||
init {
|
||||
setDefaultCloseAction()
|
||||
val mainTable = Table()
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.unciv.ui
|
||||
package com.unciv.ui.mapeditor
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
||||
import com.badlogic.gdx.scenes.scene2d.Group
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*
|
||||
import com.badlogic.gdx.utils.Array
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.ScrollPane
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.unciv.GameParameters
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.logic.GameSaver
|
||||
import com.unciv.logic.map.TileMap
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
@ -14,13 +14,13 @@ 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
|
||||
import com.unciv.ui.utils.center
|
||||
import com.unciv.ui.utils.onClick
|
||||
import com.unciv.ui.worldscreen.TileGroupMap
|
||||
import com.unciv.ui.worldscreen.optionstable.PopupTable
|
||||
|
||||
class MapEditorScreen(var mapToLoad:String?=null): CameraStageBaseScreen(){
|
||||
var clearTerrainFeature=false
|
||||
@ -77,7 +77,7 @@ class MapEditorScreen(var mapToLoad:String?=null): CameraStageBaseScreen(){
|
||||
|
||||
val saveMapButton = TextButton("Options".tr(),skin)
|
||||
saveMapButton.onClick {
|
||||
mapScreenOptionsTable(this)
|
||||
MapScreenOptionsTable(this)
|
||||
}
|
||||
stage.addActor(saveMapButton)
|
||||
}
|
||||
@ -187,49 +187,8 @@ class MapEditorScreen(var mapToLoad:String?=null): CameraStageBaseScreen(){
|
||||
}
|
||||
}
|
||||
|
||||
class mapScreenOptionsTable(mapEditorScreen: MapEditorScreen):PopupTable(mapEditorScreen){
|
||||
class NewMapScreen:PickerScreen(){
|
||||
init{
|
||||
val mapNameEditor = TextField(mapEditorScreen.mapName, CameraStageBaseScreen.skin)
|
||||
mapNameEditor.addListener{ mapEditorScreen.mapName=mapNameEditor.text; true }
|
||||
add(mapNameEditor).row()
|
||||
|
||||
val saveMapButton = TextButton("Save".tr(), CameraStageBaseScreen.skin)
|
||||
saveMapButton.onClick {
|
||||
GameSaver().saveMap(mapEditorScreen.mapName,mapEditorScreen.tileMap)
|
||||
UnCivGame.Current.setWorldScreen()
|
||||
}
|
||||
add(saveMapButton).row()
|
||||
|
||||
val loadMapButton = TextButton("Load".tr(),CameraStageBaseScreen.skin)
|
||||
loadMapButton.onClick { MapScreenLoadTable(mapEditorScreen); remove() }
|
||||
add(loadMapButton).row()
|
||||
|
||||
val closeOptionsButtton = TextButton("Close".tr(), CameraStageBaseScreen.skin)
|
||||
closeOptionsButtton.onClick { remove() }
|
||||
add(closeOptionsButtton).row()
|
||||
|
||||
open()
|
||||
}
|
||||
}
|
||||
|
||||
class MapScreenLoadTable(mapEditorScreen: MapEditorScreen):PopupTable(mapEditorScreen){
|
||||
init{
|
||||
val mapFileSelectBox = SelectBox<String>(CameraStageBaseScreen.skin)
|
||||
val mapNames = Array<String>()
|
||||
for (mapName in GameSaver().getMaps()) mapNames.add(mapName)
|
||||
mapFileSelectBox.items = mapNames
|
||||
add(mapFileSelectBox).row()
|
||||
|
||||
val loadMapButton = TextButton("Load".tr(),CameraStageBaseScreen.skin)
|
||||
loadMapButton.onClick {
|
||||
UnCivGame.Current.screen = MapEditorScreen(mapFileSelectBox.selected)
|
||||
}
|
||||
add(loadMapButton).row()
|
||||
|
||||
val closeOptionsButtton = TextButton("Close".tr(), CameraStageBaseScreen.skin)
|
||||
closeOptionsButtton.onClick { remove() }
|
||||
add(closeOptionsButtton).row()
|
||||
|
||||
open()
|
||||
}
|
||||
}
|
33
core/src/com/unciv/ui/mapeditor/MapScreenLoadTable.kt
Normal file
33
core/src/com/unciv/ui/mapeditor/MapScreenLoadTable.kt
Normal file
@ -0,0 +1,33 @@
|
||||
package com.unciv.ui.mapeditor
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.badlogic.gdx.utils.Array
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.logic.GameSaver
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.onClick
|
||||
import com.unciv.ui.worldscreen.optionstable.PopupTable
|
||||
|
||||
class MapScreenLoadTable(mapEditorScreen: MapEditorScreen): PopupTable(mapEditorScreen){
|
||||
init{
|
||||
val mapFileSelectBox = SelectBox<String>(CameraStageBaseScreen.skin)
|
||||
val mapNames = Array<String>()
|
||||
for (mapName in GameSaver().getMaps()) mapNames.add(mapName)
|
||||
mapFileSelectBox.items = mapNames
|
||||
add(mapFileSelectBox).row()
|
||||
|
||||
val loadMapButton = TextButton("Load".tr(), CameraStageBaseScreen.skin)
|
||||
loadMapButton.onClick {
|
||||
UnCivGame.Current.screen = MapEditorScreen(mapFileSelectBox.selected)
|
||||
}
|
||||
add(loadMapButton).row()
|
||||
|
||||
val closeOptionsButtton = TextButton("Close".tr(), CameraStageBaseScreen.skin)
|
||||
closeOptionsButtton.onClick { remove() }
|
||||
add(closeOptionsButtton).row()
|
||||
|
||||
open()
|
||||
}
|
||||
}
|
35
core/src/com/unciv/ui/mapeditor/MapScreenOptionsTable.kt
Normal file
35
core/src/com/unciv/ui/mapeditor/MapScreenOptionsTable.kt
Normal file
@ -0,0 +1,35 @@
|
||||
package com.unciv.ui.mapeditor
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextField
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.logic.GameSaver
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.ui.utils.CameraStageBaseScreen
|
||||
import com.unciv.ui.utils.onClick
|
||||
import com.unciv.ui.worldscreen.optionstable.PopupTable
|
||||
|
||||
class MapScreenOptionsTable(mapEditorScreen: MapEditorScreen): PopupTable(mapEditorScreen){
|
||||
init{
|
||||
val mapNameEditor = TextField(mapEditorScreen.mapName, CameraStageBaseScreen.skin)
|
||||
mapNameEditor.addListener{ mapEditorScreen.mapName=mapNameEditor.text; true }
|
||||
add(mapNameEditor).row()
|
||||
|
||||
val saveMapButton = TextButton("Save".tr(), CameraStageBaseScreen.skin)
|
||||
saveMapButton.onClick {
|
||||
GameSaver().saveMap(mapEditorScreen.mapName,mapEditorScreen.tileMap)
|
||||
UnCivGame.Current.setWorldScreen()
|
||||
}
|
||||
add(saveMapButton).row()
|
||||
|
||||
val loadMapButton = TextButton("Load".tr(), CameraStageBaseScreen.skin)
|
||||
loadMapButton.onClick { MapScreenLoadTable(mapEditorScreen); remove() }
|
||||
add(loadMapButton).row()
|
||||
|
||||
val closeOptionsButtton = TextButton("Close".tr(), CameraStageBaseScreen.skin)
|
||||
closeOptionsButtton.onClick { remove() }
|
||||
add(closeOptionsButtton).row()
|
||||
|
||||
open()
|
||||
}
|
||||
}
|
@ -56,7 +56,6 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
|
||||
fun simulateBattle(attacker: ICombatant, defender: ICombatant){
|
||||
clear()
|
||||
defaults().pad(5f)
|
||||
println("debuglog simulateBattle")
|
||||
|
||||
val attackerNameWrapper = Table()
|
||||
val attackerLabel = Label(attacker.getName(), skin)
|
||||
|
@ -3,7 +3,6 @@ package com.unciv.ui.worldscreen.bottombar
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.Touchable
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.unciv.logic.city.CityInfo
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.ui.utils.ImageGetter
|
||||
import com.unciv.ui.worldscreen.WorldScreen
|
||||
@ -16,7 +15,7 @@ class WorldScreenBottomBar(val worldScreen: WorldScreen) : Table(){
|
||||
|
||||
init {
|
||||
touchable= Touchable.enabled
|
||||
add(unitTable).width(worldScreen.stage.width/3)
|
||||
add(unitTable).width(worldScreen.stage.width/3).fill()
|
||||
add(battleTable).width(worldScreen.stage.width/3).fill() // so that background fills entire middle third
|
||||
add(tileInfoTable).width(worldScreen.stage.width/3).fill()
|
||||
|
||||
|
@ -3,7 +3,7 @@ package com.unciv.ui.worldscreen.optionstable
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.ui.CivilopediaScreen
|
||||
import com.unciv.ui.MapEditorScreen
|
||||
import com.unciv.ui.mapeditor.MapEditorScreen
|
||||
import com.unciv.ui.NewGameScreen
|
||||
import com.unciv.ui.VictoryScreen
|
||||
import com.unciv.ui.pickerscreens.PolicyPickerScreen
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.unciv.ui.worldscreen.unit
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.scenes.scene2d.Touchable
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
@ -22,6 +24,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
||||
var selectedCity : CityInfo? = null
|
||||
var currentlyExecutingAction : String? = null
|
||||
var lastSelectedCityButton : Boolean = false
|
||||
val deselectUnitButton = Table()
|
||||
|
||||
// This is so that not on every update(), we will update the unit table.
|
||||
// Most of the time it's the same unit with the same stats so why waste precious time?
|
||||
@ -40,6 +43,12 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
||||
separator= addSeparator().actor!!
|
||||
add(promotionsTable).colspan(2).row()
|
||||
add(unitDescriptionTable)
|
||||
|
||||
deselectUnitButton.add(Label("X",CameraStageBaseScreen.skin).setFontColor(Color.WHITE)).pad(20f)
|
||||
deselectUnitButton.pack()
|
||||
deselectUnitButton.touchable = Touchable.enabled
|
||||
deselectUnitButton.onClick { selectedUnit=null; selectedCity=null; worldScreen.shouldUpdate=true }
|
||||
addActor(deselectUnitButton)
|
||||
}
|
||||
|
||||
fun update() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user