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