diff --git a/android/assets/ExtraImages/TileClicked.png b/android/assets/ExtraImages/TileClicked.png new file mode 100644 index 0000000000..bc255e9fc2 Binary files /dev/null and b/android/assets/ExtraImages/TileClicked.png differ diff --git a/android/assets/ExtraImages/TileLayout.png b/android/assets/ExtraImages/TileLayout.png new file mode 100644 index 0000000000..47d9569c06 Binary files /dev/null and b/android/assets/ExtraImages/TileLayout.png differ diff --git a/android/assets/ExtraImages/UnitSelected.png b/android/assets/ExtraImages/UnitSelected.png new file mode 100644 index 0000000000..a365d452ca Binary files /dev/null and b/android/assets/ExtraImages/UnitSelected.png differ diff --git a/android/assets/jsons/Tutorials_English.json b/android/assets/jsons/Tutorials_English.json index dcd443b5e4..c25df36b74 100644 --- a/android/assets/jsons/Tutorials_English.json +++ b/android/assets/jsons/Tutorials_English.json @@ -79,13 +79,6 @@ ] ], - TileClicked : [ - [ - "Clicking on a tile selects that tile,", - " and displays information on that tile on the bottom-right,", - " as well as unit actions, if the tile contains a unit" - ] - ], CityFounded : [ [ @@ -113,11 +106,6 @@ " be guiding you along your first journey.", "Before we begin, let's review some basic game concepts." ], - [ - "This is the world map, which is made up of multiple tiles.", - "Each tile can contain units, as well as resources", - " and improvements, which we'll get to later" - ], [ "You start out with two units -", " a Settler - who can found a city,", @@ -126,6 +114,32 @@ ] ], + TileLayout: [ + [ + "This is the world map, which is made up of multiple tiles.", + "Each tile can contain units, resources and improvements, which we'll get to later.", + "The position of the icon tells you what it signifies.", + "For more details, you can click on the tile and see the tile information." + ] + ], + + + TileClicked : [ + [ + "Clicking on a tile selects that tile,", + " and displays information on that tile on the bottom-right.", + "If the tile contains a unit, that will become the selected unit," + " and its info and actions will be displayed on the bottom left." + ] + ], + + UnitSelected : [ + [ + "When a unit is selected, its information will be displayed on the bottom-left corner.", + "The available actions of that unit will appear above the tile information." + ] + ], + AfterCityEntered : [ [ "Once you've done everything you can, ", diff --git a/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt b/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt index 2f2f847cee..1efb09c4a2 100644 --- a/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt +++ b/core/src/com/unciv/ui/utils/CameraStageBaseScreen.kt @@ -18,14 +18,17 @@ import com.badlogic.gdx.utils.viewport.ExtendViewport import com.unciv.UnCivGame import com.unciv.models.gamebasics.GameBasics import java.util.* +import kotlin.collections.ArrayList import kotlin.collections.HashMap +class Tutorial(var name: String, var texts: ArrayList) {} + open class CameraStageBaseScreen : Screen { var game: UnCivGame = UnCivGame.Current var stage: Stage - private val tutorialTexts = mutableListOf() + private val tutorialTexts = mutableListOf() private var isTutorialShowing = false @@ -58,16 +61,16 @@ open class CameraStageBaseScreen : Screen { override fun dispose() {} - fun getTutorialsOfLanguage(language: String): HashMap> { + fun getTutorialsOfLanguage(language: String): HashMap> { if(!Gdx.files.internal("jsons/Tutorials_$language.json").exists()) return hashMapOf() // ...Yes. Disgusting. I wish I didn't have to do this. val x = LinkedHashMap>>() val tutorials: LinkedHashMap>> = GameBasics.getFromJson(x.javaClass, "Tutorials_$language") - val tutorialMap = HashMap>() + val tutorialMap = HashMap>() for (tut in tutorials){ - val list = mutableListOf() + val list = ArrayList() for(paragraph in tut.value) list += paragraph.joinToString("\n") tutorialMap[tut.key] = list @@ -75,7 +78,7 @@ open class CameraStageBaseScreen : Screen { return tutorialMap } - fun getTutorials(name:String, language:String):List{ + fun getTutorials(name:String, language:String):ArrayList{ val tutorialsOfLanguage = getTutorialsOfLanguage(language) if(tutorialsOfLanguage.containsKey(name)) return tutorialsOfLanguage[name]!! return getTutorialsOfLanguage("English")[name]!! @@ -86,7 +89,7 @@ open class CameraStageBaseScreen : Screen { UnCivGame.Current.settings.tutorialsShown.add(name) UnCivGame.Current.settings.save() val texts = getTutorials(name,UnCivGame.Current.settings.language) - tutorialTexts.addAll(texts) + tutorialTexts.add(Tutorial(name,texts)) if (!isTutorialShowing) displayTutorial() } @@ -94,11 +97,17 @@ open class CameraStageBaseScreen : Screen { isTutorialShowing = true val tutorialTable = Table().pad(10f) tutorialTable.background = ImageGetter.getBackground(Color(0x101050cf)) - val label = Label(tutorialTexts[0], skin) + val currentTutorial = tutorialTexts[0] + val label = Label(currentTutorial.texts[0], skin) label.setAlignment(Align.center) - tutorialTexts.removeAt(0) + if(Gdx.files.internal("ExtraImages/"+currentTutorial.name+".png").exists()) + tutorialTable.add(Table().apply { add(ImageGetter.getExternalImage(currentTutorial.name)) }).row() tutorialTable.add(label).pad(10f).row() val button = TextButton("Close".tr(), skin) + + currentTutorial.texts.removeAt(0) + if(currentTutorial.texts.isEmpty()) tutorialTexts.removeAt(0) + button.onClick { tutorialTable.remove() if (!tutorialTexts.isEmpty()) diff --git a/core/src/com/unciv/ui/utils/ImageGetter.kt b/core/src/com/unciv/ui/utils/ImageGetter.kt index 74c540432d..51cee2e43e 100644 --- a/core/src/com/unciv/ui/utils/ImageGetter.kt +++ b/core/src/com/unciv/ui/utils/ImageGetter.kt @@ -1,6 +1,7 @@ package com.unciv.ui.utils import com.badlogic.gdx.graphics.Color +import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.graphics.g2d.TextureAtlas import com.badlogic.gdx.graphics.g2d.TextureRegion import com.badlogic.gdx.scenes.scene2d.Actor @@ -24,6 +25,10 @@ object ImageGetter { init{ } + fun getExternalImage(fileName:String): Image { + return Image(TextureRegion(Texture("ExtraImages/$fileName.png"))) + } + fun getImage(fileName: String): Image { return Image(getTextureRegion(fileName)) } diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index 92f43f83cc..2ddbf4ba38 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -79,12 +79,19 @@ class WorldScreen : CameraStageBaseScreen() { tileMapHolder.setCenterPosition(tileToCenterOn) createNextTurnButton() // needs civ table to be positioned displayTutorials("NewGame") + displayTutorials("TileLayout") } fun update() { // many of the display functions will be called with the game clone and not the actual game, // because that's guaranteed to stay the exact same and so we won't get any concurrent modification exceptions +// val showImageTable = PopupTable() +// showImageTable.add(ImageGetter.getExternalImage("IconTutorial.png")).row() +// showImageTable.addButton("Close"){showImageTable.remove()} +// showImageTable.pack() +// stage.addActor(showImageTable) + val gameClone = gameInfo.clone() val cloneCivilization = gameClone.getPlayerCivilization() @@ -92,6 +99,10 @@ class WorldScreen : CameraStageBaseScreen() { civInfo.happiness = gameClone.getPlayerCivilization().getHappinessForNextTurn().values.sum().toInt() } + if(bottomBar.unitTable.selectedUnit!=null){ + displayTutorials("UnitSelected") + } + if(UnCivGame.Current.settings.hasCrashedRecently){ displayTutorials("GameCrashed") UnCivGame.Current.settings.tutorialsShown.remove("GameCrashed")