Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 15, 2012, 11:51:58 PM (12 years ago)
Author:
jo
Message:

Merging presentation2011 branch to trunk. Please check for possible bugs.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/data/gui/scripts/MiscConfigMenu.lua

    r8729 r9016  
    1111P.lineHeight = 0
    1212P.commandWidth = 0
    13 P.configWidth = 0
     13P.editboxWidth = 0
    1414P.resetWidth = 0
    1515P.spaceWidth = 0
     
    3636    table.insert(P.commandList, "ChatOverlay displayTime_")
    3737    table.insert(P.commandList, "Core bDevMode_")
     38    table.insert(P.commandList, "HUDNavigation MarkerLimit_")
     39    table.insert(P.commandList, "HUDNavigation showDistance")
    3840
    3941    P.nameList = {}
     
    5658    table.insert(P.nameList, "Chat: display time")
    5759    table.insert(P.nameList, "Developer's Mode")
     60    table.insert(P.nameList, "Marker Limit")
     61    table.insert(P.nameList, "Show Distance next to cursor")
    5862
    5963    P.linesList = {}
     
    7579    end
    7680
    77     P.sampleWindow:setText("configure")
    78     size = getMinTextSize(P.sampleWindow)
    79     P.configWidth = size[2]+20
    80 
    8181    P.sampleWindow:setText("reset")
    8282    size = getMinTextSize(P.sampleWindow)
    8383    P.resetWidth = size[2]+20
    8484
    85     P.spaceWidth = math.floor(1/8*P.configWidth)
     85    P.spaceWidth = 10
     86   
     87    local pane = tolua.cast(winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane"), "CEGUI::ScrollablePane")
     88    size = pane:getViewableArea()
     89    P.editboxWidth = size:getWidth() - P.commandWidth - P.resetWidth - 5*P.spaceWidth
    8690
    8791    P.createLines()
    8892
    8993    P:setButton(1, 1, {
    90             ["button"] = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigBackButton"),
    91             ["callback"]  = P.MiscConfigBackButton_clicked
     94            ["button"] = winMgr:getWindow("orxonox/MiscConfigMenu/CancelButton"),
     95            ["callback"]  = P.MiscConfigCancelButton_clicked
     96    })
     97   
     98    P:setButton(1, 2, {
     99            ["button"] = winMgr:getWindow("orxonox/MiscConfigMenu/OKButton"),
     100            ["callback"]  = P.MiscConfigOKButton_clicked
    92101    })
    93102end
     
    95104function P.createLine(k)
    96105    local offset = 0
     106    -- content window for the entire line
    97107    local line = winMgr:createWindow("DefaultWindow", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k)
    98108    line:setHeight(CEGUI.UDim(0, P.lineHeight))
    99109    line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, P.lineHeight*(k-1))))
    100110
     111    -- config name
    101112    local command = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Command")
    102113    command:setText(P.nameList[k])
     
    106117    offset = offset + P.commandWidth + P.spaceWidth
    107118
     119    -- config value (editable)
    108120    local configvalue = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Configvalue")
    109121    configvalue:setProperty("ReadOnly", "set:False")
    110122    local value = orxonox.CommandExecutor:query("getConfig " .. P.commandList[k])
    111123    configvalue:setText(value)
    112     P.sampleWindow:setText(value)
    113     local size = getMinTextSize(P.sampleWindow)
    114     local configvalueWidth = 2*size[2]
    115     configvalue:setSize(CEGUI.UVector2(CEGUI.UDim(0, configvalueWidth), CEGUI.UDim(0.9, 0)))
     124    configvalue:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.editboxWidth), CEGUI.UDim(0.9, 0)))
    116125    configvalue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0)))
     126    -- enable the reset button if the value changed
     127    orxonox.GUIManager:subscribeEventHelper(configvalue, "TextAccepted", P.name .. ".MiscConfigEditbox_textAccepted")
    117128    line:addChildWindow(configvalue)
    118     offset = offset + configvalueWidth + P.spaceWidth
    119 
    120     local config = winMgr:createWindow("MenuWidgets/Button", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Config")
    121     config:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.configWidth), CEGUI.UDim(0.9, 0)))
    122     config:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0)))
    123     config:setText("configure")
    124     orxonox.GUIManager:subscribeEventHelper(config, "Clicked", P.name .. ".MiscConfigConfigure_clicked")
    125     line:addChildWindow(config)
    126     offset = offset + P.configWidth + P.spaceWidth
    127 
     129    offset = offset + P.editboxWidth + P.spaceWidth
     130
     131    -- reset button (only available when value changed)
    128132    local reset = winMgr:createWindow("MenuWidgets/Button", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Reset")
    129133    reset:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.resetWidth), CEGUI.UDim(0.9, 0)))
    130134    reset:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0)))
    131135    reset:setText("reset")
    132     orxonox.GUIManager:subscribeEventHelper(reset, "Clicked", P.name .. ".MiscConfigReset_clicked")
     136    orxonox.GUIManager:subscribeEventHelper(reset, "Clicked", P.name .. ".MiscConfigResetButton_clicked")
    133137    line:addChildWindow(reset)
    134138    reset:setEnabled(false)
     
    153157end
    154158
    155 function P.MiscConfigReset_clicked(e)
     159function P.MiscConfigOKButton_clicked(e)
     160    for k,v in pairs(P.commandList) do
     161        -- save the changes
     162        local editbox = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Configvalue")
     163        orxonox.CommandExecutor:execute("config " .. P.commandList[k] .. " " .. editbox:getText())
     164        local resetButton = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Reset")
     165        resetButton:setEnabled(false)
     166    end
     167   
     168    hideMenuSheet("MiscConfigMenu")
     169end
     170
     171function P.MiscConfigCancelButton_clicked(e)
     172    hideMenuSheet("MiscConfigMenu")
     173end
     174
     175function P.MiscConfigEditbox_textAccepted(e)
    156176    local we = CEGUI.toWindowEventArgs(e)
    157177    local name = we.window:getName()
     
    160180    local commandNr = tonumber(match())
    161181
    162     -- TODO: Implement reset.
    163 end
    164 
    165 function P.MiscConfigConfigure_clicked(e)
     182    local resetButton = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. commandNr .. "/Reset")
     183    resetButton:setEnabled(true)
     184end
     185
     186function P.MiscConfigResetButton_clicked(e)
    166187    local we = CEGUI.toWindowEventArgs(e)
    167188    local name = we.window:getName()
     
    170191    local commandNr = tonumber(match())
    171192
    172     local window = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. commandNr .. "/Configvalue")
    173 
    174     orxonox.CommandExecutor:execute("config " .. P.commandList[commandNr] .. " " .. window:getText())
     193    -- reload the old value
     194    local editbox = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. commandNr .. "/Configvalue")
    175195    local value = orxonox.CommandExecutor:query("getConfig " .. P.commandList[commandNr])
    176     window:setText(value)
    177 end
    178 
    179 function P.MiscConfigBackButton_clicked(e)
    180     hideMenuSheet("MiscConfigMenu")
     196    editbox:setText(value)
     197   
     198    we.window:setEnabled(false)
    181199end
    182200
Note: See TracChangeset for help on using the changeset viewer.