mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 05:46:43 -04:00
Resolved #5692 - exiting Civilopedia always brings you o the previous screen
This commit is contained in:
parent
ff3cd7511c
commit
bdeccb87e8
@ -51,7 +51,7 @@ class CityScreen(
|
||||
private var tileTable = CityScreenTileTable(this)
|
||||
|
||||
/** Displays selected construction info, alternate with tileTable - sits on BOTTOM RIGHT */
|
||||
private var selectedConstructionTable = ConstructionInfoTable(this.city)
|
||||
private var selectedConstructionTable = ConstructionInfoTable(this)
|
||||
|
||||
/** Displays city name, allows switching between cities - sits on BOTTOM CENTER */
|
||||
private var cityPickerTable = CityScreenCityPickerTable(this)
|
||||
|
@ -39,7 +39,7 @@ class CityScreenTileTable(private val cityScreen: CityScreen): Table() {
|
||||
|
||||
innerTable.add( MarkupRenderer.render(selectedTile.toMarkup(city.civInfo), iconDisplay = IconDisplay.None) {
|
||||
// Sorry, this will leave the city screen
|
||||
UncivGame.Current.setScreen(CivilopediaScreen(city.getRuleset(), link = it))
|
||||
UncivGame.Current.setScreen(CivilopediaScreen(city.getRuleset(), cityScreen, link = it))
|
||||
} )
|
||||
innerTable.row()
|
||||
innerTable.add(getTileStatsTable(stats)).row()
|
||||
|
@ -16,8 +16,9 @@ import com.unciv.ui.utils.onClick
|
||||
import com.unciv.ui.utils.surroundWithCircle
|
||||
import com.unciv.ui.utils.toLabel
|
||||
|
||||
class ConstructionInfoTable(val city: CityInfo): Table() {
|
||||
class ConstructionInfoTable(val cityScreen: CityScreen): Table() {
|
||||
private val selectedConstructionTable = Table()
|
||||
val city = cityScreen.city
|
||||
|
||||
init {
|
||||
selectedConstructionTable.background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
|
||||
@ -72,7 +73,7 @@ class ConstructionInfoTable(val city: CityInfo): Table() {
|
||||
if (link.isEmpty()) return
|
||||
touchable = Touchable.enabled
|
||||
onClick {
|
||||
UncivGame.Current.setScreen(CivilopediaScreen(city.getRuleset(), link = link))
|
||||
UncivGame.Current.setScreen(CivilopediaScreen(city.getRuleset(), cityScreen, link = link))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,9 +23,10 @@ import com.unciv.ui.utils.AutoScrollPane as ScrollPane
|
||||
* overriding the [category] parameter, or just `entry` to complement it.
|
||||
*/
|
||||
class CivilopediaScreen(
|
||||
val ruleset: Ruleset
|
||||
, category: CivilopediaCategories = CivilopediaCategories.Tutorial
|
||||
, link: String = ""
|
||||
val ruleset: Ruleset,
|
||||
val previousScreen: BaseScreen,
|
||||
category: CivilopediaCategories = CivilopediaCategories.Tutorial,
|
||||
link: String = ""
|
||||
) : BaseScreen() {
|
||||
|
||||
/** Container collecting data per Civilopedia entry
|
||||
@ -168,7 +169,7 @@ class CivilopediaScreen(
|
||||
|
||||
init {
|
||||
val imageSize = 50f
|
||||
onBackButtonClicked { UncivGame.Current.setWorldScreen() }
|
||||
onBackButtonClicked { game.setScreen(previousScreen) }
|
||||
|
||||
val hideReligionItems = !game.gameInfo.isReligionEnabled()
|
||||
|
||||
@ -306,7 +307,7 @@ class CivilopediaScreen(
|
||||
|
||||
override fun resize(width: Int, height: Int) {
|
||||
if (stage.viewport.screenWidth != width || stage.viewport.screenHeight != height) {
|
||||
game.setScreen(CivilopediaScreen(game.worldScreen.gameInfo.ruleSet, currentCategory, currentEntry))
|
||||
game.setScreen(CivilopediaScreen(game.worldScreen.gameInfo.ruleSet, previousScreen, currentCategory, currentEntry))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ class ReligionOverviewTable(
|
||||
yieldAll(getCivilopediaTextLines(gameInfo.ruleSet, true))
|
||||
} }.toList()
|
||||
) {
|
||||
UncivGame.Current.setScreen(CivilopediaScreen(gameInfo.ruleSet, link = it))
|
||||
UncivGame.Current.setScreen(CivilopediaScreen(gameInfo.ruleSet, overviewScreen, link = it))
|
||||
}.apply {
|
||||
background = ImageGetter.getBackground(ImageGetter.getBlue())
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ class WonderOverviewTable(
|
||||
|
||||
val image = wonder.getImage()
|
||||
image?.onClick {
|
||||
UncivGame.Current.setScreen(CivilopediaScreen(ruleSet, wonder.category, wonder.name))
|
||||
UncivGame.Current.setScreen(CivilopediaScreen(ruleSet, overviewScreen, wonder.category, wonder.name))
|
||||
}
|
||||
// Terrain image padding is a bit unpredictable, they need ~5f more. Ensure equal line spacing on name, not image:
|
||||
add(image).pad(0f, 10f, 0f, 10f)
|
||||
|
@ -59,7 +59,7 @@ class TechPickerScreen(
|
||||
|
||||
descriptionLabel.onClick {
|
||||
if (selectedTech != null)
|
||||
game.setScreen(CivilopediaScreen(civInfo.gameInfo.ruleSet, CivilopediaCategories.Technology, selectedTech!!.name))
|
||||
game.setScreen(CivilopediaScreen(civInfo.gameInfo.ruleSet, this, CivilopediaCategories.Technology, selectedTech!!.name))
|
||||
}
|
||||
|
||||
tempTechsToResearch = ArrayList(civTech.techsToResearch)
|
||||
|
@ -159,6 +159,7 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo): BaseScreen() {
|
||||
wrapper.onClick {
|
||||
val pedia = CivilopediaScreen(
|
||||
UncivGame.Current.gameInfo.ruleSet,
|
||||
this,
|
||||
link = "Resource/$name"
|
||||
)
|
||||
UncivGame.Current.setScreen(pedia)
|
||||
|
@ -236,7 +236,7 @@ class WorldScreen(val gameInfo: GameInfo, val viewingCiv:CivilizationInfo) : Bas
|
||||
}
|
||||
|
||||
// Space and N are assigned in createNextTurnButton
|
||||
keyPressDispatcher[Input.Keys.F1] = { game.setScreen(CivilopediaScreen(gameInfo.ruleSet)) }
|
||||
keyPressDispatcher[Input.Keys.F1] = { game.setScreen(CivilopediaScreen(gameInfo.ruleSet, this)) }
|
||||
keyPressDispatcher['E'] = { game.setScreen(EmpireOverviewScreen(selectedCiv)) } // Empire overview last used page
|
||||
/*
|
||||
* These try to be faithful to default Civ5 key bindings as found in several places online
|
||||
|
@ -197,7 +197,16 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
|
||||
selectedCivTable.x = getMenuButton().width + 20f
|
||||
|
||||
selectedCivLabel.setFontSize(25)
|
||||
selectedCivLabel.onClick { worldScreen.game.setScreen(CivilopediaScreen( worldScreen.selectedCiv.gameInfo.ruleSet, CivilopediaCategories.Nation, worldScreen.selectedCiv.civName)) }
|
||||
|
||||
selectedCivLabel.onClick {
|
||||
val civilopeidaScreen = CivilopediaScreen(
|
||||
worldScreen.selectedCiv.gameInfo.ruleSet,
|
||||
worldScreen,
|
||||
CivilopediaCategories.Nation,
|
||||
worldScreen.selectedCiv.civName
|
||||
)
|
||||
worldScreen.game.setScreen(civilopeidaScreen)
|
||||
}
|
||||
|
||||
val nation = worldScreen.gameInfo.ruleSet.nations[worldScreen.selectedCiv.civName]!!
|
||||
val selectedCivIcon = ImageGetter.getNationIndicator(nation, 35f)
|
||||
|
@ -24,7 +24,8 @@ class TileInfoTable(private val viewingCiv :CivilizationInfo) : Table(BaseScreen
|
||||
if (tile != null && (UncivGame.Current.viewEntireMapForDebug || viewingCiv.exploredTiles.contains(tile.position)) ) {
|
||||
add(getStatsTable(tile))
|
||||
add( MarkupRenderer.render(tile.toMarkup(viewingCiv), padding = 0f, iconDisplay = IconDisplay.None) {
|
||||
UncivGame.Current.setScreen(CivilopediaScreen(viewingCiv.gameInfo.ruleSet, link = it))
|
||||
// We need to pass the current screen here to get this to work and I can't be bothered now
|
||||
// UncivGame.Current.setScreen(CivilopediaScreen(viewingCiv.gameInfo.ruleSet, link = it))
|
||||
} ).pad(5f).row()
|
||||
if (UncivGame.Current.viewEntireMapForDebug)
|
||||
add(tile.position.run { "(${x.toInt()},${y.toInt()})" }.toLabel()).colspan(2).pad(5f)
|
||||
|
@ -16,7 +16,7 @@ class WorldScreenMenuPopup(val worldScreen: WorldScreen) : Popup(worldScreen) {
|
||||
defaults().fillX()
|
||||
|
||||
addButton("Main menu") { worldScreen.game.setScreen(MainMenuScreen()) }
|
||||
addButton("Civilopedia") { worldScreen.game.setScreen(CivilopediaScreen(worldScreen.gameInfo.ruleSet)) }
|
||||
addButton("Civilopedia") { worldScreen.game.setScreen(CivilopediaScreen(worldScreen.gameInfo.ruleSet, worldScreen)) }
|
||||
addButton("Save game") { worldScreen.game.setScreen(SaveGameScreen(worldScreen.gameInfo)) }
|
||||
addButton("Load game") { worldScreen.game.setScreen(LoadGameScreen(worldScreen)) }
|
||||
|
||||
|
@ -130,7 +130,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
||||
}
|
||||
unitIconNameGroup.clearListeners()
|
||||
unitIconNameGroup.onClick {
|
||||
worldScreen.game.setScreen(CivilopediaScreen(worldScreen.gameInfo.ruleSet, CivilopediaCategories.Unit, unit.name))
|
||||
worldScreen.game.setScreen(CivilopediaScreen(worldScreen.gameInfo.ruleSet, worldScreen, CivilopediaCategories.Unit, unit.name))
|
||||
}
|
||||
|
||||
unitDescriptionTable.clear()
|
||||
|
Loading…
x
Reference in New Issue
Block a user