| [6206] | 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() | 
|---|
| [6233] | 16 |     block = false | 
|---|
| [6206] | 17 |     masterscrollbar_active = false | 
|---|
 | 18 |     musicscrollbar_active = false | 
|---|
 | 19 |     effectsscrollbar_active = false | 
|---|
 | 20 |     mastervolume = soundMgr:getVolume(orxonox.SoundType.none) | 
|---|
 | 21 |     musicvolume = soundMgr:getVolume(orxonox.SoundType.ambient) | 
|---|
 | 22 |     effectsvolume = soundMgr:getVolume(orxonox.SoundType.effects) | 
|---|
| [6233] | 23 |     mastermute = soundMgr:getMute(orxonox.SoundType.none) | 
|---|
 | 24 |     musicmute = soundMgr:getMute(orxonox.SoundType.ambient) | 
|---|
 | 25 |     effectsmute = soundMgr:getMute(orxonox.SoundType.effects) | 
|---|
 | 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 |     dropdownwindow = winMgr:getWindow("orxonox/AudioThemeCombobox") | 
|---|
| [6206] | 40 |     local themeList = {} | 
|---|
 | 41 |     table.insert(themeList, "Default") | 
|---|
 | 42 |     table.insert(themeList, "Drum n' Bass") | 
|---|
 | 43 |     for k,v in pairs(themeList) do | 
|---|
 | 44 |         item = CEGUI.createListboxTextItem(v)         | 
|---|
 | 45 |         item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush") | 
|---|
| [6233] | 46 |         CEGUI.toCombobox(dropdownwindow):addItem(item) | 
|---|
| [6206] | 47 |     end | 
|---|
| [6233] | 48 |     dropdownwindow:setItemSelectState(0,true) | 
|---|
| [6206] | 49 | end | 
|---|
 | 50 |  | 
|---|
 | 51 | function P.AudioMasterScrollbar_changed(e) | 
|---|
| [6233] | 52 |     if mastermute then | 
|---|
 | 53 |         block = true | 
|---|
 | 54 |         mastermutewindow:setSelected(false) | 
|---|
 | 55 |         block = false | 
|---|
 | 56 |         mastermute = false | 
|---|
 | 57 |     end | 
|---|
| [6206] | 58 |     if masterscrollbar_active == false then | 
|---|
| [6233] | 59 |         mastervolume = masterscrollbarwindow:getScrollPosition() | 
|---|
 | 60 |         orxonox.CommandExecutor:execute("config SoundManager soundVolume_ " .. mastervolume) | 
|---|
| [6206] | 61 |     end | 
|---|
 | 62 | end | 
|---|
 | 63 |  | 
|---|
 | 64 | function P.AudioMasterScrollbar_started(e) | 
|---|
 | 65 |     masterscrollbar_active = true | 
|---|
 | 66 | end | 
|---|
 | 67 |  | 
|---|
 | 68 | function P.AudioMasterScrollbar_ended(e) | 
|---|
| [6233] | 69 |     mastervolume = masterscrollbarwindow:getScrollPosition() | 
|---|
 | 70 |     orxonox.CommandExecutor:execute("config SoundManager soundVolume_ " .. mastervolume) | 
|---|
| [6206] | 71 |     masterscrollbar_active = false | 
|---|
 | 72 | end | 
|---|
 | 73 |  | 
|---|
 | 74 | function P.AudioMusicScrollbar_changed(e) | 
|---|
| [6233] | 75 |     if musicmute then | 
|---|
 | 76 |         block = true | 
|---|
 | 77 |         musicmutewindow:setSelected(false) | 
|---|
 | 78 |         block = false | 
|---|
 | 79 |         musicmute = false | 
|---|
 | 80 |     end | 
|---|
| [6206] | 81 |     if musicscrollbar_active == false then | 
|---|
| [6233] | 82 |         musicvolume = musicscrollbarwindow:getScrollPosition() | 
|---|
 | 83 |         orxonox.CommandExecutor:execute("config SoundManager ambientVolume_ " .. musicvolume) | 
|---|
| [6206] | 84 |     end | 
|---|
 | 85 | end | 
|---|
 | 86 |  | 
|---|
 | 87 | function P.AudioMusicScrollbar_started(e) | 
|---|
 | 88 |     musicscrollbar_active = true | 
|---|
 | 89 | end | 
|---|
 | 90 |  | 
|---|
 | 91 | function P.AudioMusicScrollbar_ended(e) | 
|---|
| [6233] | 92 |     musicmutewindow:setSelected(false) | 
|---|
 | 93 |     musicvolume = musicscrollbarwindow:getScrollPosition() | 
|---|
 | 94 |     orxonox.CommandExecutor:execute("config SoundManager ambientVolume_ " .. musicvolume) | 
|---|
| [6206] | 95 |     musicscrollbar_active = false | 
|---|
 | 96 | end | 
|---|
 | 97 |  | 
|---|
 | 98 | function P.AudioEffectsScrollbar_changed(e) | 
|---|
| [6233] | 99 |     if effectsmute then | 
|---|
 | 100 |         block = true | 
|---|
 | 101 |         effectsmutewindow:setSelected(false) | 
|---|
 | 102 |         block = false | 
|---|
 | 103 |         effectsmute = false | 
|---|
 | 104 |     end | 
|---|
| [6206] | 105 |     if effectsscrollbar_active == false then | 
|---|
| [6233] | 106 |         effectsvolume = effectsscrollbarwindow:getScrollPosition() | 
|---|
 | 107 |         orxonox.CommandExecutor:execute("config SoundManager effectsVolume_ " .. effectsvolume) | 
|---|
| [6206] | 108 |     end | 
|---|
 | 109 | end | 
|---|
 | 110 |  | 
|---|
 | 111 | function P.AudioEffectsScrollbar_started(e) | 
|---|
 | 112 |     effectsscrollbar_active = true | 
|---|
 | 113 | end | 
|---|
 | 114 |  | 
|---|
 | 115 | function P.AudioEffectsScrollbar_ended(e) | 
|---|
| [6233] | 116 |     effectsmutewindow:setSelected(false) | 
|---|
 | 117 |     effectsvolume = effectsscrollbarwindow:getScrollPosition() | 
|---|
 | 118 |     orxonox.CommandExecutor:execute("config SoundManager effectsVolume_ " .. effectsvolume) | 
|---|
| [6206] | 119 |     effectsscrollbar_active = false | 
|---|
 | 120 | end | 
|---|
 | 121 |  | 
|---|
 | 122 | function P.AudioMuteMasterCheckbox_clicked(e) | 
|---|
| [6233] | 123 |     if block == false then | 
|---|
 | 124 |         if mastermute then | 
|---|
 | 125 |             masterscrollbarwindow:setScrollPosition(mastervolume) | 
|---|
 | 126 |             mastermute = false | 
|---|
 | 127 |         else | 
|---|
 | 128 |             temp = masterscrollbarwindow:getScrollPosition() | 
|---|
 | 129 |             masterscrollbarwindow:setScrollPosition(0) | 
|---|
 | 130 |             mastervolume = temp | 
|---|
 | 131 |             mastermute = true | 
|---|
 | 132 |         end | 
|---|
 | 133 |     end | 
|---|
| [6235] | 134 |     soundMgr:toggleMute(orxonox.SoundType.none) | 
|---|
| [6206] | 135 | end | 
|---|
 | 136 |  | 
|---|
 | 137 | function P.AudioMuteMusicCheckbox_clicked(e) | 
|---|
| [6233] | 138 |     if block == false then | 
|---|
 | 139 |         if musicmute then | 
|---|
 | 140 |             musicscrollbarwindow:setScrollPosition(musicvolume) | 
|---|
 | 141 |             musicmute = false | 
|---|
 | 142 |         else | 
|---|
 | 143 |             temp = musicscrollbarwindow:getScrollPosition() | 
|---|
 | 144 |             musicscrollbarwindow:setScrollPosition(0) | 
|---|
 | 145 |             musicvolume = temp | 
|---|
 | 146 |             musicmute = true | 
|---|
 | 147 |         end | 
|---|
 | 148 |     end | 
|---|
| [6235] | 149 |     soundMgr:toggleMute(orxonox.SoundType.ambient) | 
|---|
| [6206] | 150 | end | 
|---|
 | 151 |  | 
|---|
 | 152 | function P.AudioMuteEffectsCheckbox_clicked(e) | 
|---|
| [6233] | 153 |     if block == false then | 
|---|
 | 154 |         if effectsmute then | 
|---|
 | 155 |             effectsscrollbarwindow:setScrollPosition(effectsvolume) | 
|---|
 | 156 |             effectsmute = false | 
|---|
 | 157 |         else | 
|---|
 | 158 |             temp = effectsscrollbarwindow:getScrollPosition() | 
|---|
 | 159 |             effectsscrollbarwindow:setScrollPosition(0) | 
|---|
 | 160 |             effectsvolume = temp | 
|---|
 | 161 |             effectsmute = true | 
|---|
 | 162 |         end | 
|---|
 | 163 |     end | 
|---|
| [6235] | 164 |     soundMgr:toggleMute(orxonox.SoundType.effects) | 
|---|
| [6206] | 165 | end | 
|---|
 | 166 |  | 
|---|
 | 167 | function P.AudioThemeCombobox_changed(e) | 
|---|
| [6233] | 168 |     if dropdownwindow:isItemSelected(1) then | 
|---|
 | 169 |         orxonox.CommandExecutor:execute("setMood dnb") | 
|---|
 | 170 |     else | 
|---|
 | 171 |         orxonox.CommandExecutor:execute("setMood default") | 
|---|
 | 172 |     end | 
|---|
| [6206] | 173 | end | 
|---|
 | 174 |  | 
|---|
 | 175 | function P.AudioBackButton_clicked(e) | 
|---|
 | 176 |     hideGUI(P.filename) | 
|---|
 | 177 | end | 
|---|
 | 178 |  | 
|---|
 | 179 | return P | 
|---|
 | 180 |  | 
|---|