Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 11634 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
RevLine 
[6363]1-- AudioMenu.lua
2
[6746]3local P = createMenuSheet("AudioMenu")
[6363]4
[6746]5function P.onLoad()
[6773]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")
[6363]31    local themeList = {}
32    table.insert(themeList, "Default")
33    table.insert(themeList, "Drum n' Bass")
34    for k,v in pairs(themeList) do
[6773]35        local item = CEGUI.createListboxTextItem(v)
[6746]36        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
[6773]37        CEGUI.toListbox(P.listboxwindow):addItem(item)
[6363]38    end
[6406]39    if orxonox.getConfig("MoodManager", "mood_") == "dnb" then
[6773]40        P.listboxwindow:setItemSelectState(1,true)
[6406]41    else
[6773]42        P.listboxwindow:setItemSelectState(0,true)
[6406]43    end
[6363]44end
45
46function P.AudioMasterScrollbar_changed(e)
[6773]47    if P.mastermute then
48        P.block = true
49        P.mastermutewindow:setSelected(false)
50        P.block = false
51        P.mastermute = false
[6363]52    end
[6773]53    if P.masterscrollbar_active == false then
54        P.mastervolume = P.masterscrollbarwindow:getScrollPosition()
55        orxonox.config("SoundManager", "soundVolume_", P.mastervolume)
[6363]56    end
57end
58
59function P.AudioMasterScrollbar_started(e)
[6773]60    P.masterscrollbar_active = true
[6363]61end
62
63function P.AudioMasterScrollbar_ended(e)
[6773]64    P.mastervolume = P.masterscrollbarwindow:getScrollPosition()
65    orxonox.config("SoundManager", "soundVolume_", P.mastervolume)
66    P.masterscrollbar_active = false
[6363]67end
68
69function P.AudioMusicScrollbar_changed(e)
[6773]70    if P.musicmute then
71        P.block = true
72        P.musicmutewindow:setSelected(false)
73        P.block = false
74        P.musicmute = false
[6363]75    end
[6773]76    if P.musicscrollbar_active == false then
77        P.musicvolume = P.musicscrollbarwindow:getScrollPosition()
78        orxonox.config("SoundManager", "ambientVolume_", P.musicvolume)
[6363]79    end
80end
81
82function P.AudioMusicScrollbar_started(e)
[6773]83    P.musicscrollbar_active = true
[6363]84end
85
86function P.AudioMusicScrollbar_ended(e)
[6773]87    P.musicmutewindow:setSelected(false)
88    P.musicvolume = P.musicscrollbarwindow:getScrollPosition()
89    orxonox.config("SoundManager", "ambientVolume_", P.musicvolume)
90    P.musicscrollbar_active = false
[6363]91end
92
93function P.AudioEffectsScrollbar_changed(e)
[6773]94    if P.effectsmute then
95        P.block = true
96        P.effectsmutewindow:setSelected(false)
97        P.block = false
98        P.effectsmute = false
[6363]99    end
[6773]100    if P.effectsscrollbar_active == false then
101        P.effectsvolume = P.effectsscrollbarwindow:getScrollPosition()
102        orxonox.config("SoundManager", "effectsVolume_", P.effectsvolume)
[6363]103    end
104end
105
106function P.AudioEffectsScrollbar_started(e)
[6773]107    P.effectsscrollbar_active = true
[6363]108end
109
110function P.AudioEffectsScrollbar_ended(e)
[6773]111    P.effectsmutewindow:setSelected(false)
112    P.effectsvolume = P.effectsscrollbarwindow:getScrollPosition()
113    orxonox.config("SoundManager", "effectsVolume_", P.effectsvolume)
114    P.effectsscrollbar_active = false
[6363]115end
116
117function P.AudioMuteMasterCheckbox_clicked(e)
[6773]118    if P.block == false then
119        if P.mastermute then
120            P.masterscrollbarwindow:setScrollPosition(P.mastervolume)
121            P.mastermute = false
[6363]122        else
[6773]123            temp = P.masterscrollbarwindow:getScrollPosition()
124            P.masterscrollbarwindow:setScrollPosition(0)
125            P.mastervolume = temp
126            P.mastermute = true
[6363]127        end
128    end
[6773]129    P.soundMgr:toggleMute(orxonox.SoundType.All)
[6363]130end
131
132function P.AudioMuteMusicCheckbox_clicked(e)
[6773]133    if P.block == false then
134        if P.musicmute then
135            P.musicscrollbarwindow:setScrollPosition(P.musicvolume)
136            P.musicmute = false
[6363]137        else
[6773]138            temp = P.musicscrollbarwindow:getScrollPosition()
139            P.musicscrollbarwindow:setScrollPosition(0)
140            P.musicvolume = temp
141            P.musicmute = true
[6363]142        end
143    end
[6773]144    P.soundMgr:toggleMute(orxonox.SoundType.Music)
[6363]145end
146
147function P.AudioMuteEffectsCheckbox_clicked(e)
[6773]148    if P.block == false then
149        if P.effectsmute then
150            P.effectsscrollbarwindow:setScrollPosition(P.effectsvolume)
151            P.effectsmute = false
[6363]152        else
[6773]153            temp = P.effectsscrollbarwindow:getScrollPosition()
154            P.effectsscrollbarwindow:setScrollPosition(0)
155            P.effectsvolume = temp
156            P.effectsmute = true
[6363]157        end
158    end
[6773]159    P.soundMgr:toggleMute(orxonox.SoundType.Effects)
[6363]160end
161
162function P.AudioThemeListbox_changed(e)
[6773]163    if P.listboxwindow:isItemSelected(1) then
[6406]164        orxonox.config("MoodManager", "mood_", "dnb")
[6363]165    else
[6406]166        orxonox.config("MoodManager", "mood_", "default")
[6363]167    end
168end
169
170function P.AudioBackButton_clicked(e)
[6746]171    hideMenuSheet(P.name)
[6363]172end
173
174return P
175
Note: See TracBrowser for help on using the repository browser.