Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentation2/data/gui/scripts/AudioMenu.lua @ 6217

Last change on this file since 6217 was 6206, checked in by cmueri, 15 years ago

The new menus (but not all functions of the menu) are now available.

File size: 4.6 KB
Line 
1-- AudioMenu.lua
2
3BasicGUI = require("BasicGUI")
4local P = BasicGUI:new() --inherit everything from the gui package
5if _REQUIREDNAME == nil then
6    AudioMenu = P
7else
8    _G[_REQUIREDNAME] = P
9end
10
11P.filename = "AudioMenu"
12P.layoutString = "AudioMenu.layout"
13
14function P:init()
15    soundMgr = orxonox.SoundManager:getInstance()
16    masterscrollbar_active = false
17    musicscrollbar_active = false
18    effectsscrollbar_active = false
19    mastervolume = soundMgr:getVolume(orxonox.SoundType.none)
20    musicvolume = soundMgr:getVolume(orxonox.SoundType.ambient)
21    effectsvolume = soundMgr:getVolume(orxonox.SoundType.effects)
22    window = tolua.cast(winMgr:getWindow("orxonox/MasterScrollbar"),"CEGUI::Scrollbar")
23    window:setScrollPosition(mastervolume)
24    window = tolua.cast(winMgr:getWindow("orxonox/MusicScrollbar"),"CEGUI::Scrollbar")
25    window:setScrollPosition(musicvolume)
26    window = tolua.cast(winMgr:getWindow("orxonox/EffectsScrollbar"),"CEGUI::Scrollbar")
27    window:setScrollPosition(effectsvolume)
28    dropdown = winMgr:getWindow("orxonox/AudioThemeCombobox")
29    local themeList = {}
30    table.insert(themeList, "Default")
31    table.insert(themeList, "Drum n' Bass")
32    for k,v in pairs(themeList) do
33        item = CEGUI.createListboxTextItem(v)       
34        item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush")
35        CEGUI.toCombobox(dropdown):addItem(item)
36    end
37end
38
39function P.AudioMasterScrollbar_changed(e)
40    if masterscrollbar_active == false then
41        window = tolua.cast(winMgr:getWindow("orxonox/MasterScrollbar"),"CEGUI::Scrollbar")
42        volume = window:getScrollPosition()
43        orxonox.CommandExecutor:execute("config SoundManager soundVolume_ " .. volume)
44    end
45end
46
47function P.AudioMasterScrollbar_started(e)
48    masterscrollbar_active = true
49end
50
51function P.AudioMasterScrollbar_ended(e)
52    window = tolua.cast(winMgr:getWindow("orxonox/MasterScrollbar"),"CEGUI::Scrollbar")
53    volume = window:getScrollPosition()
54    orxonox.CommandExecutor:execute("config SoundManager soundVolume_ " .. volume)
55    masterscrollbar_active = false
56end
57
58function P.AudioMusicScrollbar_changed(e)
59    if musicscrollbar_active == false then
60        window = tolua.cast(winMgr:getWindow("orxonox/MusicScrollbar"),"CEGUI::Scrollbar")
61        volume = window:getScrollPosition()
62        orxonox.CommandExecutor:execute("config SoundManager ambientVolume_ " .. volume)
63    end
64end
65
66function P.AudioMusicScrollbar_started(e)
67    musicscrollbar_active = true
68end
69
70function P.AudioMusicScrollbar_ended(e)
71    window = tolua.cast(winMgr:getWindow("orxonox/MusicScrollbar"),"CEGUI::Scrollbar")
72    volume = window:getScrollPosition()
73    orxonox.CommandExecutor:execute("config SoundManager ambientVolume_ " .. volume)
74    musicscrollbar_active = false
75end
76
77function P.AudioEffectsScrollbar_changed(e)
78    if effectsscrollbar_active == false then
79        window = tolua.cast(winMgr:getWindow("orxonox/EffectsScrollbar"),"CEGUI::Scrollbar")
80        volume = window:getScrollPosition()
81        orxonox.CommandExecutor:execute("config SoundManager effectsVolume_ " .. volume)
82    end
83end
84
85function P.AudioEffectsScrollbar_started(e)
86    effectsscrollbar_active = true
87end
88
89function P.AudioEffectsScrollbar_ended(e)
90    window = tolua.cast(winMgr:getWindow("orxonox/EffectsScrollbar"),"CEGUI::Scrollbar")
91    volume = window:getScrollPosition()
92    orxonox.CommandExecutor:execute("config SoundManager effectsVolume_ " .. volume)
93    effectsscrollbar_active = false
94end
95
96function P.AudioMuteMasterCheckbox_clicked(e)
97--    if
98--        mastervolume = soundMgr:getVolume(orxonox.SoundType.none)
99--        window = tolua.cast(winMgr:getWindow("orxonox/MasterScrollbar"),"CEGUI::Scrollbar")
100--        window:setScrollPosition(0)
101--    end
102    soundMgr:toggleMute(orxonox.SoundType.none)
103end
104
105function P.AudioMuteMusicCheckbox_clicked(e)
106    soundMgr:toggleMute(orxonox.SoundType.ambient)
107end
108
109function P.AudioMuteEffectsCheckbox_clicked(e)
110    soundMgr:toggleMute(orxonox.SoundType.effects)
111end
112
113function P.AudioThemeCombobox_changed(e)
114--    local choice = winMgr:getWindow("orxonox/AudioThemeCombobox"):getFirstSelectedItem()
115--    if choice == "Default" then
116--        orxonox.CommandExecutor:execute("setMood default")
117--        debug("default selected")
118--    end
119--    if choice == "Drum 'n Bass" then
120--        orxonox.CommandExecutor:execute("setMood dnb")
121--        debug("dnb selected")
122--    end
123end
124
125function P.AudioBackButton_clicked(e)
126    hideGUI(P.filename)
127end
128
129return P
130
Note: See TracBrowser for help on using the repository browser.