[5559] | 1 | gui = require("gui") |
---|
| 2 | local P = gui:new() --inherit everything from the gui package |
---|
| 3 | |
---|
| 4 | PickupInventory = P |
---|
| 5 | |
---|
| 6 | P.filename = "PickupInventory" |
---|
[5587] | 7 | P.layoutString = "PickupInventory.layout" |
---|
| 8 | |
---|
| 9 | P.lastEquipmentCount_ = 0 |
---|
| 10 | P.lastUsableCount_ = 0 |
---|
| 11 | P.currentUsableID_ = 0 |
---|
| 12 | |
---|
| 13 | -- events |
---|
| 14 | function P:frmUpdate(e) |
---|
| 15 | local equipCount = orxonox.PickupInventory:getEquipmentCount() |
---|
| 16 | local usableCount = orxonox.PickupInventory:getUsableCount() |
---|
| 17 | |
---|
| 18 | if equipCount ~= self.lastEquipmentCount_ or usableCount ~= self.lastUsableCount_ then |
---|
| 19 | self:updateTabs() |
---|
| 20 | end |
---|
[5559] | 21 | end |
---|
| 22 | |
---|
| 23 | function P.update(e) |
---|
| 24 | loadedGUIs["PickupInventory"]:frmUpdate(e) |
---|
| 25 | end |
---|
| 26 | |
---|
| 27 | function P.itemClicked(e) |
---|
| 28 | loadedGUIs["PickupInventory"]:mItemClicked(e) |
---|
| 29 | end |
---|
| 30 | |
---|
[5587] | 31 | function P:mItemClicked(e) |
---|
| 32 | local w = CEGUI.toWindowEventArgs(e).window |
---|
| 33 | local name = w:getName() |
---|
| 34 | local t = name:sub(25, 27) |
---|
| 35 | local i = name:sub(29) |
---|
| 36 | |
---|
| 37 | if t == "equ" then |
---|
| 38 | |
---|
| 39 | end |
---|
| 40 | |
---|
| 41 | if t == "use" then |
---|
| 42 | if self.currentUsableID_ >= 0 then |
---|
| 43 | winMgr:getWindow("orxonox/Inventory/Title/use/" .. self.currentUsableID_):setProperty("TextColours", "tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF") |
---|
| 44 | end |
---|
| 45 | orxonox.PickupInventory:selectUsable(tonumber(i)) |
---|
| 46 | self.currentUsableID_ = tonumber(i) |
---|
| 47 | winMgr:getWindow("orxonox/Inventory/Title/use/" .. i):setProperty("TextColours", "tl:FFFF4444 tr:FFFF4444 bl:FFFF4444 br:FFFF4444") |
---|
| 48 | end |
---|
| 49 | end |
---|
| 50 | |
---|
| 51 | -- methods |
---|
| 52 | function P:updateTabs() |
---|
| 53 | local eqWin = winMgr:getWindow("orxonox/Inventory/TabControl/TabEquipment") |
---|
| 54 | local usWin = winMgr:getWindow("orxonox/Inventory/TabControl/TabUsable") |
---|
| 55 | orxonox.PickupInventory:getSingleton():clearInventory(winMgr, eqWin, usWin) |
---|
| 56 | orxonox.PickupInventory:getSingleton():updateTabs(winMgr, eqWin, usWin) |
---|
| 57 | |
---|
| 58 | self.currentUsableID_ = orxonox.PickupInventory:getCurrentUsableIndex() |
---|
| 59 | self.lastEquipmentCount_ = orxonox.PickupInventory:getEquipmentCount() |
---|
| 60 | self.lastUsableCount_ = orxonox.PickupInventory:getUsableCount() |
---|
| 61 | end |
---|
| 62 | |
---|
| 63 | return PickupInventory |
---|