Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentation2/data/gui/scripts/AudioMenu.lua @ 6268

Last change on this file since 6268 was 6235, checked in by cmueri, 15 years ago

Small bug in audio menu fixed.

File size: 6.2 KB
RevLine 
[6206]1-- AudioMenu.lua
2
3BasicGUI = require("BasicGUI")
4local P = BasicGUI:new() --inherit everything from the gui package
5if _REQUIREDNAME == nil then
6    AudioMenu = P
7else
8    _G[_REQUIREDNAME] = P
9end
10
11P.filename = "AudioMenu"
12P.layoutString = "AudioMenu.layout"
13
14function 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]49end
50
51function 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
62end
63
64function P.AudioMasterScrollbar_started(e)
65    masterscrollbar_active = true
66end
67
68function P.AudioMasterScrollbar_ended(e)
[6233]69    mastervolume = masterscrollbarwindow:getScrollPosition()
70    orxonox.CommandExecutor:execute("config SoundManager soundVolume_ " .. mastervolume)
[6206]71    masterscrollbar_active = false
72end
73
74function 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
85end
86
87function P.AudioMusicScrollbar_started(e)
88    musicscrollbar_active = true
89end
90
91function 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
96end
97
98function 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
109end
110
111function P.AudioEffectsScrollbar_started(e)
112    effectsscrollbar_active = true
113end
114
115function 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
120end
121
122function 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]135end
136
137function 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]150end
151
152function 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]165end
166
167function 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]173end
174
175function P.AudioBackButton_clicked(e)
176    hideGUI(P.filename)
177end
178
179return P
180
Note: See TracBrowser for help on using the repository browser.