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