There is no SettingsEvent, no one's listening for settings changes

This commit is contained in:
yairm210 2024-04-14 23:37:30 +03:00
parent 0530e262db
commit 296a499ae6
2 changed files with 1 additions and 21 deletions

View File

@ -1,9 +0,0 @@
package com.unciv.models.metadata
import com.unciv.logic.event.Event
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
}

View File

@ -5,11 +5,9 @@ import com.badlogic.gdx.scenes.scene2d.ui.SelectBox
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.logic.event.EventBus
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.translations.tr
import com.unciv.ui.audio.SoundPlayer
import com.unciv.ui.components.input.onChange
@ -60,7 +58,7 @@ open class SettingsSelect<T : Any>(
selectBox.onChange {
val newValue = selectBox.selected.value
settingsProperty.set(newValue)
sendChangeEvent(newValue)
if (newValue is UncivSound) SoundPlayer.play(newValue)
}
return selectBox
@ -81,13 +79,4 @@ open class SettingsSelect<T : Any>(
refreshSelectBox.items = options
refreshSelectBox.selected = prev
}
private fun sendChangeEvent(item: T) {
when (item) {
is UncivSound -> SoundPlayer.play(item)
else -> EventBus.send(object : SettingsPropertyChanged {
override val gameSetting = setting
})
}
}
}