Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

All the menus (inclusive InGameMenus) have an equal design, some menus have a larger window. They should be ready to presentate now.
BUG REPORT in KeyBindMenu: If there are >4 buttons in a row, the GUI doesn't show those correctly.

File size: 6.1 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    block = false
17    masterscrollbar_active = false
18    musicscrollbar_active = false
19    effectsscrollbar_active = false
20    mastervolume = soundMgr:getVolume(orxonox.SoundType.none)
21    musicvolume = soundMgr:getVolume(orxonox.SoundType.ambient)
22    effectsvolume = soundMgr:getVolume(orxonox.SoundType.effects)
23    mastermute = soundMgr:getMute(orxonox.SoundType.none)
24    musicmute = soundMgr:getMute(orxonox.SoundType.ambient)
25    effectsmute = soundMgr:getMute(orxonox.SoundType.effects)
26    masterscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/MasterScrollbar"),"CEGUI::Scrollbar")
27    musicscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/MusicScrollbar"),"CEGUI::Scrollbar")
28    effectsscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/EffectsScrollbar"),"CEGUI::Scrollbar")
29    mastermutewindow = tolua.cast(winMgr:getWindow("orxonox/MasterCheckbox"),"CEGUI::Checkbox")
30    musicmutewindow = tolua.cast(winMgr:getWindow("orxonox/MusicCheckbox"),"CEGUI::Checkbox")
31    effectsmutewindow = tolua.cast(winMgr:getWindow("orxonox/EffectsCheckbox"),"CEGUI::Checkbox")
32    masterscrollbarwindow:setScrollPosition(mastervolume)
33    musicscrollbarwindow:setScrollPosition(musicvolume)
34    effectsscrollbarwindow:setScrollPosition(effectsvolume)
35    mastermutewindow:setSelected(mastermute)
36    musicmutewindow:setSelected(musicmute)
37    effectsmutewindow:setSelected(effectsmute)
38    choice = "Default"
39    listboxwindow = winMgr:getWindow("orxonox/AudioThemeListbox")
40    local themeList = {}
41    table.insert(themeList, "Default")
42    table.insert(themeList, "Drum n' Bass")
43    for k,v in pairs(themeList) do
44        item = CEGUI.createListboxTextItem(v)       
45        item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush")
46        CEGUI.toListbox(listboxwindow):addItem(item)
47    end
48end
49
50function P.AudioMasterScrollbar_changed(e)
51    if mastermute then
52        block = true
53        mastermutewindow:setSelected(false)
54        block = false
55        mastermute = false
56    end
57    if masterscrollbar_active == false then
58        mastervolume = masterscrollbarwindow:getScrollPosition()
59        orxonox.CommandExecutor:execute("config SoundManager soundVolume_ " .. mastervolume)
60    end
61end
62
63function P.AudioMasterScrollbar_started(e)
64    masterscrollbar_active = true
65end
66
67function P.AudioMasterScrollbar_ended(e)
68    mastervolume = masterscrollbarwindow:getScrollPosition()
69    orxonox.CommandExecutor:execute("config SoundManager soundVolume_ " .. mastervolume)
70    masterscrollbar_active = false
71end
72
73function P.AudioMusicScrollbar_changed(e)
74    if musicmute then
75        block = true
76        musicmutewindow:setSelected(false)
77        block = false
78        musicmute = false
79    end
80    if musicscrollbar_active == false then
81        musicvolume = musicscrollbarwindow:getScrollPosition()
82        orxonox.CommandExecutor:execute("config SoundManager ambientVolume_ " .. musicvolume)
83    end
84end
85
86function P.AudioMusicScrollbar_started(e)
87    musicscrollbar_active = true
88end
89
90function P.AudioMusicScrollbar_ended(e)
91    musicmutewindow:setSelected(false)
92    musicvolume = musicscrollbarwindow:getScrollPosition()
93    orxonox.CommandExecutor:execute("config SoundManager ambientVolume_ " .. musicvolume)
94    musicscrollbar_active = false
95end
96
97function P.AudioEffectsScrollbar_changed(e)
98    if effectsmute then
99        block = true
100        effectsmutewindow:setSelected(false)
101        block = false
102        effectsmute = false
103    end
104    if effectsscrollbar_active == false then
105        effectsvolume = effectsscrollbarwindow:getScrollPosition()
106        orxonox.CommandExecutor:execute("config SoundManager effectsVolume_ " .. effectsvolume)
107    end
108end
109
110function P.AudioEffectsScrollbar_started(e)
111    effectsscrollbar_active = true
112end
113
114function P.AudioEffectsScrollbar_ended(e)
115    effectsmutewindow:setSelected(false)
116    effectsvolume = effectsscrollbarwindow:getScrollPosition()
117    orxonox.CommandExecutor:execute("config SoundManager effectsVolume_ " .. effectsvolume)
118    effectsscrollbar_active = false
119end
120
121function P.AudioMuteMasterCheckbox_clicked(e)
122    if block == false then
123        if mastermute then
124            masterscrollbarwindow:setScrollPosition(mastervolume)
125            mastermute = false
126        else
127            temp = masterscrollbarwindow:getScrollPosition()
128            masterscrollbarwindow:setScrollPosition(0)
129            mastervolume = temp
130            mastermute = true
131        end
132    end
133    soundMgr:toggleMute(orxonox.SoundType.none)
134end
135
136function P.AudioMuteMusicCheckbox_clicked(e)
137    if block == false then
138        if musicmute then
139            musicscrollbarwindow:setScrollPosition(musicvolume)
140            musicmute = false
141        else
142            temp = musicscrollbarwindow:getScrollPosition()
143            musicscrollbarwindow:setScrollPosition(0)
144            musicvolume = temp
145            musicmute = true
146        end
147    end
148    soundMgr:toggleMute(orxonox.SoundType.ambient)
149end
150
151function P.AudioMuteEffectsCheckbox_clicked(e)
152    if block == false then
153        if effectsmute then
154            effectsscrollbarwindow:setScrollPosition(effectsvolume)
155            effectsmute = false
156        else
157            temp = effectsscrollbarwindow:getScrollPosition()
158            effectsscrollbarwindow:setScrollPosition(0)
159            effectsvolume = temp
160            effectsmute = true
161        end
162    end
163    soundMgr:toggleMute(orxonox.SoundType.effects)
164end
165
166function P.AudioThemeListbox_changed(e)
167    if listboxwindow:isItemSelected(1) then
168        orxonox.CommandExecutor:execute("setMood dnb")
169    else
170        orxonox.CommandExecutor:execute("setMood default")
171    end
172end
173
174function P.AudioBackButton_clicked(e)
175    hideGUI(P.filename)
176end
177
178return P
179
Note: See TracBrowser for help on using the repository browser.