Changeset 7663 for code/branches/menu/data/gui/scripts
- Timestamp:
- Nov 24, 2010, 3:33:26 PM (14 years ago)
- Location:
- code/branches/menu/data/gui/scripts
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/menu/data/gui/scripts/CreditsMenu.lua
r6746 r7663 2 2 3 3 local P = createMenuSheet("CreditsMenu") 4 5 P.buttonList = {} 6 7 function P.onLoad() 8 local item = { 9 ["button"] = winMgr:getWindow("orxonox/CreditsBackButton"), 10 ["function"] = P.CreditsBackButton_clicked 11 } 12 P.buttonList[1] = item 13 end 14 15 function P.onShow() 16 P.oldindex = -2 17 P.index = -1 18 end 4 19 5 20 function P.CreditsBackButton_clicked(e) … … 7 22 end 8 23 24 function P.onKeyPressed() 25 buttonIteratorHelper(P.buttonList, code, P, 1, 1) 26 end 27 9 28 return P 10 29 -
code/branches/menu/data/gui/scripts/GUITools.lua
r7163 r7663 54 54 return height 55 55 end 56 57 58 --@arguments: 59 -- list: 2-dimensional table, arguments are items that contain a button and its function 60 -- code: code of any key on the keyboard 61 -- P: menusheet 62 -- n: number of rows 63 -- m: number of colums 64 65 function buttonIteratorHelper(list, code, P, n, m) 66 67 --key down 68 if code == "208" then 69 if P.index < 0 then -- initial status 70 P.index = 0 71 P.oldindex = -1 72 else 73 P.oldindex = P.index 74 P.index = (P.index + m) % (m*n) 75 76 while list[P.index+1] == nil do 77 P.oldindex = P.index 78 P.index = (P.index + m) % (m*n) 79 end 80 end 81 82 --key up 83 elseif code == "200" then 84 if P.index < 0 then 85 P.index = 0 86 P.oldindex = -1 87 elseif(P.index == 0) then 88 P.oldindex = P.index 89 P.index = m*n-m 90 91 while list[P.index+1] == nil do 92 P.oldindex = P.index 93 P.index = (P.index-m)%(m*n) 94 end 95 else 96 P.oldindex = P.index 97 P.index = (P.index -m) % (m*n) 98 99 while list[P.index+1] == nil do 100 cout(0,P.index) 101 P.oldindex = P.index 102 P.index = (P.index-m)%(m*n) 103 end 104 end 105 106 --key right 107 elseif code == "205" then 108 if P.index < 0 then 109 P.index = 0 110 P.oldindex = -1 111 elseif (P.index+1) % m == 0 then -- we are at the right-end of a row 112 P.oldindex = P.index 113 P.index = P.index + 1 -m 114 115 while list[P.index+1] == nil do 116 P.oldindex = P.index 117 P.index = P.index + 1 118 end 119 else 120 P.oldindex = P.index 121 P.index = P.index + 1 122 123 while list[P.index+1] == nil do 124 if (P.index+1) % m == 0 then -- we are at the right-end of a row 125 P.oldindex = P.index 126 P.index = P.index + 1-m 127 128 else 129 P.oldindex = P.index 130 P.index = P.index + 1 131 end 132 end 133 end 134 135 --key left 136 elseif code == "203" then 137 if P.index < 0 then 138 P.index = 0 139 P.oldindex = -1 140 elseif P.index % m == 0 then -- we are at the left-end of a row 141 P.oldindex = P.index 142 P.index = P.index +m-1 143 144 while list[P.index+1] == nil do 145 P.oldindex = P.index 146 P.index = P.index -1 147 end 148 else 149 P.oldindex = P.index 150 P.index = P.index -1 151 152 while list[P.index+1] == nil do 153 if P.index % m == 0 then -- we are at the left-end of a row 154 P.oldindex = P.index 155 P.index = P.index -1 + m 156 else 157 P.oldindex = P.index 158 P.index = P.index -1 159 end 160 end 161 end 162 end 163 164 if (code == "208" or code == "200" or code == "203" or code == "205") and P.oldindex~= P.index then 165 166 local system = CEGUI.System:getSingleton() 167 local window = winMgr:getWindow("orxonox/MainMenuBackground") 168 169 local item = list[P.index+1] 170 local child = item["button"] 171 172 --teste ob der Button nicht schon gehighlightet ist 173 cout(0,child:getProperty("NormalImageRightEdge")) 174 if child:getProperty("NormalImageRightEdge") == "set:TaharezGreenLook image:ButtonRightHighlight" then 175 --nop 176 else 177 child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-7) .. "Highlight") 178 child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-7) .. "Highlight") 179 child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-7) .. "Highlight") 180 if P.oldindex >= 0 then 181 if list[P.oldindex+1] ~= nil then 182 local item = list[P.oldindex+1] 183 local oldChild = item["button"] 184 oldChild:setProperty("NormalImageRightEdge", string.sub(oldChild:getProperty("NormalImageRightEdge"),1,-10) .. "Normal") 185 oldChild:setProperty("NormalImageLeftEdge", string.sub(oldChild:getProperty("NormalImageLeftEdge"),1,-10) .. "Normal") 186 oldChild:setProperty("NormalImageBackground", string.sub(oldChild:getProperty("NormalImageBackground"),1,-10) .. "Normal") 187 end 188 end 189 end 190 191 local i = 1 192 while i < (n*m) do 193 if i == P.index +1 then 194 i = i+1 195 else 196 if list[i] ~= nil then 197 local item = list[i] 198 local child = item["button"] 199 if child:getProperty("NormalImageRightEdge") == "set:TaharezGreenLook image:ButtonRightHighlight" then 200 child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-10) .. "Normal") 201 child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-10) .. "Normal") 202 child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-10) .. "Normal") 203 end 204 end 205 end 206 i=i+1 207 end 208 end 209 210 --enter 211 if code == "28" then 212 local item = list[P.index+1] 213 local child = item["button"] 214 child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-10) .. "Normal") 215 child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-10) .. "Normal") 216 child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-10) .. "Normal") 217 218 local foo = item["function"] 219 foo() 220 end 221 222 cout(0, P.oldindex) 223 cout(0, P.index) 224 225 end 226 227 function indexTester(list,code,P,n,m) 228 --key down 229 if code == "208" then 230 if P.index < 0 then -- initial status 231 P.index = 0 232 P.oldindex = -1 233 else 234 P.oldindex = P.index 235 P.index = (P.index + m) % (m*n) 236 237 while list[P.index+1] == nil do 238 P.oldindex = P.index 239 P.index = (P.index + m) % (m*n) 240 end 241 end 242 243 --key up 244 elseif code == "200" then 245 if P.index < 0 then 246 P.index = 0 247 P.oldindex = -1 248 elseif(P.index == 0) then 249 P.oldindex = P.index 250 P.index = m*n-m 251 252 while list[P.index+1] == nil do 253 P.oldindex = P.index 254 P.index = (P.index-m)%(m*n) 255 end 256 else 257 P.oldindex = P.index 258 P.index = (P.index -m) % (m*n) 259 260 while list[P.index+1] == nil do 261 P.oldindex = P.index 262 P.index = P.index -m 263 end 264 end 265 266 --key right 267 elseif code == "205" then 268 if P.index < 0 then 269 P.index = 0 270 P.oldindex = -1 271 elseif (P.index+1) % m == 0 then -- we are at the right-end of a row 272 P.oldindex = P.index 273 P.index = P.index + 1 -m 274 275 while list[P.index+1] == nil do 276 P.oldindex = P.index 277 P.index = P.index + 1 278 end 279 else 280 P.oldindex = P.index 281 P.index = P.index + 1 282 283 while list[P.index+1] == nil do 284 if (P.index+1) % m == 0 then -- we are at the right-end of a row 285 P.oldindex = P.index 286 P.index = P.index + 1-m 287 288 else 289 P.oldindex = P.index 290 P.index = P.index + 1 291 end 292 end 293 end 294 295 --key left 296 elseif code == "203" then 297 if P.index < 0 then 298 P.index = 0 299 P.oldindex = -1 300 elseif P.index % m == 0 then -- we are at the left-end of a row 301 P.oldindex = P.index 302 P.index = P.index +m-1 303 304 while list[P.index+1] == nil do 305 P.oldindex = P.index 306 P.index = P.index -1 307 end 308 else 309 P.oldindex = P.index 310 P.index = P.index -1 311 312 while list[P.index+1] == nil do 313 if P.index % m == 0 then -- we are at the left-end of a row 314 P.oldindex = P.index 315 P.index = P.index -1 + m 316 else 317 P.oldindex = P.index 318 P.index = P.index -1 319 end 320 end 321 end 322 end 323 324 cout(0, P.oldindex) 325 cout(0, P.index) 326 327 end 328 329 330 331 -
code/branches/menu/data/gui/scripts/MainMenu.lua
r7608 r7663 4 4 P.loadAlong = { "SingleplayerMenu", "MultiplayerMenu", "SettingsMenu", "CreditsMenu" } 5 5 6 P.index = 0 6 P.buttonList = {} 7 8 P.testArray = {} 9 10 11 function P.onLoad() 12 local item = { 13 ["button"] = winMgr:getWindow("orxonox/QuickGameTestButton"), 14 ["function"] = P.QuickGameTestButton_clicked 15 } 16 table.insert(P.buttonList,item) 17 18 item = { 19 ["button"] = winMgr:getWindow("orxonox/SingleplayerButton"), 20 ["function"] = P.SingleplayerButton_clicked 21 } 22 table.insert(P.buttonList,item) 23 24 item = { 25 ["button"] = winMgr:getWindow("orxonox/MultiplayerButton"), 26 ["function"] = P.MultiplayerButton_clicked 27 } 28 table.insert(P.buttonList,item) 29 30 item = { 31 ["button"] = winMgr:getWindow("orxonox/SettingsButton"), 32 ["function"] = P.SettingsButton_clicked 33 } 34 table.insert(P.buttonList,item) 35 36 item = { 37 ["button"] = winMgr:getWindow("orxonox/CreditsButton"), 38 ["function"] = P.CreditsButton_clicked 39 } 40 table.insert(P.buttonList,item) 41 42 item = { 43 ["button"] = winMgr:getWindow("orxonox/ExitButton"), 44 ["function"] = P.ExitButton_clicked 45 } 46 table.insert(P.buttonList,item) 47 end 48 49 function P.onShow() 50 P.oldindex = -2 51 P.index = -1 52 end 7 53 8 54 -- events for MainMenu … … 10 56 hideAllMenuSheets() 11 57 orxonox.execute("startGame") 12 end13 14 function P.onShow()15 16 58 end 17 59 … … 36 78 end 37 79 38 function P.onKeyPressed() 39 --local we = tolua.cast(e, "CEGUI::KeyEventArgs") 40 cout(0, code) 41 if code == "15" then 42 P.index = P.index + 1 43 local window = winMgr:getWindow("orxonox/MainMenuBackground") 44 if P.index == window:getChildCount() then 45 P.index = 1 46 end 47 local child = window:getChildAtIdx(P.index-1) 48 child:setProperty("NormalImageRightEdge", string.sub(child:getProperty("NormalImageRightEdge"),1,-7) .. "Highlight") 49 child:setProperty("NormalImageLeftEdge", string.sub(child:getProperty("NormalImageLeftEdge"),1,-7) .. "Highlight") 50 child:setProperty("NormalImageBackground", string.sub(child:getProperty("NormalImageBackground"),1,-7) .. "Highlight") 51 elseif code == "28" and P.index ~= 0 then 52 if P.index == 1 then 53 P.QuickGameTestButton_clicked() 54 elseif P.index == 2 then 55 P.SingleplayerButton_clicked() 56 elseif P.index == 3 then 57 P.MultiplayerButton_clicked() 58 elseif P.index == 4 then 59 P.SettingsButton_clicked() 60 elseif P.index == 5 then 61 P.CreditsButton_clicked() 62 elseif P.index == 6 then 63 P.ExitButton_clicked() 64 end 80 81 --[[ 82 list = {} 83 local item = 84 { 85 ["button"] = buttonWindow, 86 ["function"] = buttonFunction, 87 } 88 table.insert(list, item) 89 item = list[i] 90 91 for i,item in pairs(list) do 92 button = item["button"] 93 end 94 95 --]] 96 --[[ 97 function createList() 98 list = {} 99 100 local j 101 while j < P.loadAlong 102 local item = 103 { 104 ["button"] = buttonWindow, 105 ["function"] = buttonFunction, 106 } 107 table.insert(list, item) 65 108 end 109 110 --]] 111 112 function P.onKeyPressed() 113 cout(0,code) 114 buttonIteratorHelper(P.buttonList, code, P, 6, 1) 115 --indexTester(P.buttonList,code,P,6,1) 66 116 end 67 117 68 118 return P 119 -
code/branches/menu/data/gui/scripts/MultiplayerMenu.lua
r7587 r7663 3 3 local P = createMenuSheet("MultiplayerMenu") 4 4 5 P.buttonList = {} 6 5 7 function P.onLoad() 6 P.multiplayerMode = "startClient" 8 P.multiplayerMode = "startClient" 9 10 local item = { 11 ["button"] = winMgr:getWindow("orxonox/MultiplayerJoinButton2"), 12 ["function"] = P.MultiplayerJoinButton_clicked 13 } 14 P.buttonList[1] = item 15 16 local item = { 17 ["button"] = winMgr:getWindow("orxonox/MultiplayerHostButton2"), 18 ["function"] = P.MultiplayerHostButton_clicked 19 } 20 P.buttonList[2] = item 21 22 local item = { 23 ["button"] = winMgr:getWindow("orxonox/MultiplayerBackButton"), 24 ["function"] = P.MultiplayerBackButton_clicked 25 } 26 P.buttonList[4] = item 27 7 28 end 8 29 9 30 function P.onShow() 10 31 P.showServerList() 32 P.oldindex = -2 33 P.index = -1 11 34 end 12 35 … … 109 132 end 110 133 134 function P.onKeyPressed() 135 cout(0,code) 136 buttonIteratorHelper(P.buttonList, code, P, 2, 2) 137 --indexTester(P.buttonList,code,P,2,3) 138 end 139 111 140 return P 112 141 -
code/branches/menu/data/gui/scripts/SettingsMenu.lua
r7163 r7663 3 3 local P = createMenuSheet("SettingsMenu") 4 4 P.loadAlong = { "ControlsMenu", "AudioMenu", "GraphicsMenu" } 5 6 P.buttonList = {} 7 8 function P.onLoad() 9 --"Gameplay" and "Multiplayer Options" are not integrated in the list 10 11 local item = { 12 ["button"] = winMgr:getWindow("orxonox/SettingsMenu/GraphicsButton"), 13 ["function"] = P.SettingsGraphicsButton_clicked 14 } 15 P.buttonList[2] = item 16 17 local item = { 18 ["button"] = winMgr:getWindow("orxonox/SettingsMenu/AudioButton"), 19 ["function"] = P.SettingsAudioButton_clicked 20 } 21 P.buttonList[4] = item 22 23 24 local item = { 25 ["button"] = winMgr:getWindow("orxonox/SettingsMenu/ControlsButton"), 26 ["function"] = P.SettingsControlsButton_clicked 27 } 28 P.buttonList[5] = item 29 30 local item = { 31 ["button"] = winMgr:getWindow("orxonox/SettingsMenu/MiscellaneousButton"), 32 ["function"] = P.SettingsMiscellaneousButton_clicked 33 } 34 P.buttonList[6] = item 35 36 local item = { 37 ["button"] = winMgr:getWindow("orxonox/SettingsMenu/SettingsBackButton"), 38 ["function"] = P.SettingsBackButton_clicked 39 } 40 P.buttonList[7] = item 41 42 end 43 44 function P.onShow() 45 P.oldindex = 3 46 P.index = 2 47 end 5 48 6 49 function P.SettingsGameplayButton_clicked(e) … … 32 75 end 33 76 77 function P.onKeyPressed() 78 cout(0,code) 79 buttonIteratorHelper(P.buttonList, code, P, 4, 2) 80 --indexTester(P.buttonList,code,P,4,2) 81 end 82 34 83 return P 35 84
Note: See TracChangeset
for help on using the changeset viewer.