Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/hudimprovements/data/gui/scripts/AudioMenu.lua @ 8328

Last change on this file since 8328 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
Line 
1-- AudioMenu.lua
2
3local P = createMenuSheet("AudioMenu")
4
5P.buttonList = {}
6
7function P.onShow()
8    P.oldindex = -2
9    P.index = -1
10end
11
12function P.onLoad()
13    soundMgr = orxonox.SoundManager:getInstance()
14    block = false
15    masterscrollbar_active = false
16    musicscrollbar_active = false
17    effectsscrollbar_active = false
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)
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
42        item = CEGUI.createListboxTextItem(v)
43        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
44        CEGUI.toListbox(listboxwindow):addItem(item)
45    end
46    if orxonox.getConfig("MoodManager", "mood_") == "dnb" then
47        listboxwindow:setItemSelectState(1,true)
48    else
49        listboxwindow:setItemSelectState(0,true)
50    end
51
52    local item = {
53            ["button"] = winMgr:getWindow("orxonox/AudioBackButton"),
54            ["function"]  = P.AudioBackButton_clicked
55    }
56    P.buttonList[1] = item
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()
68        orxonox.config("SoundManager", "soundVolume_", mastervolume)
69    end
70end
71
72function P.AudioMasterScrollbar_started(e)
73    masterscrollbar_active = true
74end
75
76function P.AudioMasterScrollbar_ended(e)
77    mastervolume = masterscrollbarwindow:getScrollPosition()
78    orxonox.config("SoundManager", "soundVolume_", mastervolume)
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()
91        orxonox.config("SoundManager", "ambientVolume_", musicvolume)
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()
102    orxonox.config("SoundManager", "ambientVolume_", musicvolume)
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()
115        orxonox.config("SoundManager", "effectsVolume_", effectsvolume)
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()
126    orxonox.config("SoundManager", "effectsVolume_", effectsvolume)
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
142    soundMgr:toggleMute(orxonox.SoundType.All)
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
157    soundMgr:toggleMute(orxonox.SoundType.Music)
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
172    soundMgr:toggleMute(orxonox.SoundType.Effects)
173end
174
175function P.AudioThemeListbox_changed(e)
176    if listboxwindow:isItemSelected(1) then
177        orxonox.config("MoodManager", "mood_", "dnb")
178    else
179        orxonox.config("MoodManager", "mood_", "default")
180    end
181end
182
183function P.AudioBackButton_clicked(e)
184    hideMenuSheet(P.name)
185end
186
187function P.onKeyPressed() 
188    buttonIteratorHelper(P.buttonList, code, P, 1, 1)
189end
190
191return P
192
Note: See TracBrowser for help on using the repository browser.