mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-24 10:01:39 +07:00
EventBus removal - remove 'settings updated' sound playing via eventbus
This commit is contained in:
parent
43e38e3869
commit
0530e262db
@ -1,14 +1,9 @@
|
||||
package com.unciv.models.metadata
|
||||
|
||||
import com.unciv.logic.event.Event
|
||||
import com.unciv.models.UncivSound
|
||||
import com.unciv.models.metadata.GameSettings.GameSetting
|
||||
|
||||
/** **Warning:** this event is in the process of completion and **not** used for all settings yet! **Only the settings in [GameSetting] get events sent!** */
|
||||
interface SettingsPropertyChanged : Event {
|
||||
val gameSetting: GameSetting
|
||||
}
|
||||
|
||||
interface SettingsPropertyUncivSoundChanged : SettingsPropertyChanged {
|
||||
val value: UncivSound
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import com.unciv.UncivGame
|
||||
import com.unciv.logic.event.EventBus
|
||||
import com.unciv.logic.multiplayer.MultiplayerGameUpdated
|
||||
import com.unciv.logic.multiplayer.isUsersTurn
|
||||
import com.unciv.models.metadata.SettingsPropertyUncivSoundChanged
|
||||
|
||||
/**
|
||||
* Controls which sounds should be played when something happens while playing the game.
|
||||
@ -18,16 +17,9 @@ object GameSounds {
|
||||
* Has to be called for sounds to be played.
|
||||
*/
|
||||
fun init() {
|
||||
playSettingsSounds()
|
||||
playMultiplayerTurnNotification()
|
||||
}
|
||||
|
||||
private fun playSettingsSounds() {
|
||||
events.receive(SettingsPropertyUncivSoundChanged::class) {
|
||||
SoundPlayer.play(it.value)
|
||||
}
|
||||
}
|
||||
|
||||
private fun playMultiplayerTurnNotification() {
|
||||
events.receive(MultiplayerGameUpdated::class, { it.preview.isUsersTurn() }) {
|
||||
if (UncivGame.isDeepLinkedGameLoading()) return@receive // This means we already arrived here through a turn notification, no need to notify again
|
||||
|
@ -10,8 +10,8 @@ import com.unciv.models.UncivSound
|
||||
import com.unciv.models.metadata.GameSettings
|
||||
import com.unciv.models.metadata.GameSettings.GameSetting
|
||||
import com.unciv.models.metadata.SettingsPropertyChanged
|
||||
import com.unciv.models.metadata.SettingsPropertyUncivSoundChanged
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.audio.SoundPlayer
|
||||
import com.unciv.ui.components.input.onChange
|
||||
import com.unciv.ui.components.extensions.toGdxArray
|
||||
import com.unciv.ui.components.extensions.toLabel
|
||||
@ -84,10 +84,7 @@ open class SettingsSelect<T : Any>(
|
||||
|
||||
private fun sendChangeEvent(item: T) {
|
||||
when (item) {
|
||||
is UncivSound -> EventBus.send(object : SettingsPropertyUncivSoundChanged {
|
||||
override val gameSetting = setting
|
||||
override val value: UncivSound = settingsProperty.get() as UncivSound
|
||||
})
|
||||
is UncivSound -> SoundPlayer.play(item)
|
||||
else -> EventBus.send(object : SettingsPropertyChanged {
|
||||
override val gameSetting = setting
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user