Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gamestates3/data/gui/scripts/AudioMenu.lua @ 6907

Last change on this file since 6907 was 6773, checked in by rgrieder, 15 years ago

Eliminated all unnecessary global Lua variables and replaced them either with a local or a instance variable (P.myVar).

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