Index: code/branches/menue/data/gui/scripts/MiscConfigMenu.lua
===================================================================
--- code/branches/menue/data/gui/scripts/MiscConfigMenu.lua	(revision 8945)
+++ code/branches/menue/data/gui/scripts/MiscConfigMenu.lua	(revision 8964)
@@ -11,5 +11,5 @@
 P.lineHeight = 0
 P.commandWidth = 0
-P.configWidth = 0
+P.editboxWidth = 0
 P.resetWidth = 0
 P.spaceWidth = 0
@@ -75,19 +75,24 @@
     end
 
-    P.sampleWindow:setText("configure")
-    size = getMinTextSize(P.sampleWindow)
-    P.configWidth = size[2]+20
-
     P.sampleWindow:setText("reset")
     size = getMinTextSize(P.sampleWindow)
     P.resetWidth = size[2]+20
 
-    P.spaceWidth = math.floor(1/8*P.configWidth)
+    P.spaceWidth = 10
+    
+    local pane = tolua.cast(winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane"), "CEGUI::ScrollablePane")
+    size = pane:getViewableArea()
+    P.editboxWidth = size:getWidth() - P.commandWidth - P.resetWidth - 5*P.spaceWidth
 
     P.createLines()
 
     P:setButton(1, 1, {
-            ["button"] = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigBackButton"),
-            ["callback"]  = P.MiscConfigBackButton_clicked
+            ["button"] = winMgr:getWindow("orxonox/MiscConfigMenu/CancelButton"),
+            ["callback"]  = P.MiscConfigCancelButton_clicked
+    })
+    
+    P:setButton(1, 2, {
+            ["button"] = winMgr:getWindow("orxonox/MiscConfigMenu/OKButton"),
+            ["callback"]  = P.MiscConfigOKButton_clicked
     })
 end
@@ -95,8 +100,10 @@
 function P.createLine(k)
     local offset = 0
+    -- content window for the entire line
     local line = winMgr:createWindow("DefaultWindow", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k)
     line:setHeight(CEGUI.UDim(0, P.lineHeight))
     line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, P.lineHeight*(k-1))))
 
+    -- config name
     local command = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Command")
     command:setText(P.nameList[k])
@@ -106,29 +113,22 @@
     offset = offset + P.commandWidth + P.spaceWidth
 
+    -- config value (editable)
     local configvalue = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Configvalue")
     configvalue:setProperty("ReadOnly", "set:False")
     local value = orxonox.CommandExecutor:query("getConfig " .. P.commandList[k])
     configvalue:setText(value)
-    P.sampleWindow:setText(value)
-    local size = getMinTextSize(P.sampleWindow)
-    local configvalueWidth = 2*size[2]
-    configvalue:setSize(CEGUI.UVector2(CEGUI.UDim(0, configvalueWidth), CEGUI.UDim(0.9, 0)))
+    configvalue:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.editboxWidth), CEGUI.UDim(0.9, 0)))
     configvalue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0)))
+    -- enable the reset button if the value changed
+    orxonox.GUIManager:subscribeEventHelper(configvalue, "TextAccepted", P.name .. ".MiscConfigEditbox_textAccepted")
     line:addChildWindow(configvalue)
-    offset = offset + configvalueWidth + P.spaceWidth
+    offset = offset + P.editboxWidth + P.spaceWidth
 
-    local config = winMgr:createWindow("MenuWidgets/Button", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Config")
-    config:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.configWidth), CEGUI.UDim(0.9, 0)))
-    config:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0)))
-    config:setText("configure")
-    orxonox.GUIManager:subscribeEventHelper(config, "Clicked", P.name .. ".MiscConfigConfigure_clicked")
-    line:addChildWindow(config)
-    offset = offset + P.configWidth + P.spaceWidth
-
+    -- reset button (only available when value changed)
     local reset = winMgr:createWindow("MenuWidgets/Button", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Reset")
     reset:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.resetWidth), CEGUI.UDim(0.9, 0)))
     reset:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0)))
     reset:setText("reset")
-    orxonox.GUIManager:subscribeEventHelper(reset, "Clicked", P.name .. ".MiscConfigReset_clicked")
+    orxonox.GUIManager:subscribeEventHelper(reset, "Clicked", P.name .. ".MiscConfigResetButton_clicked")
     line:addChildWindow(reset)
     reset:setEnabled(false)
@@ -153,5 +153,21 @@
 end
 
-function P.MiscConfigReset_clicked(e)
+function P.MiscConfigOKButton_clicked(e)
+    for k,v in pairs(P.commandList) do
+        -- save the changes
+        local editbox = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Configvalue")
+        orxonox.CommandExecutor:execute("config " .. P.commandList[k] .. " " .. editbox:getText())
+        local resetButton = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Reset")
+        resetButton:setEnabled(false)
+    end
+    
+    hideMenuSheet("MiscConfigMenu")
+end
+
+function P.MiscConfigCancelButton_clicked(e)
+    hideMenuSheet("MiscConfigMenu")
+end
+
+function P.MiscConfigEditbox_textAccepted(e)
     local we = CEGUI.toWindowEventArgs(e)
     local name = we.window:getName()
@@ -160,8 +176,9 @@
     local commandNr = tonumber(match())
 
-    -- TODO: Implement reset.
+    local resetButton = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. commandNr .. "/Reset")
+    resetButton:setEnabled(true)
 end
 
-function P.MiscConfigConfigure_clicked(e)
+function P.MiscConfigResetButton_clicked(e)
     local we = CEGUI.toWindowEventArgs(e)
     local name = we.window:getName()
@@ -170,13 +187,10 @@
     local commandNr = tonumber(match())
 
-    local window = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. commandNr .. "/Configvalue")
-
-    orxonox.CommandExecutor:execute("config " .. P.commandList[commandNr] .. " " .. window:getText())
+    -- reload the old value
+    local editbox = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. commandNr .. "/Configvalue")
     local value = orxonox.CommandExecutor:query("getConfig " .. P.commandList[commandNr])
-    window:setText(value)
-end
-
-function P.MiscConfigBackButton_clicked(e)
-    hideMenuSheet("MiscConfigMenu")
+    editbox:setText(value)
+    
+    we.window:setEnabled(false)
 end
 
Index: code/branches/menue/data/gui/scripts/SingleplayerConfigMenu.lua
===================================================================
--- code/branches/menue/data/gui/scripts/SingleplayerConfigMenu.lua	(revision 8945)
+++ code/branches/menue/data/gui/scripts/SingleplayerConfigMenu.lua	(revision 8964)
@@ -28,8 +28,4 @@
             ["callback"]  = P.SingleplayerConfigOKButton_clicked
     })
-end
-
-function P.onHide()
-    
 end
 
@@ -101,11 +97,14 @@
 function P.createLine(k)
     local offset = 0
+    -- destroy config line, if it already exists (otherwise would cause an error)
     if winMgr:isWindowPresent("orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k) then
         winMgr:destroyWindow("orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k)
     end
+    -- content window for the entire line
     local line = winMgr:createWindow("DefaultWindow", "orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k)
     line:setHeight(CEGUI.UDim(0, P.lineHeight))
     line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, P.lineHeight*(k-1))))
 
+    -- config name
     local command = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Command")
     command:setText(P.nameList[k])
@@ -115,4 +114,5 @@
     offset = offset + P.commandWidth + P.spaceWidth
 
+    -- config value (editable)
     local configvalue = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Configvalue")
     configvalue:setProperty("ReadOnly", "set:False")
@@ -121,8 +121,10 @@
     configvalue:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.editboxWidth), CEGUI.UDim(0.9, 0)))
     configvalue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0)))
+    -- enable the reset button if the value changed
     orxonox.GUIManager:subscribeEventHelper(configvalue, "TextAccepted", P.name .. ".SingleplayerConfigEditbox_textAccepted")
     line:addChildWindow(configvalue)
     offset = offset + P.editboxWidth + P.spaceWidth
 
+    -- reset button (only available when value changed)
     local reset = winMgr:createWindow("MenuWidgets/Button", "orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Reset")
     reset:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.resetWidth), CEGUI.UDim(0.9, 0)))
@@ -154,4 +156,5 @@
 function P.SingleplayerConfigOKButton_clicked(e)
     for k,v in pairs(P.commandList) do
+        -- save the changes
         local editbox = winMgr:getWindow("orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Configvalue")
         orxonox.CommandExecutor:execute("config " .. P.commandList[k] .. " " .. editbox:getText())
@@ -185,4 +188,5 @@
     local commandNr = tonumber(match())
 
+    -- reload the old value
     local editbox = winMgr:getWindow("orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. commandNr .. "/Configvalue")
     local value = orxonox.CommandExecutor:query("getConfig " .. P.commandList[commandNr])
Index: code/branches/menue/data/gui/scripts/SingleplayerMenu.lua
===================================================================
--- code/branches/menue/data/gui/scripts/SingleplayerMenu.lua	(revision 8945)
+++ code/branches/menue/data/gui/scripts/SingleplayerMenu.lua	(revision 8964)
@@ -19,5 +19,6 @@
     P.createFilterTab("Show All", nil)
     
-    SingleplayerSelectionChanged()
+    -- update description and screenshot boxes
+    P.SingleplayerSelectionChanged()
     
     --buttons are arranged in a 1x3 matrix
@@ -47,4 +48,5 @@
         if level ~= nil then
             local levelXMLFilename = level:getXMLFilename()
+            -- create an imageset for each screenshot
             local imageName = level:getScreenshot()
             if imageName ~= "" then
@@ -89,7 +91,8 @@
     end
     table.insert(P.activeTabIndexes, tabIndexes)
-    listbox:subscribeEvent("ItemSelectionChanged", "SingleplayerSelectionChanged")
+    -- listen to selection changes
+    orxonox.GUIManager:subscribeEventHelper(listbox, "ItemSelectionChanged", P.name..".SingleplayerSelectionChanged")
     local tabControl = winMgr:getWindow("orxonox/SingleplayerTabControl")
-    tabControl:subscribeEvent("TabSelectionChanged", "SingleplayerSelectionChanged")
+    orxonox.GUIManager:subscribeEventHelper(tabControl, "TabSelectionChanged", P.name..".SingleplayerSelectionChanged")
     if listbox:getItemCount() > 0 then
         tabControl:addChildWindow(tabName)
@@ -103,4 +106,5 @@
     local choice = listbox:getFirstSelectedItem()
     if choice ~= nil then
+        -- get the right tab and the right index
         local tabIndexes = P.activeTabIndexes[tabControl:getSelectedTabIndex()+1]
         local index = tabIndexes[listbox:getItemIndex(choice)+1]
@@ -111,5 +115,5 @@
 end
 
-function SingleplayerSelectionChanged(e)
+function P.SingleplayerSelectionChanged(e)
     local levelImage = winMgr:getWindow("orxonox/SingleplayerLevelImage")
     local levelDescription = winMgr:getWindow("orxonox/SingleplayerLevelDescription")
@@ -119,6 +123,8 @@
         local levelXMLFilename = level:getXMLFilename()
         local imageName = level:getScreenshot()
+        -- set the screenshot and the description for the selected level
         levelImage:setProperty("Image", "set:"..levelXMLFilename..imageName.." image:full_image")
         levelDescription:setText(level:getDescription())
+        -- only enable config button for "gametype" levels
         if level:hasTag("gametype") then
             configButton:setProperty("Disabled", "False")
@@ -127,4 +133,5 @@
         end
     else
+        -- also take care of "no level selected"
         levelImage:setProperty("Image", nil)
         levelDescription:setText("")
@@ -144,6 +151,6 @@
     local level = P.SingleplayerGetSelectedLevel()
     if level ~= nil then
-        local X = showMenuSheet("SingleplayerConfigMenu")
-        X:loadConfig(level)
+        local configMenu = showMenuSheet("SingleplayerConfigMenu")
+        configMenu:loadConfig(level)
     end
 end
