mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-24 03:53:12 -04:00
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:
parent
a7de6744ae
commit
4710909495
@ -893,8 +893,10 @@ Could not download music! =
|
||||
## Advanced tab
|
||||
Advanced =
|
||||
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 =
|
||||
|
||||
Enter =
|
||||
|
||||
Screen orientation =
|
||||
Landscape (fixed) =
|
||||
|
@ -280,8 +280,8 @@ open class Popup(
|
||||
* @param text The caption text.
|
||||
* @param size The font size for the label.
|
||||
*/
|
||||
fun addGoodSizedLabel(text: String, size: Int = Constants.defaultFontSize, hideIcons:Boolean = false): Cell<Label> {
|
||||
val label = text.toLabel(fontSize = size, hideIcons = hideIcons)
|
||||
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, fontColor = color)
|
||||
label.wrap = true
|
||||
label.setAlignment(Align.center)
|
||||
return add(label).width(stageToShowOn.width / 2)
|
||||
|
@ -34,7 +34,9 @@ import com.unciv.ui.components.input.onActivation
|
||||
import com.unciv.ui.components.input.onChange
|
||||
import com.unciv.ui.components.input.onClick
|
||||
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.Popup
|
||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||
import com.unciv.utils.Concurrency
|
||||
import com.unciv.utils.Display
|
||||
@ -56,9 +58,9 @@ class AdvancedTab(
|
||||
pad(10f)
|
||||
defaults().pad(5f)
|
||||
|
||||
addMaxAutosavesStored()
|
||||
|
||||
addAutosaveField()
|
||||
addAutosaveTurnsSelectBox()
|
||||
|
||||
addSeparator()
|
||||
|
||||
if (Display.hasCutout())
|
||||
@ -98,29 +100,50 @@ class AdvancedTab(
|
||||
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() {
|
||||
add("Turns between autosaves".toLabel()).left().fillX()
|
||||
|
||||
val autosaveTurnsSelectBox = SelectBox<Int>(skin)
|
||||
val autosaveTurnsArray = Array<Int>()
|
||||
autosaveTurnsArray.addAll(1, 2, 5, 10)
|
||||
autosaveTurnsArray.addAll(1,2,5,10,20,50,100,1000)
|
||||
autosaveTurnsSelectBox.items = autosaveTurnsArray
|
||||
autosaveTurnsSelectBox.selected = settings.turnsBetweenAutosaves
|
||||
|
||||
@ -129,6 +152,7 @@ class AdvancedTab(
|
||||
autosaveTurnsSelectBox.onChange {
|
||||
settings.turnsBetweenAutosaves = autosaveTurnsSelectBox.selected
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun addFontFamilySelect(onFontChange: () -> Unit) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user