| 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() |
|---|
| 16 | block = false |
|---|
| 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) |
|---|
| 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") |
|---|
| 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") |
|---|
| 46 | CEGUI.toCombobox(dropdownwindow):addItem(item) |
|---|
| 47 | end |
|---|
| 48 | dropdownwindow:setItemSelectState(0,true) |
|---|
| 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() |
|---|
| 60 | orxonox.CommandExecutor:execute("config SoundManager soundVolume_ " .. mastervolume) |
|---|
| 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() |
|---|
| 70 | orxonox.CommandExecutor:execute("config SoundManager soundVolume_ " .. mastervolume) |
|---|
| 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() |
|---|
| 83 | orxonox.CommandExecutor:execute("config SoundManager ambientVolume_ " .. musicvolume) |
|---|
| 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() |
|---|
| 94 | orxonox.CommandExecutor:execute("config SoundManager ambientVolume_ " .. musicvolume) |
|---|
| 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() |
|---|
| 107 | orxonox.CommandExecutor:execute("config SoundManager effectsVolume_ " .. effectsvolume) |
|---|
| 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() |
|---|
| 118 | orxonox.CommandExecutor:execute("config SoundManager effectsVolume_ " .. effectsvolume) |
|---|
| 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 |
|---|
| 134 | soundMgr:toggleMute(orxonox.SoundType.none) |
|---|
| 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 |
|---|
| 149 | soundMgr:toggleMute(orxonox.SoundType.ambient) |
|---|
| 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 |
|---|
| 164 | soundMgr:toggleMute(orxonox.SoundType.effects) |
|---|
| 165 | end |
|---|
| 166 | |
|---|
| 167 | function P.AudioThemeCombobox_changed(e) |
|---|
| 168 | if dropdownwindow:isItemSelected(1) then |
|---|
| 169 | orxonox.CommandExecutor:execute("setMood dnb") |
|---|
| 170 | else |
|---|
| 171 | orxonox.CommandExecutor:execute("setMood default") |
|---|
| 172 | end |
|---|
| 173 | end |
|---|
| 174 | |
|---|
| 175 | function P.AudioBackButton_clicked(e) |
|---|
| 176 | hideGUI(P.filename) |
|---|
| 177 | end |
|---|
| 178 | |
|---|
| 179 | return P |
|---|
| 180 | |
|---|