Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/kicklib2/data/gui/scripts/AudioMenu.lua @ 8284

Last change on this file since 8284 was 8284, checked in by rgrieder, 13 years ago

Merged revisions 7978 - 8096 from kicklib to kicklib2.

  • Property svn:eol-style set to native
File size: 6.4 KB
Line 
1-- AudioMenu.lua
2
3local P = createMenuSheet("AudioMenu")
4
5function P.onLoad()
6    soundMgr = orxonox.SoundManager:getInstance()
7    block = false
8    masterscrollbar_active = false
9    musicscrollbar_active = false
10    effectsscrollbar_active = false
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)
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    table.insert(themeList, "8-Bit Style")
35    table.insert(themeList, "Corny Jazz")
36    for k,v in pairs(themeList) do
37        item = CEGUI.createListboxTextItem(v)
38        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
39        CEGUI.toListbox(listboxwindow):addItem(item)
40    end
41    if orxonox.getConfig("MoodManager", "mood_") == "dnb" then
42        listboxwindow:setItemSelectState(1,true)
43    elseif orxonox.getConfig("MoodManager", "mood_") == "eightbit" then
44        listboxwindow:setItemSelectState(2,true)
45    elseif orxonox.getConfig("MoodManager", "mood_") == "jazzy" then
46        listboxwindow:setItemSelectState(3,true)
47    else
48        listboxwindow:setItemSelectState(0,true)
49    end
50
51    P:setButton(1, 1, {
52            ["button"] = winMgr:getWindow("orxonox/AudioBackButton"),
53            ["callback"]  = P.AudioBackButton_clicked
54    })
55end
56
57function P.AudioMasterScrollbar_changed(e)
58    if mastermute then
59        block = true
60        mastermutewindow:setSelected(false)
61        block = false
62        mastermute = false
63    end
64    if masterscrollbar_active == false then
65        mastervolume = masterscrollbarwindow:getScrollPosition()
66        orxonox.config("SoundManager", "soundVolume_", mastervolume)
67    end
68end
69
70function P.AudioMasterScrollbar_started(e)
71    masterscrollbar_active = true
72end
73
74function P.AudioMasterScrollbar_ended(e)
75    mastervolume = masterscrollbarwindow:getScrollPosition()
76    orxonox.config("SoundManager", "soundVolume_", mastervolume)
77    masterscrollbar_active = false
78end
79
80function P.AudioMusicScrollbar_changed(e)
81    if musicmute then
82        block = true
83        musicmutewindow:setSelected(false)
84        block = false
85        musicmute = false
86    end
87    if musicscrollbar_active == false then
88        musicvolume = musicscrollbarwindow:getScrollPosition()
89        orxonox.config("SoundManager", "ambientVolume_", musicvolume)
90    end
91end
92
93function P.AudioMusicScrollbar_started(e)
94    musicscrollbar_active = true
95end
96
97function P.AudioMusicScrollbar_ended(e)
98    musicmutewindow:setSelected(false)
99    musicvolume = musicscrollbarwindow:getScrollPosition()
100    orxonox.config("SoundManager", "ambientVolume_", musicvolume)
101    musicscrollbar_active = false
102end
103
104function P.AudioEffectsScrollbar_changed(e)
105    if effectsmute then
106        block = true
107        effectsmutewindow:setSelected(false)
108        block = false
109        effectsmute = false
110    end
111    if effectsscrollbar_active == false then
112        effectsvolume = effectsscrollbarwindow:getScrollPosition()
113        orxonox.config("SoundManager", "effectsVolume_", effectsvolume)
114    end
115end
116
117function P.AudioEffectsScrollbar_started(e)
118    effectsscrollbar_active = true
119end
120
121function P.AudioEffectsScrollbar_ended(e)
122    effectsmutewindow:setSelected(false)
123    effectsvolume = effectsscrollbarwindow:getScrollPosition()
124    orxonox.config("SoundManager", "effectsVolume_", effectsvolume)
125    effectsscrollbar_active = false
126end
127
128function P.AudioMuteMasterCheckbox_clicked(e)
129    if block == false then
130        if mastermute then
131            masterscrollbarwindow:setScrollPosition(mastervolume)
132            mastermute = false
133        else
134            temp = masterscrollbarwindow:getScrollPosition()
135            masterscrollbarwindow:setScrollPosition(0)
136            mastervolume = temp
137            mastermute = true
138        end
139    end
140    soundMgr:toggleMute(orxonox.SoundType.All)
141end
142
143function P.AudioMuteMusicCheckbox_clicked(e)
144    if block == false then
145        if musicmute then
146            musicscrollbarwindow:setScrollPosition(musicvolume)
147            musicmute = false
148        else
149            temp = musicscrollbarwindow:getScrollPosition()
150            musicscrollbarwindow:setScrollPosition(0)
151            musicvolume = temp
152            musicmute = true
153        end
154    end
155    soundMgr:toggleMute(orxonox.SoundType.Music)
156end
157
158function P.AudioMuteEffectsCheckbox_clicked(e)
159    if block == false then
160        if effectsmute then
161            effectsscrollbarwindow:setScrollPosition(effectsvolume)
162            effectsmute = false
163        else
164            temp = effectsscrollbarwindow:getScrollPosition()
165            effectsscrollbarwindow:setScrollPosition(0)
166            effectsvolume = temp
167            effectsmute = true
168        end
169    end
170    soundMgr:toggleMute(orxonox.SoundType.Effects)
171end
172
173function P.AudioThemeListbox_changed(e)
174    if listboxwindow:isItemSelected(1) then
175        orxonox.config("MoodManager", "mood_", "dnb")
176    elseif listboxwindow:isItemSelected(2) then
177        orxonox.config("MoodManager", "mood_", "eightbit")
178    elseif listboxwindow:isItemSelected(3) then
179        orxonox.config("MoodManager", "mood_", "jazzy")
180    else
181        orxonox.config("MoodManager", "mood_", "default")
182    end
183end
184
185function P.AudioBackButton_clicked(e)
186    hideMenuSheet(P.name)
187end
188
189return P
190
Note: See TracBrowser for help on using the repository browser.