Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8964 for code/branches


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.

Location:
code/branches/menue/data/gui
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/menue/data/gui/layouts/MiscConfigMenu.layout

    r7888 r8964  
    22
    33<GUILayout >
    4     <Window Type="DefaultWindow" Name="orxonox/MiscConfigMenu/Background" >
     4    <Window Type="MenuWidgets/StaticImage" Name="orxonox/MiscConfigMenu/Background" >
     5        <Property Name="FrameEnabled" Value="False" />
    56        <Property Name="InheritsAlpha" Value="False" />
    67        <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    78        <Property Name="UnifiedAreaRect" Value="{{0,0},{0,0},{1,0},{1,0}}" />
     9        <Property Name="BackgroundEnabled" Value="False" />
    810        <Window Type="MenuWidgets/StaticText" Name="orxonox/MicsConfigMenu/ConfigWindow" >
    911            <Property Name="Text" Value="Miscellaneous" />
     
    3436            </Window>
    3537        </Window>
    36         <Window Type="MenuWidgets/Button" Name="orxonox/MiscConfigMenu/MiscConfigBackButton" >
    37             <Property Name="Text" Value="Back" />
     38        <Window Type="MenuWidgets/Button" Name="orxonox/MiscConfigMenu/CancelButton" >
     39            <Property Name="Text" Value="Cancel" />
    3840            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
    39             <Property Name="UnifiedAreaRect" Value="{{0.4,0},{0.6625,0},{0.6,0},{0.7125,0}}" />
    40             <Event Name="Clicked" Function="MiscConfigMenu.MiscConfigBackButton_clicked"/>
     41            <Property Name="UnifiedAreaRect" Value="{{0.25,0},{0.725,0},{0.4,0},{0.775,0}}" />
     42            <Event Name="Clicked" Function="MiscConfigMenu.MiscConfigCancelButton_clicked"/>
     43        </Window>
     44        <Window Type="MenuWidgets/Button" Name="orxonox/MiscConfigMenu/OKButton" >
     45            <Property Name="Text" Value="OK" />
     46            <Property Name="UnifiedMaxSize" Value="{{1,0},{1,0}}" />
     47            <Property Name="UnifiedAreaRect" Value="{{0.6,0},{0.725,0},{0.75,0},{0.775,0}}" />
     48            <Event Name="Clicked" Function="MiscConfigMenu.MiscConfigOKButton_clicked"/>
    4149        </Window>
    4250    </Window>
  • code/branches/menue/data/gui/scripts/MiscConfigMenu.lua

    r8729 r8964  
    1111P.lineHeight = 0
    1212P.commandWidth = 0
    13 P.configWidth = 0
     13P.editboxWidth = 0
    1414P.resetWidth = 0
    1515P.spaceWidth = 0
     
    7575    end
    7676
    77     P.sampleWindow:setText("configure")
    78     size = getMinTextSize(P.sampleWindow)
    79     P.configWidth = size[2]+20
    80 
    8177    P.sampleWindow:setText("reset")
    8278    size = getMinTextSize(P.sampleWindow)
    8379    P.resetWidth = size[2]+20
    8480
    85     P.spaceWidth = math.floor(1/8*P.configWidth)
     81    P.spaceWidth = 10
     82   
     83    local pane = tolua.cast(winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane"), "CEGUI::ScrollablePane")
     84    size = pane:getViewableArea()
     85    P.editboxWidth = size:getWidth() - P.commandWidth - P.resetWidth - 5*P.spaceWidth
    8686
    8787    P.createLines()
    8888
    8989    P:setButton(1, 1, {
    90             ["button"] = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigBackButton"),
    91             ["callback"]  = P.MiscConfigBackButton_clicked
     90            ["button"] = winMgr:getWindow("orxonox/MiscConfigMenu/CancelButton"),
     91            ["callback"]  = P.MiscConfigCancelButton_clicked
     92    })
     93   
     94    P:setButton(1, 2, {
     95            ["button"] = winMgr:getWindow("orxonox/MiscConfigMenu/OKButton"),
     96            ["callback"]  = P.MiscConfigOKButton_clicked
    9297    })
    9398end
     
    95100function P.createLine(k)
    96101    local offset = 0
     102    -- content window for the entire line
    97103    local line = winMgr:createWindow("DefaultWindow", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k)
    98104    line:setHeight(CEGUI.UDim(0, P.lineHeight))
    99105    line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, P.lineHeight*(k-1))))
    100106
     107    -- config name
    101108    local command = winMgr:createWindow("MenuWidgets/StaticText", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Command")
    102109    command:setText(P.nameList[k])
     
    106113    offset = offset + P.commandWidth + P.spaceWidth
    107114
     115    -- config value (editable)
    108116    local configvalue = winMgr:createWindow("MenuWidgets/Editbox", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Configvalue")
    109117    configvalue:setProperty("ReadOnly", "set:False")
    110118    local value = orxonox.CommandExecutor:query("getConfig " .. P.commandList[k])
    111119    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)))
     120    configvalue:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.editboxWidth), CEGUI.UDim(0.9, 0)))
    116121    configvalue:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0)))
     122    -- enable the reset button if the value changed
     123    orxonox.GUIManager:subscribeEventHelper(configvalue, "TextAccepted", P.name .. ".MiscConfigEditbox_textAccepted")
    117124    line:addChildWindow(configvalue)
    118     offset = offset + configvalueWidth + P.spaceWidth
     125    offset = offset + P.editboxWidth + P.spaceWidth
    119126
    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 
     127    -- reset button (only available when value changed)
    128128    local reset = winMgr:createWindow("MenuWidgets/Button", "orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Reset")
    129129    reset:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.resetWidth), CEGUI.UDim(0.9, 0)))
    130130    reset:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0)))
    131131    reset:setText("reset")
    132     orxonox.GUIManager:subscribeEventHelper(reset, "Clicked", P.name .. ".MiscConfigReset_clicked")
     132    orxonox.GUIManager:subscribeEventHelper(reset, "Clicked", P.name .. ".MiscConfigResetButton_clicked")
    133133    line:addChildWindow(reset)
    134134    reset:setEnabled(false)
     
    153153end
    154154
    155 function P.MiscConfigReset_clicked(e)
     155function P.MiscConfigOKButton_clicked(e)
     156    for k,v in pairs(P.commandList) do
     157        -- save the changes
     158        local editbox = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Configvalue")
     159        orxonox.CommandExecutor:execute("config " .. P.commandList[k] .. " " .. editbox:getText())
     160        local resetButton = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. k .. "/Reset")
     161        resetButton:setEnabled(false)
     162    end
     163   
     164    hideMenuSheet("MiscConfigMenu")
     165end
     166
     167function P.MiscConfigCancelButton_clicked(e)
     168    hideMenuSheet("MiscConfigMenu")
     169end
     170
     171function P.MiscConfigEditbox_textAccepted(e)
    156172    local we = CEGUI.toWindowEventArgs(e)
    157173    local name = we.window:getName()
     
    160176    local commandNr = tonumber(match())
    161177
    162     -- TODO: Implement reset.
     178    local resetButton = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. commandNr .. "/Reset")
     179    resetButton:setEnabled(true)
    163180end
    164181
    165 function P.MiscConfigConfigure_clicked(e)
     182function P.MiscConfigResetButton_clicked(e)
    166183    local we = CEGUI.toWindowEventArgs(e)
    167184    local name = we.window:getName()
     
    170187    local commandNr = tonumber(match())
    171188
    172     local window = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. commandNr .. "/Configvalue")
    173 
    174     orxonox.CommandExecutor:execute("config " .. P.commandList[commandNr] .. " " .. window:getText())
     189    -- reload the old value
     190    local editbox = winMgr:getWindow("orxonox/MiscConfigMenu/MiscConfigPane/ConfigCommand" .. commandNr .. "/Configvalue")
    175191    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")
     192    editbox:setText(value)
     193   
     194    we.window:setEnabled(false)
    181195end
    182196
  • 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])
  • code/branches/menue/data/gui/scripts/SingleplayerMenu.lua

    r8945 r8964  
    1919    P.createFilterTab("Show All", nil)
    2020   
    21     SingleplayerSelectionChanged()
     21    -- update description and screenshot boxes
     22    P.SingleplayerSelectionChanged()
    2223   
    2324    --buttons are arranged in a 1x3 matrix
     
    4748        if level ~= nil then
    4849            local levelXMLFilename = level:getXMLFilename()
     50            -- create an imageset for each screenshot
    4951            local imageName = level:getScreenshot()
    5052            if imageName ~= "" then
     
    8991    end
    9092    table.insert(P.activeTabIndexes, tabIndexes)
    91     listbox:subscribeEvent("ItemSelectionChanged", "SingleplayerSelectionChanged")
     93    -- listen to selection changes
     94    orxonox.GUIManager:subscribeEventHelper(listbox, "ItemSelectionChanged", P.name..".SingleplayerSelectionChanged")
    9295    local tabControl = winMgr:getWindow("orxonox/SingleplayerTabControl")
    93     tabControl:subscribeEvent("TabSelectionChanged", "SingleplayerSelectionChanged")
     96    orxonox.GUIManager:subscribeEventHelper(tabControl, "TabSelectionChanged", P.name..".SingleplayerSelectionChanged")
    9497    if listbox:getItemCount() > 0 then
    9598        tabControl:addChildWindow(tabName)
     
    103106    local choice = listbox:getFirstSelectedItem()
    104107    if choice ~= nil then
     108        -- get the right tab and the right index
    105109        local tabIndexes = P.activeTabIndexes[tabControl:getSelectedTabIndex()+1]
    106110        local index = tabIndexes[listbox:getItemIndex(choice)+1]
     
    111115end
    112116
    113 function SingleplayerSelectionChanged(e)
     117function P.SingleplayerSelectionChanged(e)
    114118    local levelImage = winMgr:getWindow("orxonox/SingleplayerLevelImage")
    115119    local levelDescription = winMgr:getWindow("orxonox/SingleplayerLevelDescription")
     
    119123        local levelXMLFilename = level:getXMLFilename()
    120124        local imageName = level:getScreenshot()
     125        -- set the screenshot and the description for the selected level
    121126        levelImage:setProperty("Image", "set:"..levelXMLFilename..imageName.." image:full_image")
    122127        levelDescription:setText(level:getDescription())
     128        -- only enable config button for "gametype" levels
    123129        if level:hasTag("gametype") then
    124130            configButton:setProperty("Disabled", "False")
     
    127133        end
    128134    else
     135        -- also take care of "no level selected"
    129136        levelImage:setProperty("Image", nil)
    130137        levelDescription:setText("")
     
    144151    local level = P.SingleplayerGetSelectedLevel()
    145152    if level ~= nil then
    146         local X = showMenuSheet("SingleplayerConfigMenu")
    147         X:loadConfig(level)
     153        local configMenu = showMenuSheet("SingleplayerConfigMenu")
     154        configMenu:loadConfig(level)
    148155    end
    149156end
Note: See TracChangeset for help on using the changeset viewer.