Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/mac_osx/data/gui/scripts/AudioMenu.lua @ 7869

Last change on this file since 7869 was 7767, checked in by youngk, 14 years ago

Committing a few minor changes to some files. They affect: Keyboard input on the Mac; Introduction of new Moods and debugging of Mac sound.

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