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:
lishaoxia1985 2019-10-18 21:22:38 +08:00 committed by Yair Morgenstern
parent 7aa55f8024
commit 6d1edd67e0
11 changed files with 35 additions and 67 deletions

View file

@ -87,7 +87,7 @@ class CityScreenCityPickerTable(val cityScreen: CityScreen) : Table(){
val game = cityScreen.game
game.setWorldScreen()
game.worldScreen.tileMapHolder.setCenterPosition(city.location)
game.worldScreen.bottomBar.unitTable.selectedUnit=null
game.worldScreen.bottomUnitTable.selectedUnit=null
}
add(exitCityButton).pad(10f).colspan(columns)

View file

@ -61,7 +61,7 @@ class CityButton(val city: CityInfo, internal val tileGroup: WorldTileGroup, ski
private fun setButtonActions() {
val unitTable = tileGroup.worldScreen.bottomBar.unitTable
val unitTable = tileGroup.worldScreen.bottomUnitTable
if (UnCivGame.Current.viewEntireMapForDebug || belongsToViewingCiv()) {
// So you can click anywhere on the button to go to the city

View file

@ -68,6 +68,6 @@ class WorldTileGroup(internal val worldScreen: WorldScreen, tileInfo: TileInfo,
fun selectCity(city: CityInfo?) : Boolean {
if (city == null) return false
return worldScreen.bottomBar.unitTable.citySelected(city)
return worldScreen.bottomUnitTable.citySelected(city)
}
}

View file

@ -80,7 +80,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
override fun zoom(event: InputEvent?, initialDistance: Float, distance: Float) {
// deselect any unit, as zooming occasionally forwards clicks on to the map
worldScreen.bottomBar.unitTable.selectedUnit = null
worldScreen.bottomUnitTable.selectedUnit = null
if (lastInitialDistance != initialDistance) {
lastInitialDistance = initialDistance
lastScale = scaleX
@ -100,7 +100,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
unitActionOverlay?.remove()
selectedTile = tileInfo
val unitTable = worldScreen.bottomBar.unitTable
val unitTable = worldScreen.bottomUnitTable
val previousSelectedUnit = unitTable.selectedUnit
val previousSelectedCity = unitTable.selectedCity
unitTable.tileSelected(tileInfo)
@ -143,7 +143,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
if(UnCivGame.Current.settings.singleTapMove && turnsToGetThere==1) {
// single turn instant move
selectedUnit.movement.headTowards(tileInfo)
worldScreen.bottomBar.unitTable.selectedUnit = selectedUnit // keep moved unit selected
worldScreen.bottomUnitTable.selectedUnit = selectedUnit // keep moved unit selected
} else {
// add "move to" button
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
unitGroup.touchable = Touchable.enabled
unitGroup.onClick {
worldScreen.bottomBar.unitTable.selectedUnit = unit
worldScreen.bottomBar.unitTable.selectedCity = null
worldScreen.bottomUnitTable.selectedUnit = unit
worldScreen.bottomUnitTable.selectedCity = null
worldScreen.shouldUpdate = true
unitActionOverlay?.remove()
}
@ -211,8 +211,8 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
unitActionOverlay?.remove()
selectedTile = tileInfo
val selectedUnit = worldScreen.bottomBar.unitTable.selectedUnit
worldScreen.bottomBar.unitTable.tileSelected(tileInfo)
val selectedUnit = worldScreen.bottomUnitTable.selectedUnit
worldScreen.bottomUnitTable.tileSelected(tileInfo)
worldScreen.shouldUpdate = true
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
}
val unitTable = worldScreen.bottomBar.unitTable
val unitTable = worldScreen.bottomUnitTable
when {
unitTable.selectedCity!=null -> {
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 }
selectedTile = tileGroup.tileInfo
if(selectUnit)
worldScreen.bottomBar.unitTable.tileSelected(selectedTile!!)
worldScreen.bottomUnitTable.tileSelected(selectedTile!!)
val originalScrollX = scrollX
val originalScrollY = scrollY

View file

@ -26,10 +26,11 @@ import com.unciv.ui.pickerscreens.TechPickerScreen
import com.unciv.ui.trade.DiplomacyScreen
import com.unciv.ui.utils.*
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.PopupTable
import com.unciv.ui.worldscreen.unit.UnitActionsTable
import com.unciv.ui.worldscreen.unit.UnitTable
import kotlin.concurrent.thread
class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
@ -41,7 +42,8 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
val minimapWrapper = MinimapHolder(tileMapHolder)
private val topBar = WorldScreenTopBar(this)
val bottomBar = WorldScreenBottomBar(this)
val bottomUnitTable = UnitTable(this)
val bottomTileInfoTable = TileInfoTable(this)
val battleTable = BattleTable(this)
val unitActionsTable = UnitActionsTable(this)
@ -90,10 +92,8 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
diplomacyButtonWrapper.defaults().pad(5f)
stage.addActor(diplomacyButtonWrapper)
bottomBar.width = stage.width
stage.addActor(bottomBar)
stage.addActor(bottomUnitTable)
stage.addActor(bottomTileInfoTable)
battleTable.width = stage.width/3
battleTable.x = stage.width/3
stage.addActor(battleTable)
@ -160,14 +160,15 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
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()
minimapWrapper.update(viewingCiv)
minimapWrapper.y = bottomBar.height // couldn't be bothered to create a separate val for minimap wrapper
unitActionsTable.update(bottomBar.unitTable.selectedUnit)
unitActionsTable.y = bottomBar.unitTable.height
unitActionsTable.update(bottomUnitTable.selectedUnit)
unitActionsTable.y = bottomUnitTable.height
// 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
@ -207,7 +208,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
UnCivGame.Current.settings.save()
}
if (bottomBar.unitTable.selectedUnit != null) displayTutorials("Unit_Selected")
if (bottomUnitTable.selectedUnit != null) displayTutorials("Unit_Selected")
if (viewingCiv.cities.isNotEmpty()){
displayTutorials("_City_Founded")
displayTutorials("First_Steps")
@ -290,7 +291,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
val nextDueUnit = viewingCiv.getNextDueUnit()
if(nextDueUnit!=null) {
tileMapHolder.setCenterPosition(nextDueUnit.currentTile.position, false, false)
bottomBar.unitTable.selectedUnit = nextDueUnit
bottomUnitTable.selectedUnit = nextDueUnit
shouldUpdate=true
}
return@onClick

View file

@ -34,7 +34,7 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
}
fun update() {
val unitTable = worldScreen.bottomBar.unitTable
val unitTable = worldScreen.bottomUnitTable
val attacker : ICombatant?
if (unitTable.selectedUnit != null
&& !unitTable.selectedUnit!!.type.isCivilian()) {

View file

@ -19,26 +19,22 @@ class TileInfoTable(private val worldScreen: WorldScreen) : Table(CameraStageBas
internal fun updateTileTable(tile: TileInfo) {
clearChildren()
val civInfo = worldScreen.viewingCiv
columnDefaults(0).padRight(10f)
if (UnCivGame.Current.viewEntireMapForDebug || civInfo.exploredTiles.contains(tile.position)) {
add(getStatsTable(tile)).pad(10f)
add(tile.toString().toLabel()).colspan(2)
add(getStatsTable(tile))
add(tile.toString().toLabel()).colspan(2).pad(10f)
}
pack()
setPosition(worldScreen.stage.width - 10f - width, 10f)
}
fun getStatsTable(tile: TileInfo):Table{
val table=Table()
table.pad(10f)
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(Label(entry.value.toInt().toString(), skin)).align(Align.left)
table.add(Label(entry.value.toInt().toString(), skin)).align(Align.left).padRight(10f)
table.row()
}
return table

View file

@ -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()
}
}

View file

@ -28,7 +28,7 @@ class UnitActions {
fun getUnitActions(unit:MapUnit,worldScreen: WorldScreen): List<UnitAction> {
val tile = unit.getTile()
val unitTable = worldScreen.bottomBar.unitTable
val unitTable = worldScreen.bottomUnitTable
val actionList = ArrayList<UnitAction>()
if(unit.action!=null && unit.action!!.startsWith("moveTo")) {

View file

@ -74,7 +74,7 @@ class UnitContextMenu(val tileMapHolder: TileMapHolder, val selectedUnit: MapUni
if (selectedUnit.currentTile != targetTile)
selectedUnit.action = "moveTo " + targetTile.position.x.toInt() + "," + targetTile.position.y.toInt()
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

View file

@ -61,13 +61,12 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
}).left()
add(prevIdleUnitButton)
add(Table().apply {
add(Table().apply {
add(prevIdleUnitButton)
add(unitIconHolder)
add(unitNameLabel).pad(5f)
add(nextIdleUnitButton)
}).colspan(2).fill().row()
separator= addSeparator().actor!!
add(promotionsTable).colspan(2).row()
@ -80,8 +79,6 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
}
}).expand()
add(nextIdleUnitButton)
}
fun update() {