Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gamestate/data/gui/scripts/AudioMenu.lua @ 6518

Last change on this file since 6518 was 6459, checked in by rgrieder, 15 years ago

Simplified BasicGUI construction. Just give the name of the GUI as argument. The rest will be deduced.

  • Property svn:eol-style set to native
File size: 5.9 KB
RevLine 
[6363]1-- AudioMenu.lua
2
3BasicGUI = require("BasicGUI")
[6459]4local P = BasicGUI:new("AudioMenu")
[6363]5if _REQUIREDNAME == nil then
6    AudioMenu = P
7else
8    _G[_REQUIREDNAME] = P
9end
10
11function P:init()
12    soundMgr = orxonox.SoundManager:getInstance()
13    block = false
14    masterscrollbar_active = false
15    musicscrollbar_active = false
16    effectsscrollbar_active = false
[6370]17    mastervolume = soundMgr:getVolume(orxonox.SoundType.All)
18    musicvolume = soundMgr:getVolume(orxonox.SoundType.Music)
19    effectsvolume = soundMgr:getVolume(orxonox.SoundType.Effects)
20    mastermute = soundMgr:getMute(orxonox.SoundType.All)
21    musicmute = soundMgr:getMute(orxonox.SoundType.Music)
22    effectsmute = soundMgr:getMute(orxonox.SoundType.Effects)
[6363]23    masterscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/MasterScrollbar"),"CEGUI::Scrollbar")
24    musicscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/MusicScrollbar"),"CEGUI::Scrollbar")
25    effectsscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/EffectsScrollbar"),"CEGUI::Scrollbar")
26    mastermutewindow = tolua.cast(winMgr:getWindow("orxonox/MasterCheckbox"),"CEGUI::Checkbox")
27    musicmutewindow = tolua.cast(winMgr:getWindow("orxonox/MusicCheckbox"),"CEGUI::Checkbox")
28    effectsmutewindow = tolua.cast(winMgr:getWindow("orxonox/EffectsCheckbox"),"CEGUI::Checkbox")
29    masterscrollbarwindow:setScrollPosition(mastervolume)
30    musicscrollbarwindow:setScrollPosition(musicvolume)
31    effectsscrollbarwindow:setScrollPosition(effectsvolume)
32    mastermutewindow:setSelected(mastermute)
33    musicmutewindow:setSelected(musicmute)
34    effectsmutewindow:setSelected(effectsmute)
35    choice = "Default"
36    listboxwindow = winMgr:getWindow("orxonox/AudioThemeListbox")
37    local themeList = {}
38    table.insert(themeList, "Default")
39    table.insert(themeList, "Drum n' Bass")
40    for k,v in pairs(themeList) do
[6388]41        item = CEGUI.createListboxTextItem(v)
[6363]42        item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush")
43        CEGUI.toListbox(listboxwindow):addItem(item)
44    end
[6406]45    if orxonox.getConfig("MoodManager", "mood_") == "dnb" then
46        listboxwindow:setItemSelectState(1,true)
47    else
48        listboxwindow:setItemSelectState(0,true)
49    end
[6363]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()
[6403]61        orxonox.config("SoundManager", "soundVolume_", mastervolume)
[6363]62    end
63end
64
65function P.AudioMasterScrollbar_started(e)
66    masterscrollbar_active = true
67end
68
69function P.AudioMasterScrollbar_ended(e)
70    mastervolume = masterscrollbarwindow:getScrollPosition()
[6403]71    orxonox.config("SoundManager", "soundVolume_", mastervolume)
[6363]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()
[6403]84        orxonox.config("SoundManager", "ambientVolume_", musicvolume)
[6363]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()
[6403]95    orxonox.config("SoundManager", "ambientVolume_", musicvolume)
[6363]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()
[6403]108        orxonox.config("SoundManager", "effectsVolume_", effectsvolume)
[6363]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()
[6403]119    orxonox.config("SoundManager", "effectsVolume_", effectsvolume)
[6363]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
[6370]135    soundMgr:toggleMute(orxonox.SoundType.All)
[6363]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
[6370]150    soundMgr:toggleMute(orxonox.SoundType.Music)
[6363]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
[6370]165    soundMgr:toggleMute(orxonox.SoundType.Effects)
[6363]166end
167
168function P.AudioThemeListbox_changed(e)
169    if listboxwindow:isItemSelected(1) then
[6406]170        orxonox.config("MoodManager", "mood_", "dnb")
[6363]171    else
[6406]172        orxonox.config("MoodManager", "mood_", "default")
[6363]173    end
174end
175
176function P.AudioBackButton_clicked(e)
177    hideGUI(P.filename)
178end
179
180return P
181
Note: See TracBrowser for help on using the repository browser.