1 | -- PickupInventory.lua |
---|
2 | |
---|
3 | BasicGUI = require("BasicGUI") |
---|
4 | local P = BasicGUI:new() --inherit everything from the gui package |
---|
5 | if _REQUIREDNAME == nil then |
---|
6 | PickupInventory = P |
---|
7 | else |
---|
8 | _G[_REQUIREDNAME] = P |
---|
9 | end |
---|
10 | |
---|
11 | P.filename = "PickupInventory" |
---|
12 | P.layoutString = "PickupInventory.layout" |
---|
13 | |
---|
14 | P.lastEquipmentCount_ = 0 |
---|
15 | P.lastUsableCount_ = 0 |
---|
16 | P.currentUsableID_ = 0 |
---|
17 | |
---|
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() |
---|
25 | end |
---|
26 | end |
---|
27 | |
---|
28 | function P.update(e) |
---|
29 | loadedGUIs["PickupInventory"]:frmUpdate(e) |
---|
30 | end |
---|
31 | |
---|
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 | |
---|
44 | 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") |
---|
49 | 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") |
---|
53 | end |
---|
54 | end |
---|
55 | |
---|
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) |
---|
62 | |
---|
63 | self.currentUsableID_ = orxonox.PickupInventory:getCurrentUsableIndex() |
---|
64 | self.lastEquipmentCount_ = orxonox.PickupInventory:getEquipmentCount() |
---|
65 | self.lastUsableCount_ = orxonox.PickupInventory:getUsableCount() |
---|
66 | end |
---|
67 | |
---|
68 | return P |
---|