mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 06:16:37 -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)
|
private var tileTable = CityScreenTileTable(this)
|
||||||
|
|
||||||
/** Displays selected construction info, alternate with tileTable - sits on BOTTOM RIGHT */
|
/** 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 */
|
/** Displays city name, allows switching between cities - sits on BOTTOM CENTER */
|
||||||
private var cityPickerTable = CityScreenCityPickerTable(this)
|
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) {
|
innerTable.add( MarkupRenderer.render(selectedTile.toMarkup(city.civInfo), iconDisplay = IconDisplay.None) {
|
||||||
// Sorry, this will leave the city screen
|
// 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.row()
|
||||||
innerTable.add(getTileStatsTable(stats)).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.surroundWithCircle
|
||||||
import com.unciv.ui.utils.toLabel
|
import com.unciv.ui.utils.toLabel
|
||||||
|
|
||||||
class ConstructionInfoTable(val city: CityInfo): Table() {
|
class ConstructionInfoTable(val cityScreen: CityScreen): Table() {
|
||||||
private val selectedConstructionTable = Table()
|
private val selectedConstructionTable = Table()
|
||||||
|
val city = cityScreen.city
|
||||||
|
|
||||||
init {
|
init {
|
||||||
selectedConstructionTable.background = ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f))
|
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
|
if (link.isEmpty()) return
|
||||||
touchable = Touchable.enabled
|
touchable = Touchable.enabled
|
||||||
onClick {
|
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.
|
* overriding the [category] parameter, or just `entry` to complement it.
|
||||||
*/
|
*/
|
||||||
class CivilopediaScreen(
|
class CivilopediaScreen(
|
||||||
val ruleset: Ruleset
|
val ruleset: Ruleset,
|
||||||
, category: CivilopediaCategories = CivilopediaCategories.Tutorial
|
val previousScreen: BaseScreen,
|
||||||
, link: String = ""
|
category: CivilopediaCategories = CivilopediaCategories.Tutorial,
|
||||||
|
link: String = ""
|
||||||
) : BaseScreen() {
|
) : BaseScreen() {
|
||||||
|
|
||||||
/** Container collecting data per Civilopedia entry
|
/** Container collecting data per Civilopedia entry
|
||||||
@ -168,7 +169,7 @@ class CivilopediaScreen(
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
val imageSize = 50f
|
val imageSize = 50f
|
||||||
onBackButtonClicked { UncivGame.Current.setWorldScreen() }
|
onBackButtonClicked { game.setScreen(previousScreen) }
|
||||||
|
|
||||||
val hideReligionItems = !game.gameInfo.isReligionEnabled()
|
val hideReligionItems = !game.gameInfo.isReligionEnabled()
|
||||||
|
|
||||||
@ -306,7 +307,7 @@ class CivilopediaScreen(
|
|||||||
|
|
||||||
override fun resize(width: Int, height: Int) {
|
override fun resize(width: Int, height: Int) {
|
||||||
if (stage.viewport.screenWidth != width || stage.viewport.screenHeight != height) {
|
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))
|
yieldAll(getCivilopediaTextLines(gameInfo.ruleSet, true))
|
||||||
} }.toList()
|
} }.toList()
|
||||||
) {
|
) {
|
||||||
UncivGame.Current.setScreen(CivilopediaScreen(gameInfo.ruleSet, link = it))
|
UncivGame.Current.setScreen(CivilopediaScreen(gameInfo.ruleSet, overviewScreen, link = it))
|
||||||
}.apply {
|
}.apply {
|
||||||
background = ImageGetter.getBackground(ImageGetter.getBlue())
|
background = ImageGetter.getBackground(ImageGetter.getBlue())
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ class WonderOverviewTable(
|
|||||||
|
|
||||||
val image = wonder.getImage()
|
val image = wonder.getImage()
|
||||||
image?.onClick {
|
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:
|
// 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)
|
add(image).pad(0f, 10f, 0f, 10f)
|
||||||
|
@ -59,7 +59,7 @@ class TechPickerScreen(
|
|||||||
|
|
||||||
descriptionLabel.onClick {
|
descriptionLabel.onClick {
|
||||||
if (selectedTech != null)
|
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)
|
tempTechsToResearch = ArrayList(civTech.techsToResearch)
|
||||||
|
@ -159,6 +159,7 @@ class DiplomacyScreen(val viewingCiv:CivilizationInfo): BaseScreen() {
|
|||||||
wrapper.onClick {
|
wrapper.onClick {
|
||||||
val pedia = CivilopediaScreen(
|
val pedia = CivilopediaScreen(
|
||||||
UncivGame.Current.gameInfo.ruleSet,
|
UncivGame.Current.gameInfo.ruleSet,
|
||||||
|
this,
|
||||||
link = "Resource/$name"
|
link = "Resource/$name"
|
||||||
)
|
)
|
||||||
UncivGame.Current.setScreen(pedia)
|
UncivGame.Current.setScreen(pedia)
|
||||||
|
@ -236,7 +236,7 @@ class WorldScreen(val gameInfo: GameInfo, val viewingCiv:CivilizationInfo) : Bas
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Space and N are assigned in createNextTurnButton
|
// 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
|
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
|
* 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
|
selectedCivTable.x = getMenuButton().width + 20f
|
||||||
|
|
||||||
selectedCivLabel.setFontSize(25)
|
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 nation = worldScreen.gameInfo.ruleSet.nations[worldScreen.selectedCiv.civName]!!
|
||||||
val selectedCivIcon = ImageGetter.getNationIndicator(nation, 35f)
|
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)) ) {
|
if (tile != null && (UncivGame.Current.viewEntireMapForDebug || viewingCiv.exploredTiles.contains(tile.position)) ) {
|
||||||
add(getStatsTable(tile))
|
add(getStatsTable(tile))
|
||||||
add( MarkupRenderer.render(tile.toMarkup(viewingCiv), padding = 0f, iconDisplay = IconDisplay.None) {
|
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()
|
} ).pad(5f).row()
|
||||||
if (UncivGame.Current.viewEntireMapForDebug)
|
if (UncivGame.Current.viewEntireMapForDebug)
|
||||||
add(tile.position.run { "(${x.toInt()},${y.toInt()})" }.toLabel()).colspan(2).pad(5f)
|
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()
|
defaults().fillX()
|
||||||
|
|
||||||
addButton("Main menu") { worldScreen.game.setScreen(MainMenuScreen()) }
|
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("Save game") { worldScreen.game.setScreen(SaveGameScreen(worldScreen.gameInfo)) }
|
||||||
addButton("Load game") { worldScreen.game.setScreen(LoadGameScreen(worldScreen)) }
|
addButton("Load game") { worldScreen.game.setScreen(LoadGameScreen(worldScreen)) }
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ class UnitTable(val worldScreen: WorldScreen) : Table(){
|
|||||||
}
|
}
|
||||||
unitIconNameGroup.clearListeners()
|
unitIconNameGroup.clearListeners()
|
||||||
unitIconNameGroup.onClick {
|
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()
|
unitDescriptionTable.clear()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user