Changeset 6334 for code/branches/presentation2/data/gui/scripts
- Timestamp:
- Dec 13, 2009, 1:12:13 PM (15 years ago)
- Location:
- code/branches/presentation2/data/gui/scripts
- Files:
-
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2/data/gui/scripts/AudioMenu.lua
r6235 r6334 37 37 effectsmutewindow:setSelected(effectsmute) 38 38 choice = "Default" 39 dropdownwindow = winMgr:getWindow("orxonox/AudioThemeCombobox")39 listboxwindow = winMgr:getWindow("orxonox/AudioThemeListbox") 40 40 local themeList = {} 41 41 table.insert(themeList, "Default") … … 44 44 item = CEGUI.createListboxTextItem(v) 45 45 item:setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush") 46 CEGUI.to Combobox(dropdownwindow):addItem(item)46 CEGUI.toListbox(listboxwindow):addItem(item) 47 47 end 48 dropdownwindow:setItemSelectState(0,true)49 48 end 50 49 … … 165 164 end 166 165 167 function P.AudioTheme Combobox_changed(e)168 if dropdownwindow:isItemSelected(1) then166 function P.AudioThemeListbox_changed(e) 167 if listboxwindow:isItemSelected(1) then 169 168 orxonox.CommandExecutor:execute("setMood dnb") 170 169 else -
code/branches/presentation2/data/gui/scripts/InfoPopup.lua
r6311 r6334 1 1 -- InfoPopup.lua 2 3 2 4 3 5 BasicGUI = require("BasicGUI") 4 6 local P = BasicGUI:new() --inherit everything from the gui package 7 8 5 9 if _REQUIREDNAME == nil then 10 6 11 InfoPopup = P 12 7 13 else 14 8 15 _G[_REQUIREDNAME] = P 16 9 17 end 10 18 19 20 11 21 P.filename = "InfoPopup" 22 12 23 P.layoutString = "InfoPopup.layout" 13 24 25 26 14 27 function P:init() 28 15 29 end 16 30 31 32 17 33 function P.execute(functionPtr, arguments) 34 18 35 if functionPtr ~= nil then 36 19 37 if arguments ~= nil then 38 20 39 functionPtr(arguments) 40 21 41 else 42 22 43 functionPtr() 44 23 45 end 46 24 47 end 48 25 49 end 26 50 51 52 27 53 function P.setText( text ) 54 28 55 winMgr:getWindow("orxonox/InfoPopup_text"):setText( text ) 56 29 57 end 30 58 59 60 31 61 function P.setCloseButton(closeButton) 62 32 63 close = winMgr:getWindow("orxonox/InfoPopup_close") 64 33 65 close:setVisible(closeButton) 66 34 67 if(not closeButton) then 68 35 69 close:deactivate(); 70 36 71 else 72 37 73 close:activate(); 74 38 75 end 76 39 77 end 40 78 79 80 41 81 -- events for ingamemenu 82 83 42 84 function P.close(e) 85 43 86 hideGUI("InfoPopup") 87 44 88 end 89 90 45 91 46 92 return P -
code/branches/presentation2/data/gui/scripts/KeyBindMenu.lua
r6324 r6334 1 1 -- KeyBindMenu.lua 2 2 3 4 3 5 BasicGUI = require("BasicGUI") 6 4 7 local P = BasicGUI:new() --inherit everything from the gui package 8 9 5 10 if _REQUIREDNAME == nil then 11 6 12 KeyBindMenu = P 13 7 14 else 8 15 _G[_REQUIREDNAME] = P 9 end 16 17 end 18 19 10 20 11 21 P.filename = "KeyBindMenu" 22 12 23 P.layoutString = "KeyBindMenu.layout" 13 24 25 26 14 27 function P:init() 28 15 29 commandList = {} 30 16 31 table.insert(commandList, "fire 0") 32 17 33 table.insert(commandList, "fire 1 | unfire") 34 18 35 table.insert(commandList, "onpress fire 2") 36 19 37 table.insert(commandList, "scale 1 moveFrontBack") 38 20 39 table.insert(commandList, "scale -1 moveFrontBack") 40 21 41 table.insert(commandList, "boost") 42 22 43 table.insert(commandList, "scale 1 moveRightLeft") 44 23 45 table.insert(commandList, "scale -1 moveRightLeft") 46 24 47 table.insert(commandList, "scale 1 moveUpDown") 48 25 49 table.insert(commandList, "scale -1 moveUpDown") 50 26 51 table.insert(commandList, "scale 1 rotateRoll") 52 27 53 table.insert(commandList, "scale -1 rotateRoll") 54 28 55 table.insert(commandList, "switchCamera") 56 29 57 table.insert(commandList, "openConsole") 58 30 59 table.insert(commandList, "OverlayGroup toggleVisibility Debug") 60 31 61 table.insert(commandList, "OverlayGroup toggleVisibility Stats") 62 32 63 table.insert(commandList, "mouseLook") 64 33 65 table.insert(commandList, "pause") 34 66 67 68 35 69 nameList = {} 70 36 71 table.insert(nameList, "Primary Fire") 72 37 73 table.insert(nameList, "Secondary Fire") 74 38 75 table.insert(nameList, "Fire Rocket") 76 39 77 table.insert(nameList, "Accelerate") 78 40 79 table.insert(nameList, "Break") 41 80 table.insert(nameList, "Boost") 81 42 82 table.insert(nameList, "Move Right") 83 43 84 table.insert(nameList, "Move Left") 85 44 86 table.insert(nameList, "Move Up") 87 45 88 table.insert(nameList, "Move Down") 89 46 90 table.insert(nameList, "Roll Right") 91 47 92 table.insert(nameList, "Roll Left") 93 48 94 table.insert(nameList, "Switch Camera") 95 49 96 table.insert(nameList, "Open Console") 97 50 98 table.insert(nameList, "Show Debug") 99 51 100 table.insert(nameList, "Show Stats") 101 52 102 table.insert(nameList, "Look Around") 103 53 104 table.insert(nameList, "Pause") 54 105 106 107 55 108 linesList = {} 56 109 57 lineHeight = 35 58 commandWidth = 200 59 buttonWidth = 170 110 111 lineHeight = 25 112 commandWidth = 125 113 buttonWidth = 125 60 114 clearWidth = 20 115 addWidth = 25 116 61 117 spaceWidth = 10 62 118 119 120 63 121 P.createLines() 64 122 123 124 65 125 local funct = luaState:createLuaFunctor("KeyBindMenu.callback()") 126 66 127 orxonox.KeyBinderManager:getInstance():registerKeybindCallback(funct) 67 end 128 129 end 130 131 68 132 69 133 70 134 function P.KeyNameNiceifier(key) 135 71 136 local name = string.sub(key, string.find(key, '%.(.*)')+1) 72 137 local group = string.sub(key, string.find(key, '(.*)%.')) 138 73 139 group = string.sub(group,1,string.len(group)-1) 140 74 141 if( group == "Keys") then 142 75 143 return "Key " .. string.sub(name, string.find(name, 'Key(.*)')+3) 144 76 145 elseif( group == "MouseButtons") then 146 77 147 return "Mouse " .. name 78 end 148 149 end 150 79 151 return key 80 end 152 153 end 154 155 81 156 82 157 function P.createLine(k) 158 83 159 local offset = 0 160 84 161 local line = winMgr:createWindow("DefaultWindow", "orxonox/KeyBindPane/Binding" .. k) 162 85 163 line:setHeight(CEGUI.UDim(0, lineHeight)) 164 86 165 line:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, lineHeight*(k-1)))) 87 166 167 168 88 169 local command = winMgr:createWindow("TaharezLook/StaticText", "orxonox/KeyBindPane/Binding" .. k .. "/Command") 89 command:setSize(CEGUI.UVector2(CEGUI.UDim(0, commandWidth), CEGUI.UDim(0.9, 0))) 90 command:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.05, 0))) 170 171 command:setSize(CEGUI.UVector2(CEGUI.UDim(0, commandWidth), CEGUI.UDim(1, 0))) 172 173 command:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0, 0))) 174 91 175 command:setText(nameList[k]) 92 176 line:addChildWindow(command) 177 93 178 offset = offset + commandWidth + spaceWidth 94 179 180 181 95 182 local plus = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Plus") 96 plus:setSize(CEGUI.UVector2(CEGUI.UDim(0, clearWidth), CEGUI.UDim(0.7, 0))) 183 184 plus:setSize(CEGUI.UVector2(CEGUI.UDim(0, addWidth), CEGUI.UDim(0.7, 0))) 185 97 186 plus:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.15, 0))) 98 plus:setText("+") 187 188 plus:setText("add") 189 99 190 orxonox.KeyBinderManager:getInstance():subscribeEventHelper(plus, "Clicked", P.filename .. ".KeyBindPlus_clicked") 191 100 192 line:addChildWindow(plus) 101 offset = offset + clearWidth + spaceWidth 102 193 194 offset = offset + addWidth + spaceWidth 195 196 197 103 198 local numButtons = orxonox.KeyBinderManager:getInstance():getCurrent():getNumberOfBindings(commandList[k]); 199 104 200 for i=0,(numButtons-1) do 201 105 202 local button = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Button" .. i) 203 106 204 button:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0.7, 0))) 205 107 206 button:setPosition(CEGUI.UVector2(CEGUI.UDim(0, offset), CEGUI.UDim(0.15, 0))) 207 108 208 local name = orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(commandList[k],i) 209 109 210 name = P.KeyNameNiceifier(name) 211 110 212 button:setText(name) 213 111 214 orxonox.KeyBinderManager:getInstance():subscribeEventHelper(button, "Clicked", P.filename .. ".KeyBindButton_clicked") 215 112 216 --button:subscribeScriptedEvent("EventClicked", P.filename .. ".KeyBindButton_clicked") 217 113 218 line:addChildWindow(button) 219 114 220 offset = offset + buttonWidth 221 115 222 223 116 224 local clear = winMgr:createWindow("TaharezLook/TabButton", "orxonox/KeyBindPane/Binding" .. k .. "/Clear" .. i) 225 117 226 clear:setSize(CEGUI.UVector2(CEGUI.UDim(0, clearWidth), CEGUI.UDim(0.7, 0))) 227 118 228 clear:setPosition(CEGUI.UVector2(CEGUI.UDim(0, (i*(buttonWidth+clearWidth+spaceWidth)+buttonWidth)+commandWidth+clearWidth+2*spaceWidth), CEGUI.UDim(0.15, 0))) 229 119 230 clear:setText("X") 231 120 232 orxonox.KeyBinderManager:getInstance():subscribeEventHelper(clear, "Clicked", P.filename .. ".KeyBindClear_clicked") 233 121 234 line:addChildWindow(clear) 235 122 236 offset = offset + clearWidth + spaceWidth 123 end 124 237 238 end 239 240 241 125 242 line:setWidth(CEGUI.UDim(0, offset+clearWidth)) 126 243 244 245 127 246 return line 128 end 247 248 end 249 250 129 251 130 252 function P.createLines() 131 253 254 132 255 local window = winMgr:getWindow("orxonox/KeyBindPane") 133 256 257 134 258 for k,v in pairs(commandList) do 259 135 260 local line = P.createLine(k) 261 136 262 table.insert(linesList, line) 263 137 264 window:addChildWindow(line) 138 end 139 140 end 265 266 end 267 268 269 end 270 271 141 272 142 273 function P.KeyBindButton_clicked(e) 274 143 275 local we = CEGUI.toWindowEventArgs(e) 276 144 277 local name = we.window:getName() 145 278 279 146 280 local match = string.gmatch(name, "%d+") 281 147 282 local commandNr = tonumber(match()) 283 148 284 local buttonNr = tonumber(match()) 149 285 286 287 150 288 local arguments = {} 289 151 290 arguments[1] = commandNr 291 152 292 arguments[2] = buttonNr 293 153 294 openInfoPopup("Press any button/key or move a mouse/joystick axis.", KeyBindMenu.keybind, false, arguments) 154 295 end 155 296 156 297 function P.KeyBindPlus_clicked(e) 298 157 299 local we = CEGUI.toWindowEventArgs(e) 300 158 301 local name = we.window:getName() 159 302 303 304 160 305 local match = string.gmatch(name, "%d+") 306 161 307 local commandNr = tonumber(match()) 162 308 309 163 310 local arguments = {} 311 164 312 arguments[1] = commandNr 313 165 314 openInfoPopup("Press any button/key or move a mouse/joystick axis.", KeyBindMenu.keybind, false, arguments) 166 315 end 167 316 168 317 function P.KeyBindClear_clicked(e) 318 169 319 local we = CEGUI.toWindowEventArgs(e) 320 170 321 local name = we.window:getName() 171 322 323 324 172 325 local match = string.gmatch(name, "%d+") 326 173 327 local commandNr = tonumber(match()) 328 174 329 local buttonNr = tonumber(match()) 175 330 331 176 332 orxonox.KeyBinderManager:getInstance():unbind(orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(commandList[commandNr], buttonNr)) 177 333 334 335 178 336 P.callback() 179 end 337 338 end 339 340 180 341 181 342 function P.keybind(arguments) 343 182 344 local commandNr = arguments[1] 345 183 346 local buttonNr = arguments[2] 347 184 348 if buttonNr ~= nil then 349 185 350 orxonox.KeyBinderManager:getInstance():unbind(orxonox.KeyBinderManager:getInstance():getCurrent():getBinding(commandList[commandNr], buttonNr)) 186 end 351 352 end 353 354 187 355 orxonox.KeyBinderManager:getInstance():keybind(commandList[commandNr]) 188 end 356 357 end 358 359 189 360 190 361 function P.callback() 362 191 363 while table.getn(linesList) ~= 0 do 364 192 365 if linesList[1] ~= nil then 366 193 367 winMgr:destroyWindow(linesList[1]:getName()) 368 194 369 end 370 195 371 table.remove(linesList, 1) 196 end 197 372 373 end 374 375 376 198 377 linesList = {} 199 378 379 200 380 P.createLines() 201 381 202 382 if(InfoPopup ~= nil) then 383 203 384 InfoPopup.close() 204 end 205 end 385 386 end 387 388 end 389 390 206 391 207 392 function P.KeyBindBackButton_clicked(e) 393 208 394 hideGUI("KeyBindMenu") 209 end 395 396 end 397 398 210 399 211 400 return P
Note: See TracChangeset
for help on using the changeset viewer.