mirror of
https://github.com/yairm210/Unciv.git
synced 2025-10-03 08:56:17 -04:00
Resolved #383 - Configurable amount of turns between autosaves
This commit is contained in:
parent
4669d4aa2a
commit
479b3a02ad
@ -685,6 +685,10 @@
|
||||
Japanese:"表示オプション"
|
||||
}
|
||||
|
||||
"Turns between autosaves:":{}
|
||||
|
||||
"Sound effects volume":{}
|
||||
|
||||
"Show":{
|
||||
Italian:"Mostra"
|
||||
Russian:"Показать"
|
||||
|
@ -10,6 +10,7 @@ class GameSettings {
|
||||
var tutorialsShown = ArrayList<String>()
|
||||
var hasCrashedRecently = false
|
||||
var soundEffectsVolume = 0.5f
|
||||
var turnsBetweenAutosaves = 1
|
||||
|
||||
fun save(){
|
||||
GameSaver().setGeneralSettings(this)
|
||||
|
@ -87,7 +87,7 @@ class TradeLogic(val ourCivilization:CivilizationInfo, val otherCivilization: Ci
|
||||
|
||||
var value = 50*min(offer.amount,civsWithLuxToTrade.size) // they'll buy at 50 each only, and that's so they can trade it away
|
||||
if(!theirAvailableOffers.any { it.name==offer.name })
|
||||
value+=300 // only if they're lacking will they buy the first one at 300
|
||||
value+=200 // only if they're lacking will they buy the first one at 240 (Civ V standard, see https://www.reddit.com/r/civ/comments/1go7i9/luxury_and_strategic_resource_pricing/ & others)
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
@ -253,7 +253,8 @@ class WorldScreen : CameraStageBaseScreen() {
|
||||
// the save takes a long time( up to a second!) and we can do it while the player continues his game.
|
||||
// On the other hand if we alter the game data while it's being serialized we could get a concurrent modification exception.
|
||||
// So what we do is we clone all the game data and serialize the clone.
|
||||
GameSaver().saveGame(gameInfoClone, "Autosave")
|
||||
if(gameInfo.turns % game.settings.turnsBetweenAutosaves == 0)
|
||||
GameSaver().saveGame(gameInfoClone, "Autosave")
|
||||
nextTurnButton.enable() // only enable the user to next turn once we've saved the current one
|
||||
}
|
||||
|
||||
|
@ -5,10 +5,12 @@ import com.badlogic.gdx.graphics.g2d.Batch
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Slider
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
|
||||
import com.badlogic.gdx.utils.Array
|
||||
import com.unciv.UnCivGame
|
||||
import com.unciv.models.gamebasics.GameBasics
|
||||
import com.unciv.models.gamebasics.tr
|
||||
import com.unciv.ui.utils.*
|
||||
import com.unciv.ui.worldscreen.WorldScreen
|
||||
import kotlin.concurrent.thread
|
||||
@ -47,12 +49,39 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
|
||||
addButton("{Hide} {resources and improvements}") { settings.showResourcesAndImprovements = false; update() }
|
||||
else addButton("{Show} {resources and improvements}") { settings.showResourcesAndImprovements = true; update() }
|
||||
|
||||
|
||||
addLanguageSelectBox()
|
||||
|
||||
val resolutionSelectBox= SelectBox<String>(skin)
|
||||
val resolutionArray = com.badlogic.gdx.utils.Array<String>()
|
||||
resolutionArray.addAll("900x600","1050x700","1200x800","1500x1000")
|
||||
addResolutionSelectBox()
|
||||
|
||||
addAutosaveTurnsSelectBox()
|
||||
|
||||
addSoundEffectsVolumeSlider()
|
||||
|
||||
addButton("Close"){ remove() }
|
||||
|
||||
pack() // Needed to show the background.
|
||||
center(UnCivGame.Current.worldScreen.stage)
|
||||
UnCivGame.Current.worldScreen.shouldUpdate=true
|
||||
}
|
||||
|
||||
private fun addSoundEffectsVolumeSlider() {
|
||||
val soundEffectsVolumeSlider = Slider(0f, 1.0f, 0.1f, false, skin)
|
||||
soundEffectsVolumeSlider.value = UnCivGame.Current.settings.soundEffectsVolume
|
||||
soundEffectsVolumeSlider.addListener(object : ChangeListener() {
|
||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||
UnCivGame.Current.settings.soundEffectsVolume = soundEffectsVolumeSlider.value
|
||||
UnCivGame.Current.settings.save()
|
||||
Sounds.play("click")
|
||||
}
|
||||
})
|
||||
add("Sound effects volume".tr()).row()
|
||||
add(soundEffectsVolumeSlider).row()
|
||||
}
|
||||
|
||||
private fun addResolutionSelectBox() {
|
||||
val resolutionSelectBox = SelectBox<String>(skin)
|
||||
val resolutionArray = Array<String>()
|
||||
resolutionArray.addAll("900x600", "1050x700", "1200x800", "1500x1000")
|
||||
resolutionSelectBox.items = resolutionArray
|
||||
resolutionSelectBox.selected = UnCivGame.Current.settings.resolution
|
||||
add(resolutionSelectBox).pad(10f).row()
|
||||
@ -66,24 +95,27 @@ class WorldScreenOptionsTable(screen:WorldScreen) : PopupTable(screen){
|
||||
WorldScreenOptionsTable(UnCivGame.Current.worldScreen)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
val soundEffectsVolumeSlider = Slider(0f,1.0f,0.1f,false,skin)
|
||||
soundEffectsVolumeSlider.value = UnCivGame.Current.settings.soundEffectsVolume
|
||||
soundEffectsVolumeSlider.addListener(object: ChangeListener(){
|
||||
private fun addAutosaveTurnsSelectBox() {
|
||||
val autosaveTurnsSelectBox = SelectBox<Int>(skin)
|
||||
val autosaveTurnsArray = Array<Int>()
|
||||
autosaveTurnsArray.addAll(1,2,5,10)
|
||||
autosaveTurnsSelectBox.items = autosaveTurnsArray
|
||||
autosaveTurnsSelectBox.selected = UnCivGame.Current.settings.turnsBetweenAutosaves
|
||||
|
||||
val table = Table()
|
||||
table.add("Turns between autosaves:".toLabel())
|
||||
table.add(autosaveTurnsSelectBox).pad(10f)
|
||||
add(table).row()
|
||||
|
||||
autosaveTurnsSelectBox.addListener(object : ChangeListener() {
|
||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||
UnCivGame.Current.settings.soundEffectsVolume= soundEffectsVolumeSlider.value
|
||||
UnCivGame.Current.settings.turnsBetweenAutosaves= autosaveTurnsSelectBox.selected
|
||||
UnCivGame.Current.settings.save()
|
||||
Sounds.play("click")
|
||||
update()
|
||||
}
|
||||
})
|
||||
add("Sound effects volume").row()
|
||||
add(soundEffectsVolumeSlider).row()
|
||||
|
||||
addButton("Close"){ remove() }
|
||||
|
||||
pack() // Needed to show the background.
|
||||
center(UnCivGame.Current.worldScreen.stage)
|
||||
UnCivGame.Current.worldScreen.shouldUpdate=true
|
||||
}
|
||||
|
||||
private fun addLanguageSelectBox() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user