mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-10 15:59:33 +07:00
Energy saving: music and sounds (#2128)
This commit is contained in:
@ -96,7 +96,7 @@ class UncivGame(
|
||||
Gdx.app.postRunnable {
|
||||
CameraStageBaseScreen.resetFonts()
|
||||
autoLoadGame()
|
||||
thread { startMusic() }
|
||||
thread(name="Music") { startMusic() }
|
||||
isInitialized = true
|
||||
}
|
||||
}
|
||||
@ -114,6 +114,7 @@ class UncivGame(
|
||||
}
|
||||
|
||||
fun startMusic() {
|
||||
if (settings.musicVolume < 0.01) return
|
||||
|
||||
val musicFile = Gdx.files.local(musicLocation)
|
||||
if (musicFile.exists()) {
|
||||
|
@ -16,7 +16,8 @@ object Sounds {
|
||||
}
|
||||
|
||||
fun play(sound: UncivSound) {
|
||||
if (sound == UncivSound.Silent) return
|
||||
get(sound).play(UncivGame.Current.settings.soundEffectsVolume)
|
||||
val volume = UncivGame.Current.settings.soundEffectsVolume
|
||||
if (sound == UncivSound.Silent || volume < 0.01) return
|
||||
get(sound).play(volume)
|
||||
}
|
||||
}
|
@ -201,7 +201,12 @@ class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen){
|
||||
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||
UncivGame.Current.settings.musicVolume = musicVolumeSlider.value
|
||||
UncivGame.Current.settings.save()
|
||||
UncivGame.Current.music?.volume = 0.4f * musicVolumeSlider.value
|
||||
|
||||
val music = UncivGame.Current.music
|
||||
if (music == null) // restart music, if it was off at the app start
|
||||
thread(name="Music") { UncivGame.Current.startMusic() }
|
||||
|
||||
music?.volume = 0.4f * musicVolumeSlider.value
|
||||
}
|
||||
})
|
||||
innerTable.add(musicVolumeSlider).pad(10f).row()
|
||||
|
Reference in New Issue
Block a user