Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6699 was 6417, checked in by rgrieder, 15 years ago

Merged presentation2 branch back to trunk.
Major new features:

  • Actual GUI with settings, etc.
  • Improved space ship steering (human interaction)
  • Rocket fire and more particle effects
  • Advanced sound framework
  • Property svn:eol-style set to native
File size: 6.0 KB
RevLine 
[6363]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
[6370]20    mastervolume = soundMgr:getVolume(orxonox.SoundType.All)
21    musicvolume = soundMgr:getVolume(orxonox.SoundType.Music)
22    effectsvolume = soundMgr:getVolume(orxonox.SoundType.Effects)
23    mastermute = soundMgr:getMute(orxonox.SoundType.All)
24    musicmute = soundMgr:getMute(orxonox.SoundType.Music)
25    effectsmute = soundMgr:getMute(orxonox.SoundType.Effects)
[6363]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
[6388]44        item = CEGUI.createListboxTextItem(v)
[6363]45        item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush")
46        CEGUI.toListbox(listboxwindow):addItem(item)
47    end
[6406]48    if orxonox.getConfig("MoodManager", "mood_") == "dnb" then
49        listboxwindow:setItemSelectState(1,true)
50    else
51        listboxwindow:setItemSelectState(0,true)
52    end
[6363]53end
54
55function P.AudioMasterScrollbar_changed(e)
56    if mastermute then
57        block = true
58        mastermutewindow:setSelected(false)
59        block = false
60        mastermute = false
61    end
62    if masterscrollbar_active == false then
63        mastervolume = masterscrollbarwindow:getScrollPosition()
[6403]64        orxonox.config("SoundManager", "soundVolume_", mastervolume)
[6363]65    end
66end
67
68function P.AudioMasterScrollbar_started(e)
69    masterscrollbar_active = true
70end
71
72function P.AudioMasterScrollbar_ended(e)
73    mastervolume = masterscrollbarwindow:getScrollPosition()
[6403]74    orxonox.config("SoundManager", "soundVolume_", mastervolume)
[6363]75    masterscrollbar_active = false
76end
77
78function P.AudioMusicScrollbar_changed(e)
79    if musicmute then
80        block = true
81        musicmutewindow:setSelected(false)
82        block = false
83        musicmute = false
84    end
85    if musicscrollbar_active == false then
86        musicvolume = musicscrollbarwindow:getScrollPosition()
[6403]87        orxonox.config("SoundManager", "ambientVolume_", musicvolume)
[6363]88    end
89end
90
91function P.AudioMusicScrollbar_started(e)
92    musicscrollbar_active = true
93end
94
95function P.AudioMusicScrollbar_ended(e)
96    musicmutewindow:setSelected(false)
97    musicvolume = musicscrollbarwindow:getScrollPosition()
[6403]98    orxonox.config("SoundManager", "ambientVolume_", musicvolume)
[6363]99    musicscrollbar_active = false
100end
101
102function P.AudioEffectsScrollbar_changed(e)
103    if effectsmute then
104        block = true
105        effectsmutewindow:setSelected(false)
106        block = false
107        effectsmute = false
108    end
109    if effectsscrollbar_active == false then
110        effectsvolume = effectsscrollbarwindow:getScrollPosition()
[6403]111        orxonox.config("SoundManager", "effectsVolume_", effectsvolume)
[6363]112    end
113end
114
115function P.AudioEffectsScrollbar_started(e)
116    effectsscrollbar_active = true
117end
118
119function P.AudioEffectsScrollbar_ended(e)
120    effectsmutewindow:setSelected(false)
121    effectsvolume = effectsscrollbarwindow:getScrollPosition()
[6403]122    orxonox.config("SoundManager", "effectsVolume_", effectsvolume)
[6363]123    effectsscrollbar_active = false
124end
125
126function P.AudioMuteMasterCheckbox_clicked(e)
127    if block == false then
128        if mastermute then
129            masterscrollbarwindow:setScrollPosition(mastervolume)
130            mastermute = false
131        else
132            temp = masterscrollbarwindow:getScrollPosition()
133            masterscrollbarwindow:setScrollPosition(0)
134            mastervolume = temp
135            mastermute = true
136        end
137    end
[6370]138    soundMgr:toggleMute(orxonox.SoundType.All)
[6363]139end
140
141function P.AudioMuteMusicCheckbox_clicked(e)
142    if block == false then
143        if musicmute then
144            musicscrollbarwindow:setScrollPosition(musicvolume)
145            musicmute = false
146        else
147            temp = musicscrollbarwindow:getScrollPosition()
148            musicscrollbarwindow:setScrollPosition(0)
149            musicvolume = temp
150            musicmute = true
151        end
152    end
[6370]153    soundMgr:toggleMute(orxonox.SoundType.Music)
[6363]154end
155
156function P.AudioMuteEffectsCheckbox_clicked(e)
157    if block == false then
158        if effectsmute then
159            effectsscrollbarwindow:setScrollPosition(effectsvolume)
160            effectsmute = false
161        else
162            temp = effectsscrollbarwindow:getScrollPosition()
163            effectsscrollbarwindow:setScrollPosition(0)
164            effectsvolume = temp
165            effectsmute = true
166        end
167    end
[6370]168    soundMgr:toggleMute(orxonox.SoundType.Effects)
[6363]169end
170
171function P.AudioThemeListbox_changed(e)
172    if listboxwindow:isItemSelected(1) then
[6406]173        orxonox.config("MoodManager", "mood_", "dnb")
[6363]174    else
[6406]175        orxonox.config("MoodManager", "mood_", "default")
[6363]176    end
177end
178
179function P.AudioBackButton_clicked(e)
180    hideGUI(P.filename)
181end
182
183return P
184
Note: See TracBrowser for help on using the repository browser.