Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/data/gui/scripts/AudioMenu.lua @ 6747

Last change on this file since 6747 was 6746, checked in by rgrieder, 15 years ago

Merged gamestates2 branch back to trunk.
This brings in some heavy changes in the GUI framework.
It should also fix problems with triggered asserts in the InputManager.

Note: PickupInventory does not seem to work —> Segfault when showing because before, the owner in GUIOverlay::setGUIName is already NULL.
I haven't tested it before, so I can't tell whether it's my changes.

  • Property svn:eol-style set to native
File size: 5.8 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    for k,v in pairs(themeList) do
35        item = CEGUI.createListboxTextItem(v)
36        item:setSelectionBrushImage(menuImageSet, "MultiListSelectionBrush")
37        CEGUI.toListbox(listboxwindow):addItem(item)
38    end
39    if orxonox.getConfig("MoodManager", "mood_") == "dnb" then
40        listboxwindow:setItemSelectState(1,true)
41    else
42        listboxwindow:setItemSelectState(0,true)
43    end
44end
45
46function P.AudioMasterScrollbar_changed(e)
47    if mastermute then
48        block = true
49        mastermutewindow:setSelected(false)
50        block = false
51        mastermute = false
52    end
53    if masterscrollbar_active == false then
54        mastervolume = masterscrollbarwindow:getScrollPosition()
55        orxonox.config("SoundManager", "soundVolume_", mastervolume)
56    end
57end
58
59function P.AudioMasterScrollbar_started(e)
60    masterscrollbar_active = true
61end
62
63function P.AudioMasterScrollbar_ended(e)
64    mastervolume = masterscrollbarwindow:getScrollPosition()
65    orxonox.config("SoundManager", "soundVolume_", mastervolume)
66    masterscrollbar_active = false
67end
68
69function P.AudioMusicScrollbar_changed(e)
70    if musicmute then
71        block = true
72        musicmutewindow:setSelected(false)
73        block = false
74        musicmute = false
75    end
76    if musicscrollbar_active == false then
77        musicvolume = musicscrollbarwindow:getScrollPosition()
78        orxonox.config("SoundManager", "ambientVolume_", musicvolume)
79    end
80end
81
82function P.AudioMusicScrollbar_started(e)
83    musicscrollbar_active = true
84end
85
86function P.AudioMusicScrollbar_ended(e)
87    musicmutewindow:setSelected(false)
88    musicvolume = musicscrollbarwindow:getScrollPosition()
89    orxonox.config("SoundManager", "ambientVolume_", musicvolume)
90    musicscrollbar_active = false
91end
92
93function P.AudioEffectsScrollbar_changed(e)
94    if effectsmute then
95        block = true
96        effectsmutewindow:setSelected(false)
97        block = false
98        effectsmute = false
99    end
100    if effectsscrollbar_active == false then
101        effectsvolume = effectsscrollbarwindow:getScrollPosition()
102        orxonox.config("SoundManager", "effectsVolume_", effectsvolume)
103    end
104end
105
106function P.AudioEffectsScrollbar_started(e)
107    effectsscrollbar_active = true
108end
109
110function P.AudioEffectsScrollbar_ended(e)
111    effectsmutewindow:setSelected(false)
112    effectsvolume = effectsscrollbarwindow:getScrollPosition()
113    orxonox.config("SoundManager", "effectsVolume_", effectsvolume)
114    effectsscrollbar_active = false
115end
116
117function P.AudioMuteMasterCheckbox_clicked(e)
118    if block == false then
119        if mastermute then
120            masterscrollbarwindow:setScrollPosition(mastervolume)
121            mastermute = false
122        else
123            temp = masterscrollbarwindow:getScrollPosition()
124            masterscrollbarwindow:setScrollPosition(0)
125            mastervolume = temp
126            mastermute = true
127        end
128    end
129    soundMgr:toggleMute(orxonox.SoundType.All)
130end
131
132function P.AudioMuteMusicCheckbox_clicked(e)
133    if block == false then
134        if musicmute then
135            musicscrollbarwindow:setScrollPosition(musicvolume)
136            musicmute = false
137        else
138            temp = musicscrollbarwindow:getScrollPosition()
139            musicscrollbarwindow:setScrollPosition(0)
140            musicvolume = temp
141            musicmute = true
142        end
143    end
144    soundMgr:toggleMute(orxonox.SoundType.Music)
145end
146
147function P.AudioMuteEffectsCheckbox_clicked(e)
148    if block == false then
149        if effectsmute then
150            effectsscrollbarwindow:setScrollPosition(effectsvolume)
151            effectsmute = false
152        else
153            temp = effectsscrollbarwindow:getScrollPosition()
154            effectsscrollbarwindow:setScrollPosition(0)
155            effectsvolume = temp
156            effectsmute = true
157        end
158    end
159    soundMgr:toggleMute(orxonox.SoundType.Effects)
160end
161
162function P.AudioThemeListbox_changed(e)
163    if 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.