mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-16 18:59:15 +07:00
Removed may references to UncivGame.Current
This commit is contained in:
@ -28,11 +28,11 @@ class EmpireOverviewScreen(private val viewingPlayer:CivilizationInfo, private v
|
||||
private val centerTable = Table().apply { defaults().pad(20f) }
|
||||
|
||||
init {
|
||||
onBackButtonClicked { UncivGame.Current.setWorldScreen() }
|
||||
onBackButtonClicked { game.setWorldScreen() }
|
||||
val clicks = HashMap<String,() -> Unit>()
|
||||
|
||||
val closeButton = Constants.close.toTextButton()
|
||||
closeButton.onClick { UncivGame.Current.setWorldScreen() }
|
||||
closeButton.onClick { game.setWorldScreen() }
|
||||
closeButton.y = stage.height - closeButton.height - 5
|
||||
topTable.add(closeButton)
|
||||
|
||||
@ -351,7 +351,7 @@ class EmpireOverviewScreen(private val viewingPlayer:CivilizationInfo, private v
|
||||
for (city in cityList) {
|
||||
val button = Button(city.name.toLabel(), skin)
|
||||
button.onClick {
|
||||
UncivGame.Current.setScreen(CityScreen(city))
|
||||
game.setScreen(CityScreen(city))
|
||||
}
|
||||
citiesTable.add(button)
|
||||
citiesTable.add(city.cityConstructions.getCityProductionTextForCityButton()).actor!!.setAlignment(Align.left)
|
||||
@ -385,8 +385,8 @@ class EmpireOverviewScreen(private val viewingPlayer:CivilizationInfo, private v
|
||||
val baseUnit = unit.baseUnit()
|
||||
val button = unit.name.toTextButton()
|
||||
button.onClick {
|
||||
UncivGame.Current.setWorldScreen()
|
||||
UncivGame.Current.worldScreen.mapHolder.setCenterPosition(unit.currentTile.position)
|
||||
game.setWorldScreen()
|
||||
game.worldScreen.mapHolder.setCenterPosition(unit.currentTile.position)
|
||||
}
|
||||
table.add(button).left()
|
||||
val mapUnitAction = unit.mapUnitAction
|
||||
@ -404,7 +404,7 @@ class EmpireOverviewScreen(private val viewingPlayer:CivilizationInfo, private v
|
||||
if (unit.canUpgrade()) promotionsTable.add(ImageGetter.getUnitIcon(baseUnit.upgradesTo!!, Color.GREEN)).size(28f).padLeft(8f)
|
||||
promotionsTable.onClick {
|
||||
if (unit.promotions.canBePromoted() || unit.promotions.promotions.isNotEmpty()) {
|
||||
UncivGame.Current.setScreen(PromotionPickerScreen(unit))
|
||||
game.setScreen(PromotionPickerScreen(unit))
|
||||
}
|
||||
}
|
||||
table.add(promotionsTable)
|
||||
@ -600,7 +600,7 @@ class EmpireOverviewScreen(private val viewingPlayer:CivilizationInfo, private v
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getCivGroup(civ: CivilizationInfo, afterCivNameText:String,currentPlayer:CivilizationInfo): Table {
|
||||
fun getCivGroup(civ: CivilizationInfo, afterCivNameText:String, currentPlayer:CivilizationInfo): Table {
|
||||
val civGroup = Table()
|
||||
|
||||
var labelText = civ.civName.tr()+afterCivNameText
|
||||
@ -611,7 +611,7 @@ class EmpireOverviewScreen(private val viewingPlayer:CivilizationInfo, private v
|
||||
civGroup.add(ImageGetter.getImage("OtherIcons/DisbandUnit")).size(30f)
|
||||
backgroundColor = Color.LIGHT_GRAY
|
||||
labelColor = Color.BLACK
|
||||
} else if (currentPlayer==civ || UncivGame.Current.viewEntireMapForDebug
|
||||
} else if (currentPlayer==civ // game.viewEntireMapForDebug
|
||||
|| currentPlayer.knows(civ) || currentPlayer.isDefeated() || currentPlayer.victoryManager.hasWon()) {
|
||||
civGroup.add(ImageGetter.getNationIndicator(civ.nation, 30f))
|
||||
backgroundColor = civ.nation.getOuterColor()
|
||||
|
@ -15,7 +15,7 @@ import com.unciv.ui.worldscreen.mainmenu.OnlineMultiplayer
|
||||
import java.util.*
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
class MultiplayerScreen() : PickerScreen() {
|
||||
class MultiplayerScreen(val uncivGame: UncivGame) : PickerScreen() {
|
||||
|
||||
private lateinit var selectedGame: GameInfo
|
||||
private lateinit var selectedGameName: String
|
||||
@ -77,7 +77,7 @@ class MultiplayerScreen() : PickerScreen() {
|
||||
|
||||
//rightTable Setup
|
||||
copyUserIdButton.onClick {
|
||||
Gdx.app.clipboard.contents = UncivGame.Current.settings.userId
|
||||
Gdx.app.clipboard.contents = uncivGame.settings.userId
|
||||
ResponsePopup("UserID copied to clipboard".tr(), this)
|
||||
}
|
||||
rightSideTable.add(copyUserIdButton).pad(10f).padBottom(30f).row()
|
||||
@ -89,14 +89,14 @@ class MultiplayerScreen() : PickerScreen() {
|
||||
rightSideTable.add(copyGameIdButton).pad(10f).row()
|
||||
|
||||
editButton.onClick {
|
||||
UncivGame.Current.setScreen(EditMultiplayerGameInfoScreen(selectedGame, selectedGameName, this))
|
||||
uncivGame.setScreen(EditMultiplayerGameInfoScreen(selectedGame, selectedGameName, this))
|
||||
//game must be unselected in case the game gets deleted inside the EditScreen
|
||||
unselectGame()
|
||||
}
|
||||
rightSideTable.add(editButton).pad(10f).row()
|
||||
|
||||
addGameButton.onClick {
|
||||
UncivGame.Current.setScreen(AddMultiplayerGameScreen(this))
|
||||
uncivGame.setScreen(AddMultiplayerGameScreen(this))
|
||||
}
|
||||
rightSideTable.add(addGameButton).pad(10f).padBottom(30f).row()
|
||||
|
||||
@ -161,7 +161,7 @@ class MultiplayerScreen() : PickerScreen() {
|
||||
//the game will be downloaded opon joining it anyway
|
||||
private fun joinMultiplaerGame(){
|
||||
try {
|
||||
UncivGame.Current.loadGame(selectedGame)
|
||||
uncivGame.loadGame(selectedGame)
|
||||
} catch (ex: Exception) {
|
||||
val errorPopup = Popup(this)
|
||||
errorPopup.addGoodSizedLabel("Could not download game!".tr())
|
||||
@ -267,7 +267,7 @@ class MultiplayerScreen() : PickerScreen() {
|
||||
|
||||
//Adds a Button to add the currently running game to multiplayerGameList
|
||||
private fun addCurrentGameButton(){
|
||||
val currentlyRunningGame = UncivGame.Current.gameInfo
|
||||
val currentlyRunningGame = uncivGame.gameInfo
|
||||
if (!currentlyRunningGame.gameParameters.isOnlineMultiplayer || gameIsAlreadySavedAsMultiplayer(currentlyRunningGame.gameId))
|
||||
return
|
||||
|
||||
@ -301,7 +301,7 @@ class MultiplayerScreen() : PickerScreen() {
|
||||
|
||||
//check if its the users turn
|
||||
private fun isUsersTurn(game: GameInfo) : Boolean{
|
||||
return (game.currentPlayerCiv.playerId == UncivGame.Current.settings.userId)
|
||||
return (game.currentPlayerCiv.playerId == uncivGame.settings.userId)
|
||||
}
|
||||
|
||||
fun removeFromList(gameId: String){
|
||||
@ -328,7 +328,7 @@ class EditMultiplayerGameInfoScreen(game: GameInfo, gameName: String, backScreen
|
||||
askPopup.addButton("Yes"){
|
||||
try {
|
||||
GameSaver.deleteSave(gameName, true)
|
||||
UncivGame.Current.setScreen(backScreen)
|
||||
backScreen.uncivGame.setScreen(backScreen)
|
||||
backScreen.reloadGameListUI()
|
||||
}catch (ex: Exception) {
|
||||
askPopup.close()
|
||||
@ -346,7 +346,7 @@ class EditMultiplayerGameInfoScreen(game: GameInfo, gameName: String, backScreen
|
||||
//CloseButton Setup
|
||||
closeButton.setText("Back".tr())
|
||||
closeButton.onClick {
|
||||
UncivGame.Current.setScreen(backScreen)
|
||||
backScreen.uncivGame.setScreen(backScreen)
|
||||
}
|
||||
|
||||
//RightSideButton Setup
|
||||
@ -359,7 +359,7 @@ class EditMultiplayerGameInfoScreen(game: GameInfo, gameName: String, backScreen
|
||||
//using addMultiplayerGame will download the game from Dropbox so the descriptionLabel displays the right things
|
||||
backScreen.addMultiplayerGame(game.gameId, textField.text)
|
||||
GameSaver.deleteSave(gameName, true)
|
||||
UncivGame.Current.setScreen(backScreen)
|
||||
backScreen.uncivGame.setScreen(backScreen)
|
||||
backScreen.reloadGameListUI()
|
||||
}catch (ex: Exception) {
|
||||
val errorPopup = Popup(this)
|
||||
@ -393,7 +393,7 @@ class AddMultiplayerGameScreen(backScreen: MultiplayerScreen) : PickerScreen(){
|
||||
//CloseButton Setup
|
||||
closeButton.setText("Back".tr())
|
||||
closeButton.onClick {
|
||||
UncivGame.Current.setScreen(backScreen)
|
||||
backScreen.uncivGame.setScreen(backScreen)
|
||||
}
|
||||
|
||||
//RightSideButton Setup
|
||||
@ -408,7 +408,7 @@ class AddMultiplayerGameScreen(backScreen: MultiplayerScreen) : PickerScreen(){
|
||||
}
|
||||
|
||||
backScreen.addMultiplayerGame(gameIDTextField.text.trim(), gameNameTextField.text.trim())
|
||||
UncivGame.Current.setScreen(backScreen)
|
||||
backScreen.uncivGame.setScreen(backScreen)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,8 @@ import com.badlogic.gdx.scenes.scene2d.Group
|
||||
import com.badlogic.gdx.scenes.scene2d.Touchable
|
||||
import com.badlogic.gdx.scenes.scene2d.actions.Actions
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Label
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.city.CityConstructions
|
||||
import com.unciv.logic.city.CityInfo
|
||||
import com.unciv.logic.city.PerpetualConstruction
|
||||
@ -18,7 +16,9 @@ import com.unciv.ui.cityscreen.CityScreen
|
||||
import com.unciv.ui.trade.DiplomacyScreen
|
||||
import com.unciv.ui.utils.*
|
||||
|
||||
class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup, skin: Skin): Table(skin){
|
||||
class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup): Table(CameraStageBaseScreen.skin){
|
||||
val worldScreen = tileGroup.worldScreen
|
||||
val uncivGame = worldScreen.game
|
||||
|
||||
init {
|
||||
isTransform = true // If this is not set then the city button won't scale!
|
||||
@ -126,11 +126,11 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup, skin
|
||||
add(airUnitTable).row()
|
||||
}
|
||||
|
||||
private fun belongsToViewingCiv() = city.civInfo == UncivGame.Current.worldScreen.viewingCiv
|
||||
private fun belongsToViewingCiv() = city.civInfo == worldScreen.viewingCiv
|
||||
|
||||
private fun setButtonActions() {
|
||||
|
||||
val unitTable = tileGroup.worldScreen.bottomUnitTable
|
||||
val unitTable = worldScreen.bottomUnitTable
|
||||
|
||||
// So you can click anywhere on the button to go to the city
|
||||
touchable = Touchable.childrenOnly
|
||||
@ -139,16 +139,16 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup, skin
|
||||
// clicking swings the button a little down to allow selection of units there.
|
||||
// this also allows to target selected units to move to the city tile from elsewhere.
|
||||
if (isButtonMoved) {
|
||||
val viewingCiv = UncivGame.Current.worldScreen.viewingCiv
|
||||
val viewingCiv = worldScreen.viewingCiv
|
||||
// second tap on the button will go to the city screen
|
||||
// if this city belongs to you
|
||||
if (UncivGame.Current.viewEntireMapForDebug || belongsToViewingCiv()) {
|
||||
UncivGame.Current.setScreen(CityScreen(city))
|
||||
if (uncivGame.viewEntireMapForDebug || belongsToViewingCiv()) {
|
||||
uncivGame.setScreen(CityScreen(city))
|
||||
} else if (viewingCiv.knows(city.civInfo)) {
|
||||
// If city doesn't belong to you, go directly to its owner's diplomacy screen.
|
||||
val screen = DiplomacyScreen(viewingCiv)
|
||||
screen.updateRightSide(city.civInfo)
|
||||
UncivGame.Current.setScreen(screen)
|
||||
uncivGame.setScreen(screen)
|
||||
}
|
||||
} else {
|
||||
moveButtonDown()
|
||||
@ -203,7 +203,7 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup, skin
|
||||
iconTable.add(connectionImage).size(20f).pad(2f).padLeft(5f)
|
||||
}
|
||||
|
||||
iconTable.add(getPopulationGroup(UncivGame.Current.viewEntireMapForDebug || belongsToViewingCiv()))
|
||||
iconTable.add(getPopulationGroup(uncivGame.viewEntireMapForDebug || belongsToViewingCiv()))
|
||||
.padLeft(10f)
|
||||
|
||||
val cityButtonText = city.name
|
||||
@ -211,7 +211,7 @@ class CityButton(val city: CityInfo, private val tileGroup: WorldTileGroup, skin
|
||||
iconTable.add(label).pad(10f) // sufficient horizontal padding
|
||||
.fillY() // provide full-height clicking area
|
||||
|
||||
if (UncivGame.Current.viewEntireMapForDebug || belongsToViewingCiv())
|
||||
if (uncivGame.viewEntireMapForDebug || belongsToViewingCiv())
|
||||
iconTable.add(getConstructionGroup(city.cityConstructions)).padRight(10f).padLeft(10f)
|
||||
else if (city.civInfo.isMajorCiv()) {
|
||||
val nationIcon = ImageGetter.getNationIcon(city.civInfo.nation.name)
|
||||
|
@ -47,7 +47,7 @@ class WorldTileGroup(internal val worldScreen: WorldScreen, tileInfo: TileInfo,
|
||||
}
|
||||
if (city != null && tileInfo.isCityCenter()) {
|
||||
if (cityButton == null) {
|
||||
cityButton = CityButton(city, this, CameraStageBaseScreen.skin)
|
||||
cityButton = CityButton(city, this)
|
||||
cityButtonLayerGroup.addActor(cityButton)
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.Constants
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.GameSaver
|
||||
import com.unciv.logic.civilization.CivilizationInfo
|
||||
import com.unciv.logic.civilization.diplomacy.DiplomaticStatus
|
||||
@ -246,7 +245,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
bottomUnitTable.update()
|
||||
bottomTileInfoTable.updateTileTable(mapHolder.selectedTile)
|
||||
bottomTileInfoTable.x = stage.width - bottomTileInfoTable.width
|
||||
bottomTileInfoTable.y = if (UncivGame.Current.settings.showMinimap) minimapWrapper.height else 0f
|
||||
bottomTileInfoTable.y = if (game.settings.showMinimap) minimapWrapper.height else 0f
|
||||
battleTable.update()
|
||||
|
||||
tutorialTaskTable.clear()
|
||||
@ -341,7 +340,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
}
|
||||
|
||||
private fun displayTutorialsOnUpdate() {
|
||||
UncivGame.Current.crashController.showDialogIfNeeded()
|
||||
game.crashController.showDialogIfNeeded()
|
||||
|
||||
displayTutorial(Tutorial.Introduction)
|
||||
|
||||
@ -376,7 +375,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
.any()) {
|
||||
displayTutorial(Tutorial.OtherCivEncountered)
|
||||
val btn = "Diplomacy".toTextButton()
|
||||
btn.onClick { UncivGame.Current.setScreen(DiplomacyScreen(viewingCiv)) }
|
||||
btn.onClick { game.setScreen(DiplomacyScreen(viewingCiv)) }
|
||||
btn.label.setFontSize(30)
|
||||
btn.labelCell.pad(10f)
|
||||
diplomacyButtonWrapper.add(btn)
|
||||
@ -453,7 +452,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
}
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
UncivGame.Current.crashController.crashOccurred()
|
||||
game.crashController.crashOccurred()
|
||||
throw ex
|
||||
}
|
||||
|
||||
@ -478,7 +477,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
|
||||
if (gameInfoClone.currentPlayerCiv.civName != viewingCiv.civName
|
||||
&& !gameInfoClone.gameParameters.isOnlineMultiplayer)
|
||||
UncivGame.Current.setScreen(PlayerReadyScreen(gameInfoClone.getCurrentPlayerCivilization()))
|
||||
game.setScreen(PlayerReadyScreen(gameInfoClone.getCurrentPlayerCivilization()))
|
||||
else {
|
||||
createNewWorldScreen()
|
||||
}
|
||||
@ -577,7 +576,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
}
|
||||
|
||||
private fun showTutorialsOnNextTurn(){
|
||||
if (!UncivGame.Current.settings.showTutorials) return
|
||||
if (!game.settings.showTutorials) return
|
||||
displayTutorial(Tutorial.SlowStart)
|
||||
displayTutorial(Tutorial.CityExpansion){ viewingCiv.cities.any { it.expansion.tilesClaimed()>0 } }
|
||||
displayTutorial(Tutorial.BarbarianEncountered) { viewingCiv.viewableTiles.any { it.getUnits().any { unit -> unit.civInfo.isBarbarian() } } }
|
||||
@ -585,7 +584,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
|
||||
displayTutorial(Tutorial.Happiness) { viewingCiv.getHappiness() < 5 }
|
||||
displayTutorial(Tutorial.Unhappiness) { viewingCiv.getHappiness() < 0 }
|
||||
displayTutorial(Tutorial.GoldenAge) { viewingCiv.goldenAges.isGoldenAge() }
|
||||
displayTutorial(Tutorial.IdleUnits) { gameInfo.turns >= 50 && UncivGame.Current.settings.checkForDueUnits }
|
||||
displayTutorial(Tutorial.IdleUnits) { gameInfo.turns >= 50 && game.settings.checkForDueUnits }
|
||||
displayTutorial(Tutorial.ContactMe) { gameInfo.turns >= 100 }
|
||||
val resources = viewingCiv.detailedCivResources.asSequence().filter { it.origin == "All" } // Avoid full list copy
|
||||
displayTutorial(Tutorial.LuxuryResource) { resources.any { it.resource.resourceType==ResourceType.Luxury } }
|
||||
|
@ -51,7 +51,7 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
|
||||
val overviewButton = "Overview".toTextButton()
|
||||
overviewButton.labelCell.pad(10f)
|
||||
overviewButton.pack()
|
||||
overviewButton.onClick { UncivGame.Current.setScreen(EmpireOverviewScreen(worldScreen.viewingCiv)) }
|
||||
overviewButton.onClick { worldScreen.game.setScreen(EmpireOverviewScreen(worldScreen.viewingCiv)) }
|
||||
overviewButton.center(this)
|
||||
overviewButton.x = worldScreen.stage.width-overviewButton.width-10
|
||||
addActor(overviewButton)
|
||||
@ -70,7 +70,7 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
|
||||
val resourceLabel = "0".toLabel()
|
||||
resourceLabels[resource.name] = resourceLabel
|
||||
resourceTable.add(resourceLabel)
|
||||
val invokeResourcesPage = { UncivGame.Current.setScreen(EmpireOverviewScreen(worldScreen.viewingCiv, "Resources")) }
|
||||
val invokeResourcesPage = { worldScreen.game.setScreen(EmpireOverviewScreen(worldScreen.viewingCiv, "Resources")) }
|
||||
resourceLabel.onClick(invokeResourcesPage)
|
||||
resourceImage.onClick(invokeResourcesPage)
|
||||
}
|
||||
@ -86,27 +86,27 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
|
||||
statsTable.add(goldLabel)
|
||||
val goldImage = ImageGetter.getStatIcon("Gold")
|
||||
statsTable.add(goldImage).padRight(20f).size(20f)
|
||||
val invokeStatsPage = { UncivGame.Current.setScreen(EmpireOverviewScreen(worldScreen.viewingCiv, "Stats")) }
|
||||
val invokeStatsPage = { worldScreen.game.setScreen(EmpireOverviewScreen(worldScreen.viewingCiv, "Stats")) }
|
||||
goldLabel.onClick(invokeStatsPage)
|
||||
goldImage.onClick(invokeStatsPage)
|
||||
|
||||
statsTable.add(scienceLabel) //.apply { setAlignment(Align.center) }).align(Align.top)
|
||||
val scienceImage = ImageGetter.getStatIcon("Science")
|
||||
statsTable.add(scienceImage).padRight(20f).size(20f)
|
||||
val invokeTechScreen = { UncivGame.Current.setScreen(TechPickerScreen(worldScreen.viewingCiv)) }
|
||||
val invokeTechScreen = { worldScreen.game.setScreen(TechPickerScreen(worldScreen.viewingCiv)) }
|
||||
scienceLabel.onClick(invokeTechScreen)
|
||||
scienceImage.onClick(invokeTechScreen)
|
||||
|
||||
statsTable.add(happinessImage).size(20f)
|
||||
statsTable.add(happinessLabel).padRight(20f)//.apply { setAlignment(Align.center) }).align(Align.top)
|
||||
val invokeResourcesPage = { UncivGame.Current.setScreen(EmpireOverviewScreen(worldScreen.viewingCiv, "Resources")) }
|
||||
val invokeResourcesPage = { worldScreen.game.setScreen(EmpireOverviewScreen(worldScreen.viewingCiv, "Resources")) }
|
||||
happinessImage.onClick(invokeResourcesPage)
|
||||
happinessLabel.onClick(invokeResourcesPage)
|
||||
|
||||
statsTable.add(cultureLabel)//.apply { setAlignment(Align.center) }).align(Align.top)
|
||||
val cultureImage = ImageGetter.getStatIcon("Culture")
|
||||
statsTable.add(cultureImage).size(20f)
|
||||
val invokePoliciesPage = { UncivGame.Current.setScreen(PolicyPickerScreen(worldScreen)) }
|
||||
val invokePoliciesPage = { worldScreen.game.setScreen(PolicyPickerScreen(worldScreen)) }
|
||||
cultureLabel.onClick(invokePoliciesPage)
|
||||
cultureImage.onClick(invokePoliciesPage)
|
||||
|
||||
@ -155,7 +155,7 @@ class WorldScreenTopBar(val worldScreen: WorldScreen) : Table() {
|
||||
|
||||
val yearText = "["+ abs(year)+"] "+ if (year<0) "BC" else "AD"
|
||||
turnsLabel.setText("Turn".tr()+" " + civInfo.gameInfo.turns + " | "+ yearText.tr())
|
||||
turnsLabel.onClick { UncivGame.Current.setScreen(VictoryScreen(worldScreen)) }
|
||||
turnsLabel.onClick { worldScreen.game.setScreen(VictoryScreen(worldScreen)) }
|
||||
|
||||
val nextTurnStats = civInfo.statsForNextTurn
|
||||
val goldPerTurn = "(" + (if (nextTurnStats.gold > 0) "+" else "") + nextTurnStats.gold.roundToInt() + ")"
|
||||
|
@ -52,7 +52,7 @@ class WorldScreenMenuPopup(val worldScreen: WorldScreen) : Popup(worldScreen) {
|
||||
addSeparator()
|
||||
|
||||
addSquareButton("Multiplayer".tr()){
|
||||
worldScreen.game.setScreen(MultiplayerScreen())
|
||||
worldScreen.game.setScreen(MultiplayerScreen(worldScreen.game))
|
||||
close()
|
||||
}.size(width,height)
|
||||
addSeparator()
|
||||
@ -91,7 +91,7 @@ class WorldScreenMenuPopup(val worldScreen: WorldScreen) : Popup(worldScreen) {
|
||||
|
||||
// Create a new map
|
||||
mapEditorPopup.addButton("New map") {
|
||||
UncivGame.Current.setScreen(NewMapScreen())
|
||||
worldScreen.game.setScreen(NewMapScreen())
|
||||
mapEditorPopup.close()
|
||||
}
|
||||
|
||||
@ -100,9 +100,9 @@ class WorldScreenMenuPopup(val worldScreen: WorldScreen) : Popup(worldScreen) {
|
||||
val loadMapScreen = LoadMapScreen(null)
|
||||
loadMapScreen.closeButton.isVisible = true
|
||||
loadMapScreen.closeButton.onClick {
|
||||
UncivGame.Current.setWorldScreen()
|
||||
worldScreen.game.setWorldScreen()
|
||||
loadMapScreen.dispose() }
|
||||
UncivGame.Current.setScreen(loadMapScreen)
|
||||
worldScreen.game.setScreen(loadMapScreen)
|
||||
mapEditorPopup.close()
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ class Language(val language:String, val percentComplete:Int){
|
||||
|
||||
class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen) {
|
||||
var selectedLanguage: String = "English"
|
||||
private val settings = UncivGame.Current.settings
|
||||
private val settings = worldScreen.game.settings
|
||||
private val innerTable = Table(CameraStageBaseScreen.skin)
|
||||
|
||||
init {
|
||||
@ -43,7 +43,7 @@ class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen)
|
||||
addCloseButton() { worldScreen.enableNextTurnButtonAfterOptions() }
|
||||
|
||||
pack() // Needed to show the background.
|
||||
center(UncivGame.Current.worldScreen.stage)
|
||||
center(worldScreen.game.worldScreen.stage)
|
||||
}
|
||||
|
||||
private fun addHeader (text: String) {
|
||||
@ -56,16 +56,16 @@ class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen)
|
||||
action(it)
|
||||
settings.save()
|
||||
if (updateWorld)
|
||||
UncivGame.Current.worldScreen.shouldUpdate = true
|
||||
worldScreen.game.worldScreen.shouldUpdate = true
|
||||
}
|
||||
innerTable.add(button).row()
|
||||
}
|
||||
|
||||
private fun reloadWorldAndOptions() {
|
||||
settings.save()
|
||||
UncivGame.Current.worldScreen = WorldScreen(worldScreen.viewingCiv)
|
||||
UncivGame.Current.setWorldScreen()
|
||||
WorldScreenOptionsPopup(UncivGame.Current.worldScreen).open()
|
||||
worldScreen.game.worldScreen = WorldScreen(worldScreen.viewingCiv)
|
||||
worldScreen.game.setWorldScreen()
|
||||
WorldScreenOptionsPopup(worldScreen.game.worldScreen).open()
|
||||
}
|
||||
|
||||
private fun rebuildInnerTable() {
|
||||
@ -104,7 +104,7 @@ class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen)
|
||||
addYesNoRow ("Auto-assign city production", settings.autoAssignCityProduction, true) {
|
||||
settings.autoAssignCityProduction = it
|
||||
if (it && worldScreen.viewingCiv.isCurrentPlayer() && worldScreen.viewingCiv.playerType == PlayerType.Human) {
|
||||
UncivGame.Current.gameInfo.currentPlayerCiv.cities.forEach {
|
||||
worldScreen.game.gameInfo.currentPlayerCiv.cities.forEach {
|
||||
city -> city.cityConstructions.chooseNextConstruction()
|
||||
}
|
||||
}
|
||||
@ -125,7 +125,7 @@ class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen)
|
||||
addSetUserId()
|
||||
|
||||
innerTable.add("Version".toLabel()).pad(10f)
|
||||
innerTable.add(UncivGame.Current.version.toLabel()).pad(10f).row()
|
||||
innerTable.add(worldScreen.game.version.toLabel()).pad(10f).row()
|
||||
}
|
||||
|
||||
private fun addSetUserId() {
|
||||
@ -196,7 +196,7 @@ class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen)
|
||||
}
|
||||
|
||||
private fun addMusicVolumeSlider() {
|
||||
val musicLocation = Gdx.files.local(UncivGame.Current.musicLocation)
|
||||
val musicLocation = Gdx.files.local(worldScreen.game.musicLocation)
|
||||
if (musicLocation.exists()) {
|
||||
innerTable.add("Music volume".tr())
|
||||
|
||||
@ -206,9 +206,9 @@ class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen)
|
||||
settings.musicVolume = musicVolumeSlider.value
|
||||
settings.save()
|
||||
|
||||
val music = UncivGame.Current.music
|
||||
val music = worldScreen.game.music
|
||||
if (music == null) // restart music, if it was off at the app start
|
||||
thread(name = "Music") { UncivGame.Current.startMusic() }
|
||||
thread(name = "Music") { worldScreen.game.startMusic() }
|
||||
|
||||
music?.volume = 0.4f * musicVolumeSlider.value
|
||||
}
|
||||
@ -229,7 +229,7 @@ class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen)
|
||||
val file = DropBox.downloadFile("/Music/thatched-villagers.mp3")
|
||||
musicLocation.write(file, false)
|
||||
rebuildInnerTable()
|
||||
UncivGame.Current.startMusic()
|
||||
worldScreen.game.startMusic()
|
||||
} catch (ex: Exception) {
|
||||
errorTable.clear()
|
||||
errorTable.add("Could not download music!".toLabel(Color.RED))
|
||||
@ -310,7 +310,7 @@ class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen)
|
||||
private fun addLanguageSelectBox() {
|
||||
val languageSelectBox = SelectBox<Language>(skin)
|
||||
val languageArray = Array<Language>()
|
||||
UncivGame.Current.translations.percentCompleteOfLanguages
|
||||
worldScreen.game.translations.percentCompleteOfLanguages
|
||||
.map { Language(it.key, if (it.key == "English") 100 else it.value) }
|
||||
.sortedByDescending { it.percentComplete }
|
||||
.forEach { languageArray.add(it) }
|
||||
@ -333,7 +333,7 @@ class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen)
|
||||
|
||||
private fun selectLanguage() {
|
||||
settings.language = selectedLanguage
|
||||
UncivGame.Current.translations.tryReadTranslationForCurrentLanguage()
|
||||
worldScreen.game.translations.tryReadTranslationForCurrentLanguage()
|
||||
CameraStageBaseScreen.resetFonts() // to load chinese characters if necessary
|
||||
reloadWorldAndOptions()
|
||||
}
|
||||
|
Reference in New Issue
Block a user