Changeset 7687 for code/branches/menu/data/gui/scripts/GUITools.lua
- Timestamp:
- Dec 1, 2010, 2:04:54 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/menu/data/gui/scripts/GUITools.lua
r7663 r7687 55 55 end 56 56 57 --function to iterate through a menu sheet by using arrowkeys 57 58 58 59 --@arguments: 59 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!! 60 62 -- code: code of any key on the keyboard 61 63 -- P: menusheet 62 -- n: number of rows 63 -- m: number of colums 64 -- n: number of rows of the buttontable 65 -- m: number of colums of the buttontable 64 66 65 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 66 70 67 71 --key down … … 72 76 else 73 77 P.oldindex = P.index 74 P.index = (P.index + m) % (m*n) 75 76 while list[P.index+1] == nil do 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 77 81 P.oldindex = P.index 78 82 P.index = (P.index + m) % (m*n) … … 98 102 99 103 while list[P.index+1] == nil do 100 cout(0,P.index)101 104 P.oldindex = P.index 102 105 P.index = (P.index-m)%(m*n) … … 162 165 end 163 166 167 --to update the new current button 164 168 if (code == "208" or code == "200" or code == "203" or code == "205") and P.oldindex~= P.index then 165 169 … … 171 175 172 176 --teste ob der Button nicht schon gehighlightet ist 173 cout(0,child:getProperty("NormalImageRightEdge"))174 177 if child:getProperty("NormalImageRightEdge") == "set:TaharezGreenLook image:ButtonRightHighlight" then 175 178 --nop … … 189 192 end 190 193 194 --for every highlighted button check if index is on its position. If not, set imageproperty on "normal" 191 195 local i = 1 192 196 while i < (n*m) do … … 220 224 end 221 225 222 cout(0, P.oldindex) 223 cout(0, P.index) 224 225 end 226 226 end 227 228 --write index and oldindex on the console 229 --works like buttonIteratorHelper 227 230 function indexTester(list,code,P,n,m) 228 231 --key down
Note: See TracChangeset
for help on using the changeset viewer.