mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-14 01:39:40 +07:00
EmpireOverviewCategories rework (#8953)
This commit is contained in:
@ -10,6 +10,7 @@ import com.unciv.models.UncivSound
|
|||||||
import com.unciv.ui.components.FontFamilyData
|
import com.unciv.ui.components.FontFamilyData
|
||||||
import com.unciv.ui.components.Fonts
|
import com.unciv.ui.components.Fonts
|
||||||
import com.unciv.ui.components.KeyboardBindings
|
import com.unciv.ui.components.KeyboardBindings
|
||||||
|
import com.unciv.ui.screens.overviewscreen.EmpireOverviewCategories
|
||||||
import com.unciv.utils.ScreenOrientation
|
import com.unciv.utils.ScreenOrientation
|
||||||
import java.text.Collator
|
import java.text.Collator
|
||||||
import java.time.Duration
|
import java.time.Duration
|
||||||
@ -86,7 +87,7 @@ class GameSettings {
|
|||||||
|
|
||||||
var enableEspionageOption = false
|
var enableEspionageOption = false
|
||||||
|
|
||||||
var lastOverviewPage: String = "Cities"
|
var lastOverviewPage = EmpireOverviewCategories.Cities // serializes same as the String we had before
|
||||||
|
|
||||||
/** Orientation for mobile platforms */
|
/** Orientation for mobile platforms */
|
||||||
var displayOrientation = ScreenOrientation.Landscape
|
var displayOrientation = ScreenOrientation.Landscape
|
||||||
|
@ -84,7 +84,7 @@ class CityReligionInfoTable(
|
|||||||
if (religion == null) return icon
|
if (religion == null) return icon
|
||||||
icon.onClick {
|
icon.onClick {
|
||||||
val newScreen = if (religion == iconName) {
|
val newScreen = if (religion == iconName) {
|
||||||
EmpireOverviewScreen(civInfo, EmpireOverviewCategories.Religion.name, religion)
|
EmpireOverviewScreen(civInfo, EmpireOverviewCategories.Religion, religion)
|
||||||
} else {
|
} else {
|
||||||
CivilopediaScreen(gameInfo.ruleset, CivilopediaCategories.Belief, religion)
|
CivilopediaScreen(gameInfo.ruleset, CivilopediaCategories.Belief, religion)
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,11 @@
|
|||||||
package com.unciv.ui.screens.overviewscreen
|
package com.unciv.ui.screens.overviewscreen
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.Align
|
import com.badlogic.gdx.utils.Align
|
||||||
import com.unciv.UncivGame
|
|
||||||
import com.unciv.logic.civilization.Civilization
|
import com.unciv.logic.civilization.Civilization
|
||||||
import com.unciv.models.ruleset.tile.ResourceType
|
import com.unciv.models.ruleset.tile.ResourceType
|
||||||
import com.unciv.ui.screens.overviewscreen.EmpireOverviewTab.EmpireOverviewTabPersistableData
|
import com.unciv.ui.screens.overviewscreen.EmpireOverviewTab.EmpireOverviewTabPersistableData
|
||||||
import com.unciv.ui.components.KeyCharAndCode
|
import com.unciv.ui.components.KeyCharAndCode
|
||||||
|
|
||||||
private typealias FactoryType = (Civilization, EmpireOverviewScreen, EmpireOverviewTabPersistableData?) -> EmpireOverviewTab
|
|
||||||
|
|
||||||
enum class EmpireOverviewTabState { Normal, Disabled, Hidden }
|
|
||||||
private typealias StateTesterType = (Civilization) -> EmpireOverviewTabState
|
|
||||||
private fun Boolean.toState(): EmpireOverviewTabState = if (this) EmpireOverviewTabState.Disabled else EmpireOverviewTabState.Normal
|
|
||||||
|
|
||||||
/** This controls which Tabs for the [EmpireOverviewScreen] exist and their order.
|
/** This controls which Tabs for the [EmpireOverviewScreen] exist and their order.
|
||||||
*
|
*
|
||||||
@ -21,54 +15,69 @@ private fun Boolean.toState(): EmpireOverviewTabState = if (this) EmpireOverview
|
|||||||
enum class EmpireOverviewCategories(
|
enum class EmpireOverviewCategories(
|
||||||
val iconName: String,
|
val iconName: String,
|
||||||
val shortcutKey: KeyCharAndCode,
|
val shortcutKey: KeyCharAndCode,
|
||||||
val scrollAlign: Int,
|
val scrollAlign: Int
|
||||||
val factory: FactoryType,
|
|
||||||
val stateTester: StateTesterType
|
|
||||||
) {
|
) {
|
||||||
Cities("OtherIcons/Cities", 'C', Align.topLeft,
|
Cities("OtherIcons/Cities", 'C', Align.topLeft) {
|
||||||
fun (viewingPlayer: Civilization, overviewScreen: EmpireOverviewScreen, persistedData: EmpireOverviewTabPersistableData?)
|
override fun createTab(viewingPlayer: Civilization, overviewScreen: EmpireOverviewScreen, persistedData: EmpireOverviewTabPersistableData?) =
|
||||||
= CityOverviewTab(viewingPlayer, overviewScreen, persistedData),
|
CityOverviewTab(viewingPlayer, overviewScreen, persistedData)
|
||||||
fun (viewingPlayer: Civilization) = viewingPlayer.cities.isEmpty().toState()),
|
override fun showDisabled(viewingPlayer: Civilization) = viewingPlayer.cities.isEmpty()
|
||||||
Stats("StatIcons/Gold", 'S', Align.top,
|
},
|
||||||
fun (viewingPlayer: Civilization, overviewScreen: EmpireOverviewScreen, _: EmpireOverviewTabPersistableData?)
|
Stats("StatIcons/Gold", 'S', Align.top) {
|
||||||
= StatsOverviewTab(viewingPlayer, overviewScreen),
|
override fun createTab(viewingPlayer: Civilization, overviewScreen: EmpireOverviewScreen, persistedData: EmpireOverviewTabPersistableData?) =
|
||||||
fun (_: Civilization) = EmpireOverviewTabState.Normal),
|
StatsOverviewTab(viewingPlayer, overviewScreen)
|
||||||
Trades("StatIcons/Acquire", 'T', Align.top,
|
},
|
||||||
fun (viewingPlayer: Civilization, overviewScreen: EmpireOverviewScreen, _: EmpireOverviewTabPersistableData?)
|
Trades("StatIcons/Acquire", 'T', Align.top) {
|
||||||
= TradesOverviewTab(viewingPlayer, overviewScreen),
|
override fun createTab(viewingPlayer: Civilization, overviewScreen: EmpireOverviewScreen, persistedData: EmpireOverviewTabPersistableData?) =
|
||||||
fun (viewingPlayer: Civilization) =
|
TradesOverviewTab(viewingPlayer, overviewScreen)
|
||||||
(viewingPlayer.diplomacy.values.all { it.trades.isEmpty()} && !viewingPlayer.diplomacy.values.any{it.otherCiv().tradeRequests.any { it.requestingCiv == viewingPlayer.civName }}).toState()),
|
override fun showDisabled(viewingPlayer: Civilization) =
|
||||||
Units("OtherIcons/Shield", 'U', Align.topLeft,
|
viewingPlayer.diplomacy.values.all { it.trades.isEmpty() } &&
|
||||||
fun (viewingPlayer: Civilization, overviewScreen: EmpireOverviewScreen, persistedData: EmpireOverviewTabPersistableData?)
|
viewingPlayer.diplomacy.values.none { diplomacyManager ->
|
||||||
= UnitOverviewTab(viewingPlayer, overviewScreen, persistedData),
|
diplomacyManager.otherCiv().tradeRequests.any { it.requestingCiv == viewingPlayer.civName }
|
||||||
fun (viewingPlayer: Civilization) = viewingPlayer.units.getCivUnits().none().toState()),
|
}
|
||||||
Politics("OtherIcons/Politics", 'P', Align.top,
|
},
|
||||||
fun (viewingPlayer: Civilization, overviewScreen: EmpireOverviewScreen, persistedData: EmpireOverviewTabPersistableData?)
|
Units("OtherIcons/Shield", 'U', Align.topLeft) {
|
||||||
= GlobalPoliticsOverviewTable(viewingPlayer, overviewScreen, persistedData),
|
override fun createTab(viewingPlayer: Civilization, overviewScreen: EmpireOverviewScreen, persistedData: EmpireOverviewTabPersistableData?) =
|
||||||
fun (_: Civilization) = EmpireOverviewTabState.Normal),
|
UnitOverviewTab(viewingPlayer, overviewScreen, persistedData)
|
||||||
Resources("StatIcons/Happiness", 'R', Align.topLeft,
|
override fun showDisabled(viewingPlayer: Civilization) = viewingPlayer.units.getCivUnits().none()
|
||||||
fun (viewingPlayer: Civilization, overviewScreen: EmpireOverviewScreen, persistedData: EmpireOverviewTabPersistableData?)
|
},
|
||||||
= ResourcesOverviewTab(viewingPlayer, overviewScreen, persistedData),
|
Politics("OtherIcons/Politics", 'P', Align.top) {
|
||||||
fun (viewingPlayer: Civilization) = (!viewingPlayer.detailedCivResources.any { it.resource.resourceType != ResourceType.Bonus }).toState()),
|
override fun createTab(viewingPlayer: Civilization, overviewScreen: EmpireOverviewScreen, persistedData: EmpireOverviewTabPersistableData?) =
|
||||||
Religion("StatIcons/Faith", 'F', Align.top,
|
GlobalPoliticsOverviewTable(viewingPlayer, overviewScreen, persistedData)
|
||||||
fun (viewingPlayer: Civilization, overviewScreen: EmpireOverviewScreen, persistedData: EmpireOverviewTabPersistableData?)
|
},
|
||||||
= ReligionOverviewTab(viewingPlayer, overviewScreen, persistedData),
|
Resources("StatIcons/Happiness", 'R', Align.topLeft) {
|
||||||
fun (viewingPlayer: Civilization) = when {
|
override fun createTab(viewingPlayer: Civilization, overviewScreen: EmpireOverviewScreen, persistedData: EmpireOverviewTabPersistableData?) =
|
||||||
|
ResourcesOverviewTab(viewingPlayer, overviewScreen, persistedData)
|
||||||
|
override fun showDisabled(viewingPlayer: Civilization) = viewingPlayer.detailedCivResources.none { it.resource.resourceType != ResourceType.Bonus }
|
||||||
|
},
|
||||||
|
Religion("StatIcons/Faith", 'F', Align.top) {
|
||||||
|
override fun createTab(viewingPlayer: Civilization, overviewScreen: EmpireOverviewScreen, persistedData: EmpireOverviewTabPersistableData?) =
|
||||||
|
ReligionOverviewTab(viewingPlayer, overviewScreen, persistedData)
|
||||||
|
override fun testState(viewingPlayer: Civilization) = when {
|
||||||
!viewingPlayer.gameInfo.isReligionEnabled() -> EmpireOverviewTabState.Hidden
|
!viewingPlayer.gameInfo.isReligionEnabled() -> EmpireOverviewTabState.Hidden
|
||||||
viewingPlayer.gameInfo.religions.isEmpty() -> EmpireOverviewTabState.Disabled
|
viewingPlayer.gameInfo.religions.isEmpty() -> EmpireOverviewTabState.Disabled
|
||||||
else -> EmpireOverviewTabState.Normal
|
else -> EmpireOverviewTabState.Normal
|
||||||
}),
|
}
|
||||||
Wonders("OtherIcons/Wonders", 'W', Align.top,
|
},
|
||||||
fun (viewingPlayer: Civilization, overviewScreen: EmpireOverviewScreen, _: EmpireOverviewTabPersistableData?)
|
Wonders("OtherIcons/Wonders", 'W', Align.top) {
|
||||||
= WonderOverviewTab(viewingPlayer, overviewScreen),
|
override fun createTab(viewingPlayer: Civilization, overviewScreen: EmpireOverviewScreen, persistedData: EmpireOverviewTabPersistableData?) =
|
||||||
fun (viewingPlayer: Civilization) = (viewingPlayer.naturalWonders.isEmpty() && viewingPlayer.cities.isEmpty()).toState()),
|
WonderOverviewTab(viewingPlayer, overviewScreen)
|
||||||
Notifications("OtherIcons/Notifications", 'N', Align.top,
|
override fun showDisabled(viewingPlayer: Civilization) = (viewingPlayer.naturalWonders.isEmpty() && viewingPlayer.cities.isEmpty())
|
||||||
fun (viewingPlayer: Civilization, overviewScreen: EmpireOverviewScreen, persistedData: EmpireOverviewTabPersistableData?)
|
},
|
||||||
= NotificationsOverviewTable(viewingPlayer, overviewScreen, persistedData),
|
Notifications("OtherIcons/Notifications", 'N', Align.top) {
|
||||||
fun (_: Civilization) = EmpireOverviewTabState.Normal)
|
override fun createTab(viewingPlayer: Civilization, overviewScreen: EmpireOverviewScreen, persistedData: EmpireOverviewTabPersistableData?) =
|
||||||
|
NotificationsOverviewTable(viewingPlayer, overviewScreen, persistedData)
|
||||||
|
}
|
||||||
|
|
||||||
; //must be here
|
;
|
||||||
|
|
||||||
constructor(iconName: String, shortcutChar: Char, scrollAlign: Int, factory: FactoryType, stateTester: StateTesterType = { _ -> EmpireOverviewTabState.Normal })
|
constructor(iconName: String, shortcutChar: Char, scrollAlign: Int)
|
||||||
: this(iconName, KeyCharAndCode(shortcutChar), scrollAlign, factory, stateTester)
|
: this(iconName, KeyCharAndCode(shortcutChar), scrollAlign)
|
||||||
|
|
||||||
|
enum class EmpireOverviewTabState { Normal, Disabled, Hidden }
|
||||||
|
|
||||||
|
abstract fun createTab(viewingPlayer: Civilization, overviewScreen: EmpireOverviewScreen, persistedData: EmpireOverviewTabPersistableData?): EmpireOverviewTab
|
||||||
|
open fun showDisabled(viewingPlayer: Civilization) = false
|
||||||
|
open fun testState(viewingPlayer: Civilization) =
|
||||||
|
if (showDisabled(viewingPlayer)) EmpireOverviewTabState.Disabled
|
||||||
|
else EmpireOverviewTabState.Normal
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color
|
|||||||
import com.unciv.Constants
|
import com.unciv.Constants
|
||||||
import com.unciv.logic.civilization.Civilization
|
import com.unciv.logic.civilization.Civilization
|
||||||
import com.unciv.ui.images.ImageGetter
|
import com.unciv.ui.images.ImageGetter
|
||||||
|
import com.unciv.ui.screens.overviewscreen.EmpireOverviewCategories.EmpireOverviewTabState
|
||||||
import com.unciv.ui.screens.overviewscreen.EmpireOverviewTab.EmpireOverviewTabPersistableData
|
import com.unciv.ui.screens.overviewscreen.EmpireOverviewTab.EmpireOverviewTabPersistableData
|
||||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||||
import com.unciv.ui.components.KeyCharAndCode
|
import com.unciv.ui.components.KeyCharAndCode
|
||||||
@ -12,7 +13,7 @@ import com.unciv.ui.components.TabbedPager
|
|||||||
|
|
||||||
class EmpireOverviewScreen(
|
class EmpireOverviewScreen(
|
||||||
private var viewingPlayer: Civilization,
|
private var viewingPlayer: Civilization,
|
||||||
defaultPage: String = "",
|
defaultCategory: EmpireOverviewCategories? = null,
|
||||||
selection: String = ""
|
selection: String = ""
|
||||||
) : BaseScreen(), RecreateOnResize {
|
) : BaseScreen(), RecreateOnResize {
|
||||||
// 50 normal button height + 2*10 topTable padding + 2 Separator + 2*5 centerTable padding
|
// 50 normal button height + 2*10 topTable padding + 2 Separator + 2*5 centerTable padding
|
||||||
@ -38,12 +39,7 @@ class EmpireOverviewScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val page =
|
val selectCategory = defaultCategory ?: game.settings.lastOverviewPage
|
||||||
if (defaultPage != "") {
|
|
||||||
game.settings.lastOverviewPage = defaultPage
|
|
||||||
defaultPage
|
|
||||||
}
|
|
||||||
else game.settings.lastOverviewPage
|
|
||||||
val iconSize = Constants.defaultFontSize.toFloat()
|
val iconSize = Constants.defaultFontSize.toFloat()
|
||||||
|
|
||||||
globalShortcuts.add(KeyCharAndCode.BACK) { game.popScreen() }
|
globalShortcuts.add(KeyCharAndCode.BACK) { game.popScreen() }
|
||||||
@ -57,10 +53,10 @@ class EmpireOverviewScreen(
|
|||||||
tabbedPager.addClosePage { game.popScreen() }
|
tabbedPager.addClosePage { game.popScreen() }
|
||||||
|
|
||||||
for (category in EmpireOverviewCategories.values()) {
|
for (category in EmpireOverviewCategories.values()) {
|
||||||
val tabState = category.stateTester(viewingPlayer)
|
val tabState = category.testState(viewingPlayer)
|
||||||
if (tabState == EmpireOverviewTabState.Hidden) continue
|
if (tabState == EmpireOverviewTabState.Hidden) continue
|
||||||
val icon = if (category.iconName.isEmpty()) null else ImageGetter.getImage(category.iconName)
|
val icon = if (category.iconName.isEmpty()) null else ImageGetter.getImage(category.iconName)
|
||||||
val pageObject = category.factory(viewingPlayer, this, persistState?.get(category))
|
val pageObject = category.createTab(viewingPlayer, this, persistState?.get(category))
|
||||||
pageObject.pad(10f, 0f, 10f, 0f)
|
pageObject.pad(10f, 0f, 10f, 0f)
|
||||||
pageObjects[category] = pageObject
|
pageObjects[category] = pageObject
|
||||||
val index = tabbedPager.addPage(
|
val index = tabbedPager.addPage(
|
||||||
@ -71,7 +67,7 @@ class EmpireOverviewScreen(
|
|||||||
shortcutKey = category.shortcutKey,
|
shortcutKey = category.shortcutKey,
|
||||||
scrollAlign = category.scrollAlign
|
scrollAlign = category.scrollAlign
|
||||||
)
|
)
|
||||||
if (category.name == page) {
|
if (category == selectCategory) {
|
||||||
tabbedPager.selectPage(index)
|
tabbedPager.selectPage(index)
|
||||||
select(pageObject, selection)
|
select(pageObject, selection)
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,10 @@ abstract class EmpireOverviewTab (
|
|||||||
open val persistableData = persistedData ?: EmpireOverviewTabPersistableData()
|
open val persistableData = persistedData ?: EmpireOverviewTabPersistableData()
|
||||||
|
|
||||||
override fun activated(index: Int, caption: String, pager: TabbedPager) {
|
override fun activated(index: Int, caption: String, pager: TabbedPager) {
|
||||||
val settings = overviewScreen.game.settings
|
overviewScreen.game.settings.lastOverviewPage =
|
||||||
if (caption == "Stats")
|
// shouldn't throw because EmpireOverviewScreen takes the TabbedPager
|
||||||
settings.addCompletedTutorialTask("See your stats breakdown")
|
// captions directly from EmpireOverviewCategories.name
|
||||||
settings.lastOverviewPage = caption
|
EmpireOverviewCategories.valueOf(caption)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Override if the tab can _select_ something specific.
|
/** Override if the tab can _select_ something specific.
|
||||||
|
@ -4,11 +4,11 @@ import com.badlogic.gdx.graphics.Color
|
|||||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||||
import com.unciv.Constants
|
import com.unciv.Constants
|
||||||
import com.unciv.GUI
|
import com.unciv.GUI
|
||||||
import com.unciv.UncivGame
|
|
||||||
import com.unciv.logic.civilization.Civilization
|
import com.unciv.logic.civilization.Civilization
|
||||||
import com.unciv.models.ruleset.ModOptionsConstants
|
import com.unciv.models.ruleset.ModOptionsConstants
|
||||||
import com.unciv.models.stats.Stat
|
import com.unciv.models.stats.Stat
|
||||||
import com.unciv.models.stats.StatMap
|
import com.unciv.models.stats.StatMap
|
||||||
|
import com.unciv.ui.components.TabbedPager
|
||||||
import com.unciv.ui.images.ImageGetter
|
import com.unciv.ui.images.ImageGetter
|
||||||
import com.unciv.ui.components.UncivSlider
|
import com.unciv.ui.components.UncivSlider
|
||||||
import com.unciv.ui.components.extensions.addSeparator
|
import com.unciv.ui.components.extensions.addSeparator
|
||||||
@ -29,6 +29,11 @@ class StatsOverviewTab(
|
|||||||
private val scoreTable = Table()
|
private val scoreTable = Table()
|
||||||
private val isReligionEnabled = gameInfo.isReligionEnabled()
|
private val isReligionEnabled = gameInfo.isReligionEnabled()
|
||||||
|
|
||||||
|
override fun activated(index: Int, caption: String, pager: TabbedPager) {
|
||||||
|
overviewScreen.game.settings.addCompletedTutorialTask("See your stats breakdown")
|
||||||
|
super.activated(index, caption, pager)
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val tablePadding = 30f // Padding around each of the stat tables
|
val tablePadding = 30f // Padding around each of the stat tables
|
||||||
defaults().pad(tablePadding).top()
|
defaults().pad(tablePadding).top()
|
||||||
|
@ -191,25 +191,30 @@ class UnitOverviewTab(
|
|||||||
}
|
}
|
||||||
add(button).fillX()
|
add(button).fillX()
|
||||||
|
|
||||||
// Columns: action, strength, ranged, moves
|
// Column: edit-name
|
||||||
val editIcon = ImageGetter.getImage("OtherIcons/Pencil").apply { this.color = Color.WHITE }.surroundWithCircle(30f, true, Color.valueOf("000c31"))
|
val editIcon = ImageGetter.getImage("OtherIcons/Pencil").apply { this.color = Color.WHITE }.surroundWithCircle(30f, true, Color.valueOf("000c31"))
|
||||||
editIcon.onClick {
|
editIcon.onClick {
|
||||||
UnitRenamePopup(
|
UnitRenamePopup(
|
||||||
screen = overviewScreen,
|
screen = overviewScreen,
|
||||||
unit = unit,
|
unit = unit,
|
||||||
actionOnClose = {
|
actionOnClose = {
|
||||||
overviewScreen.game.replaceCurrentScreen(EmpireOverviewScreen(viewingPlayer, "", "")) })
|
overviewScreen.game.replaceCurrentScreen(
|
||||||
|
EmpireOverviewScreen(viewingPlayer, selection = getUnitIdentifier(unit))
|
||||||
|
)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
add(editIcon)
|
add(editIcon)
|
||||||
|
|
||||||
|
// Column: action
|
||||||
fun getActionLabel(unit: MapUnit) = when {
|
fun getActionLabel(unit: MapUnit) = when {
|
||||||
unit.action == null -> ""
|
unit.action == null -> ""
|
||||||
unit.isFortified() -> UnitActionType.Fortify.value
|
unit.isFortified() -> UnitActionType.Fortify.value
|
||||||
unit.isMoving() -> "Moving"
|
unit.isMoving() -> "Moving"
|
||||||
else -> unit.action!!
|
else -> unit.action!!
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unit.action == null) add() else add(getActionLabel(unit).toLabel())
|
if (unit.action == null) add() else add(getActionLabel(unit).toLabel())
|
||||||
|
|
||||||
|
// Columns: strength, ranged
|
||||||
if (baseUnit.strength > 0) add(baseUnit.strength.toLabel()) else add()
|
if (baseUnit.strength > 0) add(baseUnit.strength.toLabel()) else add()
|
||||||
if (baseUnit.rangedStrength > 0) add(baseUnit.rangedStrength.toLabel()) else add()
|
if (baseUnit.rangedStrength > 0) add(baseUnit.rangedStrength.toLabel()) else add()
|
||||||
add(unit.getMovementString().toLabel())
|
add(unit.getMovementString().toLabel())
|
||||||
|
@ -45,6 +45,7 @@ import com.unciv.ui.screens.basescreen.BaseScreen
|
|||||||
import com.unciv.ui.screens.cityscreen.CityScreen
|
import com.unciv.ui.screens.cityscreen.CityScreen
|
||||||
import com.unciv.ui.screens.civilopediascreen.CivilopediaScreen
|
import com.unciv.ui.screens.civilopediascreen.CivilopediaScreen
|
||||||
import com.unciv.ui.screens.mainmenuscreen.MainMenuScreen
|
import com.unciv.ui.screens.mainmenuscreen.MainMenuScreen
|
||||||
|
import com.unciv.ui.screens.overviewscreen.EmpireOverviewCategories
|
||||||
import com.unciv.ui.screens.overviewscreen.EmpireOverviewScreen
|
import com.unciv.ui.screens.overviewscreen.EmpireOverviewScreen
|
||||||
import com.unciv.ui.screens.pickerscreens.DiplomaticVoteResultScreen
|
import com.unciv.ui.screens.pickerscreens.DiplomaticVoteResultScreen
|
||||||
import com.unciv.ui.screens.pickerscreens.GreatPersonPickerScreen
|
import com.unciv.ui.screens.pickerscreens.GreatPersonPickerScreen
|
||||||
@ -219,24 +220,28 @@ class WorldScreen(
|
|||||||
super.dispose()
|
super.dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun openEmpireOverview(category: EmpireOverviewCategories? = null) {
|
||||||
|
game.pushScreen(EmpireOverviewScreen(selectedCiv, category))
|
||||||
|
}
|
||||||
|
|
||||||
private fun addKeyboardPresses() {
|
private fun addKeyboardPresses() {
|
||||||
// Space and N are assigned in NextTurnButton constructor
|
// Space and N are assigned in NextTurnButton constructor
|
||||||
globalShortcuts.add(KeyboardBinding.Civilopedia) { game.pushScreen(CivilopediaScreen(gameInfo.ruleset)) }
|
globalShortcuts.add(KeyboardBinding.Civilopedia) { game.pushScreen(CivilopediaScreen(gameInfo.ruleset)) }
|
||||||
globalShortcuts.add(KeyboardBinding.EmpireOverview) { game.pushScreen(EmpireOverviewScreen(selectedCiv)) } // Empire overview last used page
|
globalShortcuts.add(KeyboardBinding.EmpireOverview) { openEmpireOverview() } // Empire overview last used page
|
||||||
/*
|
/*
|
||||||
* These try to be faithful to default Civ5 key bindings as found in several places online
|
* These try to be faithful to default Civ5 key bindings as found in several places online
|
||||||
* Some are a little arbitrary, e.g. Economic info, Military info
|
* Some are a little arbitrary, e.g. Economic info, Military info
|
||||||
* Some are very much so as Unciv *is* Strategic View and the Notification log is always visible
|
* Some are very much so as Unciv *is* Strategic View and the Notification log is always visible
|
||||||
*/
|
*/
|
||||||
globalShortcuts.add(Input.Keys.F2) { game.pushScreen(EmpireOverviewScreen(selectedCiv, "Trades")) } // Economic info
|
globalShortcuts.add(Input.Keys.F2) { openEmpireOverview(EmpireOverviewCategories.Trades) } // Economic info
|
||||||
globalShortcuts.add(Input.Keys.F3) { game.pushScreen(EmpireOverviewScreen(selectedCiv, "Units")) } // Military info
|
globalShortcuts.add(Input.Keys.F3) { openEmpireOverview(EmpireOverviewCategories.Units) } // Military info
|
||||||
globalShortcuts.add(Input.Keys.F4) { game.pushScreen(EmpireOverviewScreen(selectedCiv, "Politics")) } // Diplomacy info
|
globalShortcuts.add(Input.Keys.F4) { openEmpireOverview(EmpireOverviewCategories.Politics) } // Diplomacy info
|
||||||
globalShortcuts.add(Input.Keys.F5) { game.pushScreen(PolicyPickerScreen(selectedCiv, canChangeState)) } // Social Policies Screen
|
globalShortcuts.add(Input.Keys.F5) { game.pushScreen(PolicyPickerScreen(selectedCiv, canChangeState)) } // Social Policies Screen
|
||||||
globalShortcuts.add(Input.Keys.F6) { game.pushScreen(TechPickerScreen(viewingCiv)) } // Tech Screen
|
globalShortcuts.add(Input.Keys.F6) { game.pushScreen(TechPickerScreen(viewingCiv)) } // Tech Screen
|
||||||
globalShortcuts.add(Input.Keys.F7) { game.pushScreen(EmpireOverviewScreen(selectedCiv, "Cities")) } // originally Notification Log
|
globalShortcuts.add(Input.Keys.F7) { openEmpireOverview(EmpireOverviewCategories.Notifications) } // Notification Log
|
||||||
globalShortcuts.add(Input.Keys.F8) { game.pushScreen(VictoryScreen(this)) } // Victory Progress
|
globalShortcuts.add(Input.Keys.F8) { game.pushScreen(VictoryScreen(this)) } // Victory Progress
|
||||||
globalShortcuts.add(Input.Keys.F9) { game.pushScreen(EmpireOverviewScreen(selectedCiv, "Stats")) } // Demographics
|
globalShortcuts.add(Input.Keys.F9) { openEmpireOverview(EmpireOverviewCategories.Stats) } // Demographics
|
||||||
globalShortcuts.add(Input.Keys.F10) { game.pushScreen(EmpireOverviewScreen(selectedCiv, "Resources")) } // originally Strategic View
|
globalShortcuts.add(Input.Keys.F10) { openEmpireOverview(EmpireOverviewCategories.Resources) } // originally Strategic View
|
||||||
globalShortcuts.add(Input.Keys.F11) { QuickSave.save(gameInfo, this) } // Quick Save
|
globalShortcuts.add(Input.Keys.F11) { QuickSave.save(gameInfo, this) } // Quick Save
|
||||||
globalShortcuts.add(Input.Keys.F12) { QuickSave.load(this) } // Quick Load
|
globalShortcuts.add(Input.Keys.F12) { QuickSave.load(this) } // Quick Load
|
||||||
globalShortcuts.add(Input.Keys.HOME) { // Capital City View
|
globalShortcuts.add(Input.Keys.HOME) { // Capital City View
|
||||||
@ -561,10 +566,10 @@ class WorldScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateSelectedCiv() {
|
private fun updateSelectedCiv() {
|
||||||
when {
|
selectedCiv = when {
|
||||||
bottomUnitTable.selectedUnit != null -> selectedCiv = bottomUnitTable.selectedUnit!!.civ
|
bottomUnitTable.selectedUnit != null -> bottomUnitTable.selectedUnit!!.civ
|
||||||
bottomUnitTable.selectedCity != null -> selectedCiv = bottomUnitTable.selectedCity!!.civ
|
bottomUnitTable.selectedCity != null -> bottomUnitTable.selectedCity!!.civ
|
||||||
else -> selectedCiv = viewingCiv
|
else -> viewingCiv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import com.unciv.ui.popups.popups
|
|||||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||||
import com.unciv.ui.screens.civilopediascreen.CivilopediaCategories
|
import com.unciv.ui.screens.civilopediascreen.CivilopediaCategories
|
||||||
import com.unciv.ui.screens.civilopediascreen.CivilopediaScreen
|
import com.unciv.ui.screens.civilopediascreen.CivilopediaScreen
|
||||||
|
import com.unciv.ui.screens.overviewscreen.EmpireOverviewCategories
|
||||||
import com.unciv.ui.screens.overviewscreen.EmpireOverviewScreen
|
import com.unciv.ui.screens.overviewscreen.EmpireOverviewScreen
|
||||||
import com.unciv.ui.screens.pickerscreens.PolicyPickerScreen
|
import com.unciv.ui.screens.pickerscreens.PolicyPickerScreen
|
||||||
import com.unciv.ui.screens.pickerscreens.TechPickerScreen
|
import com.unciv.ui.screens.pickerscreens.TechPickerScreen
|
||||||
@ -45,7 +46,7 @@ import kotlin.math.roundToInt
|
|||||||
*/
|
*/
|
||||||
//region Fields
|
//region Fields
|
||||||
class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
|
class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
|
||||||
|
//TODO shouldn't most onClick be addActivationAction instead?
|
||||||
private val turnsLabel = "Turns: 0/400".toLabel()
|
private val turnsLabel = "Turns: 0/400".toLabel()
|
||||||
private val goldLabel = "0".toLabel(colorFromRGB(225, 217, 71))
|
private val goldLabel = "0".toLabel(colorFromRGB(225, 217, 71))
|
||||||
private val scienceLabel = "0".toLabel(colorFromRGB(78, 140, 151))
|
private val scienceLabel = "0".toLabel(colorFromRGB(78, 140, 151))
|
||||||
@ -104,23 +105,23 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
|
|||||||
if (!isLast) padRight(20f)
|
if (!isLast) padRight(20f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fun addStat(label: Label, icon: String, overviewPage: String, isLast: Boolean = false) =
|
fun addStat(label: Label, icon: String, overviewPage: EmpireOverviewCategories, isLast: Boolean = false) =
|
||||||
addStat(label, icon, isLast) { EmpireOverviewScreen(worldScreen.selectedCiv, overviewPage) }
|
addStat(label, icon, isLast) { EmpireOverviewScreen(worldScreen.selectedCiv, overviewPage) }
|
||||||
|
|
||||||
addStat(goldLabel, "Gold", "Stats")
|
addStat(goldLabel, "Gold", EmpireOverviewCategories.Stats)
|
||||||
addStat(scienceLabel, "Science") { TechPickerScreen(worldScreen.selectedCiv) }
|
addStat(scienceLabel, "Science") { TechPickerScreen(worldScreen.selectedCiv) }
|
||||||
|
|
||||||
statsTable.add(happinessImage).padBottom(6f).size(20f)
|
statsTable.add(happinessImage).padBottom(6f).size(20f)
|
||||||
statsTable.add(happinessLabel).padRight(20f)
|
statsTable.add(happinessLabel).padRight(20f)
|
||||||
val invokeResourcesPage = {
|
val invokeResourcesPage = {
|
||||||
worldScreen.game.pushScreen(EmpireOverviewScreen(worldScreen.selectedCiv, "Resources"))
|
worldScreen.openEmpireOverview(EmpireOverviewCategories.Resources)
|
||||||
}
|
}
|
||||||
happinessImage.onClick(invokeResourcesPage)
|
happinessImage.onClick(invokeResourcesPage)
|
||||||
happinessLabel.onClick(invokeResourcesPage)
|
happinessLabel.onClick(invokeResourcesPage)
|
||||||
|
|
||||||
addStat(cultureLabel, "Culture") { PolicyPickerScreen(worldScreen.selectedCiv, worldScreen.canChangeState) }
|
addStat(cultureLabel, "Culture") { PolicyPickerScreen(worldScreen.selectedCiv, worldScreen.canChangeState) }
|
||||||
if (worldScreen.gameInfo.isReligionEnabled()) {
|
if (worldScreen.gameInfo.isReligionEnabled()) {
|
||||||
addStat(faithLabel, "Faith", "Religion", isLast = true)
|
addStat(faithLabel, "Faith", EmpireOverviewCategories.Religion, isLast = true)
|
||||||
} else {
|
} else {
|
||||||
statsTable.add("Religion: Off".toLabel())
|
statsTable.add("Religion: Off".toLabel())
|
||||||
}
|
}
|
||||||
@ -145,7 +146,7 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
resourcesWrapper.onClick {
|
resourcesWrapper.onClick {
|
||||||
worldScreen.game.pushScreen(EmpireOverviewScreen(worldScreen.selectedCiv, "Resources"))
|
worldScreen.openEmpireOverview(EmpireOverviewCategories.Resources)
|
||||||
}
|
}
|
||||||
|
|
||||||
val strategicResources = worldScreen.gameInfo.ruleset.tileResources.values
|
val strategicResources = worldScreen.gameInfo.ruleset.tileResources.values
|
||||||
@ -174,12 +175,12 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
unitSupplyImage.onClick {
|
unitSupplyImage.onClick {
|
||||||
worldScreen.game.pushScreen(EmpireOverviewScreen(worldScreen.selectedCiv, "Units"))
|
worldScreen.openEmpireOverview(EmpireOverviewCategories.Units)
|
||||||
}
|
}
|
||||||
|
|
||||||
val overviewButton = "Overview".toTextButton()
|
val overviewButton = "Overview".toTextButton()
|
||||||
overviewButton.addTooltip('e')
|
overviewButton.addTooltip('e')
|
||||||
overviewButton.onClick { worldScreen.game.pushScreen(EmpireOverviewScreen(worldScreen.selectedCiv)) }
|
overviewButton.onClick { worldScreen.openEmpireOverview() }
|
||||||
|
|
||||||
unitSupplyCell = add()
|
unitSupplyCell = add()
|
||||||
add(overviewButton).pad(10f)
|
add(overviewButton).pad(10f)
|
||||||
@ -225,7 +226,7 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
selectedCivIconHolder.onClick {
|
selectedCivIconHolder.onClick {
|
||||||
worldScreen.game.pushScreen(EmpireOverviewScreen(worldScreen.selectedCiv))
|
worldScreen.openEmpireOverview()
|
||||||
}
|
}
|
||||||
|
|
||||||
add(menuButton).size(50f).padRight(0f)
|
add(menuButton).size(50f).padRight(0f)
|
||||||
|
Reference in New Issue
Block a user