Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gamestate/data/gui/scripts/PickupInventory.lua @ 6621

Last change on this file since 6621 was 6621, checked in by rgrieder, 14 years ago

Simplified GUI sheet creation (first lines in the lua file) a lot by exporting it to GUITools.lua

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1-- PickupInventory.lua
2
3local P = createSheet("PickupInventory")
4
5P.lastEquipmentCount_ = 0
6P.lastUsableCount_ = 0
7P.currentUsableID_ = 0
8
9-- events
10function P:frmUpdate(e)
11    local equipCount = orxonox.PickupInventory:getEquipmentCount()
12    local usableCount = orxonox.PickupInventory:getUsableCount()
13
14    if equipCount ~= self.lastEquipmentCount_ or usableCount ~= self.lastUsableCount_ then
15        self:updateTabs()
16    end
17end
18
19function P.update(e)
20    loadedGUIs["PickupInventory"]:frmUpdate(e)
21end
22
23function P.itemClicked(e)
24    loadedGUIs["PickupInventory"]:mItemClicked(e)
25end
26
27function P:mItemClicked(e)
28    local w = CEGUI.toWindowEventArgs(e).window
29    local name = w:getName()
30    local t = name:sub(25, 27)
31    local i = name:sub(29)
32
33    if t == "equ" then
34
35    end
36
37    if t == "use" then
38        if self.currentUsableID_ >= 0 then
39            winMgr:getWindow("orxonox/Inventory/Title/use/" .. self.currentUsableID_):setProperty("TextColours", "tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF")
40        end
41        orxonox.PickupInventory:selectUsable(tonumber(i))
42        self.currentUsableID_ = tonumber(i)
43        winMgr:getWindow("orxonox/Inventory/Title/use/" .. i):setProperty("TextColours", "tl:FFFF4444 tr:FFFF4444 bl:FFFF4444 br:FFFF4444")
44    end
45end
46
47-- methods
48function P:updateTabs()
49    local eqWin = winMgr:getWindow("orxonox/Inventory/TabControl/TabEquipment")
50    local usWin = winMgr:getWindow("orxonox/Inventory/TabControl/TabUsable")
51    orxonox.PickupInventory:getSingleton():clearInventory(winMgr, eqWin, usWin)
52    orxonox.PickupInventory:getSingleton():updateTabs(winMgr, eqWin, usWin)
53
54    self.currentUsableID_ = orxonox.PickupInventory:getCurrentUsableIndex()
55    self.lastEquipmentCount_ = orxonox.PickupInventory:getEquipmentCount()
56    self.lastUsableCount_ = orxonox.PickupInventory:getUsableCount()
57end
58
59return P
Note: See TracBrowser for help on using the repository browser.