1 | -- AudioMenu.lua |
---|
2 | |
---|
3 | BasicGUI = require("BasicGUI") |
---|
4 | local P = BasicGUI:new() --inherit everything from the gui package |
---|
5 | if _REQUIREDNAME == nil then |
---|
6 | AudioMenu = P |
---|
7 | else |
---|
8 | _G[_REQUIREDNAME] = P |
---|
9 | end |
---|
10 | |
---|
11 | P.filename = "AudioMenu" |
---|
12 | P.layoutString = "AudioMenu.layout" |
---|
13 | |
---|
14 | function 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 |
---|
37 | end |
---|
38 | |
---|
39 | function 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 |
---|
45 | end |
---|
46 | |
---|
47 | function P.AudioMasterScrollbar_started(e) |
---|
48 | masterscrollbar_active = true |
---|
49 | end |
---|
50 | |
---|
51 | function 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 |
---|
56 | end |
---|
57 | |
---|
58 | function 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 |
---|
64 | end |
---|
65 | |
---|
66 | function P.AudioMusicScrollbar_started(e) |
---|
67 | musicscrollbar_active = true |
---|
68 | end |
---|
69 | |
---|
70 | function 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 |
---|
75 | end |
---|
76 | |
---|
77 | function 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 |
---|
83 | end |
---|
84 | |
---|
85 | function P.AudioEffectsScrollbar_started(e) |
---|
86 | effectsscrollbar_active = true |
---|
87 | end |
---|
88 | |
---|
89 | function 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 |
---|
94 | end |
---|
95 | |
---|
96 | function 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) |
---|
103 | end |
---|
104 | |
---|
105 | function P.AudioMuteMusicCheckbox_clicked(e) |
---|
106 | soundMgr:toggleMute(orxonox.SoundType.ambient) |
---|
107 | end |
---|
108 | |
---|
109 | function P.AudioMuteEffectsCheckbox_clicked(e) |
---|
110 | soundMgr:toggleMute(orxonox.SoundType.effects) |
---|
111 | end |
---|
112 | |
---|
113 | function 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 |
---|
123 | end |
---|
124 | |
---|
125 | function P.AudioBackButton_clicked(e) |
---|
126 | hideGUI(P.filename) |
---|
127 | end |
---|
128 | |
---|
129 | return P |
---|
130 | |
---|