Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6551 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
RevLine 
[5661]1-- PickupInventory.lua
[5559]2
[5661]3BasicGUI = require("BasicGUI")
[6459]4local P = BasicGUI:new("PickupInventory")
[5661]5if _REQUIREDNAME == nil then
6    PickupInventory = P
7else
8    _G[_REQUIREDNAME] = P
9end
[5559]10
[5587]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()
[6417]19
[5587]20    if equipCount ~= self.lastEquipmentCount_ or usableCount ~= self.lastUsableCount_ then
21        self:updateTabs()
22    end
[5559]23end
24
25function P.update(e)
26    loadedGUIs["PickupInventory"]:frmUpdate(e)
27end
28
29function P.itemClicked(e)
30    loadedGUIs["PickupInventory"]:mItemClicked(e)
31end
32
[5587]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)
[6417]38
[5587]39    if t == "equ" then
[6417]40
[5587]41    end
[6417]42
[5587]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)
[6417]59
[5587]60    self.currentUsableID_ = orxonox.PickupInventory:getCurrentUsableIndex()
61    self.lastEquipmentCount_ = orxonox.PickupInventory:getEquipmentCount()
62    self.lastUsableCount_ = orxonox.PickupInventory:getUsableCount()
63end
64
[5661]65return P
Note: See TracBrowser for help on using the repository browser.