[6363] | 1 | -- AudioMenu.lua |
---|
| 2 | |
---|
| 3 | BasicGUI = require("BasicGUI") |
---|
| 4 | local P = BasicGUI:new() --inherit everything from the gui package |
---|
| 5 | if _REQUIREDNAME == nil then |
---|
| 6 | AudioMenu = P |
---|
| 7 | else |
---|
| 8 | _G[_REQUIREDNAME] = P |
---|
| 9 | end |
---|
| 10 | |
---|
| 11 | P.filename = "AudioMenu" |
---|
| 12 | P.layoutString = "AudioMenu.layout" |
---|
| 13 | |
---|
| 14 | function P:init() |
---|
| 15 | soundMgr = orxonox.SoundManager:getInstance() |
---|
| 16 | block = false |
---|
| 17 | masterscrollbar_active = false |
---|
| 18 | musicscrollbar_active = false |
---|
| 19 | effectsscrollbar_active = false |
---|
[6370] | 20 | mastervolume = soundMgr:getVolume(orxonox.SoundType.All) |
---|
| 21 | musicvolume = soundMgr:getVolume(orxonox.SoundType.Music) |
---|
| 22 | effectsvolume = soundMgr:getVolume(orxonox.SoundType.Effects) |
---|
| 23 | mastermute = soundMgr:getMute(orxonox.SoundType.All) |
---|
| 24 | musicmute = soundMgr:getMute(orxonox.SoundType.Music) |
---|
| 25 | effectsmute = soundMgr:getMute(orxonox.SoundType.Effects) |
---|
[6363] | 26 | masterscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/MasterScrollbar"),"CEGUI::Scrollbar") |
---|
| 27 | musicscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/MusicScrollbar"),"CEGUI::Scrollbar") |
---|
| 28 | effectsscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/EffectsScrollbar"),"CEGUI::Scrollbar") |
---|
| 29 | mastermutewindow = tolua.cast(winMgr:getWindow("orxonox/MasterCheckbox"),"CEGUI::Checkbox") |
---|
| 30 | musicmutewindow = tolua.cast(winMgr:getWindow("orxonox/MusicCheckbox"),"CEGUI::Checkbox") |
---|
| 31 | effectsmutewindow = tolua.cast(winMgr:getWindow("orxonox/EffectsCheckbox"),"CEGUI::Checkbox") |
---|
| 32 | masterscrollbarwindow:setScrollPosition(mastervolume) |
---|
| 33 | musicscrollbarwindow:setScrollPosition(musicvolume) |
---|
| 34 | effectsscrollbarwindow:setScrollPosition(effectsvolume) |
---|
| 35 | mastermutewindow:setSelected(mastermute) |
---|
| 36 | musicmutewindow:setSelected(musicmute) |
---|
| 37 | effectsmutewindow:setSelected(effectsmute) |
---|
| 38 | choice = "Default" |
---|
| 39 | listboxwindow = winMgr:getWindow("orxonox/AudioThemeListbox") |
---|
| 40 | local themeList = {} |
---|
| 41 | table.insert(themeList, "Default") |
---|
| 42 | table.insert(themeList, "Drum n' Bass") |
---|
| 43 | for k,v in pairs(themeList) do |
---|
[6388] | 44 | item = CEGUI.createListboxTextItem(v) |
---|
[6363] | 45 | item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush") |
---|
| 46 | CEGUI.toListbox(listboxwindow):addItem(item) |
---|
| 47 | end |
---|
[6406] | 48 | if orxonox.getConfig("MoodManager", "mood_") == "dnb" then |
---|
| 49 | listboxwindow:setItemSelectState(1,true) |
---|
| 50 | else |
---|
| 51 | listboxwindow:setItemSelectState(0,true) |
---|
| 52 | end |
---|
[6363] | 53 | end |
---|
| 54 | |
---|
| 55 | function P.AudioMasterScrollbar_changed(e) |
---|
| 56 | if mastermute then |
---|
| 57 | block = true |
---|
| 58 | mastermutewindow:setSelected(false) |
---|
| 59 | block = false |
---|
| 60 | mastermute = false |
---|
| 61 | end |
---|
| 62 | if masterscrollbar_active == false then |
---|
| 63 | mastervolume = masterscrollbarwindow:getScrollPosition() |
---|
[6403] | 64 | orxonox.config("SoundManager", "soundVolume_", mastervolume) |
---|
[6363] | 65 | end |
---|
| 66 | end |
---|
| 67 | |
---|
| 68 | function P.AudioMasterScrollbar_started(e) |
---|
| 69 | masterscrollbar_active = true |
---|
| 70 | end |
---|
| 71 | |
---|
| 72 | function P.AudioMasterScrollbar_ended(e) |
---|
| 73 | mastervolume = masterscrollbarwindow:getScrollPosition() |
---|
[6403] | 74 | orxonox.config("SoundManager", "soundVolume_", mastervolume) |
---|
[6363] | 75 | masterscrollbar_active = false |
---|
| 76 | end |
---|
| 77 | |
---|
| 78 | function P.AudioMusicScrollbar_changed(e) |
---|
| 79 | if musicmute then |
---|
| 80 | block = true |
---|
| 81 | musicmutewindow:setSelected(false) |
---|
| 82 | block = false |
---|
| 83 | musicmute = false |
---|
| 84 | end |
---|
| 85 | if musicscrollbar_active == false then |
---|
| 86 | musicvolume = musicscrollbarwindow:getScrollPosition() |
---|
[6403] | 87 | orxonox.config("SoundManager", "ambientVolume_", musicvolume) |
---|
[6363] | 88 | end |
---|
| 89 | end |
---|
| 90 | |
---|
| 91 | function P.AudioMusicScrollbar_started(e) |
---|
| 92 | musicscrollbar_active = true |
---|
| 93 | end |
---|
| 94 | |
---|
| 95 | function P.AudioMusicScrollbar_ended(e) |
---|
| 96 | musicmutewindow:setSelected(false) |
---|
| 97 | musicvolume = musicscrollbarwindow:getScrollPosition() |
---|
[6403] | 98 | orxonox.config("SoundManager", "ambientVolume_", musicvolume) |
---|
[6363] | 99 | musicscrollbar_active = false |
---|
| 100 | end |
---|
| 101 | |
---|
| 102 | function P.AudioEffectsScrollbar_changed(e) |
---|
| 103 | if effectsmute then |
---|
| 104 | block = true |
---|
| 105 | effectsmutewindow:setSelected(false) |
---|
| 106 | block = false |
---|
| 107 | effectsmute = false |
---|
| 108 | end |
---|
| 109 | if effectsscrollbar_active == false then |
---|
| 110 | effectsvolume = effectsscrollbarwindow:getScrollPosition() |
---|
[6403] | 111 | orxonox.config("SoundManager", "effectsVolume_", effectsvolume) |
---|
[6363] | 112 | end |
---|
| 113 | end |
---|
| 114 | |
---|
| 115 | function P.AudioEffectsScrollbar_started(e) |
---|
| 116 | effectsscrollbar_active = true |
---|
| 117 | end |
---|
| 118 | |
---|
| 119 | function P.AudioEffectsScrollbar_ended(e) |
---|
| 120 | effectsmutewindow:setSelected(false) |
---|
| 121 | effectsvolume = effectsscrollbarwindow:getScrollPosition() |
---|
[6403] | 122 | orxonox.config("SoundManager", "effectsVolume_", effectsvolume) |
---|
[6363] | 123 | effectsscrollbar_active = false |
---|
| 124 | end |
---|
| 125 | |
---|
| 126 | function P.AudioMuteMasterCheckbox_clicked(e) |
---|
| 127 | if block == false then |
---|
| 128 | if mastermute then |
---|
| 129 | masterscrollbarwindow:setScrollPosition(mastervolume) |
---|
| 130 | mastermute = false |
---|
| 131 | else |
---|
| 132 | temp = masterscrollbarwindow:getScrollPosition() |
---|
| 133 | masterscrollbarwindow:setScrollPosition(0) |
---|
| 134 | mastervolume = temp |
---|
| 135 | mastermute = true |
---|
| 136 | end |
---|
| 137 | end |
---|
[6370] | 138 | soundMgr:toggleMute(orxonox.SoundType.All) |
---|
[6363] | 139 | end |
---|
| 140 | |
---|
| 141 | function P.AudioMuteMusicCheckbox_clicked(e) |
---|
| 142 | if block == false then |
---|
| 143 | if musicmute then |
---|
| 144 | musicscrollbarwindow:setScrollPosition(musicvolume) |
---|
| 145 | musicmute = false |
---|
| 146 | else |
---|
| 147 | temp = musicscrollbarwindow:getScrollPosition() |
---|
| 148 | musicscrollbarwindow:setScrollPosition(0) |
---|
| 149 | musicvolume = temp |
---|
| 150 | musicmute = true |
---|
| 151 | end |
---|
| 152 | end |
---|
[6370] | 153 | soundMgr:toggleMute(orxonox.SoundType.Music) |
---|
[6363] | 154 | end |
---|
| 155 | |
---|
| 156 | function P.AudioMuteEffectsCheckbox_clicked(e) |
---|
| 157 | if block == false then |
---|
| 158 | if effectsmute then |
---|
| 159 | effectsscrollbarwindow:setScrollPosition(effectsvolume) |
---|
| 160 | effectsmute = false |
---|
| 161 | else |
---|
| 162 | temp = effectsscrollbarwindow:getScrollPosition() |
---|
| 163 | effectsscrollbarwindow:setScrollPosition(0) |
---|
| 164 | effectsvolume = temp |
---|
| 165 | effectsmute = true |
---|
| 166 | end |
---|
| 167 | end |
---|
[6370] | 168 | soundMgr:toggleMute(orxonox.SoundType.Effects) |
---|
[6363] | 169 | end |
---|
| 170 | |
---|
| 171 | function P.AudioThemeListbox_changed(e) |
---|
| 172 | if listboxwindow:isItemSelected(1) then |
---|
[6406] | 173 | orxonox.config("MoodManager", "mood_", "dnb") |
---|
[6363] | 174 | else |
---|
[6406] | 175 | orxonox.config("MoodManager", "mood_", "default") |
---|
[6363] | 176 | end |
---|
| 177 | end |
---|
| 178 | |
---|
| 179 | function P.AudioBackButton_clicked(e) |
---|
| 180 | hideGUI(P.filename) |
---|
| 181 | end |
---|
| 182 | |
---|
| 183 | return P |
---|
| 184 | |
---|