Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/data/gui/scripts/AudioMenu.lua @ 10403

Last change on this file since 10403 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
RevLine 
[6363]1-- AudioMenu.lua
2
[6746]3local P = createMenuSheet("AudioMenu")
[6363]4
[6746]5function 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")
[8351]34    table.insert(themeList, "8-Bit Style")
35    table.insert(themeList, "Corny Jazz")
[9348]36    table.insert(themeList, "Metal")
[6363]37    for k,v in pairs(themeList) do
[6388]38        item = CEGUI.createListboxTextItem(v)
[6746]39        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
[6363]40        CEGUI.toListbox(listboxwindow):addItem(item)
41    end
[6406]42    if orxonox.getConfig("MoodManager", "mood_") == "dnb" then
43        listboxwindow:setItemSelectState(1,true)
[8351]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)
[9348]48    elseif orxonox.getConfig("MoodManager", "mood_") == "metal" then
49        listboxwindow:setItemSelectState(4,true)
[6406]50    else
51        listboxwindow:setItemSelectState(0,true)
52    end
[7689]53
[8079]54    P:setButton(1, 1, {
[7689]55            ["button"] = winMgr:getWindow("orxonox/AudioBackButton"),
[8079]56            ["callback"]  = P.AudioBackButton_clicked
57    })
[6363]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()
[6403]69        orxonox.config("SoundManager", "soundVolume_", mastervolume)
[6363]70    end
71end
72
73function P.AudioMasterScrollbar_started(e)
74    masterscrollbar_active = true
75end
76
77function P.AudioMasterScrollbar_ended(e)
78    mastervolume = masterscrollbarwindow:getScrollPosition()
[6403]79    orxonox.config("SoundManager", "soundVolume_", mastervolume)
[6363]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()
[6403]92        orxonox.config("SoundManager", "ambientVolume_", musicvolume)
[6363]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()
[6403]103    orxonox.config("SoundManager", "ambientVolume_", musicvolume)
[6363]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()
[6403]116        orxonox.config("SoundManager", "effectsVolume_", effectsvolume)
[6363]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()
[6403]127    orxonox.config("SoundManager", "effectsVolume_", effectsvolume)
[6363]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
[6370]143    soundMgr:toggleMute(orxonox.SoundType.All)
[6363]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
[6370]158    soundMgr:toggleMute(orxonox.SoundType.Music)
[6363]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
[6370]173    soundMgr:toggleMute(orxonox.SoundType.Effects)
[6363]174end
175
176function P.AudioThemeListbox_changed(e)
177    if listboxwindow:isItemSelected(1) then
[6406]178        orxonox.config("MoodManager", "mood_", "dnb")
[8351]179    elseif listboxwindow:isItemSelected(2) then
180        orxonox.config("MoodManager", "mood_", "eightbit")
181    elseif listboxwindow:isItemSelected(3) then
182        orxonox.config("MoodManager", "mood_", "jazzy")
[9348]183    elseif listboxwindow:isItemSelected(4) then
184        orxonox.config("MoodManager", "mood_", "metal")
[6363]185    else
[6406]186        orxonox.config("MoodManager", "mood_", "default")
[6363]187    end
188end
189
190function P.AudioBackButton_clicked(e)
[6746]191    hideMenuSheet(P.name)
[6363]192end
193
194return P
195
Note: See TracBrowser for help on using the repository browser.