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