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