1 | layoutPath = "PickupInventory.layout" |
---|
2 | |
---|
3 | -- variables |
---|
4 | local winMgr = CEGUI.WindowManager:getSingleton() |
---|
5 | local lastEquipmentCount_ = 0 |
---|
6 | local lastUsableCount_ = 0 |
---|
7 | |
---|
8 | local currentUsableID_ = -1 |
---|
9 | local lastUsedEquipID_ = 0 |
---|
10 | local lastUsedUsableID_ = 0 |
---|
11 | |
---|
12 | -- events |
---|
13 | function tabChanged(e) |
---|
14 | local we = CEGUI.toWindowEventArgs(e) |
---|
15 | orxonox.PickupInventory:tabChanged(we.window) |
---|
16 | end |
---|
17 | function frmUpdate(e) |
---|
18 | local equipCount = orxonox.PickupInventory:getEquipmentCount() |
---|
19 | local usableCount = orxonox.PickupInventory:getUsableCount() |
---|
20 | |
---|
21 | if equipCount ~= lastEquipmentCount_ or usableCount ~= lastUsableCount_ then |
---|
22 | updateTabs() |
---|
23 | end |
---|
24 | end |
---|
25 | |
---|
26 | function itemClicked(e) |
---|
27 | local w = CEGUI.toWindowEventArgs(e).window |
---|
28 | local name = w:getName() |
---|
29 | local t = name:sub(25, 27) |
---|
30 | local i = name:sub(29) |
---|
31 | |
---|
32 | if t == "equ" then |
---|
33 | |
---|
34 | end |
---|
35 | |
---|
36 | if t == "use" then |
---|
37 | if currentUsableID_ >= 0 then |
---|
38 | winMgr:getWindow("orxonox/Inventory/Title/use/" .. currentUsableID_):setProperty("TextColours", "tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF") |
---|
39 | end |
---|
40 | orxonox.PickupInventory:selectUsable(tonumber(i)) |
---|
41 | currentUsableID_ = tonumber(i) |
---|
42 | winMgr:getWindow("orxonox/Inventory/Title/use/" .. i):setProperty("TextColours", "tl:FFFF4444 tr:FFFF4444 bl:FFFF4444 br:FFFF4444") |
---|
43 | end |
---|
44 | end |
---|
45 | |
---|
46 | -- methods |
---|
47 | function updateTabs() |
---|
48 | local eqWin = winMgr:getWindow("orxonox/Inventory/TabControl/TabEquipment") |
---|
49 | local usWin = winMgr:getWindow("orxonox/Inventory/TabControl/TabUsable") |
---|
50 | orxonox.PickupInventory:clearInventory(winMgr, lastEquipmentCount_, lastUsableCount_) |
---|
51 | orxonox.PickupInventory:updateTabs(winMgr, eqWin, usWin) |
---|
52 | |
---|
53 | currentUsableID_ = orxonox.PickupInventory:getCurrentUsableIndex() |
---|
54 | lastEquipmentCount_ = orxonox.PickupInventory:getEquipmentCount() |
---|
55 | lastUsableCount_ = orxonox.PickupInventory:getUsableCount() |
---|
56 | end |
---|