mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-05 00:18:13 +07:00
Add Reset tutorials button (#8536)
* Add Reset tutorials button * Fix typo
This commit is contained in:
parent
b7c9a30c38
commit
5a267e436c
@ -712,6 +712,9 @@ Check for idle units =
|
||||
Auto Unit Cycle =
|
||||
Move units with a single tap =
|
||||
Show tutorials =
|
||||
Reset tutorials =
|
||||
Do you want to reset completed tutorials? =
|
||||
Reset =
|
||||
Auto-assign city production =
|
||||
Auto-build roads =
|
||||
Automated workers replace improvements =
|
||||
|
@ -13,12 +13,15 @@ import com.unciv.models.tilesets.TileSetCache
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.images.ImageGetter
|
||||
import com.unciv.ui.newgamescreen.TranslatedSelectBox
|
||||
import com.unciv.ui.popup.ConfirmPopup
|
||||
import com.unciv.ui.utils.BaseScreen
|
||||
import com.unciv.ui.utils.UncivSlider
|
||||
import com.unciv.ui.utils.WrappableLabel
|
||||
import com.unciv.ui.utils.extensions.brighten
|
||||
import com.unciv.ui.utils.extensions.onChange
|
||||
import com.unciv.ui.utils.extensions.onClick
|
||||
import com.unciv.ui.utils.extensions.toLabel
|
||||
import com.unciv.ui.utils.extensions.toTextButton
|
||||
|
||||
private val resolutionArray = com.badlogic.gdx.utils.Array(arrayOf("750x500", "900x600", "1050x700", "1200x800", "1500x1000"))
|
||||
|
||||
@ -35,7 +38,8 @@ fun displayTab(
|
||||
optionsPopup.addCheckbox(this, "Show tile yields", settings.showTileYields, true) { settings.showTileYields = it } // JN
|
||||
optionsPopup.addCheckbox(this, "Show worked tiles", settings.showWorkedTiles, true) { settings.showWorkedTiles = it }
|
||||
optionsPopup.addCheckbox(this, "Show resources and improvements", settings.showResourcesAndImprovements, true) { settings.showResourcesAndImprovements = it }
|
||||
optionsPopup.addCheckbox(this, "Show tutorials", settings.showTutorials, true) { settings.showTutorials = it }
|
||||
optionsPopup.addCheckbox(this, "Show tutorials", settings.showTutorials, true, false) { settings.showTutorials = it }
|
||||
addResetTutorials(this, settings)
|
||||
optionsPopup.addCheckbox(this, "Show pixel improvements", settings.showPixelImprovements, true) { settings.showPixelImprovements = it }
|
||||
optionsPopup.addCheckbox(this, "Experimental Demographics scoreboard", settings.useDemographics, true) { settings.useDemographics = it }
|
||||
optionsPopup.addCheckbox(this, "Show zoom buttons in world screen", settings.showZoomButtons, true) { settings.showZoomButtons = it }
|
||||
@ -195,3 +199,21 @@ private fun addSkinSelectBox(table: Table, settings: GameSettings, selectBoxMinW
|
||||
onSkinChange()
|
||||
}
|
||||
}
|
||||
|
||||
private fun addResetTutorials(table: Table, settings: GameSettings) {
|
||||
val resetTutorialsButton = "Reset tutorials".toTextButton()
|
||||
resetTutorialsButton.onClick {
|
||||
ConfirmPopup(
|
||||
table.stage,
|
||||
"Do you want to reset completed tutorials?",
|
||||
"Reset"
|
||||
) {
|
||||
settings.tutorialsShown.clear()
|
||||
settings.tutorialTasksCompleted.clear()
|
||||
settings.save()
|
||||
resetTutorialsButton.setText("Done!".tr())
|
||||
resetTutorialsButton.clearListeners()
|
||||
}.open(true)
|
||||
}
|
||||
table.add(resetTutorialsButton).center().row()
|
||||
}
|
||||
|
@ -157,20 +157,22 @@ class OptionsPopup(
|
||||
}
|
||||
}
|
||||
|
||||
fun addCheckbox(table: Table, text: String, initialState: Boolean, updateWorld: Boolean = false, action: ((Boolean) -> Unit)) {
|
||||
fun addCheckbox(table: Table, text: String, initialState: Boolean, updateWorld: Boolean = false, newRow: Boolean = true, action: ((Boolean) -> Unit)) {
|
||||
val checkbox = text.toCheckBox(initialState) {
|
||||
action(it)
|
||||
settings.save()
|
||||
val worldScreen = UncivGame.Current.getWorldScreenIfActive()
|
||||
if (updateWorld && worldScreen != null) worldScreen.shouldUpdate = true
|
||||
}
|
||||
table.add(checkbox).colspan(2).left().row()
|
||||
if (newRow) table.add(checkbox).colspan(2).left().row()
|
||||
else table.add(checkbox).left()
|
||||
}
|
||||
|
||||
fun addCheckbox(table: Table,
|
||||
text: String,
|
||||
settingsProperty: KMutableProperty0<Boolean>,
|
||||
updateWorld: Boolean = false,
|
||||
newRow: Boolean = true,
|
||||
action: (Boolean) -> Unit = {}) {
|
||||
addCheckbox(table, text, settingsProperty.get(), updateWorld) {
|
||||
action(it)
|
||||
|
Loading…
Reference in New Issue
Block a user