Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 15, 2011, 9:47:11 PM (13 years ago)
Author:
landauf
Message:

merged usability branch back to trunk

incomplete summary of the changes in this branch:

  • enhanced keyboard navigation in GUIs
  • implemented new graphics menu and changeable window size at runtime
  • added developer mode
  • HUD shows if game is paused, game pauses if ingame menu is opened
  • removed a few obsolete commands and hid some that are more for internal use
  • numpad works in console and gui
  • faster loading of level info
  • enhanced usage of compositors (Shader class)
  • improved camera handling, configurable FOV and aspect ratio
Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

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

    r7913 r8079  
    5454    return height
    5555end
    56 
    57 --function to iterate through a menu sheet by using arrowkeys
    58 
    59 --@arguments:
    60 --  list: 2-dimensional table, arguments are items that contain a button and its function
    61 --        !!note: each button can only be in the list once!!
    62 --  code: code of any key on the keyboard
    63 --  P: menusheet
    64 --  n: number of rows of the buttontable
    65 --  m: number of colums of the buttontable
    66 
    67 function buttonIteratorHelper(list, code, P, n, m)
    68 
    69     --after a key (down,up,left,right) is pressed the index of the current button has to be updated   
    70 
    71     --key down
    72     if code == "208" then
    73         if P.index < 0 then     -- initial status
    74             P.index = 0
    75             P.oldindex = -1
    76         else
    77             P.oldindex = P.index
    78             P.index = (P.index + m) % (m*n)     --modulo operation works as a "wrap around" in the button menu
    79                                                
    80             while list[P.index+1] == nil do     
    81                 P.oldindex = P.index
    82                 P.index = (P.index + m) % (m*n)
    83             end
    84         end
    85 
    86     --key up
    87     elseif code == "200" then
    88         if P.index < 0 then
    89             P.index = 0
    90             P.oldindex = -1
    91         elseif(P.index == 0) then
    92             P.oldindex = P.index
    93             P.index = m*n-m
    94 
    95             while list[P.index+1] == nil do
    96                 P.oldindex = P.index
    97                 P.index = (P.index-m)%(m*n)
    98             end
    99         else
    100             P.oldindex = P.index
    101             P.index = (P.index -m) % (m*n)
    102 
    103             while list[P.index+1] == nil do
    104                 P.oldindex = P.index
    105                 P.index = (P.index-m)%(m*n)
    106             end
    107         end
    108 
    109     --key right
    110     elseif code == "205" then
    111         if P.index < 0 then
    112             P.index = 0
    113             P.oldindex = -1
    114         elseif (P.index+1) % m == 0 then     -- we are at the right-end of a row
    115             P.oldindex = P.index
    116             P.index = P.index + 1 -m
    117 
    118             while list[P.index+1] == nil do
    119                 P.oldindex = P.index
    120                 P.index = P.index + 1
    121             end
    122         else
    123             P.oldindex = P.index
    124             P.index = P.index + 1
    125 
    126             while list[P.index+1] == nil do
    127                 if (P.index+1) % m == 0 then     -- we are at the right-end of a row
    128                     P.oldindex = P.index
    129                     P.index = P.index + 1-m
    130 
    131                 else   
    132                     P.oldindex = P.index
    133                     P.index = P.index + 1
    134                 end
    135             end
    136         end   
    137 
    138     --key left
    139     elseif code == "203" then
    140         if P.index < 0 then
    141             P.index = 0
    142             P.oldindex = -1
    143         elseif P.index % m == 0 then         -- we are at the left-end of a row
    144             P.oldindex = P.index
    145             P.index = P.index +m-1
    146 
    147             while list[P.index+1] == nil do
    148                 P.oldindex = P.index
    149                 P.index = P.index -1
    150             end
    151         else
    152             P.oldindex = P.index
    153             P.index = P.index -1
    154 
    155             while list[P.index+1] == nil do
    156                 if P.index % m == 0 then     -- we are at the left-end of a row
    157                     P.oldindex = P.index
    158                     P.index = P.index -1 + m
    159                 else               
    160                     P.oldindex = P.index
    161                     P.index = P.index -1
    162                 end
    163             end   
    164         end
    165     end
    166        
    167     --to update the new current button
    168     if (code == "208" or code == "200" or code == "203" or code == "205") and P.oldindex~= P.index then
    169 
    170         local system = CEGUI.System:getSingleton()
    171         local window = winMgr:getWindow("orxonox/MainMenuBackground")
    172 
    173         local item = list[P.index+1]
    174         local child = item["button"]
    175         local s = child:getProperty("NormalImageRightEdge")
    176 
    177         --teste ob der Button nicht schon gehighlightet ist
    178         if string.sub(s,string.len(s)-8,string.len(s)) == "Highlight" then
    179             --nop
    180         else
    181             child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-7) .. "Highlight")
    182             child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-7) .. "Highlight")
    183             child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-7) .. "Highlight")
    184             if P.oldindex >= 0 then
    185                 if list[P.oldindex+1] ~= nil then
    186                     local item = list[P.oldindex+1]
    187                     local oldChild = item["button"]
    188                     oldChild:setProperty("NormalImageRightEdge", string.sub(oldChild:getProperty("NormalImageRightEdge"),1,-10) .. "Normal")
    189                     oldChild:setProperty("NormalImageLeftEdge", string.sub(oldChild:getProperty("NormalImageLeftEdge"),1,-10) .. "Normal")
    190                     oldChild:setProperty("NormalImageBackground", string.sub(oldChild:getProperty("NormalImageBackground"),1,-10) .. "Normal")
    191                 end
    192             end
    193         end
    194 
    195         --for every highlighted button check if index is on its position. If not, set imageproperty on "normal"
    196         local i = 1
    197         while i < (n*m) do
    198             if i == P.index +1 then
    199                 i = i+1
    200             else
    201                 if list[i] ~= nil then
    202                 local item = list[i]
    203                 local child = item["button"]
    204                 local s = child:getProperty("NormalImageRightEdge")
    205                     if string.sub(s,string.len(s)-8,string.len(s)) == "Highlight" then
    206                         child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-10) .. "Normal")
    207                         child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-10) .. "Normal")
    208                         child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-10) .. "Normal")
    209                     end
    210                 end
    211             end
    212                 i=i+1
    213         end
    214     end 
    215 
    216     --enter
    217     if code == "28" and P.index >= 0 then
    218         local item = list[P.index+1]
    219         local child = item["button"]
    220         child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-10) .. "Normal")
    221         child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-10) .. "Normal")
    222         child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-10) .. "Normal")
    223 
    224         local foo = item["function"]
    225         foo()
    226     end
    227 
    228 end
    229 
    230 --write index and oldindex on the console
    231 --works like buttonIteratorHelper
    232 function indexTester(list,code,P,n,m)
    233     --key down
    234     if code == "208" then
    235         if P.index < 0 then     -- initial status
    236             P.index = 0
    237             P.oldindex = -1
    238         else
    239             P.oldindex = P.index
    240             P.index = (P.index + m) % (m*n)
    241 
    242             while list[P.index+1] == nil do
    243                 P.oldindex = P.index
    244                 P.index = (P.index + m) % (m*n)
    245             end
    246         end
    247 
    248     --key up
    249     elseif code == "200" then
    250         if P.index < 0 then
    251             P.index = 0
    252             P.oldindex = -1
    253         elseif(P.index == 0) then
    254             P.oldindex = P.index
    255             P.index = m*n-m
    256 
    257             while list[P.index+1] == nil do
    258                 P.oldindex = P.index
    259                 P.index = (P.index-m)%(m*n)
    260             end
    261         else
    262             P.oldindex = P.index
    263             P.index = (P.index -m) % (m*n)
    264 
    265             while list[P.index+1] == nil do
    266                 P.oldindex = P.index
    267                 P.index = P.index -m
    268             end
    269         end
    270 
    271     --key right
    272     elseif code == "205" then
    273         if P.index < 0 then
    274             P.index = 0
    275             P.oldindex = -1
    276         elseif (P.index+1) % m == 0 then     -- we are at the right-end of a row
    277             P.oldindex = P.index
    278             P.index = P.index + 1 -m
    279 
    280             while list[P.index+1] == nil do
    281                 P.oldindex = P.index
    282                 P.index = P.index + 1
    283             end
    284         else
    285             P.oldindex = P.index
    286             P.index = P.index + 1
    287 
    288             while list[P.index+1] == nil do
    289                 if (P.index+1) % m == 0 then     -- we are at the right-end of a row
    290                     P.oldindex = P.index
    291                     P.index = P.index + 1-m
    292 
    293                 else   
    294                     P.oldindex = P.index
    295                     P.index = P.index + 1
    296                 end
    297             end
    298         end   
    299 
    300     --key left
    301     elseif code == "203" then
    302         if P.index < 0 then
    303             P.index = 0
    304             P.oldindex = -1
    305         elseif P.index % m == 0 then         -- we are at the left-end of a row
    306             P.oldindex = P.index
    307             P.index = P.index +m-1
    308 
    309             while list[P.index+1] == nil do
    310                 P.oldindex = P.index
    311                 P.index = P.index -1
    312             end
    313         else
    314             P.oldindex = P.index
    315             P.index = P.index -1
    316 
    317             while list[P.index+1] == nil do
    318                 if P.index % m == 0 then     -- we are at the left-end of a row
    319                     P.oldindex = P.index
    320                     P.index = P.index -1 + m
    321                 else               
    322                     P.oldindex = P.index
    323                     P.index = P.index -1
    324                 end
    325             end   
    326         end
    327     end   
    328 
    329     cout(0, P.oldindex)
    330     cout(0, P.index)
    331 
    332 end
    333 
    334 
    335 
    336 
Note: See TracChangeset for help on using the changeset viewer.