| 1 | -- PickupInventory.lua |
|---|
| 2 | |
|---|
| 3 | BasicGUI = require("BasicGUI") |
|---|
| 4 | local P = BasicGUI:new() --inherit everything from the gui package |
|---|
| 5 | |
|---|
| 6 | if _REQUIREDNAME == nil then |
|---|
| 7 | PickupInventory = P |
|---|
| 8 | else |
|---|
| 9 | _G[_REQUIREDNAME] = P |
|---|
| 10 | end |
|---|
| 11 | |
|---|
| 12 | P.filename = "PickupInventory" |
|---|
| 13 | P.layoutString = "PickupInventory.layout" |
|---|
| 14 | |
|---|
| 15 | function P:init() |
|---|
| 16 | |
|---|
| 17 | end |
|---|
| 18 | |
|---|
| 19 | function P:show() |
|---|
| 20 | self.window:show() -- TODO: Do this through parent... |
|---|
| 21 | self.visible = true |
|---|
| 22 | |
|---|
| 23 | carrierList = {} |
|---|
| 24 | |
|---|
| 25 | -- TODO: Nicer? |
|---|
| 26 | local pickupManager = orxonox.PickupManager:getInstance() |
|---|
| 27 | local carrier = pickupManager:getPawn() |
|---|
| 28 | P.getCarrierList(carrier) |
|---|
| 29 | |
|---|
| 30 | for k,v in pairs(carrierList) do |
|---|
| 31 | local args = {} |
|---|
| 32 | table.insert(args, v) |
|---|
| 33 | table.insert(args, k) |
|---|
| 34 | local window = P.createCarrierBox(args) |
|---|
| 35 | end |
|---|
| 36 | end |
|---|
| 37 | |
|---|
| 38 | function P.getCarrierList(carrier) |
|---|
| 39 | |
|---|
| 40 | -- TODO: Test for nil or 0? |
|---|
| 41 | if carrier == nil then |
|---|
| 42 | return |
|---|
| 43 | end |
|---|
| 44 | |
|---|
| 45 | table.insert(carrierList, carrier) |
|---|
| 46 | |
|---|
| 47 | local numCarriers = orxonox.PickupManager.getInstance():getNumCarrierChildren(carrier) |
|---|
| 48 | if numCarriers == 0 then |
|---|
| 49 | return |
|---|
| 50 | end |
|---|
| 51 | |
|---|
| 52 | for i=0,numCarriers-1,1 do |
|---|
| 53 | local child = orxonox.PickupManager.getInstance():getCarrierChild(i, carrier) |
|---|
| 54 | if child ~= nil then |
|---|
| 55 | P.getCarrierList(child) |
|---|
| 56 | end |
|---|
| 57 | end |
|---|
| 58 | end |
|---|
| 59 | |
|---|
| 60 | function P.createCarrierBox(args) |
|---|
| 61 | local carrier = args[1] |
|---|
| 62 | local index = args[2] |
|---|
| 63 | |
|---|
| 64 | local name = "orxonox/PickupInventory/Carrier" .. index |
|---|
| 65 | local window = winMgr:createWindow("TaharezLook/StaticText", name .. "/Title") |
|---|
| 66 | window:setText(carrier:getCarrierName()) |
|---|
| 67 | -- TODO: Does this exist? |
|---|
| 68 | local height = window:getHeight() |
|---|
| 69 | |
|---|
| 70 | local box = winMgr:createWindow("TaharezLook/ScrollablePane", name .. "/Box") |
|---|
| 71 | box:setPosition(CEGUI.UVector2(CEGUI.UDim(0.05, 0), CEGUI.UDim(0, height))) |
|---|
| 72 | box:setWidth(CEGUI.UDim(0.9, 0)) |
|---|
| 73 | |
|---|
| 74 | local numPickups = orxonox.PickupManager.getInstance():getNumPickups(carrier) |
|---|
| 75 | for i=0,numPickups-1,1 do |
|---|
| 76 | |
|---|
| 77 | end |
|---|
| 78 | |
|---|
| 79 | return window |
|---|
| 80 | end |
|---|
| 81 | |
|---|
| 82 | function P.InventoryUseButton_clicked(e) |
|---|
| 83 | |
|---|
| 84 | end |
|---|
| 85 | |
|---|
| 86 | function P.InventoryDropButton_clicked(e) |
|---|
| 87 | |
|---|
| 88 | end |
|---|
| 89 | |
|---|
| 90 | function P.InventoryShowDetails_clicked(e) |
|---|
| 91 | |
|---|
| 92 | end |
|---|
| 93 | |
|---|
| 94 | function P.InventoryBackButton_clicked(e) |
|---|
| 95 | hideGUI("PickupInventory") |
|---|
| 96 | end |
|---|
| 97 | |
|---|
| 98 | return P |
|---|