mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-13 01:08:25 +07:00
Energy saving: music and sounds (#2128)
This commit is contained in:
@ -96,7 +96,7 @@ class UncivGame(
|
|||||||
Gdx.app.postRunnable {
|
Gdx.app.postRunnable {
|
||||||
CameraStageBaseScreen.resetFonts()
|
CameraStageBaseScreen.resetFonts()
|
||||||
autoLoadGame()
|
autoLoadGame()
|
||||||
thread { startMusic() }
|
thread(name="Music") { startMusic() }
|
||||||
isInitialized = true
|
isInitialized = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -114,6 +114,7 @@ class UncivGame(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun startMusic() {
|
fun startMusic() {
|
||||||
|
if (settings.musicVolume < 0.01) return
|
||||||
|
|
||||||
val musicFile = Gdx.files.local(musicLocation)
|
val musicFile = Gdx.files.local(musicLocation)
|
||||||
if (musicFile.exists()) {
|
if (musicFile.exists()) {
|
||||||
|
@ -16,7 +16,8 @@ object Sounds {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun play(sound: UncivSound) {
|
fun play(sound: UncivSound) {
|
||||||
if (sound == UncivSound.Silent) return
|
val volume = UncivGame.Current.settings.soundEffectsVolume
|
||||||
get(sound).play(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?) {
|
override fun changed(event: ChangeEvent?, actor: Actor?) {
|
||||||
UncivGame.Current.settings.musicVolume = musicVolumeSlider.value
|
UncivGame.Current.settings.musicVolume = musicVolumeSlider.value
|
||||||
UncivGame.Current.settings.save()
|
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()
|
innerTable.add(musicVolumeSlider).pad(10f).row()
|
||||||
|
Reference in New Issue
Block a user