Suggestion: Collapsible tutorial tasks (#8591)

* Collapsible tutorial tasks

* Fix
This commit is contained in:
Gualdimar
2023-02-06 00:29:04 +02:00
committed by GitHub
parent 328cf56a22
commit d371bdedf7
3 changed files with 29 additions and 12 deletions

View File

@ -66,6 +66,8 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
lateinit var onlineMultiplayer: OnlineMultiplayer
lateinit var files: UncivFiles
var isTutorialTaskCollapsed = false
/**
* This exists so that when debugging we can see the entire map.
* Remember to turn this to false before commit and upload!

View File

@ -114,6 +114,7 @@ class GameSettings {
fun addCompletedTutorialTask(tutorialTask: String): Boolean {
if (!tutorialTasksCompleted.add(tutorialTask)) return false
UncivGame.Current.isTutorialTaskCollapsed = false
save()
return true
}

View File

@ -31,6 +31,7 @@ import com.unciv.models.ruleset.tile.ResourceType
import com.unciv.models.ruleset.unique.UniqueType
import com.unciv.ui.cityscreen.CityScreen
import com.unciv.ui.civilopedia.CivilopediaScreen
import com.unciv.ui.images.ImageGetter
import com.unciv.ui.overviewscreen.EmpireOverviewScreen
import com.unciv.ui.pickerscreens.DiplomaticVotePickerScreen
import com.unciv.ui.pickerscreens.DiplomaticVoteResultScreen
@ -391,18 +392,7 @@ class WorldScreen(
updateSelectedCiv()
tutorialTaskTable.clear()
val tutorialTask = getCurrentTutorialTask()
if (tutorialTask == "" || !game.settings.showTutorials || viewingCiv.isDefeated()) {
tutorialTaskTable.isVisible = false
} else {
tutorialTaskTable.isVisible = true
tutorialTaskTable.add(tutorialTask.toLabel()
.apply { setAlignment(Align.center) }).pad(10f)
tutorialTaskTable.pack()
tutorialTaskTable.centerX(stage)
tutorialTaskTable.y = topBar.y - tutorialTaskTable.height
}
displayTutorialTaskOnUpdate()
if (fogOfWar) minimapWrapper.update(selectedCiv)
else minimapWrapper.update(viewingCiv)
@ -548,6 +538,30 @@ class WorldScreen(
}
}
private fun displayTutorialTaskOnUpdate() {
tutorialTaskTable.clear()
val tutorialTask = getCurrentTutorialTask()
if (tutorialTask == "" || !game.settings.showTutorials || viewingCiv.isDefeated()) {
tutorialTaskTable.isVisible = false
return
}
tutorialTaskTable.isVisible = true
if (!UncivGame.Current.isTutorialTaskCollapsed) {
tutorialTaskTable.add(tutorialTask.toLabel()
.apply { setAlignment(Align.center) }).pad(10f)
} else {
tutorialTaskTable.add(ImageGetter.getImage("CityStateIcons/Cultured").apply { setSize(30f,30f) }).pad(5f)
}
tutorialTaskTable.pack()
tutorialTaskTable.centerX(stage)
tutorialTaskTable.y = topBar.y - tutorialTaskTable.height
tutorialTaskTable.onClick() {
UncivGame.Current.isTutorialTaskCollapsed = !UncivGame.Current.isTutorialTaskCollapsed
displayTutorialTaskOnUpdate()
}
}
private fun updateSelectedCiv() {
when {
bottomUnitTable.selectedUnit != null -> selectedCiv = bottomUnitTable.selectedUnit!!.civ