Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 13, 2009, 1:46:28 PM (15 years ago)
Author:
dafrick
Message:

Removed empty lines.
Adjusted size of boxes in KeyBindMenu so that the text is displayed properly.
Regarding the bug: Found the reason why this happens. The problem is, that apparently CEGUI doesn't allow for windows bigger than the displayed screen, which means, that any window that is bigger than the scrren size isn'f fully displayed. I have no idea how to circumvent this, but I'll keep looking.

Location:
code/branches/presentation2/data/gui/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/data/gui/scripts/InfoPopup.lua

    r6334 r6335  
    11-- InfoPopup.lua
    2 
    3 
    42
    53BasicGUI = require("BasicGUI")
    64local P = BasicGUI:new() --inherit everything from the gui package
    75
    8 
    96if _REQUIREDNAME == nil then
    10 
    117    InfoPopup = P
    12 
    138else
    14 
    159    _G[_REQUIREDNAME] = P
    16 
    1710end
    1811
    19 
    20 
    2112P.filename = "InfoPopup"
    22 
    2313P.layoutString = "InfoPopup.layout"
    2414
    25 
    26 
    2715function P:init()
    28 
    2916end
    3017
    31 
    32 
    3318function P.execute(functionPtr, arguments)
    34 
    3519    if functionPtr ~= nil then
    36 
    3720        if arguments ~= nil then
    38 
    3921            functionPtr(arguments)
    40 
    4122        else
    42 
    4323            functionPtr()
    44 
    4524        end
    46 
    4725    end
    48 
    4926end
    5027
    51 
    52 
    5328function P.setText( text )
    54 
    5529    winMgr:getWindow("orxonox/InfoPopup_text"):setText( text )
    56 
    5730end
    5831
    59 
    60 
    6132function P.setCloseButton(closeButton)
    62 
    6333    close = winMgr:getWindow("orxonox/InfoPopup_close")
    64 
    6534    close:setVisible(closeButton)
    66 
    6735    if(not closeButton) then
    68 
    6936        close:deactivate();
    70 
    7137    else
    72 
    7338        close:activate();
    74 
    7539    end
    76 
    7740end
    7841
    79 
    80 
    8142-- events for ingamemenu
    82 
    83 
    8443function P.close(e)
    85 
    8644    hideGUI("InfoPopup")
    87 
    8845end
    8946
    90 
    91 
    9247return P
    93 
  • code/branches/presentation2/data/gui/scripts/KeyBindMenu.lua

    r6334 r6335  
    11-- KeyBindMenu.lua
    22
    3 
    4 
    53BasicGUI = require("BasicGUI")
    6 
    74local P = BasicGUI:new() --inherit everything from the gui package
    85
    9 
    106if _REQUIREDNAME == nil then
    11 
    127    KeyBindMenu = P
    13 
    148else
    159    _G[_REQUIREDNAME] = P
    16 
    17 end
    18 
    19 
     10end
    2011
    2112P.filename = "KeyBindMenu"
    22 
    2313P.layoutString = "KeyBindMenu.layout"
    2414
    25 
    26 
    2715function P:init()
    2816
    2917    commandList = {}
    30 
    3118    table.insert(commandList, "fire 0")
    32 
    3319    table.insert(commandList, "fire 1 | unfire")
    34 
    3520    table.insert(commandList, "onpress fire 2")
    36 
    3721    table.insert(commandList, "scale 1 moveFrontBack")
    38 
    3922    table.insert(commandList, "scale -1 moveFrontBack")
    40 
    4123    table.insert(commandList, "boost")
    42 
    4324    table.insert(commandList, "scale 1 moveRightLeft")
    44 
    4525    table.insert(commandList, "scale -1 moveRightLeft")
    46 
    4726    table.insert(commandList, "scale 1 moveUpDown")
    48 
    4927    table.insert(commandList, "scale -1 moveUpDown")
    50 
    5128    table.insert(commandList, "scale 1 rotateRoll")
    52 
    5329    table.insert(commandList, "scale -1 rotateRoll")
    54 
    5530    table.insert(commandList, "switchCamera")
    56 
    5731    table.insert(commandList, "openConsole")
    58 
    5932    table.insert(commandList, "OverlayGroup toggleVisibility Debug")
    60 
    6133    table.insert(commandList, "OverlayGroup toggleVisibility Stats")
    62 
    6334    table.insert(commandList, "mouseLook")
    64 
    6535    table.insert(commandList, "pause")
    6636
    67    
    68 
    6937    nameList = {}
    70 
    7138    table.insert(nameList, "Primary Fire")
    72 
    7339    table.insert(nameList, "Secondary Fire")
    74 
    7540    table.insert(nameList, "Fire Rocket")
    76 
    7741    table.insert(nameList, "Accelerate")
    78 
    7942    table.insert(nameList, "Break")
    8043    table.insert(nameList, "Boost")
    81 
    8244    table.insert(nameList, "Move Right")
    83 
    8445    table.insert(nameList, "Move Left")
    85 
    8646    table.insert(nameList, "Move Up")
    87 
    8847    table.insert(nameList, "Move Down")
    89 
    9048    table.insert(nameList, "Roll Right")
    91 
    9249    table.insert(nameList, "Roll Left")
    93 
    9450    table.insert(nameList, "Switch Camera")
    95 
    9651    table.insert(nameList, "Open Console")
    97 
    9852    table.insert(nameList, "Show Debug")
    99 
    10053    table.insert(nameList, "Show Stats")
    101 
    10254    table.insert(nameList, "Look Around")
    103 
    10455    table.insert(nameList, "Pause")
    10556
    106    
    107 
    10857    linesList = {}
    10958
    110 
    111     lineHeight = 25
     59    lineHeight = 30
    11260    commandWidth = 125
    113     buttonWidth = 125
     61    buttonWidth = 145
    11462    clearWidth = 20
    115     addWidth = 25
    116 
     63    addWidth = 30
    11764    spaceWidth = 10
    11865
    119    
    120 
    12166    P.createLines()
    12267
    123    
    124 
    12568    local funct = luaState:createLuaFunctor("KeyBindMenu.callback()")
    126 
    12769    orxonox.KeyBinderManager:getInstance():registerKeybindCallback(funct)
    128 
    129 end
    130 
    131 
    132 
     70end
    13371
    13472function P.KeyNameNiceifier(key)
    135 
    13673    local name = string.sub(key, string.find(key, '%.(.*)')+1)
    13774    local group = string.sub(key, string.find(key, '(.*)%.'))
    138 
    13975    group = string.sub(group,1,string.len(group)-1)
    140 
    14176    if( group == "Keys") then
    142 
    14377        return "Key " .. string.sub(name, string.find(name, 'Key(.*)')+3)
    144 
    14578    elseif( group == "MouseButtons") then
    146 
    14779        return "Mouse " .. name
    148 
    149     end
    150 
     80    end
    15181    return key
    152 
    153 end
    154 
    155 
     82end
    15683
    15784function P.createLine(k)
    158 
    15985    local offset = 0
    160 
    16186    local line = winMgr:createWindow("DefaultWindow", "orxonox/KeyBindPane/Binding" .. k)
    162 
    16387    line:setHeight(CEGUI.UDim(0, lineHeight))
    164 
    16588    line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, lineHeight*(k-1))))
    16689
    167    
    168 
    16990    local command = winMgr:createWindow("TaharezLook/StaticText", "orxonox/KeyBindPane/Binding" .. k .. "/Command")
    170 
    17191    command:setSize(CEGUI.UVector2(CEGUI.UDim(0, commandWidth), CEGUI.UDim(1, 0)))
    172 
    17392    command:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0, 0)))
    174 
    17593    command:setText(nameList[k])
    17694    line:addChildWindow(command)
    177 
    17895    offset = offset + commandWidth + spaceWidth
    17996
     97    local plus = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Plus")
     98    plus:setSize(CEGUI.UVector2(CEGUI.UDim(0, addWidth), CEGUI.UDim(0.7, 0)))
     99    plus:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.15, 0)))
     100    plus:setText("add")
     101    orxonox.KeyBinderManager:getInstance():subscribeEventHelper(plus, "Clicked", P.filename .. ".KeyBindPlus_clicked")
     102    line:addChildWindow(plus)
     103    offset = offset + addWidth + spaceWidth
     104
     105    local numButtons = orxonox.KeyBinderManager:getInstance():getCurrent():getNumberOfBindings(commandList[k]);
     106    for i=0,(numButtons-1) do
     107        local button = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Button" .. i)
     108        button:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0.7, 0)))
     109        button:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.15, 0)))
     110        local name = orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(commandList[k],i)
     111        name = P.KeyNameNiceifier(name)
     112        button:setText(name)
     113        orxonox.KeyBinderManager:getInstance():subscribeEventHelper(button, "Clicked", P.filename .. ".KeyBindButton_clicked")
     114        --button:subscribeScriptedEvent("EventClicked", P.filename .. ".KeyBindButton_clicked")
     115        line:addChildWindow(button)
     116        offset = offset + buttonWidth
     117
     118        local clear = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Clear" .. i)
     119        clear:setSize(CEGUI.UVector2(CEGUI.UDim(0, clearWidth), CEGUI.UDim(0.7, 0)))
     120        clear:setPosition(CEGUI.UVector2(CEGUI.UDim(0, (i*(buttonWidth+clearWidth+spaceWidth)+buttonWidth)+commandWidth+clearWidth+2*spaceWidth), CEGUI.UDim(0.15, 0)))
     121        clear:setText("X")
     122        orxonox.KeyBinderManager:getInstance():subscribeEventHelper(clear, "Clicked", P.filename .. ".KeyBindClear_clicked")
     123        line:addChildWindow(clear)
     124        offset = offset + clearWidth + spaceWidth
     125    end
    180126   
    181 
    182     local plus = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Plus")
    183 
    184     plus:setSize(CEGUI.UVector2(CEGUI.UDim(0, addWidth), CEGUI.UDim(0.7, 0)))
    185 
    186     plus:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.15, 0)))
    187 
    188     plus:setText("add")
    189 
    190     orxonox.KeyBinderManager:getInstance():subscribeEventHelper(plus, "Clicked", P.filename .. ".KeyBindPlus_clicked")
    191 
    192     line:addChildWindow(plus)
    193 
    194     offset = offset + addWidth + spaceWidth
    195 
     127    debug(0, "OFFSET: " .. offset)
     128
     129    line:setWidth(CEGUI.UDim(0, offset+clearWidth))
    196130   
    197 
    198     local numButtons = orxonox.KeyBinderManager:getInstance():getCurrent():getNumberOfBindings(commandList[k]);
    199 
    200     for i=0,(numButtons-1) do
    201 
    202         local button = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Button" .. i)
    203 
    204         button:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0.7, 0)))
    205 
    206         button:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.15, 0)))
    207 
    208         local name = orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(commandList[k],i)
    209 
    210         name = P.KeyNameNiceifier(name)
    211 
    212         button:setText(name)
    213 
    214         orxonox.KeyBinderManager:getInstance():subscribeEventHelper(button, "Clicked", P.filename .. ".KeyBindButton_clicked")
    215 
    216         --button:subscribeScriptedEvent("EventClicked", P.filename .. ".KeyBindButton_clicked")
    217 
    218         line:addChildWindow(button)
    219 
    220         offset = offset + buttonWidth
    221 
    222        
    223 
    224         local clear = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Clear" .. i)
    225 
    226         clear:setSize(CEGUI.UVector2(CEGUI.UDim(0, clearWidth), CEGUI.UDim(0.7, 0)))
    227 
    228         clear:setPosition(CEGUI.UVector2(CEGUI.UDim(0, (i*(buttonWidth+clearWidth+spaceWidth)+buttonWidth)+commandWidth+clearWidth+2*spaceWidth), CEGUI.UDim(0.15, 0)))
    229 
    230         clear:setText("X")
    231 
    232         orxonox.KeyBinderManager:getInstance():subscribeEventHelper(clear, "Clicked", P.filename .. ".KeyBindClear_clicked")
    233 
    234         line:addChildWindow(clear)
    235 
    236         offset = offset + clearWidth + spaceWidth
    237 
    238     end
    239 
    240    
    241 
    242     line:setWidth(CEGUI.UDim(0, offset+clearWidth))
    243 
    244    
    245 
    246131    return line
    247 
    248 end
    249 
    250 
     132end
    251133
    252134function P.createLines()
    253 
    254 
    255135    local window = winMgr:getWindow("orxonox/KeyBindPane")
    256136
    257 
    258137    for k,v in pairs(commandList) do
    259 
    260138        local line = P.createLine(k)
    261 
    262139        table.insert(linesList, line)
    263 
    264140        window:addChildWindow(line)
    265 
    266     end
    267 
    268 
    269 end
    270 
    271 
     141    end
     142end
    272143
    273144function P.KeyBindButton_clicked(e)
    274 
    275145    local we = CEGUI.toWindowEventArgs(e)
    276 
    277146    local name = we.window:getName()
    278147
    279 
    280148    local match = string.gmatch(name, "%d+")
    281 
    282149    local commandNr = tonumber(match())
    283 
    284150    local buttonNr = tonumber(match())
    285151
    286    
    287 
    288152    local arguments = {}
    289 
    290153    arguments[1] = commandNr
    291 
    292154    arguments[2] = buttonNr
    293 
    294155    openInfoPopup("Press any button/key or move a mouse/joystick axis.", KeyBindMenu.keybind, false, arguments)
    295156end
    296157
    297158function P.KeyBindPlus_clicked(e)
    298 
    299159    local we = CEGUI.toWindowEventArgs(e)
    300 
    301160    local name = we.window:getName()
    302161
    303    
    304 
    305162    local match = string.gmatch(name, "%d+")
    306 
    307163    local commandNr = tonumber(match())
    308    
    309164
    310165    local arguments = {}
    311 
    312166    arguments[1] = commandNr
    313 
    314167    openInfoPopup("Press any button/key or move a mouse/joystick axis.", KeyBindMenu.keybind, false, arguments)
    315168end
    316169
    317170function P.KeyBindClear_clicked(e)
    318 
    319171    local we = CEGUI.toWindowEventArgs(e)
    320 
    321172    local name = we.window:getName()
    322173
    323    
    324 
    325174    local match = string.gmatch(name, "%d+")
    326 
    327175    local commandNr = tonumber(match())
    328 
    329176    local buttonNr = tonumber(match())
    330    
    331177 
    332178    orxonox.KeyBinderManager:getInstance():unbind(orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(commandList[commandNr], buttonNr))
    333179
    334    
    335 
    336180    P.callback()
    337 
    338 end
    339 
    340 
     181end
    341182
    342183function P.keybind(arguments)
    343 
    344184    local commandNr = arguments[1]
    345 
    346185    local buttonNr = arguments[2]
    347 
    348186    if buttonNr ~= nil then
    349 
    350187        orxonox.KeyBinderManager:getInstance():unbind(orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(commandList[commandNr], buttonNr))
    351 
    352     end
    353 
     188    end
    354189
    355190    orxonox.KeyBinderManager:getInstance():keybind(commandList[commandNr])
    356 
    357 end
    358 
    359 
     191end
    360192
    361193function P.callback()
    362 
    363194    while table.getn(linesList) ~= 0 do
    364 
    365195        if linesList[1] ~= nil then
    366 
    367196            winMgr:destroyWindow(linesList[1]:getName())
    368 
    369197        end
    370 
    371198        table.remove(linesList, 1)
    372 
    373     end
    374 
    375    
     199    end
    376200
    377201    linesList = {}
    378202
    379 
    380203    P.createLines()
    381 
    382204    if(InfoPopup ~= nil) then
    383 
    384205        InfoPopup.close()
    385 
    386     end
    387 
    388 end
    389 
    390 
     206    end
     207end
    391208
    392209function P.KeyBindBackButton_clicked(e)
    393 
    394210    hideGUI("KeyBindMenu")
    395 
    396 end
    397 
    398 
     211end
    399212
    400213return P
    401 
Note: See TracChangeset for help on using the changeset viewer.