Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 3, 2009, 8:10:07 PM (15 years ago)
Author:
cmueri
Message:

The audio menu and all its functions are now enabled.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/data/gui/scripts/AudioMenu.lua

    r6206 r6233  
    1414function P:init()
    1515    soundMgr = orxonox.SoundManager:getInstance()
     16    block = false
    1617    masterscrollbar_active = false
    1718    musicscrollbar_active = false
     
    2021    musicvolume = soundMgr:getVolume(orxonox.SoundType.ambient)
    2122    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")
     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    dropdownwindow = winMgr:getWindow("orxonox/AudioThemeCombobox")
    2940    local themeList = {}
    3041    table.insert(themeList, "Default")
     
    3344        item = CEGUI.createListboxTextItem(v)       
    3445        item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush")
    35         CEGUI.toCombobox(dropdown):addItem(item)
     46        CEGUI.toCombobox(dropdownwindow):addItem(item)
    3647    end
     48    dropdownwindow:setItemSelectState(0,true)
    3749end
    3850
    3951function P.AudioMasterScrollbar_changed(e)
     52    if mastermute then
     53        block = true
     54        mastermutewindow:setSelected(false)
     55        block = false
     56        mastermute = false
     57    end
    4058    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)
     59        mastervolume = masterscrollbarwindow:getScrollPosition()
     60        orxonox.CommandExecutor:execute("config SoundManager soundVolume_ " .. mastervolume)
    4461    end
    4562end
     
    5067
    5168function 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)
     69    mastervolume = masterscrollbarwindow:getScrollPosition()
     70    orxonox.CommandExecutor:execute("config SoundManager soundVolume_ " .. mastervolume)
    5571    masterscrollbar_active = false
    5672end
    5773
    5874function P.AudioMusicScrollbar_changed(e)
     75    if musicmute then
     76        block = true
     77        musicmutewindow:setSelected(false)
     78        block = false
     79        musicmute = false
     80    end
    5981    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)
     82        musicvolume = musicscrollbarwindow:getScrollPosition()
     83        orxonox.CommandExecutor:execute("config SoundManager ambientVolume_ " .. musicvolume)
    6384    end
    6485end
     
    6990
    7091function 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)
     92    musicmutewindow:setSelected(false)
     93    musicvolume = musicscrollbarwindow:getScrollPosition()
     94    orxonox.CommandExecutor:execute("config SoundManager ambientVolume_ " .. musicvolume)
    7495    musicscrollbar_active = false
    7596end
    7697
    7798function P.AudioEffectsScrollbar_changed(e)
     99    if effectsmute then
     100        block = true
     101        effectsmutewindow:setSelected(false)
     102        block = false
     103        effectsmute = false
     104    end
    78105    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)
     106        effectsvolume = effectsscrollbarwindow:getScrollPosition()
     107        orxonox.CommandExecutor:execute("config SoundManager effectsVolume_ " .. effectsvolume)
    82108    end
    83109end
     
    88114
    89115function 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)
     116    effectsmutewindow:setSelected(false)
     117    effectsvolume = effectsscrollbarwindow:getScrollPosition()
     118    orxonox.CommandExecutor:execute("config SoundManager effectsVolume_ " .. effectsvolume)
    93119    effectsscrollbar_active = false
    94120end
    95121
    96122function 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)
     123    if block == false then
     124        if mastermute then
     125            masterscrollbarwindow:setScrollPosition(mastervolume)
     126            mastermute = false
     127        else
     128            temp = masterscrollbarwindow:getScrollPosition()
     129            masterscrollbarwindow:setScrollPosition(0)
     130            mastervolume = temp
     131            mastermute = true
     132        end
     133        soundMgr:toggleMute(orxonox.SoundType.none)
     134    end
    103135end
    104136
    105137function P.AudioMuteMusicCheckbox_clicked(e)
    106     soundMgr:toggleMute(orxonox.SoundType.ambient)
     138    if block == false then
     139        if musicmute then
     140            musicscrollbarwindow:setScrollPosition(musicvolume)
     141            musicmute = false
     142        else
     143            temp = musicscrollbarwindow:getScrollPosition()
     144            musicscrollbarwindow:setScrollPosition(0)
     145            musicvolume = temp
     146            musicmute = true
     147        end
     148        soundMgr:toggleMute(orxonox.SoundType.ambient)
     149    end
    107150end
    108151
    109152function P.AudioMuteEffectsCheckbox_clicked(e)
    110     soundMgr:toggleMute(orxonox.SoundType.effects)
     153    if block == false then
     154        if effectsmute then
     155            effectsscrollbarwindow:setScrollPosition(effectsvolume)
     156            effectsmute = false
     157        else
     158            temp = effectsscrollbarwindow:getScrollPosition()
     159            effectsscrollbarwindow:setScrollPosition(0)
     160            effectsvolume = temp
     161            effectsmute = true
     162        end
     163        soundMgr:toggleMute(orxonox.SoundType.effects)
     164    end
    111165end
    112166
    113167function 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
     168    if dropdownwindow:isItemSelected(1) then
     169        orxonox.CommandExecutor:execute("setMood dnb")
     170    else
     171        orxonox.CommandExecutor:execute("setMood default")
     172    end
    123173end
    124174
Note: See TracChangeset for help on using the changeset viewer.