CityButton: render units in front (#784)
* CityButton: render units in front * First click on single button: move down. Second click: open city screen.
This commit is contained in:
parent
4a97d3ea18
commit
db6e2faff8
3 changed files with 8 additions and 13 deletions
|
@ -41,17 +41,16 @@ class CityButton(val city: CityInfo, internal val tileGroup: WorldTileGroup, ski
|
|||
touchable = Touchable.enabled
|
||||
label.touchable = Touchable.enabled
|
||||
|
||||
// clicking on the button swings the button a little down to allow selection of units there.
|
||||
// clicking swings the button a little down to allow selection of units there.
|
||||
// this also allows to target selected units to move to the city tile from elsewhere.
|
||||
// second tap on the button will go to the city screen
|
||||
onClick {
|
||||
if (!isButtonMoved) {
|
||||
moveButtonDown()
|
||||
if (unitTable.selectedUnit == null || unitTable.selectedUnit!!.currentMovement == 0f)
|
||||
tileGroup.selectCity(city)
|
||||
|
||||
} else {
|
||||
if (isButtonMoved) {
|
||||
UnCivGame.Current.screen = CityScreen(city)
|
||||
} else {
|
||||
moveButtonDown()
|
||||
if (unitTable.selectedUnit == null || unitTable.selectedUnit!!.currentMovement==0f)
|
||||
tileGroup.selectCity(city)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,8 +48,8 @@ class TileGroupMap<T: TileGroup>(val tileGroups:Collection<T>, padding:Float): G
|
|||
for(group in miscLayers) addActor(group)
|
||||
for(group in circleCrosshairFogLayers) addActor(group)
|
||||
for(group in tileGroups) addActor(group) // The above layers are for the visual layers, this is for the clickability
|
||||
for(group in unitLayers) addActor(group) // Aaand units above everything else.
|
||||
for(group in cityButtonLayers) addActor(group) // city buttons clickability
|
||||
for(group in unitLayers) addActor(group) // Aaand units above everything else.
|
||||
|
||||
|
||||
// there are tiles "below the zero",
|
||||
|
|
|
@ -181,18 +181,14 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||
|
||||
fun citySelected(cityInfo: CityInfo) : Boolean {
|
||||
if (cityInfo == selectedCity) return false
|
||||
lastSelectedCityButton = true
|
||||
selectedCity = cityInfo
|
||||
selectedUnit = null
|
||||
selectedUnitHasChanged = true
|
||||
worldScreen.shouldUpdate = true
|
||||
return true
|
||||
}
|
||||
|
||||
fun tileSelected(selectedTile: TileInfo) {
|
||||
if (lastSelectedCityButton) {
|
||||
lastSelectedCityButton = false
|
||||
return
|
||||
}
|
||||
|
||||
val previouslySelectedUnit = selectedUnit
|
||||
if(currentlyExecutingAction=="moveTo"){
|
||||
|
|
Loading…
Reference in a new issue