diff --git a/core/src/com/unciv/ui/cityscreen/CityScreenCityPickerTable.kt b/core/src/com/unciv/ui/cityscreen/CityScreenCityPickerTable.kt index 3caaaf0a7e..a90a1e5dea 100644 --- a/core/src/com/unciv/ui/cityscreen/CityScreenCityPickerTable.kt +++ b/core/src/com/unciv/ui/cityscreen/CityScreenCityPickerTable.kt @@ -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) diff --git a/core/src/com/unciv/ui/tilegroups/CityButton.kt b/core/src/com/unciv/ui/tilegroups/CityButton.kt index 1eda3f6210..62fed364ce 100644 --- a/core/src/com/unciv/ui/tilegroups/CityButton.kt +++ b/core/src/com/unciv/ui/tilegroups/CityButton.kt @@ -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 diff --git a/core/src/com/unciv/ui/tilegroups/WorldTileGroup.kt b/core/src/com/unciv/ui/tilegroups/WorldTileGroup.kt index 2521d4db6f..974eb732d3 100644 --- a/core/src/com/unciv/ui/tilegroups/WorldTileGroup.kt +++ b/core/src/com/unciv/ui/tilegroups/WorldTileGroup.kt @@ -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) } } \ No newline at end of file diff --git a/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt b/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt index 4cb92abf37..fbbcc5c5a8 100644 --- a/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt +++ b/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt @@ -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 diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index e0550bdaa8..b5ac59e72f 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -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 diff --git a/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt b/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt index 1818891155..3da46c3601 100644 --- a/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt +++ b/core/src/com/unciv/ui/worldscreen/bottombar/BattleTable.kt @@ -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()) { diff --git a/core/src/com/unciv/ui/worldscreen/bottombar/TileInfoTable.kt b/core/src/com/unciv/ui/worldscreen/bottombar/TileInfoTable.kt index b1cd9fc590..c2e22885ee 100644 --- a/core/src/com/unciv/ui/worldscreen/bottombar/TileInfoTable.kt +++ b/core/src/com/unciv/ui/worldscreen/bottombar/TileInfoTable.kt @@ -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 diff --git a/core/src/com/unciv/ui/worldscreen/bottombar/WorldScreenBottomBar.kt b/core/src/com/unciv/ui/worldscreen/bottombar/WorldScreenBottomBar.kt deleted file mode 100644 index c46c138a19..0000000000 --- a/core/src/com/unciv/ui/worldscreen/bottombar/WorldScreenBottomBar.kt +++ /dev/null @@ -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() - } -} - diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt index 1497e81876..4092974487 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt @@ -28,7 +28,7 @@ class UnitActions { fun getUnitActions(unit:MapUnit,worldScreen: WorldScreen): List { val tile = unit.getTile() - val unitTable = worldScreen.bottomBar.unitTable + val unitTable = worldScreen.bottomUnitTable val actionList = ArrayList() if(unit.action!=null && unit.action!!.startsWith("moveTo")) { diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitContextMenu.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitContextMenu.kt index e1f072c804..fcaea5c2bc 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitContextMenu.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitContextMenu.kt @@ -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 diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt index d7a7d709fd..b7f4fb6858 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitTable.kt @@ -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() {