Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 29, 2010, 12:30:32 PM (15 years ago)
Author:
dafrick
Message:

Working towards a functioning PickupInventory.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickup4/data/gui/scripts/PickupInventory.lua

    r6417 r6632  
    33BasicGUI = require("BasicGUI")
    44local P = BasicGUI:new() --inherit everything from the gui package
     5
    56if _REQUIREDNAME == nil then
    67    PickupInventory = P
     
    1213P.layoutString = "PickupInventory.layout"
    1314
    14 P.lastEquipmentCount_ = 0
    15 P.lastUsableCount_ = 0
    16 P.currentUsableID_ = 0
     15function P:init()
     16   
     17end
    1718
    18 -- events
    19 function P:frmUpdate(e)
    20     local equipCount = orxonox.PickupInventory:getEquipmentCount()
    21     local usableCount = orxonox.PickupInventory:getUsableCount()
    22 
    23     if equipCount ~= self.lastEquipmentCount_ or usableCount ~= self.lastUsableCount_ then
    24         self:updateTabs()
     19function 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)
    2535    end
    2636end
    2737
    28 function P.update(e)
    29     loadedGUIs["PickupInventory"]:frmUpdate(e)
    30 end
     38function P.getCarrierList(carrier)
    3139
    32 function P.itemClicked(e)
    33     loadedGUIs["PickupInventory"]:mItemClicked(e)
    34 end
    35 
    36 function P:mItemClicked(e)
    37     local w = CEGUI.toWindowEventArgs(e).window
    38     local name = w:getName()
    39     local t = name:sub(25, 27)
    40     local i = name:sub(29)
    41 
    42     if t == "equ" then
    43 
     40    -- TODO: Test for nil or 0?
     41    if carrier == nil then
     42        return
    4443    end
    45 
    46     if t == "use" then
    47         if self.currentUsableID_ >= 0 then
    48             winMgr:getWindow("orxonox/Inventory/Title/use/" .. self.currentUsableID_):setProperty("TextColours", "tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF")
     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)
    4956        end
    50         orxonox.PickupInventory:selectUsable(tonumber(i))
    51         self.currentUsableID_ = tonumber(i)
    52         winMgr:getWindow("orxonox/Inventory/Title/use/" .. i):setProperty("TextColours", "tl:FFFF4444 tr:FFFF4444 bl:FFFF4444 br:FFFF4444")
    5357    end
    5458end
    5559
    56 -- methods
    57 function P:updateTabs()
    58     local eqWin = winMgr:getWindow("orxonox/Inventory/TabControl/TabEquipment")
    59     local usWin = winMgr:getWindow("orxonox/Inventory/TabControl/TabUsable")
    60     orxonox.PickupInventory:getSingleton():clearInventory(winMgr, eqWin, usWin)
    61     orxonox.PickupInventory:getSingleton():updateTabs(winMgr, eqWin, usWin)
     60function 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
     80end
    6281
    63     self.currentUsableID_ = orxonox.PickupInventory:getCurrentUsableIndex()
    64     self.lastEquipmentCount_ = orxonox.PickupInventory:getEquipmentCount()
    65     self.lastUsableCount_ = orxonox.PickupInventory:getUsableCount()
     82function P.InventoryUseButton_clicked(e)
     83
     84end
     85
     86function P.InventoryDropButton_clicked(e)
     87
     88end
     89
     90function P.InventoryShowDetails_clicked(e)
     91
     92end
     93
     94function P.InventoryBackButton_clicked(e)
     95    hideGUI("PickupInventory")
    6696end
    6797
Note: See TracChangeset for help on using the changeset viewer.