mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-09 23:39:40 +07:00
There is no SettingsEvent, no one's listening for settings changes
This commit is contained in:
@ -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.ui.Table
|
||||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
|
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
|
||||||
import com.badlogic.gdx.utils.Array
|
import com.badlogic.gdx.utils.Array
|
||||||
import com.unciv.logic.event.EventBus
|
|
||||||
import com.unciv.models.UncivSound
|
import com.unciv.models.UncivSound
|
||||||
import com.unciv.models.metadata.GameSettings
|
import com.unciv.models.metadata.GameSettings
|
||||||
import com.unciv.models.metadata.GameSettings.GameSetting
|
import com.unciv.models.metadata.GameSettings.GameSetting
|
||||||
import com.unciv.models.metadata.SettingsPropertyChanged
|
|
||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
import com.unciv.ui.audio.SoundPlayer
|
import com.unciv.ui.audio.SoundPlayer
|
||||||
import com.unciv.ui.components.input.onChange
|
import com.unciv.ui.components.input.onChange
|
||||||
@ -60,7 +58,7 @@ open class SettingsSelect<T : Any>(
|
|||||||
selectBox.onChange {
|
selectBox.onChange {
|
||||||
val newValue = selectBox.selected.value
|
val newValue = selectBox.selected.value
|
||||||
settingsProperty.set(newValue)
|
settingsProperty.set(newValue)
|
||||||
sendChangeEvent(newValue)
|
if (newValue is UncivSound) SoundPlayer.play(newValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
return selectBox
|
return selectBox
|
||||||
@ -81,13 +79,4 @@ open class SettingsSelect<T : Any>(
|
|||||||
refreshSelectBox.items = options
|
refreshSelectBox.items = options
|
||||||
refreshSelectBox.selected = prev
|
refreshSelectBox.selected = prev
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sendChangeEvent(item: T) {
|
|
||||||
when (item) {
|
|
||||||
is UncivSound -> SoundPlayer.play(item)
|
|
||||||
else -> EventBus.send(object : SettingsPropertyChanged {
|
|
||||||
override val gameSetting = setting
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user