Randomize seed checkbox (#10782)

* randomize seed checkbox working

* don't reseed when checking the box
This commit is contained in:
Rémi Dufour 2023-12-28 21:40:19 +01:00 committed by GitHub
parent 3b7974942c
commit f1bd13c80c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -66,7 +66,10 @@ class MapEditorGenerateTab(
}
private fun generate(step: MapGeneratorSteps) {
if (step <= MapGeneratorSteps.Landmass && step in seedUsedForStep) {
if (step == MapGeneratorSteps.All && newTab.mapParametersTable.randomizeSeed) {
newTab.mapParametersTable.reseed()
}
if (step == MapGeneratorSteps.Landmass && step in seedUsedForStep) {
// reseed visibly when starting from scratch (new seed shows in advanced settings widget)
newTab.mapParametersTable.reseed()
seedUsedForStep -= step
@ -92,7 +95,7 @@ class MapEditorGenerateTab(
if (step in seedUsedForStep) {
mapParameters.reseed()
} else {
} else if (step != MapGeneratorSteps.All){
seedUsedForStep += step
}

View File

@ -68,6 +68,9 @@ class MapParametersTable(
// overrides nor is a Widget a data class. Seems to work anyway.
private val advancedSliders = HashMap<UncivSlider, ()->Float>()
// used only in map editor (forMapEditor == true)
var randomizeSeed = true
init {
update()
}
@ -386,6 +389,17 @@ class MapParametersTable(
table.add(button).colspan(2).padTop(10f).row()
}
fun addCheckBox(text: String, initialState: Boolean, action: ((Boolean) -> Unit)) {
val checkbox = text.toCheckBox(initialState){
action(it)
}
table.add(checkbox).colspan(2).row()
}
if (forMapEditor) {
addCheckBox("Randomize seed", true) {
randomizeSeed = it
}
}
addSlider("Map Elevation", {mapParameters.elevationExponent}, 0.6f, 0.8f)
{ mapParameters.elevationExponent = it }