mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 22:37:02 -04:00
Fixed switching unit selection bug - #804
This commit is contained in:
parent
a67fc9d55d
commit
9352243eb4
@ -21,8 +21,8 @@ android {
|
|||||||
applicationId "com.unciv.app"
|
applicationId "com.unciv.app"
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode 246
|
versionCode 247
|
||||||
versionName "2.16.9"
|
versionName "2.16.10"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Had to add this crap for Travis to build, it wanted to sign the app
|
// Had to add this crap for Travis to build, it wanted to sign the app
|
||||||
|
@ -89,17 +89,17 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||||||
unitActionOverlay?.remove()
|
unitActionOverlay?.remove()
|
||||||
selectedTile = tileInfo
|
selectedTile = tileInfo
|
||||||
|
|
||||||
val selectedUnit = worldScreen.bottomBar.unitTable.selectedUnit
|
val previousSelectedUnit = worldScreen.bottomBar.unitTable.selectedUnit
|
||||||
worldScreen.bottomBar.unitTable.tileSelected(tileInfo)
|
worldScreen.bottomBar.unitTable.tileSelected(tileInfo)
|
||||||
|
val newSelectedUnit = worldScreen.bottomBar.unitTable.selectedUnit
|
||||||
|
|
||||||
if (selectedUnit != null && selectedUnit.getTile() != tileInfo
|
if (previousSelectedUnit != null && previousSelectedUnit.getTile() != tileInfo
|
||||||
&& selectedUnit.canMoveTo(tileInfo) && selectedUnit.movementAlgs().canReach(tileInfo)) {
|
&& previousSelectedUnit.canMoveTo(tileInfo) && previousSelectedUnit.movementAlgs().canReach(tileInfo)) {
|
||||||
// this can take a long time, because of the unit-to-tile calculation needed, so we put it in a different thread
|
// this can take a long time, because of the unit-to-tile calculation needed, so we put it in a different thread
|
||||||
moveHere(selectedUnit, tileInfo)
|
moveHere(previousSelectedUnit, tileInfo)
|
||||||
worldScreen.bottomBar.unitTable.selectedUnit = selectedUnit // keep moved unit selected
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(selectedUnit==null || selectedUnit.type==UnitType.Civilian){
|
if(newSelectedUnit==null || newSelectedUnit.type==UnitType.Civilian){
|
||||||
val unitsInTile = selectedTile!!.getUnits()
|
val unitsInTile = selectedTile!!.getUnits()
|
||||||
if(unitsInTile.isNotEmpty() && unitsInTile.first().civInfo.isAtWarWith(worldScreen.currentPlayerCiv)){
|
if(unitsInTile.isNotEmpty() && unitsInTile.first().civInfo.isAtWarWith(worldScreen.currentPlayerCiv)){
|
||||||
// try to select the closest city to bombard this guy
|
// try to select the closest city to bombard this guy
|
||||||
@ -127,6 +127,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||||||
if(UnCivGame.Current.settings.singleTapMove && turnsToGetThere==1) {
|
if(UnCivGame.Current.settings.singleTapMove && turnsToGetThere==1) {
|
||||||
// single turn instant move
|
// single turn instant move
|
||||||
selectedUnit.movementAlgs().headTowards(tileInfo)
|
selectedUnit.movementAlgs().headTowards(tileInfo)
|
||||||
|
worldScreen.bottomBar.unitTable.selectedUnit = selectedUnit // keep moved unit selected
|
||||||
} else {
|
} else {
|
||||||
// add "move to" button
|
// add "move to" button
|
||||||
val moveHereButtonDto = MoveHereButtonDto(selectedUnit, tileInfo, turnsToGetThere)
|
val moveHereButtonDto = MoveHereButtonDto(selectedUnit, tileInfo, turnsToGetThere)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user