[6363] | 1 | -- AudioMenu.lua |
---|
| 2 | |
---|
[6746] | 3 | local P = createMenuSheet("AudioMenu") |
---|
[6363] | 4 | |
---|
[6746] | 5 | function P.onLoad() |
---|
[6363] | 6 | soundMgr = orxonox.SoundManager:getInstance() |
---|
| 7 | block = false |
---|
| 8 | masterscrollbar_active = false |
---|
| 9 | musicscrollbar_active = false |
---|
| 10 | effectsscrollbar_active = false |
---|
[6370] | 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) |
---|
[6363] | 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 |
---|
[6388] | 35 | item = CEGUI.createListboxTextItem(v) |
---|
[6746] | 36 | item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush") |
---|
[6363] | 37 | CEGUI.toListbox(listboxwindow):addItem(item) |
---|
| 38 | end |
---|
[6406] | 39 | if orxonox.getConfig("MoodManager", "mood_") == "dnb" then |
---|
| 40 | listboxwindow:setItemSelectState(1,true) |
---|
| 41 | else |
---|
| 42 | listboxwindow:setItemSelectState(0,true) |
---|
| 43 | end |
---|
[7689] | 44 | |
---|
[8079] | 45 | P:setButton(1, 1, { |
---|
[7689] | 46 | ["button"] = winMgr:getWindow("orxonox/AudioBackButton"), |
---|
[8079] | 47 | ["callback"] = P.AudioBackButton_clicked |
---|
| 48 | }) |
---|
[6363] | 49 | end |
---|
| 50 | |
---|
| 51 | function P.AudioMasterScrollbar_changed(e) |
---|
| 52 | if mastermute then |
---|
| 53 | block = true |
---|
| 54 | mastermutewindow:setSelected(false) |
---|
| 55 | block = false |
---|
| 56 | mastermute = false |
---|
| 57 | end |
---|
| 58 | if masterscrollbar_active == false then |
---|
| 59 | mastervolume = masterscrollbarwindow:getScrollPosition() |
---|
[6403] | 60 | orxonox.config("SoundManager", "soundVolume_", mastervolume) |
---|
[6363] | 61 | end |
---|
| 62 | end |
---|
| 63 | |
---|
| 64 | function P.AudioMasterScrollbar_started(e) |
---|
| 65 | masterscrollbar_active = true |
---|
| 66 | end |
---|
| 67 | |
---|
| 68 | function P.AudioMasterScrollbar_ended(e) |
---|
| 69 | mastervolume = masterscrollbarwindow:getScrollPosition() |
---|
[6403] | 70 | orxonox.config("SoundManager", "soundVolume_", mastervolume) |
---|
[6363] | 71 | masterscrollbar_active = false |
---|
| 72 | end |
---|
| 73 | |
---|
| 74 | function P.AudioMusicScrollbar_changed(e) |
---|
| 75 | if musicmute then |
---|
| 76 | block = true |
---|
| 77 | musicmutewindow:setSelected(false) |
---|
| 78 | block = false |
---|
| 79 | musicmute = false |
---|
| 80 | end |
---|
| 81 | if musicscrollbar_active == false then |
---|
| 82 | musicvolume = musicscrollbarwindow:getScrollPosition() |
---|
[6403] | 83 | orxonox.config("SoundManager", "ambientVolume_", musicvolume) |
---|
[6363] | 84 | end |
---|
| 85 | end |
---|
| 86 | |
---|
| 87 | function P.AudioMusicScrollbar_started(e) |
---|
| 88 | musicscrollbar_active = true |
---|
| 89 | end |
---|
| 90 | |
---|
| 91 | function P.AudioMusicScrollbar_ended(e) |
---|
| 92 | musicmutewindow:setSelected(false) |
---|
| 93 | musicvolume = musicscrollbarwindow:getScrollPosition() |
---|
[6403] | 94 | orxonox.config("SoundManager", "ambientVolume_", musicvolume) |
---|
[6363] | 95 | musicscrollbar_active = false |
---|
| 96 | end |
---|
| 97 | |
---|
| 98 | function P.AudioEffectsScrollbar_changed(e) |
---|
| 99 | if effectsmute then |
---|
| 100 | block = true |
---|
| 101 | effectsmutewindow:setSelected(false) |
---|
| 102 | block = false |
---|
| 103 | effectsmute = false |
---|
| 104 | end |
---|
| 105 | if effectsscrollbar_active == false then |
---|
| 106 | effectsvolume = effectsscrollbarwindow:getScrollPosition() |
---|
[6403] | 107 | orxonox.config("SoundManager", "effectsVolume_", effectsvolume) |
---|
[6363] | 108 | end |
---|
| 109 | end |
---|
| 110 | |
---|
| 111 | function P.AudioEffectsScrollbar_started(e) |
---|
| 112 | effectsscrollbar_active = true |
---|
| 113 | end |
---|
| 114 | |
---|
| 115 | function P.AudioEffectsScrollbar_ended(e) |
---|
| 116 | effectsmutewindow:setSelected(false) |
---|
| 117 | effectsvolume = effectsscrollbarwindow:getScrollPosition() |
---|
[6403] | 118 | orxonox.config("SoundManager", "effectsVolume_", effectsvolume) |
---|
[6363] | 119 | effectsscrollbar_active = false |
---|
| 120 | end |
---|
| 121 | |
---|
| 122 | function P.AudioMuteMasterCheckbox_clicked(e) |
---|
| 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 |
---|
[6370] | 134 | soundMgr:toggleMute(orxonox.SoundType.All) |
---|
[6363] | 135 | end |
---|
| 136 | |
---|
| 137 | function P.AudioMuteMusicCheckbox_clicked(e) |
---|
| 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 |
---|
[6370] | 149 | soundMgr:toggleMute(orxonox.SoundType.Music) |
---|
[6363] | 150 | end |
---|
| 151 | |
---|
| 152 | function P.AudioMuteEffectsCheckbox_clicked(e) |
---|
| 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 |
---|
[6370] | 164 | soundMgr:toggleMute(orxonox.SoundType.Effects) |
---|
[6363] | 165 | end |
---|
| 166 | |
---|
| 167 | function P.AudioThemeListbox_changed(e) |
---|
| 168 | if listboxwindow:isItemSelected(1) then |
---|
[6406] | 169 | orxonox.config("MoodManager", "mood_", "dnb") |
---|
[6363] | 170 | else |
---|
[6406] | 171 | orxonox.config("MoodManager", "mood_", "default") |
---|
[6363] | 172 | end |
---|
| 173 | end |
---|
| 174 | |
---|
| 175 | function P.AudioBackButton_clicked(e) |
---|
[6746] | 176 | hideMenuSheet(P.name) |
---|
[6363] | 177 | end |
---|
| 178 | |
---|
| 179 | return P |
---|
| 180 | |
---|