Added more option autosaves from 500 to 10000 (#13809)

* Final update

* update ish

* Remove a lot of space and move text under enter button

* Final update replace  addMaxAutosavesStored with addAutosaveField

Added more to Turns between autosaves from 15 to 1000.
Also change popup class so you can change the color.

* Update core/src/com/unciv/ui/popups/options/AdvancedTab.kt

Co-authored-by: Yair Morgenstern <yairm210@hotmail.com>

* Update core/src/com/unciv/ui/popups/options/AdvancedTab.kt

Co-authored-by: Yair Morgenstern <yairm210@hotmail.com>

* final update

* Fix error template.properties

* update

---------

Co-authored-by: Yair Morgenstern <yairm210@hotmail.com>
This commit is contained in:
General_E 2025-08-30 19:47:52 +02:00 committed by GitHub
parent a7de6744ae
commit 4710909495
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 48 additions and 22 deletions

View File

@ -893,8 +893,10 @@ Could not download music! =
## Advanced tab ## Advanced tab
Advanced = Advanced =
Number of autosave files stored = Number of autosave files stored =
Autosave turns must be larger than 0! =
Autosave turns over 200 may take a lot of space on your device. =
Turns between autosaves = Turns between autosaves =
Enter =
Screen orientation = Screen orientation =
Landscape (fixed) = Landscape (fixed) =

View File

@ -280,8 +280,8 @@ open class Popup(
* @param text The caption text. * @param text The caption text.
* @param size The font size for the label. * @param size The font size for the label.
*/ */
fun addGoodSizedLabel(text: String, size: Int = Constants.defaultFontSize, hideIcons:Boolean = false): Cell<Label> { fun addGoodSizedLabel(text: String, size: Int = Constants.defaultFontSize, hideIcons:Boolean = false, color: Color = Color.WHITE): Cell<Label> {
val label = text.toLabel(fontSize = size, hideIcons = hideIcons) val label = text.toLabel(fontSize = size, hideIcons = hideIcons, fontColor = color)
label.wrap = true label.wrap = true
label.setAlignment(Align.center) label.setAlignment(Align.center)
return add(label).width(stageToShowOn.width / 2) return add(label).width(stageToShowOn.width / 2)

View File

@ -34,7 +34,9 @@ import com.unciv.ui.components.input.onActivation
import com.unciv.ui.components.input.onChange import com.unciv.ui.components.input.onChange
import com.unciv.ui.components.input.onClick import com.unciv.ui.components.input.onClick
import com.unciv.ui.components.widgets.UncivSlider import com.unciv.ui.components.widgets.UncivSlider
import com.unciv.ui.components.widgets.UncivTextField
import com.unciv.ui.popups.ConfirmPopup import com.unciv.ui.popups.ConfirmPopup
import com.unciv.ui.popups.Popup
import com.unciv.ui.screens.basescreen.BaseScreen import com.unciv.ui.screens.basescreen.BaseScreen
import com.unciv.utils.Concurrency import com.unciv.utils.Concurrency
import com.unciv.utils.Display import com.unciv.utils.Display
@ -56,9 +58,9 @@ class AdvancedTab(
pad(10f) pad(10f)
defaults().pad(5f) defaults().pad(5f)
addMaxAutosavesStored() addAutosaveField()
addAutosaveTurnsSelectBox() addAutosaveTurnsSelectBox()
addSeparator() addSeparator()
if (Display.hasCutout()) if (Display.hasCutout())
@ -98,29 +100,50 @@ class AdvancedTab(
optionsPopup.reopenAfterDisplayLayoutChange() optionsPopup.reopenAfterDisplayLayoutChange()
} }
} }
private fun addMaxAutosavesStored() {
add("Number of autosave files stored".toLabel()).left().fillX()
val maxAutosavesStoredSelectBox = SelectBox<Int>(skin)
val maxAutosavesStoredArray = Array<Int>()
maxAutosavesStoredArray.addAll(1,2,5,10,15,20,35,50,100,150,200,250)
maxAutosavesStoredSelectBox.items = maxAutosavesStoredArray
maxAutosavesStoredSelectBox.selected = settings.maxAutosavesStored
add(maxAutosavesStoredSelectBox).pad(10f).row()
maxAutosavesStoredSelectBox.onChange {
settings.maxAutosavesStored = maxAutosavesStoredSelectBox.selected
}
}
private fun addAutosaveField() {
add("Number of autosave files stored".toLabel()).left().fillX()
val autosaveFieldTable = Table()
val autoSaveTrunsTextField = UncivTextField("",settings.maxAutosavesStored.toString())
autoSaveTrunsTextField.setTextFieldFilter { _, c -> c in "1234567890" }
autosaveFieldTable.add(autoSaveTrunsTextField)
val autoSaveTrunsTextFieldButton = "Enter".toTextButton()
autoSaveTrunsTextFieldButton.onClick {
if (autoSaveTrunsTextField.text.isEmpty()) return@onClick
val numberAutosaveTurns = autoSaveTrunsTextField.text.toInt()
if (numberAutosaveTurns <= 0) {
val popup = Popup(stage)
popup.addGoodSizedLabel("Autosave turns must be larger than 0!", color = Color.RED)
popup.addCloseButton()
popup.open(true)
} else if (numberAutosaveTurns >= 200) {
val popup = Popup(stage)
popup.addGoodSizedLabel(
"Autosave turns over 200 may take a lot of space on your device.",
color = Color.ORANGE)
popup.addCloseButton()
popup.open(true)
settings.maxAutosavesStored = numberAutosaveTurns
} else {
settings.maxAutosavesStored = numberAutosaveTurns
}
}
autosaveFieldTable.add(autoSaveTrunsTextFieldButton).row()
add(autosaveFieldTable).row()
}
private fun addAutosaveTurnsSelectBox() { private fun addAutosaveTurnsSelectBox() {
add("Turns between autosaves".toLabel()).left().fillX() add("Turns between autosaves".toLabel()).left().fillX()
val autosaveTurnsSelectBox = SelectBox<Int>(skin) val autosaveTurnsSelectBox = SelectBox<Int>(skin)
val autosaveTurnsArray = Array<Int>() val autosaveTurnsArray = Array<Int>()
autosaveTurnsArray.addAll(1, 2, 5, 10) autosaveTurnsArray.addAll(1,2,5,10,20,50,100,1000)
autosaveTurnsSelectBox.items = autosaveTurnsArray autosaveTurnsSelectBox.items = autosaveTurnsArray
autosaveTurnsSelectBox.selected = settings.turnsBetweenAutosaves autosaveTurnsSelectBox.selected = settings.turnsBetweenAutosaves
@ -129,6 +152,7 @@ class AdvancedTab(
autosaveTurnsSelectBox.onChange { autosaveTurnsSelectBox.onChange {
settings.turnsBetweenAutosaves = autosaveTurnsSelectBox.selected settings.turnsBetweenAutosaves = autosaveTurnsSelectBox.selected
} }
} }
private fun addFontFamilySelect(onFontChange: () -> Unit) { private fun addFontFamilySelect(onFontChange: () -> Unit) {