Index: code/branches/presentation2/data/gui/scripts/AudioMenu.lua
===================================================================
--- code/branches/presentation2/data/gui/scripts/AudioMenu.lua	(revision 6224)
+++ code/branches/presentation2/data/gui/scripts/AudioMenu.lua	(revision 6233)
@@ -14,4 +14,5 @@
 function P:init()
     soundMgr = orxonox.SoundManager:getInstance()
+    block = false
     masterscrollbar_active = false
     musicscrollbar_active = false
@@ -20,11 +21,21 @@
     musicvolume = soundMgr:getVolume(orxonox.SoundType.ambient)
     effectsvolume = soundMgr:getVolume(orxonox.SoundType.effects)
-    window = tolua.cast(winMgr:getWindow("orxonox/MasterScrollbar"),"CEGUI::Scrollbar")
-    window:setScrollPosition(mastervolume)
-    window = tolua.cast(winMgr:getWindow("orxonox/MusicScrollbar"),"CEGUI::Scrollbar")
-    window:setScrollPosition(musicvolume)
-    window = tolua.cast(winMgr:getWindow("orxonox/EffectsScrollbar"),"CEGUI::Scrollbar")
-    window:setScrollPosition(effectsvolume)
-    dropdown = winMgr:getWindow("orxonox/AudioThemeCombobox")
+    mastermute = soundMgr:getMute(orxonox.SoundType.none)
+    musicmute = soundMgr:getMute(orxonox.SoundType.ambient)
+    effectsmute = soundMgr:getMute(orxonox.SoundType.effects)
+    masterscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/MasterScrollbar"),"CEGUI::Scrollbar")
+    musicscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/MusicScrollbar"),"CEGUI::Scrollbar")
+    effectsscrollbarwindow = tolua.cast(winMgr:getWindow("orxonox/EffectsScrollbar"),"CEGUI::Scrollbar")
+    mastermutewindow = tolua.cast(winMgr:getWindow("orxonox/MasterCheckbox"),"CEGUI::Checkbox")
+    musicmutewindow = tolua.cast(winMgr:getWindow("orxonox/MusicCheckbox"),"CEGUI::Checkbox")
+    effectsmutewindow = tolua.cast(winMgr:getWindow("orxonox/EffectsCheckbox"),"CEGUI::Checkbox")
+    masterscrollbarwindow:setScrollPosition(mastervolume)
+    musicscrollbarwindow:setScrollPosition(musicvolume)
+    effectsscrollbarwindow:setScrollPosition(effectsvolume)
+    mastermutewindow:setSelected(mastermute)
+    musicmutewindow:setSelected(musicmute)
+    effectsmutewindow:setSelected(effectsmute)
+    choice = "Default"
+    dropdownwindow = winMgr:getWindow("orxonox/AudioThemeCombobox")
     local themeList = {}
     table.insert(themeList, "Default")
@@ -33,13 +44,19 @@
         item = CEGUI.createListboxTextItem(v)        
         item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush")
-        CEGUI.toCombobox(dropdown):addItem(item)
+        CEGUI.toCombobox(dropdownwindow):addItem(item)
     end
+    dropdownwindow:setItemSelectState(0,true)
 end
 
 function P.AudioMasterScrollbar_changed(e)
+    if mastermute then
+        block = true
+        mastermutewindow:setSelected(false)
+        block = false
+        mastermute = false
+    end
     if masterscrollbar_active == false then
-        window = tolua.cast(winMgr:getWindow("orxonox/MasterScrollbar"),"CEGUI::Scrollbar")
-        volume = window:getScrollPosition()
-        orxonox.CommandExecutor:execute("config SoundManager soundVolume_ " .. volume)
+        mastervolume = masterscrollbarwindow:getScrollPosition()
+        orxonox.CommandExecutor:execute("config SoundManager soundVolume_ " .. mastervolume)
     end
 end
@@ -50,15 +67,19 @@
 
 function P.AudioMasterScrollbar_ended(e)
-    window = tolua.cast(winMgr:getWindow("orxonox/MasterScrollbar"),"CEGUI::Scrollbar")
-    volume = window:getScrollPosition()
-    orxonox.CommandExecutor:execute("config SoundManager soundVolume_ " .. volume)
+    mastervolume = masterscrollbarwindow:getScrollPosition()
+    orxonox.CommandExecutor:execute("config SoundManager soundVolume_ " .. mastervolume)
     masterscrollbar_active = false
 end
 
 function P.AudioMusicScrollbar_changed(e)
+    if musicmute then
+        block = true
+        musicmutewindow:setSelected(false)
+        block = false
+        musicmute = false
+    end
     if musicscrollbar_active == false then
-        window = tolua.cast(winMgr:getWindow("orxonox/MusicScrollbar"),"CEGUI::Scrollbar")
-        volume = window:getScrollPosition()
-        orxonox.CommandExecutor:execute("config SoundManager ambientVolume_ " .. volume)
+        musicvolume = musicscrollbarwindow:getScrollPosition()
+        orxonox.CommandExecutor:execute("config SoundManager ambientVolume_ " .. musicvolume)
     end
 end
@@ -69,15 +90,20 @@
 
 function P.AudioMusicScrollbar_ended(e)
-    window = tolua.cast(winMgr:getWindow("orxonox/MusicScrollbar"),"CEGUI::Scrollbar")
-    volume = window:getScrollPosition()
-    orxonox.CommandExecutor:execute("config SoundManager ambientVolume_ " .. volume)
+    musicmutewindow:setSelected(false)
+    musicvolume = musicscrollbarwindow:getScrollPosition()
+    orxonox.CommandExecutor:execute("config SoundManager ambientVolume_ " .. musicvolume)
     musicscrollbar_active = false
 end
 
 function P.AudioEffectsScrollbar_changed(e)
+    if effectsmute then
+        block = true
+        effectsmutewindow:setSelected(false)
+        block = false
+        effectsmute = false
+    end
     if effectsscrollbar_active == false then
-        window = tolua.cast(winMgr:getWindow("orxonox/EffectsScrollbar"),"CEGUI::Scrollbar")
-        volume = window:getScrollPosition()
-        orxonox.CommandExecutor:execute("config SoundManager effectsVolume_ " .. volume)
+        effectsvolume = effectsscrollbarwindow:getScrollPosition()
+        orxonox.CommandExecutor:execute("config SoundManager effectsVolume_ " .. effectsvolume)
     end
 end
@@ -88,37 +114,61 @@
 
 function P.AudioEffectsScrollbar_ended(e)
-    window = tolua.cast(winMgr:getWindow("orxonox/EffectsScrollbar"),"CEGUI::Scrollbar")
-    volume = window:getScrollPosition()
-    orxonox.CommandExecutor:execute("config SoundManager effectsVolume_ " .. volume)
+    effectsmutewindow:setSelected(false)
+    effectsvolume = effectsscrollbarwindow:getScrollPosition()
+    orxonox.CommandExecutor:execute("config SoundManager effectsVolume_ " .. effectsvolume)
     effectsscrollbar_active = false
 end
 
 function P.AudioMuteMasterCheckbox_clicked(e)
---    if
---        mastervolume = soundMgr:getVolume(orxonox.SoundType.none)
---        window = tolua.cast(winMgr:getWindow("orxonox/MasterScrollbar"),"CEGUI::Scrollbar")
---        window:setScrollPosition(0)
---    end
-    soundMgr:toggleMute(orxonox.SoundType.none)
+    if block == false then
+        if mastermute then
+            masterscrollbarwindow:setScrollPosition(mastervolume)
+            mastermute = false
+        else
+            temp = masterscrollbarwindow:getScrollPosition()
+            masterscrollbarwindow:setScrollPosition(0)
+            mastervolume = temp
+            mastermute = true
+        end
+        soundMgr:toggleMute(orxonox.SoundType.none)
+    end
 end
 
 function P.AudioMuteMusicCheckbox_clicked(e)
-    soundMgr:toggleMute(orxonox.SoundType.ambient)
+    if block == false then
+        if musicmute then
+            musicscrollbarwindow:setScrollPosition(musicvolume)
+            musicmute = false
+        else
+            temp = musicscrollbarwindow:getScrollPosition()
+            musicscrollbarwindow:setScrollPosition(0)
+            musicvolume = temp
+            musicmute = true
+        end
+        soundMgr:toggleMute(orxonox.SoundType.ambient)
+    end
 end
 
 function P.AudioMuteEffectsCheckbox_clicked(e)
-    soundMgr:toggleMute(orxonox.SoundType.effects)
+    if block == false then
+        if effectsmute then
+            effectsscrollbarwindow:setScrollPosition(effectsvolume)
+            effectsmute = false
+        else
+            temp = effectsscrollbarwindow:getScrollPosition()
+            effectsscrollbarwindow:setScrollPosition(0)
+            effectsvolume = temp
+            effectsmute = true
+        end
+        soundMgr:toggleMute(orxonox.SoundType.effects)
+    end
 end
 
 function P.AudioThemeCombobox_changed(e)
---    local choice = winMgr:getWindow("orxonox/AudioThemeCombobox"):getFirstSelectedItem()
---    if choice == "Default" then
---        orxonox.CommandExecutor:execute("setMood default")
---        debug("default selected")
---    end
---    if choice == "Drum 'n Bass" then
---        orxonox.CommandExecutor:execute("setMood dnb")
---        debug("dnb selected")
---    end
+    if dropdownwindow:isItemSelected(1) then
+        orxonox.CommandExecutor:execute("setMood dnb")
+    else
+        orxonox.CommandExecutor:execute("setMood default")
+    end
 end
 
