Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnitTable: show a summary when no unit is selected #12832

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion android/assets/jsons/translations/template.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,8 @@ turns =
turn =
Next unit =
[amount] units idle =
[amount] units due =
[idleCount] idle =
[waitingCount] waiting =
Fog of War =
Pick a policy =
Move Spies =
Expand Down
8 changes: 7 additions & 1 deletion core/src/com/unciv/ui/components/widgets/ExpanderTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,14 @@ class ExpanderTab(
val persistedStates = HashMap<String, Boolean>()
}

val header = Table(skin) // Header with label and icon, touchable to show/hide
/** Header with label, [headerContent] and icon, touchable to show/hide.
* This internal container is public to allow e.g. alignment changes.
*/
val header = Table(skin)

/** Additional elements can be added to the `ExpanderTab`'s header using this container, empty by default. */
val headerContent = Table()

private val headerLabel = title.toLabel(fontSize = fontSize, hideIcons = true)
private val headerIcon = ImageGetter.getImage(arrowImage)
private val contentWrapper = Table() // Wrapper for innerTable, this is what will be shown/hidden
Expand Down
6 changes: 2 additions & 4 deletions core/src/com/unciv/ui/screens/worldscreen/WorldScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import com.unciv.ui.screens.savescreens.LoadGameScreen
import com.unciv.ui.screens.savescreens.QuickSave
import com.unciv.ui.screens.savescreens.SaveGameScreen
import com.unciv.ui.screens.victoryscreen.VictoryScreen
import com.unciv.ui.screens.worldscreen.worldmap.WorldMapTileUpdater.updateTiles
import com.unciv.ui.screens.worldscreen.bottombar.BattleTable
import com.unciv.ui.screens.worldscreen.bottombar.TileInfoTable
import com.unciv.ui.screens.worldscreen.mainmenu.WorldScreenMusicPopup
Expand All @@ -63,6 +62,7 @@ import com.unciv.ui.screens.worldscreen.unit.AutoPlay
import com.unciv.ui.screens.worldscreen.unit.UnitTable
import com.unciv.ui.screens.worldscreen.unit.actions.UnitActionsTable
import com.unciv.ui.screens.worldscreen.worldmap.WorldMapHolder
import com.unciv.ui.screens.worldscreen.worldmap.WorldMapTileUpdater.updateTiles
import com.unciv.utils.Concurrency
import com.unciv.utils.debug
import com.unciv.utils.launchOnGLThread
Expand Down Expand Up @@ -764,15 +764,13 @@ class WorldScreen(
// Deselect Unit
if (bottomUnitTable.selectedUnit != null) {
bottomUnitTable.selectUnit()
bottomUnitTable.isVisible = false
shouldUpdate = true
return
}

// Deselect city
if (bottomUnitTable.selectedCity != null) {
bottomUnitTable.selectedCity = null
bottomUnitTable.isVisible = false
bottomUnitTable.selectUnit()
shouldUpdate = true
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,7 @@ enum class NextTurnAction(protected val text: String, val color: Color) {
private fun getIdleUnitsText(worldScreen: WorldScreen): String? {
val count = worldScreen.viewingCiv.units.getDueUnits().count()
if (count > 0) {
return if (worldScreen.game.settings.checkForDueUnitsCycles)
"[$count] units idle"
else
"[$count] units due"
return "[$count] units idle"
}
return null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,18 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.badlogic.gdx.utils.Align
import com.unciv.logic.map.mapunit.MapUnit
import com.unciv.ui.components.UncivTooltip.Companion.addTooltip
import com.unciv.ui.images.ImageGetter
import com.unciv.ui.screens.worldscreen.worldmap.WorldMapHolder
import com.unciv.ui.components.input.onClick
import com.unciv.ui.components.extensions.pad
import com.unciv.ui.components.input.KeyboardBinding
import com.unciv.ui.components.input.keyShortcuts
import com.unciv.ui.components.input.onActivation
import com.unciv.ui.images.ImageGetter
import com.unciv.ui.screens.worldscreen.worldmap.WorldMapHolder

class IdleUnitButton (
internal val unitTable: UnitTable,
private val unitTable: UnitTable,
private val tileMapHolder: WorldMapHolder,
val previous: Boolean,
private val keyShortcutBind: KeyboardBinding
keyShortcutBind: KeyboardBinding
) : Table() {

val image = ImageGetter.getImage("OtherIcons/BackArrow")
Expand Down
Loading
Loading