AudioSettings = {} musicVolText = nil sliderMusicVolParams = nil soundVolText = nil sliderSoundVolParams = nil menuMusicText = nil stepperMenuMusicParams = nil function audio_options_logic_init() AudioSettings.optionsItems = {} musicVolText = "loc@UI_TEXT_MUSIC_VOLUME" sliderMusicVolParams = { currentVal = GetInt("options.audio.musicvolume"), minVal = 0, maxVal = 100, step = 1, rawVal = 0, span = 0, onValueChanged = function(self) SetInt("options.audio.musicvolume", self.currentVal) end, indicatorGetter = function(self) return tostring(self.currentVal) end, forceUpdate = function(self) self.currentVal = GetInt("options.audio.musicvolume") self.span = self.maxVal - self.minVal self.rawVal = (self.currentVal - self.minVal) / self.span end } sliderMusicVolParams.span = sliderMusicVolParams.maxVal - sliderMusicVolParams.minVal sliderMusicVolParams.rawVal = (sliderMusicVolParams.currentVal - sliderMusicVolParams.minVal) / sliderMusicVolParams.span table.insert(AudioSettings.optionsItems, sliderMusicVolParams) soundVolText = "loc@UI_TEXT_SOUND_VOLUME" sliderSoundVolParams = { currentVal = GetInt("options.audio.soundvolume"), minVal = 0, maxVal = 100, step = 1, rawVal = 0, span = 0, onValueChanged = function(self) SetInt("options.audio.soundvolume", self.currentVal) end, indicatorGetter = function(self) return tostring(self.currentVal) end, forceUpdate = function(self) self.currentVal = GetInt("options.audio.soundvolume") self.span = self.maxVal - self.minVal self.rawVal = (self.currentVal - self.minVal) / self.span end } sliderSoundVolParams.span = sliderSoundVolParams.maxVal - sliderSoundVolParams.minVal sliderSoundVolParams.rawVal = (sliderSoundVolParams.currentVal - sliderSoundVolParams.minVal) / sliderSoundVolParams.span table.insert(AudioSettings.optionsItems, sliderSoundVolParams) menuMusicText = "loc@UI_TEXT_MENU_MUSIC" stepperMenuMusicParams = { currentIdx = GetInt("options.audio.menumusic") + 1, allValues = {"loc@UI_BUTTON_DISABLED", "loc@UI_BUTTON_ENABLED"}, isCyclic = false, getCurrentValue = function(self) return self.allValues[self.currentIdx] end, onNext = function(self) self.currentIdx = self.currentIdx + 1 if self.currentIdx > #self.allValues then self.currentIdx = 1 end SetInt("options.audio.menumusic", self.currentIdx - 1) end, onPrev = function(self) self.currentIdx = self.currentIdx - 1 if self.currentIdx < 1 then self.currentIdx = #self.allValues end SetInt("options.audio.menumusic", self.currentIdx - 1) end, forceUpdate = function(self) self.currentIdx = GetInt("options.audio.menumusic") + 1 end } table.insert(AudioSettings.optionsItems, stepperMenuMusicParams) AudioSettings.onResetRequested = function() Command("options.audio.resettodefault") for i=1,#AudioSettings.optionsItems do AudioSettings.optionsItems[i]:forceUpdate() end end end audio_options_logic_init()