mirror of
https://github.com/yairm210/Unciv.git
synced 2025-08-04 09:09:21 +07:00
Prevent theme music tracks from randomly playing (#7396)
* Don't play theme music tracks randomly * Tweak * Remove redundant code * Ambient string to variable
This commit is contained in:

committed by
GitHub

parent
7c64015aed
commit
58e65978dc
@ -21,6 +21,7 @@ import com.unciv.ui.LoadingScreen
|
||||
import com.unciv.ui.audio.GameSounds
|
||||
import com.unciv.ui.audio.MusicController
|
||||
import com.unciv.ui.audio.MusicMood
|
||||
import com.unciv.ui.audio.MusicTrackChooserFlags
|
||||
import com.unciv.ui.audio.SoundPlayer
|
||||
import com.unciv.ui.crashhandling.CrashScreen
|
||||
import com.unciv.ui.crashhandling.wrapCrashHandlingUnit
|
||||
@ -145,7 +146,8 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
|
||||
|
||||
// This stuff needs to run on the main thread because it needs the GL context
|
||||
launchOnGLThread {
|
||||
musicController.chooseTrack(suffix = MusicMood.Menu)
|
||||
musicController.chooseTrack(suffixes = listOf(MusicMood.Menu, MusicMood.Ambient),
|
||||
flags = EnumSet.of(MusicTrackChooserFlags.SuffixMustMatch))
|
||||
|
||||
ImageGetter.ruleset = RulesetCache.getVanillaRuleset() // so that we can enter the map editor without having to load a game first
|
||||
|
||||
|
@ -348,8 +348,8 @@ class MusicController {
|
||||
*/
|
||||
fun chooseTrack (
|
||||
prefix: String = "",
|
||||
suffix: String = "Ambient",
|
||||
flags: EnumSet<MusicTrackChooserFlags> = EnumSet.noneOf(MusicTrackChooserFlags::class.java)
|
||||
suffix: String = MusicMood.Ambient,
|
||||
flags: EnumSet<MusicTrackChooserFlags> = EnumSet.of(MusicTrackChooserFlags.SuffixMustMatch)
|
||||
): Boolean {
|
||||
if (baseVolume == 0f) return false
|
||||
|
||||
|
@ -6,6 +6,7 @@ object MusicMood {
|
||||
const val War = "War"
|
||||
const val Defeat = "Defeat"
|
||||
const val Menu = "Menu"
|
||||
const val Ambient = "Ambient"
|
||||
|
||||
val themeOrPeace = listOf(Theme, Peace)
|
||||
fun peaceOrWar(isAtWar: Boolean) = if (isAtWar) War else Peace
|
||||
|
Reference in New Issue
Block a user