From 58d58ef3a3e72ecbe9846168a235ee2c67902bcd Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 12 Dec 2019 20:58:02 +0200 Subject: [PATCH] Cleaned up tutorials --- android/assets/GameSettingsOld.json | 2 +- .../jsons/Tutorials/Tutorials_English.json | 40 ++++--------- .../logic/civilization/CivilizationInfo.kt | 2 +- core/src/com/unciv/logic/map/MapUnit.kt | 2 +- .../com/unciv/models/metadata/GameSettings.kt | 6 +- .../src/com/unciv/ui/cityscreen/CityScreen.kt | 5 +- .../unciv/ui/cityscreen/ConstructionsTable.kt | 2 +- .../ui/pickerscreens/TechPickerScreen.kt | 2 +- core/src/com/unciv/ui/utils/Tutorials.kt | 4 +- .../com/unciv/ui/worldscreen/TileMapHolder.kt | 3 +- .../com/unciv/ui/worldscreen/WorldScreen.kt | 58 +++++++++---------- .../optionstable/WorldScreenOptionsTable.kt | 2 +- .../unciv/ui/worldscreen/unit/UnitActions.kt | 2 +- 13 files changed, 55 insertions(+), 75 deletions(-) diff --git a/android/assets/GameSettingsOld.json b/android/assets/GameSettingsOld.json index 9bc23c3353991..aa3cc5edc36aa 100644 --- a/android/assets/GameSettingsOld.json +++ b/android/assets/GameSettingsOld.json @@ -1 +1 @@ -{showWorkedTiles:true,resolution:900x600,tutorialsShown:[_OtherCivEncountered,CityFounded,_BarbarianEncountered,ContactMe,TechPickerScreen,CityEntered,AfterCityEntered,EnemyCity,GoldenAge,Roads_and_Railroads,LuxuryResource,StrategicResource,Unhappiness,NewGame,TileLayout,UnitSelected,TileClicked,Injured_Units,Workers,CanEmbark,Siege_Units,_EnemyCityNeedsConqueringWithMeleeUnit,NextTurn,PolicyPickerScreen,City_Range,Apollo_Program],soundEffectsVolume:0.1,tileSet:ThorfMaps} \ No newline at end of file +{showResourcesAndImprovements:false,tutorialsShown:[World_Map,Unit_Selected,Slow_Start,_City_Founded,First_Steps,Injured_Units,Workers,_OtherCivEncountered,_BarbarianEncountered,Roads_and_Railroads,Golden_Age,Idle_Units,Contact_Me,Luxury_Resource,Strategic_Resource,Enemy_City,Apollo_Program,Embarking,Tile_Clicked,Technology,Culture_and_Policies,City_Range,Cities,Next_Turn,Siege_Units,Happiness,Unhappiness,New_Game,_GameCrashed],missionsCompleted:[Move unit,Found city,Enter city screen,Found city,Enter city screen,Enter city screen,Found city,Pick technology,Enter city screen,Pick construction,Found city,Enter city screen,Enter city screen,Pass a turn,Enter city screen,Enter city screen,Reassign worked tiles,Pass a turn,Meet another civilization,Open the options table,Pass a turn,Pass a turn,Meet another civilization,Pass a turn,Pick technology,Pass a turn,Pass a turn,Move unit],soundEffectsVolume:1,musicVolume:0,showPixelUnits:true,nuclearWeaponEnabled:true,userId:8d2cbffc-2b96-4617-aa49-0c68f6fe15c4} \ No newline at end of file diff --git a/android/assets/jsons/Tutorials/Tutorials_English.json b/android/assets/jsons/Tutorials/Tutorials_English.json index 73af7e2e63bb0..1c8eb0fdc5d12 100644 --- a/android/assets/jsons/Tutorials/Tutorials_English.json +++ b/android/assets/jsons/Tutorials/Tutorials_English.json @@ -1,6 +1,14 @@ { // Each entry s a tutorial, but the tutorial may be spread over separate paragraphs. // Entries starting with a _ will NOT be shown in Civilopedia. + + Introduction: [ + [ + "Welcome to Unciv!", + "Because this is a complex game, there are basic tasks to help familiarize you with the game.", + "These are completely optional, and you're welcome to explore the game on your own!", + ] + ], // Civilopedia only, because players said this was too wall-of-text New_Game: [ @@ -64,26 +72,6 @@ ] ], - Cities: [ - [ - "Each population in your city can work a single tile, providing the city with that tile's yields.", - "Population can be assigned and unassigned by clicking on the tiles - ", - " but of course, you can only assign population if you have idle population to spare!" - ], - [ - "The center tile of a city is always worked, and doesn't require population,", - " but it cannot be improved by tile improvements." - "The city's production always goes towards the current construction - ", - " you can pick the city's construction by clicking on the construction button on the bottom-left" - ] - [ - "Cities grow in population when you amass enough surplus food.", - "Similarly, your city's borders grow when you amass enough culture,", - " which is not generated by tiles but rather by buildings." - ], - ], - - Happiness:[ @@ -176,19 +164,14 @@ Luxury_Resource: [ [ "Luxury resources within your domain and with their specific improvement are connected to your trade network.", - "Each unique Luxury resource you have adds 5 happiness to your civilization,", - " but extra resources of the same type don't add anything, ", - " so use them for trading with other civilizations!" + "Each unique Luxury resource you have adds 5 happiness to your civilization, but extra resources of the same type don't add anything, so use them for trading with other civilizations!" ] ] Strategic_Resource: [ [ "Strategic resources within your domain and with their specific improvement are connected to your trade network.", - "Strategic resources allow you to train units and construct buildings that", - " require those specific resources, for example the Horseman requires Horses." - "Each unit 'consumes' a copy of that resource, but if the unit is killed you can ", - " construct a new unit wth your now-unused resource.", + "Strategic resources allow you to train units and construct buildings that require those specific resources, for example the Horseman requires Horses." "The top bar keeps count of how many unused strategic resources you own." ] ] @@ -258,8 +241,7 @@ Workers:[ [ "Workers are vital to your cities' growth, since only they can construct improvements on tiles", - "Improvements raise the yield of your tiles, allowing your city to produce more and grow faster", - " while working the same amount of tiles!" + "Improvements raise the yield of your tiles, allowing your city to produce more and grow faster while working the same amount of tiles!" ] ] diff --git a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt index e6020b2de972b..174152f6e3ba5 100644 --- a/core/src/com/unciv/logic/civilization/CivilizationInfo.kt +++ b/core/src/com/unciv/logic/civilization/CivilizationInfo.kt @@ -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 diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index 42267bc7f3ec6..bebb95536d2de 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -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() diff --git a/core/src/com/unciv/models/metadata/GameSettings.kt b/core/src/com/unciv/models/metadata/GameSettings.kt index 95c9ff8db524a..568e33b57cc10 100644 --- a/core/src/com/unciv/models/metadata/GameSettings.kt +++ b/core/src/com/unciv/models/metadata/GameSettings.kt @@ -10,7 +10,7 @@ class GameSettings { var language: String = "English" var resolution: String = "900x600" var tutorialsShown = ArrayList() - var missionsCompleted = ArrayList() + var tutorialTasksCompleted = ArrayList() 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() } } \ No newline at end of file diff --git a/core/src/com/unciv/ui/cityscreen/CityScreen.kt b/core/src/com/unciv/ui/cityscreen/CityScreen.kt index 223792a0a9867..fe8e61cab364c 100644 --- a/core/src/com/unciv/ui/cityscreen/CityScreen.kt +++ b/core/src/com/unciv/ui/cityscreen/CityScreen.kt @@ -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() diff --git a/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt b/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt index 0e748ac3b7c24..03548ddd0f68b 100644 --- a/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt +++ b/core/src/com/unciv/ui/cityscreen/ConstructionsTable.kt @@ -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") } } diff --git a/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt b/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt index 8697a8c6232ff..4adf33b8a6c4a 100644 --- a/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt +++ b/core/src/com/unciv/ui/pickerscreens/TechPickerScreen.kt @@ -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 diff --git a/core/src/com/unciv/ui/utils/Tutorials.kt b/core/src/com/unciv/ui/utils/Tutorials.kt index 23f30603bc47d..6e3e8a780f3cb 100644 --- a/core/src/com/unciv/ui/utils/Tutorials.kt +++ b/core/src/com/unciv/ui/utils/Tutorials.kt @@ -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 try { texts = getTutorials(name, UncivGame.Current.settings.language) } catch (ex: Exception) { - texts = ArrayList().apply { add("Could not find matching tutorial!") } + texts = ArrayList().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) } diff --git a/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt b/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt index 299226cc92cb4..9f39f400752e5 100644 --- a/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt +++ b/core/src/com/unciv/ui/worldscreen/TileMapHolder.kt @@ -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() } diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index d3099baf32127..b7f8184beae76 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -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")) diff --git a/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenOptionsTable.kt b/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenOptionsTable.kt index 9cf37ba89f431..6c2730de9c4e7 100644 --- a/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenOptionsTable.kt +++ b/core/src/com/unciv/ui/worldscreen/optionstable/WorldScreenOptionsTable.kt @@ -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() } diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt index 1c145ab0f4768..59aae37dc5674 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt @@ -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()