mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-22 05:41:11 +07:00
Can now add images to tutorials! Added images for Tile Clicked, Unit Selected and Tile Layout tutorials.
This commit is contained in:
BIN
android/assets/ExtraImages/TileClicked.png
Normal file
BIN
android/assets/ExtraImages/TileClicked.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 62 KiB |
BIN
android/assets/ExtraImages/TileLayout.png
Normal file
BIN
android/assets/ExtraImages/TileLayout.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 82 KiB |
BIN
android/assets/ExtraImages/UnitSelected.png
Normal file
BIN
android/assets/ExtraImages/UnitSelected.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 124 KiB |
@ -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 : [
|
CityFounded : [
|
||||||
[
|
[
|
||||||
@ -113,11 +106,6 @@
|
|||||||
" be guiding you along your first journey.",
|
" be guiding you along your first journey.",
|
||||||
"Before we begin, let's review some basic game concepts."
|
"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 -",
|
"You start out with two units -",
|
||||||
" a Settler - who can found a city,",
|
" 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 : [
|
AfterCityEntered : [
|
||||||
[
|
[
|
||||||
"Once you've done everything you can, ",
|
"Once you've done everything you can, ",
|
||||||
|
@ -18,14 +18,17 @@ import com.badlogic.gdx.utils.viewport.ExtendViewport
|
|||||||
import com.unciv.UnCivGame
|
import com.unciv.UnCivGame
|
||||||
import com.unciv.models.gamebasics.GameBasics
|
import com.unciv.models.gamebasics.GameBasics
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import kotlin.collections.ArrayList
|
||||||
import kotlin.collections.HashMap
|
import kotlin.collections.HashMap
|
||||||
|
|
||||||
|
class Tutorial(var name: String, var texts: ArrayList<String>) {}
|
||||||
|
|
||||||
open class CameraStageBaseScreen : Screen {
|
open class CameraStageBaseScreen : Screen {
|
||||||
|
|
||||||
var game: UnCivGame = UnCivGame.Current
|
var game: UnCivGame = UnCivGame.Current
|
||||||
var stage: Stage
|
var stage: Stage
|
||||||
|
|
||||||
private val tutorialTexts = mutableListOf<String>()
|
private val tutorialTexts = mutableListOf<Tutorial>()
|
||||||
|
|
||||||
private var isTutorialShowing = false
|
private var isTutorialShowing = false
|
||||||
|
|
||||||
@ -58,16 +61,16 @@ open class CameraStageBaseScreen : Screen {
|
|||||||
|
|
||||||
override fun dispose() {}
|
override fun dispose() {}
|
||||||
|
|
||||||
fun getTutorialsOfLanguage(language: String): HashMap<String, List<String>> {
|
fun getTutorialsOfLanguage(language: String): HashMap<String, ArrayList<String>> {
|
||||||
if(!Gdx.files.internal("jsons/Tutorials_$language.json").exists()) return hashMapOf()
|
if(!Gdx.files.internal("jsons/Tutorials_$language.json").exists()) return hashMapOf()
|
||||||
|
|
||||||
// ...Yes. Disgusting. I wish I didn't have to do this.
|
// ...Yes. Disgusting. I wish I didn't have to do this.
|
||||||
val x = LinkedHashMap<String,com.badlogic.gdx.utils.Array<com.badlogic.gdx.utils.Array<String>>>()
|
val x = LinkedHashMap<String,com.badlogic.gdx.utils.Array<com.badlogic.gdx.utils.Array<String>>>()
|
||||||
val tutorials: LinkedHashMap<String, com.badlogic.gdx.utils.Array<com.badlogic.gdx.utils.Array<String>>> =
|
val tutorials: LinkedHashMap<String, com.badlogic.gdx.utils.Array<com.badlogic.gdx.utils.Array<String>>> =
|
||||||
GameBasics.getFromJson(x.javaClass, "Tutorials_$language")
|
GameBasics.getFromJson(x.javaClass, "Tutorials_$language")
|
||||||
val tutorialMap = HashMap<String,List<String>>()
|
val tutorialMap = HashMap<String,ArrayList<String>>()
|
||||||
for (tut in tutorials){
|
for (tut in tutorials){
|
||||||
val list = mutableListOf<String>()
|
val list = ArrayList<String>()
|
||||||
for(paragraph in tut.value)
|
for(paragraph in tut.value)
|
||||||
list += paragraph.joinToString("\n")
|
list += paragraph.joinToString("\n")
|
||||||
tutorialMap[tut.key] = list
|
tutorialMap[tut.key] = list
|
||||||
@ -75,7 +78,7 @@ open class CameraStageBaseScreen : Screen {
|
|||||||
return tutorialMap
|
return tutorialMap
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getTutorials(name:String, language:String):List<String>{
|
fun getTutorials(name:String, language:String):ArrayList<String>{
|
||||||
val tutorialsOfLanguage = getTutorialsOfLanguage(language)
|
val tutorialsOfLanguage = getTutorialsOfLanguage(language)
|
||||||
if(tutorialsOfLanguage.containsKey(name)) return tutorialsOfLanguage[name]!!
|
if(tutorialsOfLanguage.containsKey(name)) return tutorialsOfLanguage[name]!!
|
||||||
return getTutorialsOfLanguage("English")[name]!!
|
return getTutorialsOfLanguage("English")[name]!!
|
||||||
@ -86,7 +89,7 @@ open class CameraStageBaseScreen : Screen {
|
|||||||
UnCivGame.Current.settings.tutorialsShown.add(name)
|
UnCivGame.Current.settings.tutorialsShown.add(name)
|
||||||
UnCivGame.Current.settings.save()
|
UnCivGame.Current.settings.save()
|
||||||
val texts = getTutorials(name,UnCivGame.Current.settings.language)
|
val texts = getTutorials(name,UnCivGame.Current.settings.language)
|
||||||
tutorialTexts.addAll(texts)
|
tutorialTexts.add(Tutorial(name,texts))
|
||||||
if (!isTutorialShowing) displayTutorial()
|
if (!isTutorialShowing) displayTutorial()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,11 +97,17 @@ open class CameraStageBaseScreen : Screen {
|
|||||||
isTutorialShowing = true
|
isTutorialShowing = true
|
||||||
val tutorialTable = Table().pad(10f)
|
val tutorialTable = Table().pad(10f)
|
||||||
tutorialTable.background = ImageGetter.getBackground(Color(0x101050cf))
|
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)
|
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()
|
tutorialTable.add(label).pad(10f).row()
|
||||||
val button = TextButton("Close".tr(), skin)
|
val button = TextButton("Close".tr(), skin)
|
||||||
|
|
||||||
|
currentTutorial.texts.removeAt(0)
|
||||||
|
if(currentTutorial.texts.isEmpty()) tutorialTexts.removeAt(0)
|
||||||
|
|
||||||
button.onClick {
|
button.onClick {
|
||||||
tutorialTable.remove()
|
tutorialTable.remove()
|
||||||
if (!tutorialTexts.isEmpty())
|
if (!tutorialTexts.isEmpty())
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.unciv.ui.utils
|
package com.unciv.ui.utils
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color
|
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.TextureAtlas
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
import com.badlogic.gdx.scenes.scene2d.Actor
|
||||||
@ -24,6 +25,10 @@ object ImageGetter {
|
|||||||
init{
|
init{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getExternalImage(fileName:String): Image {
|
||||||
|
return Image(TextureRegion(Texture("ExtraImages/$fileName.png")))
|
||||||
|
}
|
||||||
|
|
||||||
fun getImage(fileName: String): Image {
|
fun getImage(fileName: String): Image {
|
||||||
return Image(getTextureRegion(fileName))
|
return Image(getTextureRegion(fileName))
|
||||||
}
|
}
|
||||||
|
@ -79,12 +79,19 @@ class WorldScreen : CameraStageBaseScreen() {
|
|||||||
tileMapHolder.setCenterPosition(tileToCenterOn)
|
tileMapHolder.setCenterPosition(tileToCenterOn)
|
||||||
createNextTurnButton() // needs civ table to be positioned
|
createNextTurnButton() // needs civ table to be positioned
|
||||||
displayTutorials("NewGame")
|
displayTutorials("NewGame")
|
||||||
|
displayTutorials("TileLayout")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun update() {
|
fun update() {
|
||||||
// many of the display functions will be called with the game clone and not the actual game,
|
// 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
|
// 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 gameClone = gameInfo.clone()
|
||||||
val cloneCivilization = gameClone.getPlayerCivilization()
|
val cloneCivilization = gameClone.getPlayerCivilization()
|
||||||
@ -92,6 +99,10 @@ class WorldScreen : CameraStageBaseScreen() {
|
|||||||
civInfo.happiness = gameClone.getPlayerCivilization().getHappinessForNextTurn().values.sum().toInt()
|
civInfo.happiness = gameClone.getPlayerCivilization().getHappinessForNextTurn().values.sum().toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(bottomBar.unitTable.selectedUnit!=null){
|
||||||
|
displayTutorials("UnitSelected")
|
||||||
|
}
|
||||||
|
|
||||||
if(UnCivGame.Current.settings.hasCrashedRecently){
|
if(UnCivGame.Current.settings.hasCrashedRecently){
|
||||||
displayTutorials("GameCrashed")
|
displayTutorials("GameCrashed")
|
||||||
UnCivGame.Current.settings.tutorialsShown.remove("GameCrashed")
|
UnCivGame.Current.settings.tutorialsShown.remove("GameCrashed")
|
||||||
|
Reference in New Issue
Block a user