Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6518 was 6459, checked in by rgrieder, 15 years ago

Simplified BasicGUI construction. Just give the name of the GUI as argument. The rest will be deduced.

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1-- PickupInventory.lua
2
3BasicGUI = require("BasicGUI")
4local P = BasicGUI:new("PickupInventory")
5if _REQUIREDNAME == nil then
6    PickupInventory = P
7else
8    _G[_REQUIREDNAME] = P
9end
10
11P.lastEquipmentCount_ = 0
12P.lastUsableCount_ = 0
13P.currentUsableID_ = 0
14
15-- events
16function 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
23end
24
25function P.update(e)
26    loadedGUIs["PickupInventory"]:frmUpdate(e)
27end
28
29function P.itemClicked(e)
30    loadedGUIs["PickupInventory"]:mItemClicked(e)
31end
32
33function 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
51end
52
53-- methods
54function 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()
63end
64
65return P
Note: See TracBrowser for help on using the repository browser.