mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-30 15:30:43 -04:00
move the tile table to the top of the min-map, delete the bottom bar, the size of the unit table can be changed according to resolution, especially about 900*600. (#1207)
* update * update * update * update * update
This commit is contained in:
parent
7aa55f8024
commit
6d1edd67e0
@ -87,7 +87,7 @@ class CityScreenCityPickerTable(val cityScreen: CityScreen) : Table(){
|
|||||||
val game = cityScreen.game
|
val game = cityScreen.game
|
||||||
game.setWorldScreen()
|
game.setWorldScreen()
|
||||||
game.worldScreen.tileMapHolder.setCenterPosition(city.location)
|
game.worldScreen.tileMapHolder.setCenterPosition(city.location)
|
||||||
game.worldScreen.bottomBar.unitTable.selectedUnit=null
|
game.worldScreen.bottomUnitTable.selectedUnit=null
|
||||||
}
|
}
|
||||||
|
|
||||||
add(exitCityButton).pad(10f).colspan(columns)
|
add(exitCityButton).pad(10f).colspan(columns)
|
||||||
|
@ -61,7 +61,7 @@ class CityButton(val city: CityInfo, internal val tileGroup: WorldTileGroup, ski
|
|||||||
|
|
||||||
private fun setButtonActions() {
|
private fun setButtonActions() {
|
||||||
|
|
||||||
val unitTable = tileGroup.worldScreen.bottomBar.unitTable
|
val unitTable = tileGroup.worldScreen.bottomUnitTable
|
||||||
if (UnCivGame.Current.viewEntireMapForDebug || belongsToViewingCiv()) {
|
if (UnCivGame.Current.viewEntireMapForDebug || belongsToViewingCiv()) {
|
||||||
|
|
||||||
// So you can click anywhere on the button to go to the city
|
// So you can click anywhere on the button to go to the city
|
||||||
|
@ -68,6 +68,6 @@ class WorldTileGroup(internal val worldScreen: WorldScreen, tileInfo: TileInfo,
|
|||||||
|
|
||||||
fun selectCity(city: CityInfo?) : Boolean {
|
fun selectCity(city: CityInfo?) : Boolean {
|
||||||
if (city == null) return false
|
if (city == null) return false
|
||||||
return worldScreen.bottomBar.unitTable.citySelected(city)
|
return worldScreen.bottomUnitTable.citySelected(city)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -80,7 +80,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||||||
|
|
||||||
override fun zoom(event: InputEvent?, initialDistance: Float, distance: Float) {
|
override fun zoom(event: InputEvent?, initialDistance: Float, distance: Float) {
|
||||||
// deselect any unit, as zooming occasionally forwards clicks on to the map
|
// deselect any unit, as zooming occasionally forwards clicks on to the map
|
||||||
worldScreen.bottomBar.unitTable.selectedUnit = null
|
worldScreen.bottomUnitTable.selectedUnit = null
|
||||||
if (lastInitialDistance != initialDistance) {
|
if (lastInitialDistance != initialDistance) {
|
||||||
lastInitialDistance = initialDistance
|
lastInitialDistance = initialDistance
|
||||||
lastScale = scaleX
|
lastScale = scaleX
|
||||||
@ -100,7 +100,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||||||
unitActionOverlay?.remove()
|
unitActionOverlay?.remove()
|
||||||
selectedTile = tileInfo
|
selectedTile = tileInfo
|
||||||
|
|
||||||
val unitTable = worldScreen.bottomBar.unitTable
|
val unitTable = worldScreen.bottomUnitTable
|
||||||
val previousSelectedUnit = unitTable.selectedUnit
|
val previousSelectedUnit = unitTable.selectedUnit
|
||||||
val previousSelectedCity = unitTable.selectedCity
|
val previousSelectedCity = unitTable.selectedCity
|
||||||
unitTable.tileSelected(tileInfo)
|
unitTable.tileSelected(tileInfo)
|
||||||
@ -143,7 +143,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.movement.headTowards(tileInfo)
|
selectedUnit.movement.headTowards(tileInfo)
|
||||||
worldScreen.bottomBar.unitTable.selectedUnit = selectedUnit // keep moved unit selected
|
worldScreen.bottomUnitTable.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)
|
||||||
@ -167,8 +167,8 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||||||
if (unit.currentMovement == 0f) unitGroup.color.a = 0.5f
|
if (unit.currentMovement == 0f) unitGroup.color.a = 0.5f
|
||||||
unitGroup.touchable = Touchable.enabled
|
unitGroup.touchable = Touchable.enabled
|
||||||
unitGroup.onClick {
|
unitGroup.onClick {
|
||||||
worldScreen.bottomBar.unitTable.selectedUnit = unit
|
worldScreen.bottomUnitTable.selectedUnit = unit
|
||||||
worldScreen.bottomBar.unitTable.selectedCity = null
|
worldScreen.bottomUnitTable.selectedCity = null
|
||||||
worldScreen.shouldUpdate = true
|
worldScreen.shouldUpdate = true
|
||||||
unitActionOverlay?.remove()
|
unitActionOverlay?.remove()
|
||||||
}
|
}
|
||||||
@ -211,8 +211,8 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||||||
|
|
||||||
unitActionOverlay?.remove()
|
unitActionOverlay?.remove()
|
||||||
selectedTile = tileInfo
|
selectedTile = tileInfo
|
||||||
val selectedUnit = worldScreen.bottomBar.unitTable.selectedUnit
|
val selectedUnit = worldScreen.bottomUnitTable.selectedUnit
|
||||||
worldScreen.bottomBar.unitTable.tileSelected(tileInfo)
|
worldScreen.bottomUnitTable.tileSelected(tileInfo)
|
||||||
worldScreen.shouldUpdate = true
|
worldScreen.shouldUpdate = true
|
||||||
|
|
||||||
if (selectedUnit != null) {
|
if (selectedUnit != null) {
|
||||||
@ -256,7 +256,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||||||
tileGroup.showCircle(Color.RED) // Display ALL viewable enemies with a red circle so that users don't need to go "hunting" for enemy units
|
tileGroup.showCircle(Color.RED) // Display ALL viewable enemies with a red circle so that users don't need to go "hunting" for enemy units
|
||||||
}
|
}
|
||||||
|
|
||||||
val unitTable = worldScreen.bottomBar.unitTable
|
val unitTable = worldScreen.bottomUnitTable
|
||||||
when {
|
when {
|
||||||
unitTable.selectedCity!=null -> {
|
unitTable.selectedCity!=null -> {
|
||||||
val city = unitTable.selectedCity!!
|
val city = unitTable.selectedCity!!
|
||||||
@ -331,7 +331,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
|
|||||||
val tileGroup = tileGroups.values.first { it.tileInfo.position == vector }
|
val tileGroup = tileGroups.values.first { it.tileInfo.position == vector }
|
||||||
selectedTile = tileGroup.tileInfo
|
selectedTile = tileGroup.tileInfo
|
||||||
if(selectUnit)
|
if(selectUnit)
|
||||||
worldScreen.bottomBar.unitTable.tileSelected(selectedTile!!)
|
worldScreen.bottomUnitTable.tileSelected(selectedTile!!)
|
||||||
|
|
||||||
val originalScrollX = scrollX
|
val originalScrollX = scrollX
|
||||||
val originalScrollY = scrollY
|
val originalScrollY = scrollY
|
||||||
|
@ -26,10 +26,11 @@ import com.unciv.ui.pickerscreens.TechPickerScreen
|
|||||||
import com.unciv.ui.trade.DiplomacyScreen
|
import com.unciv.ui.trade.DiplomacyScreen
|
||||||
import com.unciv.ui.utils.*
|
import com.unciv.ui.utils.*
|
||||||
import com.unciv.ui.worldscreen.bottombar.BattleTable
|
import com.unciv.ui.worldscreen.bottombar.BattleTable
|
||||||
import com.unciv.ui.worldscreen.bottombar.WorldScreenBottomBar
|
import com.unciv.ui.worldscreen.bottombar.TileInfoTable
|
||||||
import com.unciv.ui.worldscreen.optionstable.OnlineMultiplayer
|
import com.unciv.ui.worldscreen.optionstable.OnlineMultiplayer
|
||||||
import com.unciv.ui.worldscreen.optionstable.PopupTable
|
import com.unciv.ui.worldscreen.optionstable.PopupTable
|
||||||
import com.unciv.ui.worldscreen.unit.UnitActionsTable
|
import com.unciv.ui.worldscreen.unit.UnitActionsTable
|
||||||
|
import com.unciv.ui.worldscreen.unit.UnitTable
|
||||||
import kotlin.concurrent.thread
|
import kotlin.concurrent.thread
|
||||||
|
|
||||||
class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||||
@ -41,7 +42,8 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
val minimapWrapper = MinimapHolder(tileMapHolder)
|
val minimapWrapper = MinimapHolder(tileMapHolder)
|
||||||
|
|
||||||
private val topBar = WorldScreenTopBar(this)
|
private val topBar = WorldScreenTopBar(this)
|
||||||
val bottomBar = WorldScreenBottomBar(this)
|
val bottomUnitTable = UnitTable(this)
|
||||||
|
val bottomTileInfoTable = TileInfoTable(this)
|
||||||
val battleTable = BattleTable(this)
|
val battleTable = BattleTable(this)
|
||||||
val unitActionsTable = UnitActionsTable(this)
|
val unitActionsTable = UnitActionsTable(this)
|
||||||
|
|
||||||
@ -90,10 +92,8 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
|
|
||||||
diplomacyButtonWrapper.defaults().pad(5f)
|
diplomacyButtonWrapper.defaults().pad(5f)
|
||||||
stage.addActor(diplomacyButtonWrapper)
|
stage.addActor(diplomacyButtonWrapper)
|
||||||
|
stage.addActor(bottomUnitTable)
|
||||||
bottomBar.width = stage.width
|
stage.addActor(bottomTileInfoTable)
|
||||||
stage.addActor(bottomBar)
|
|
||||||
|
|
||||||
battleTable.width = stage.width/3
|
battleTable.width = stage.width/3
|
||||||
battleTable.x = stage.width/3
|
battleTable.x = stage.width/3
|
||||||
stage.addActor(battleTable)
|
stage.addActor(battleTable)
|
||||||
@ -160,14 +160,15 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
|
|
||||||
displayTutorialsOnUpdate()
|
displayTutorialsOnUpdate()
|
||||||
|
|
||||||
bottomBar.update(tileMapHolder.selectedTile) // has to come before tilemapholder update because the tilemapholder actions depend on the selected unit!
|
bottomUnitTable.update()
|
||||||
|
bottomTileInfoTable.updateTileTable(tileMapHolder.selectedTile!!)
|
||||||
|
bottomTileInfoTable.x=stage.width-bottomTileInfoTable.width
|
||||||
|
bottomTileInfoTable.y=if(UnCivGame.Current.settings.showMinimap)minimapWrapper.height else 0f
|
||||||
battleTable.update()
|
battleTable.update()
|
||||||
|
|
||||||
minimapWrapper.update(viewingCiv)
|
minimapWrapper.update(viewingCiv)
|
||||||
minimapWrapper.y = bottomBar.height // couldn't be bothered to create a separate val for minimap wrapper
|
unitActionsTable.update(bottomUnitTable.selectedUnit)
|
||||||
|
unitActionsTable.y = bottomUnitTable.height
|
||||||
unitActionsTable.update(bottomBar.unitTable.selectedUnit)
|
|
||||||
unitActionsTable.y = bottomBar.unitTable.height
|
|
||||||
|
|
||||||
// if we use the clone, then when we update viewable tiles
|
// if we use the clone, then when we update viewable tiles
|
||||||
// it doesn't update the explored tiles of the civ... need to think about that harder
|
// it doesn't update the explored tiles of the civ... need to think about that harder
|
||||||
@ -207,7 +208,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
UnCivGame.Current.settings.save()
|
UnCivGame.Current.settings.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bottomBar.unitTable.selectedUnit != null) displayTutorials("Unit_Selected")
|
if (bottomUnitTable.selectedUnit != null) displayTutorials("Unit_Selected")
|
||||||
if (viewingCiv.cities.isNotEmpty()){
|
if (viewingCiv.cities.isNotEmpty()){
|
||||||
displayTutorials("_City_Founded")
|
displayTutorials("_City_Founded")
|
||||||
displayTutorials("First_Steps")
|
displayTutorials("First_Steps")
|
||||||
@ -290,7 +291,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
|||||||
val nextDueUnit = viewingCiv.getNextDueUnit()
|
val nextDueUnit = viewingCiv.getNextDueUnit()
|
||||||
if(nextDueUnit!=null) {
|
if(nextDueUnit!=null) {
|
||||||
tileMapHolder.setCenterPosition(nextDueUnit.currentTile.position, false, false)
|
tileMapHolder.setCenterPosition(nextDueUnit.currentTile.position, false, false)
|
||||||
bottomBar.unitTable.selectedUnit = nextDueUnit
|
bottomUnitTable.selectedUnit = nextDueUnit
|
||||||
shouldUpdate=true
|
shouldUpdate=true
|
||||||
}
|
}
|
||||||
return@onClick
|
return@onClick
|
||||||
|
@ -34,7 +34,7 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun update() {
|
fun update() {
|
||||||
val unitTable = worldScreen.bottomBar.unitTable
|
val unitTable = worldScreen.bottomUnitTable
|
||||||
val attacker : ICombatant?
|
val attacker : ICombatant?
|
||||||
if (unitTable.selectedUnit != null
|
if (unitTable.selectedUnit != null
|
||||||
&& !unitTable.selectedUnit!!.type.isCivilian()) {
|
&& !unitTable.selectedUnit!!.type.isCivilian()) {
|
||||||
|
@ -19,26 +19,22 @@ class TileInfoTable(private val worldScreen: WorldScreen) : Table(CameraStageBas
|
|||||||
internal fun updateTileTable(tile: TileInfo) {
|
internal fun updateTileTable(tile: TileInfo) {
|
||||||
clearChildren()
|
clearChildren()
|
||||||
val civInfo = worldScreen.viewingCiv
|
val civInfo = worldScreen.viewingCiv
|
||||||
columnDefaults(0).padRight(10f)
|
|
||||||
|
|
||||||
if (UnCivGame.Current.viewEntireMapForDebug || civInfo.exploredTiles.contains(tile.position)) {
|
if (UnCivGame.Current.viewEntireMapForDebug || civInfo.exploredTiles.contains(tile.position)) {
|
||||||
add(getStatsTable(tile)).pad(10f)
|
add(getStatsTable(tile))
|
||||||
add(tile.toString().toLabel()).colspan(2)
|
add(tile.toString().toLabel()).colspan(2).pad(10f)
|
||||||
}
|
}
|
||||||
|
|
||||||
pack()
|
pack()
|
||||||
|
|
||||||
setPosition(worldScreen.stage.width - 10f - width, 10f)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getStatsTable(tile: TileInfo):Table{
|
fun getStatsTable(tile: TileInfo):Table{
|
||||||
val table=Table()
|
val table=Table()
|
||||||
table.pad(10f)
|
|
||||||
table.defaults().pad(2f)
|
table.defaults().pad(2f)
|
||||||
|
|
||||||
for (entry in tile.getTileStats(worldScreen.viewingCiv).toHashMap().filterNot { it.value == 0f }) {
|
for (entry in tile.getTileStats(worldScreen.viewingCiv).toHashMap().filterNot { it.value == 0f||it.key.toString() == "" }) {
|
||||||
table.add(ImageGetter.getStatIcon(entry.key.toString())).size(20f).align(Align.right)
|
table.add(ImageGetter.getStatIcon(entry.key.toString())).size(20f).align(Align.right)
|
||||||
table.add(Label(entry.value.toInt().toString(), skin)).align(Align.left)
|
table.add(Label(entry.value.toInt().toString(), skin)).align(Align.left).padRight(10f)
|
||||||
table.row()
|
table.row()
|
||||||
}
|
}
|
||||||
return table
|
return table
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
package com.unciv.ui.worldscreen.bottombar
|
|
||||||
|
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
|
||||||
import com.unciv.logic.map.TileInfo
|
|
||||||
import com.unciv.ui.worldscreen.WorldScreen
|
|
||||||
import com.unciv.ui.worldscreen.unit.UnitTable
|
|
||||||
|
|
||||||
class WorldScreenBottomBar(val worldScreen: WorldScreen) : Table(){
|
|
||||||
val unitTable = UnitTable(worldScreen)
|
|
||||||
val tileInfoTable = TileInfoTable(worldScreen)
|
|
||||||
|
|
||||||
init {
|
|
||||||
add(unitTable).width(worldScreen.stage.width/3).bottom().fillX()
|
|
||||||
add().width(worldScreen.stage.width/3) // empty space for the battle table
|
|
||||||
add(tileInfoTable).width(worldScreen.stage.width/3).fill()
|
|
||||||
|
|
||||||
pack()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun update(selectedTile: TileInfo?){
|
|
||||||
unitTable.update()
|
|
||||||
if(selectedTile!=null) tileInfoTable.updateTileTable(selectedTile)
|
|
||||||
pack()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -28,7 +28,7 @@ class UnitActions {
|
|||||||
|
|
||||||
fun getUnitActions(unit:MapUnit,worldScreen: WorldScreen): List<UnitAction> {
|
fun getUnitActions(unit:MapUnit,worldScreen: WorldScreen): List<UnitAction> {
|
||||||
val tile = unit.getTile()
|
val tile = unit.getTile()
|
||||||
val unitTable = worldScreen.bottomBar.unitTable
|
val unitTable = worldScreen.bottomUnitTable
|
||||||
val actionList = ArrayList<UnitAction>()
|
val actionList = ArrayList<UnitAction>()
|
||||||
|
|
||||||
if(unit.action!=null && unit.action!!.startsWith("moveTo")) {
|
if(unit.action!=null && unit.action!!.startsWith("moveTo")) {
|
||||||
|
@ -74,7 +74,7 @@ class UnitContextMenu(val tileMapHolder: TileMapHolder, val selectedUnit: MapUni
|
|||||||
if (selectedUnit.currentTile != targetTile)
|
if (selectedUnit.currentTile != targetTile)
|
||||||
selectedUnit.action = "moveTo " + targetTile.position.x.toInt() + "," + targetTile.position.y.toInt()
|
selectedUnit.action = "moveTo " + targetTile.position.x.toInt() + "," + targetTile.position.y.toInt()
|
||||||
if (selectedUnit.currentMovement > 0) {
|
if (selectedUnit.currentMovement > 0) {
|
||||||
tileMapHolder.worldScreen.bottomBar.unitTable.selectedUnit = selectedUnit
|
tileMapHolder.worldScreen.bottomUnitTable.selectedUnit = selectedUnit
|
||||||
}
|
}
|
||||||
|
|
||||||
// we don't update it directly because we're on a different thread; instead, we tell it to update itself
|
// we don't update it directly because we're on a different thread; instead, we tell it to update itself
|
||||||
|
@ -61,13 +61,12 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||||||
|
|
||||||
}).left()
|
}).left()
|
||||||
|
|
||||||
add(prevIdleUnitButton)
|
|
||||||
|
|
||||||
add(Table().apply {
|
add(Table().apply {
|
||||||
add(Table().apply {
|
add(Table().apply {
|
||||||
|
add(prevIdleUnitButton)
|
||||||
add(unitIconHolder)
|
add(unitIconHolder)
|
||||||
add(unitNameLabel).pad(5f)
|
add(unitNameLabel).pad(5f)
|
||||||
|
add(nextIdleUnitButton)
|
||||||
}).colspan(2).fill().row()
|
}).colspan(2).fill().row()
|
||||||
separator= addSeparator().actor!!
|
separator= addSeparator().actor!!
|
||||||
add(promotionsTable).colspan(2).row()
|
add(promotionsTable).colspan(2).row()
|
||||||
@ -80,8 +79,6 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||||||
}
|
}
|
||||||
}).expand()
|
}).expand()
|
||||||
|
|
||||||
add(nextIdleUnitButton)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun update() {
|
fun update() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user