Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7817 was 7689, checked in by dafrick, 14 years ago

Merging menu branch to trunk.

  • Property svn:eol-style set to native
File size: 6.1 KB
RevLine 
[6363]1-- AudioMenu.lua
2
[6746]3local P = createMenuSheet("AudioMenu")
[6363]4
[7689]5P.buttonList = {}
6
7function P.onShow()
8    P.oldindex = -2
9    P.index = -1
10end
11
[6746]12function P.onLoad()
[6363]13    soundMgr = orxonox.SoundManager:getInstance()
14    block = false
15    masterscrollbar_active = false
16    musicscrollbar_active = false
17    effectsscrollbar_active = false
[6370]18    mastervolume = soundMgr:getVolume(orxonox.SoundType.All)
19    musicvolume = soundMgr:getVolume(orxonox.SoundType.Music)
20    effectsvolume = soundMgr:getVolume(orxonox.SoundType.Effects)
21    mastermute = soundMgr:getMute(orxonox.SoundType.All)
22    musicmute = soundMgr:getMute(orxonox.SoundType.Music)
23    effectsmute = soundMgr:getMute(orxonox.SoundType.Effects)
[6363]24    masterscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/MasterScrollbar"),"CEGUI::Scrollbar")
25    musicscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/MusicScrollbar"),"CEGUI::Scrollbar")
26    effectsscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/EffectsScrollbar"),"CEGUI::Scrollbar")
27    mastermutewindow = tolua.cast(winMgr:getWindow("orxonox/MasterCheckbox"),"CEGUI::Checkbox")
28    musicmutewindow = tolua.cast(winMgr:getWindow("orxonox/MusicCheckbox"),"CEGUI::Checkbox")
29    effectsmutewindow = tolua.cast(winMgr:getWindow("orxonox/EffectsCheckbox"),"CEGUI::Checkbox")
30    masterscrollbarwindow:setScrollPosition(mastervolume)
31    musicscrollbarwindow:setScrollPosition(musicvolume)
32    effectsscrollbarwindow:setScrollPosition(effectsvolume)
33    mastermutewindow:setSelected(mastermute)
34    musicmutewindow:setSelected(musicmute)
35    effectsmutewindow:setSelected(effectsmute)
36    choice = "Default"
37    listboxwindow = winMgr:getWindow("orxonox/AudioThemeListbox")
38    local themeList = {}
39    table.insert(themeList, "Default")
40    table.insert(themeList, "Drum n' Bass")
41    for k,v in pairs(themeList) do
[6388]42        item = CEGUI.createListboxTextItem(v)
[6746]43        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
[6363]44        CEGUI.toListbox(listboxwindow):addItem(item)
45    end
[6406]46    if orxonox.getConfig("MoodManager", "mood_") == "dnb" then
47        listboxwindow:setItemSelectState(1,true)
48    else
49        listboxwindow:setItemSelectState(0,true)
50    end
[7689]51
52    local item = {
53            ["button"] = winMgr:getWindow("orxonox/AudioBackButton"),
54            ["function"]  = P.AudioBackButton_clicked
55    }
56    P.buttonList[1] = item
[6363]57end
58
59function P.AudioMasterScrollbar_changed(e)
60    if mastermute then
61        block = true
62        mastermutewindow:setSelected(false)
63        block = false
64        mastermute = false
65    end
66    if masterscrollbar_active == false then
67        mastervolume = masterscrollbarwindow:getScrollPosition()
[6403]68        orxonox.config("SoundManager", "soundVolume_", mastervolume)
[6363]69    end
70end
71
72function P.AudioMasterScrollbar_started(e)
73    masterscrollbar_active = true
74end
75
76function P.AudioMasterScrollbar_ended(e)
77    mastervolume = masterscrollbarwindow:getScrollPosition()
[6403]78    orxonox.config("SoundManager", "soundVolume_", mastervolume)
[6363]79    masterscrollbar_active = false
80end
81
82function P.AudioMusicScrollbar_changed(e)
83    if musicmute then
84        block = true
85        musicmutewindow:setSelected(false)
86        block = false
87        musicmute = false
88    end
89    if musicscrollbar_active == false then
90        musicvolume = musicscrollbarwindow:getScrollPosition()
[6403]91        orxonox.config("SoundManager", "ambientVolume_", musicvolume)
[6363]92    end
93end
94
95function P.AudioMusicScrollbar_started(e)
96    musicscrollbar_active = true
97end
98
99function P.AudioMusicScrollbar_ended(e)
100    musicmutewindow:setSelected(false)
101    musicvolume = musicscrollbarwindow:getScrollPosition()
[6403]102    orxonox.config("SoundManager", "ambientVolume_", musicvolume)
[6363]103    musicscrollbar_active = false
104end
105
106function P.AudioEffectsScrollbar_changed(e)
107    if effectsmute then
108        block = true
109        effectsmutewindow:setSelected(false)
110        block = false
111        effectsmute = false
112    end
113    if effectsscrollbar_active == false then
114        effectsvolume = effectsscrollbarwindow:getScrollPosition()
[6403]115        orxonox.config("SoundManager", "effectsVolume_", effectsvolume)
[6363]116    end
117end
118
119function P.AudioEffectsScrollbar_started(e)
120    effectsscrollbar_active = true
121end
122
123function P.AudioEffectsScrollbar_ended(e)
124    effectsmutewindow:setSelected(false)
125    effectsvolume = effectsscrollbarwindow:getScrollPosition()
[6403]126    orxonox.config("SoundManager", "effectsVolume_", effectsvolume)
[6363]127    effectsscrollbar_active = false
128end
129
130function P.AudioMuteMasterCheckbox_clicked(e)
131    if block == false then
132        if mastermute then
133            masterscrollbarwindow:setScrollPosition(mastervolume)
134            mastermute = false
135        else
136            temp = masterscrollbarwindow:getScrollPosition()
137            masterscrollbarwindow:setScrollPosition(0)
138            mastervolume = temp
139            mastermute = true
140        end
141    end
[6370]142    soundMgr:toggleMute(orxonox.SoundType.All)
[6363]143end
144
145function P.AudioMuteMusicCheckbox_clicked(e)
146    if block == false then
147        if musicmute then
148            musicscrollbarwindow:setScrollPosition(musicvolume)
149            musicmute = false
150        else
151            temp = musicscrollbarwindow:getScrollPosition()
152            musicscrollbarwindow:setScrollPosition(0)
153            musicvolume = temp
154            musicmute = true
155        end
156    end
[6370]157    soundMgr:toggleMute(orxonox.SoundType.Music)
[6363]158end
159
160function P.AudioMuteEffectsCheckbox_clicked(e)
161    if block == false then
162        if effectsmute then
163            effectsscrollbarwindow:setScrollPosition(effectsvolume)
164            effectsmute = false
165        else
166            temp = effectsscrollbarwindow:getScrollPosition()
167            effectsscrollbarwindow:setScrollPosition(0)
168            effectsvolume = temp
169            effectsmute = true
170        end
171    end
[6370]172    soundMgr:toggleMute(orxonox.SoundType.Effects)
[6363]173end
174
175function P.AudioThemeListbox_changed(e)
176    if listboxwindow:isItemSelected(1) then
[6406]177        orxonox.config("MoodManager", "mood_", "dnb")
[6363]178    else
[6406]179        orxonox.config("MoodManager", "mood_", "default")
[6363]180    end
181end
182
183function P.AudioBackButton_clicked(e)
[6746]184    hideMenuSheet(P.name)
[6363]185end
186
[7689]187function P.onKeyPressed() 
188    buttonIteratorHelper(P.buttonList, code, P, 1, 1)
189end
190
[6363]191return P
192
Note: See TracBrowser for help on using the repository browser.