Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 7, 2011, 3:22:46 PM (13 years ago)
Author:
baermatt
Message:

Cleaned up the miscellaneous menu and added possibility to cancel.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/menue/data/gui/scripts/SingleplayerConfigMenu.lua

    r8945 r8964  
    2828            ["callback"]  = P.SingleplayerConfigOKButton_clicked
    2929    })
    30 end
    31 
    32 function P.onHide()
    33    
    3430end
    3531
     
    10197function P.createLine(k)
    10298    local offset = 0
     99    -- destroy config line, if it already exists (otherwise would cause an error)
    103100    if winMgr:isWindowPresent("orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k) then
    104101        winMgr:destroyWindow("orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k)
    105102    end
     103    -- content window for the entire line
    106104    local line = winMgr:createWindow("DefaultWindow", "orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k)
    107105    line:setHeight(CEGUI.UDim(0, P.lineHeight))
    108106    line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, P.lineHeight*(k-1))))
    109107
     108    -- config name
    110109    local command = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Command")
    111110    command:setText(P.nameList[k])
     
    115114    offset = offset + P.commandWidth + P.spaceWidth
    116115
     116    -- config value (editable)
    117117    local configvalue = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Configvalue")
    118118    configvalue:setProperty("ReadOnly", "set:False")
     
    121121    configvalue:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.editboxWidth), CEGUI.UDim(0.9, 0)))
    122122    configvalue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0)))
     123    -- enable the reset button if the value changed
    123124    orxonox.GUIManager:subscribeEventHelper(configvalue, "TextAccepted", P.name .. ".SingleplayerConfigEditbox_textAccepted")
    124125    line:addChildWindow(configvalue)
    125126    offset = offset + P.editboxWidth + P.spaceWidth
    126127
     128    -- reset button (only available when value changed)
    127129    local reset = winMgr:createWindow("MenuWidgets/Button", "orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Reset")
    128130    reset:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.resetWidth), CEGUI.UDim(0.9, 0)))
     
    154156function P.SingleplayerConfigOKButton_clicked(e)
    155157    for k,v in pairs(P.commandList) do
     158        -- save the changes
    156159        local editbox = winMgr:getWindow("orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Configvalue")
    157160        orxonox.CommandExecutor:execute("config " .. P.commandList[k] .. " " .. editbox:getText())
     
    185188    local commandNr = tonumber(match())
    186189
     190    -- reload the old value
    187191    local editbox = winMgr:getWindow("orxonox/SingleplayerConfigMenu/MiscConfigPane/ConfigCommand" .. commandNr .. "/Configvalue")
    188192    local value = orxonox.CommandExecutor:query("getConfig " .. P.commandList[commandNr])
Note: See TracChangeset for help on using the changeset viewer.