Cleaned up tutorials

This commit is contained in:
Yair Morgenstern
2019-12-12 20:58:02 +02:00
parent acf91b4e12
commit 58d58ef3a3
13 changed files with 55 additions and 75 deletions

View File

@ -255,7 +255,7 @@ class CivilizationInfo {
popupAlerts.add(PopupAlert(AlertType.FirstContact,otherCiv.civName))
if(isCurrentPlayer() || otherCiv.isCurrentPlayer())
UncivGame.Current.settings.addMissionCompleted("Meet another civilization")
UncivGame.Current.settings.addCompletedTutorialTask("Meet another civilization")
}
override fun toString(): String {return civName} // for debug

View File

@ -327,7 +327,7 @@ class MapUnit {
if (tile.turnsToImprovement != 0) return
if(civInfo.isCurrentPlayer())
UncivGame.Current.settings.addMissionCompleted("Construct an improvement")
UncivGame.Current.settings.addCompletedTutorialTask("Construct an improvement")
when {
tile.improvementInProgress!!.startsWith("Remove") -> {
val tileImprovement = tile.getTileImprovement()

View File

@ -10,7 +10,7 @@ class GameSettings {
var language: String = "English"
var resolution: String = "900x600"
var tutorialsShown = ArrayList<String>()
var missionsCompleted = ArrayList<String>()
var tutorialTasksCompleted = ArrayList<String>()
var hasCrashedRecently = false
var soundEffectsVolume = 0.5f
var musicVolume = 0.5f
@ -30,8 +30,8 @@ class GameSettings {
GameSaver().setGeneralSettings(this)
}
fun addMissionCompleted(mission:String){
missionsCompleted.add(mission)
fun addCompletedTutorialTask(tutorialTask:String){
tutorialTasksCompleted.add(tutorialTask)
save()
}
}

View File

@ -48,7 +48,7 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
init {
onBackButtonClicked { game.setWorldScreen() }
addTiles()
UncivGame.Current.settings.addMissionCompleted("Enter city screen")
UncivGame.Current.settings.addCompletedTutorialTask("Enter city screen")
val tableBackgroundColor = ImageGetter.getBlue().lerp(Color.BLACK,0.5f)
@ -71,7 +71,6 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
stage.addActor(buildingsTableContainer)
update()
displayTutorials("Cities")
}
internal fun update() {
@ -217,7 +216,7 @@ class CityScreen(internal val city: CityInfo) : CameraStageBaseScreen() {
if (tileGroup.isWorkable && UncivGame.Current.worldScreen.isPlayersTurn) {
if (!tileInfo.isWorked() && city.population.getFreePopulation() > 0) {
city.workedTiles.add(tileInfo.position)
game.settings.addMissionCompleted("Reassign worked tiles")
game.settings.addCompletedTutorialTask("Reassign worked tiles")
}
else if (tileInfo.isWorked()) city.workedTiles.remove(tileInfo.position)
city.cityStats.update()

View File

@ -55,7 +55,7 @@ class ConstructionsTable(val cityScreen: CityScreen) : Table(CameraStageBaseScre
cityScreen.city.cityConstructions.currentConstructionIsUserSet = true
cityScreen.city.cityStats.update()
cityScreen.update()
cityScreen.game.settings.addMissionCompleted("Pick construction")
cityScreen.game.settings.addCompletedTutorialTask("Pick construction")
}
}

View File

@ -51,7 +51,7 @@ class TechPickerScreen(internal val civInfo: CivilizationInfo, centerOnTech: Tec
setButtonsInfo()
rightSideButton.setText("Pick a tech".tr())
rightSideButton.onClick("paper") {
game.settings.addMissionCompleted("Pick technology")
game.settings.addCompletedTutorialTask("Pick technology")
if (isFreeTechPick) civTech.getFreeTechnology(selectedTech!!.name)
else civTech.techsToResearch = tempTechsToResearch

View File

@ -23,14 +23,14 @@ class Tutorials{
fun displayTutorials(name: String, screen:CameraStageBaseScreen) {
if (!UncivGame.Current.settings.showTutorials) return
if (UncivGame.Current.settings.tutorialsShown.contains(name)) return
if(tutorialTexts.any { it.name==name }) return // currently showing
var texts: ArrayList<String>
try {
texts = getTutorials(name, UncivGame.Current.settings.language)
} catch (ex: Exception) {
texts = ArrayList<String>().apply { add("Could not find matching tutorial!") }
texts = ArrayList<String>().apply { add("Could not find matching tutorial: $name") }
}
if(tutorialTexts.any { it.name==name }) return // currently showing
tutorialTexts.add(Tutorial(name, texts))
if (!isTutorialShowing) displayTutorial(screen)
}

View File

@ -104,7 +104,6 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
}
private fun onTileClicked(tileInfo: TileInfo) {
worldScreen.displayTutorials("Tile_Clicked")
unitActionOverlay?.remove()
selectedTile = tileInfo
@ -205,7 +204,7 @@ class TileMapHolder(internal val worldScreen: WorldScreen, internal val tileMap:
if (dto.unit.currentMovement > 0)
moveHereButton.onClick(""){
UncivGame.Current.settings.addMissionCompleted("Move unit")
UncivGame.Current.settings.addCompletedTutorialTask("Move unit")
UnitContextMenu(this, dto.unit, dto.tileInfo).onMoveButtonClick()
}

View File

@ -51,7 +51,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
private val techButtonHolder = Table()
private val diplomacyButtonWrapper = Table()
private val nextTurnButton = createNextTurnButton()
private val missionTable=Table().apply { background=ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f)) }
private val tutorialTaskTable=Table().apply { background=ImageGetter.getBackground(ImageGetter.getBlue().lerp(Color.BLACK, 0.5f)) }
private val notificationsScroll: NotificationsScroll
var alertPopupIsOpen = false // if we have an alert popup and then we changed screens, the old one shouldn't affect us
@ -89,7 +89,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
stage.addActor(nextTurnButton)
stage.addActor(techPolicyandVictoryHolder)
stage.addActor(notificationsScroll)
stage.addActor(missionTable)
stage.addActor(tutorialTaskTable)
diplomacyButtonWrapper.defaults().pad(5f)
@ -164,19 +164,20 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
bottomUnitTable.update()
bottomTileInfoTable.updateTileTable(tileMapHolder.selectedTile!!)
bottomTileInfoTable.x=stage.width-bottomTileInfoTable.width
bottomTileInfoTable.y=if(UncivGame.Current.settings.showMinimap)minimapWrapper.height else 0f
bottomTileInfoTable.x = stage.width - bottomTileInfoTable.width
bottomTileInfoTable.y = if (UncivGame.Current.settings.showMinimap) minimapWrapper.height else 0f
battleTable.update()
missionTable.clear()
val mission =getCurrentMission()
if(mission==""){missionTable.isVisible=false}
else {
missionTable.add(mission.toLabel()
tutorialTaskTable.clear()
val tutorialTask = getCurrentTutorialTask()
if (tutorialTask == "") {
tutorialTaskTable.isVisible = false
} else {
tutorialTaskTable.add(tutorialTask.toLabel()
.apply { setAlignment(Align.center) }).pad(10f)
missionTable.pack()
missionTable.centerX(stage)
missionTable.y = topBar.y - missionTable.height
tutorialTaskTable.pack()
tutorialTaskTable.centerX(stage)
tutorialTaskTable.y = topBar.y - tutorialTaskTable.height
}
minimapWrapper.update(viewingCiv)
@ -198,7 +199,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
val isSomethingOpen = tutorials.isTutorialShowing || stage.actors.any { it is TradePopup }
|| alertPopupIsOpen
if(!isSomethingOpen && isPlayersTurn) {
if (!isSomethingOpen && isPlayersTurn) {
when {
!gameInfo.oneMoreTurnMode && gameInfo.civilizations.any { it.victoryManager.hasWon() } -> game.setScreen(VictoryScreen())
viewingCiv.policies.freePolicies > 0 && viewingCiv.policies.canAdoptPolicy() -> game.setScreen(PolicyPickerScreen(this))
@ -211,31 +212,30 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
notificationsScroll.update(viewingCiv.notifications)
notificationsScroll.setPosition(stage.width - notificationsScroll.width - 5f,
nextTurnButton.y - notificationsScroll.height - 5f)
}
private fun getCurrentMission(): String {
val completedMissions = game.settings.missionsCompleted
if(!completedMissions.contains("Move unit"))
private fun getCurrentTutorialTask(): String {
val completedTasks = game.settings.tutorialTasksCompleted
if(!completedTasks.contains("Move unit"))
return "Move a unit!\nClick on a unit > Click on a destination > Click the arrow popup"
if(!completedMissions.contains("Found city"))
if(!completedTasks.contains("Found city"))
return "Found a city!\nSelect the Settler (flag unit) > Click on 'Found city' (bottom-left corner)"
if(!completedMissions.contains("Enter city screen"))
if(!completedTasks.contains("Enter city screen"))
return "Enter the city screen!\nClick the city button twice"
if(!completedMissions.contains("Pick technology"))
if(!completedTasks.contains("Pick technology"))
return "Pick a technology to research!\nClick on the tech button (greenish, top left) > \n select technology > click 'Research' (bottom right)"
if(!completedMissions.contains("Pick construction"))
if(!completedTasks.contains("Pick construction"))
return "Pick a construction!\nEnter city screen > Click on a unit or building (left side)"
if(!completedMissions.contains("Pass a turn"))
if(!completedTasks.contains("Pass a turn"))
return "Pass a turn!\nCycle through units with 'Next unit' > Click 'Next turn'"
if(!completedMissions.contains("Reassign worked tiles"))
if(!completedTasks.contains("Reassign worked tiles"))
return "Reassign worked tiles!\nEnter city screen > click the assigned (green) tile to unassign > " +
"\n click an unassigned tile to assign population"
if(!completedMissions.contains("Meet another civilization"))
if(!completedTasks.contains("Meet another civilization"))
return "Meet another civilization!\nExplore the map until you encounter another civilization!"
if(!completedMissions.contains("Open the options table"))
if(!completedTasks.contains("Open the options table"))
return "Open the options table!\nClick the menu button (top left) > click 'Options'"
if(!completedMissions.contains("Construct an improvement"))
if(!completedTasks.contains("Construct an improvement"))
return "Construct an improvement!\nConstruct a Worker unit > Move to a Plains or Grassland tile > " +
"\n Choose 'Create improvement' > Choose the farm > " +
"\n Leave the worker there until it's finished"
@ -251,7 +251,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
UncivGame.Current.settings.save()
}
displayTutorials("Introduction")
if (!UncivGame.Current.settings.tutorialsShown.contains("_EnemyCityNeedsConqueringWithMeleeUnit")) {
for (enemyCity in viewingCiv.diplomacy.values.filter { it.diplomaticStatus == DiplomaticStatus.War }
.map { it.otherCiv() }.flatMap { it.cities }) {
@ -348,7 +348,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
return@onClick
}
game.settings.addMissionCompleted("Pass a turn")
game.settings.addCompletedTutorialTask("Pass a turn")
nextTurn() // If none of the above
}
@ -480,7 +480,7 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
if(resources.any { it.resource.resourceType==ResourceType.Luxury }) displayTutorials("Luxury_Resource")
if(resources.any { it.resource.resourceType==ResourceType.Strategic}) displayTutorials("Strategic_Resource")
if("Enemy_City" !in shownTutorials
&& gameInfo.civilizations.filter { it!=viewingCiv }
&& viewingCiv.getKnownCivs().filter { viewingCiv.isAtWarWith(it) }
.flatMap { it.cities }.any { viewingCiv.exploredTiles.contains(it.location) })
displayTutorials("Enemy_City")
if(viewingCiv.containsBuildingUnique("Enables construction of Spaceship parts"))

View File

@ -30,7 +30,7 @@ class WorldScreenOptionsTable(val worldScreen:WorldScreen) : PopupTable(worldScr
var selectedLanguage: String = "English"
init {
UncivGame.Current.settings.addMissionCompleted("Open the options table")
UncivGame.Current.settings.addCompletedTutorialTask("Open the options table")
update()
open()
}

View File

@ -132,7 +132,7 @@ class UnitActions {
unit.currentMovement >0 &&
!tile.getTilesInDistance(3).any { it.isCityCenter() })
{
UncivGame.Current.settings.addMissionCompleted("Found city")
UncivGame.Current.settings.addCompletedTutorialTask("Found city")
unit.civInfo.addCity(tile.position)
tile.improvement = null
unit.destroy()