Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/Presentation_HS17_merge/data/gui/scripts/AudioMenu.lua @ 11782

Last change on this file since 11782 was 9348, checked in by landauf, 12 years ago

merged branch presentation2012merge back to trunk

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