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