mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-24 10:01:39 +07:00
There is no SettingsEvent, no one's listening for settings changes
This commit is contained in:
parent
0530e262db
commit
296a499ae6
@ -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
|
||||
}
|
@ -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
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user