mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-04 16:11:46 +07:00
Keyboard navigation to switch panes within overview screen (#3822)
This commit is contained in:
parent
5b7170bf9f
commit
66f07347e0
@ -42,6 +42,8 @@ class GameSettings {
|
||||
var showExperimentalWorldWrap = false
|
||||
var showExperimentalTileLayering = false
|
||||
|
||||
var lastOverviewPage: String = "Cities"
|
||||
|
||||
init {
|
||||
// 26 = Android Oreo. Versions below may display permanent icon in notification bar.
|
||||
if (Gdx.app?.type == Application.ApplicationType.Android && Gdx.app.version < 26) {
|
||||
@ -60,4 +62,4 @@ class GameSettings {
|
||||
tutorialTasksCompleted.add(tutorialTask)
|
||||
save()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import kotlin.math.abs
|
||||
import kotlin.math.roundToInt
|
||||
import com.unciv.ui.utils.AutoScrollPane as ScrollPane
|
||||
|
||||
class EmpireOverviewScreen(private var viewingPlayer:CivilizationInfo, defaultPage: String = "Cities") : CameraStageBaseScreen(){
|
||||
class EmpireOverviewScreen(private var viewingPlayer:CivilizationInfo, defaultPage: String = "") : CameraStageBaseScreen(){
|
||||
private val topTable = Table().apply { defaults().pad(10f) }
|
||||
private val centerTable = Table().apply { defaults().pad(5f) }
|
||||
|
||||
@ -42,15 +42,24 @@ class EmpireOverviewScreen(private var viewingPlayer:CivilizationInfo, defaultPa
|
||||
centerTable.pack()
|
||||
for ((key, categoryButton) in categoryButtons.filterNot { it.value.touchable == Touchable.disabled })
|
||||
categoryButton.color = if (key == name) Color.BLUE else Color.WHITE
|
||||
game.settings.lastOverviewPage = name
|
||||
}
|
||||
setCategoryActions[name] = setCategoryAction
|
||||
categoryButtons[name] = button
|
||||
button.onClick(setCategoryAction)
|
||||
if (disabled) button.disable()
|
||||
else keyPressDispatcher[name[0].toLowerCase()] = setCategoryAction
|
||||
topTable.add(button)
|
||||
}
|
||||
|
||||
init {
|
||||
val page =
|
||||
if (defaultPage != "") {
|
||||
game.settings.lastOverviewPage = defaultPage
|
||||
defaultPage
|
||||
}
|
||||
else game.settings.lastOverviewPage
|
||||
|
||||
onBackButtonClicked { game.setWorldScreen() }
|
||||
|
||||
addCategory("Cities", CityOverviewTable(viewingPlayer, this))
|
||||
@ -69,7 +78,7 @@ class EmpireOverviewScreen(private var viewingPlayer:CivilizationInfo, defaultPa
|
||||
|
||||
topTable.pack()
|
||||
|
||||
setCategoryActions[defaultPage]?.invoke()
|
||||
setCategoryActions[page]?.invoke()
|
||||
|
||||
val table = Table()
|
||||
table.add(topTable).row()
|
||||
@ -572,4 +581,4 @@ class DiplomacyGroup(val viewingPlayer: CivilizationInfo, freeHeight: Float, inc
|
||||
statusLine.toBack()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user