Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/resource2/media/gui/scripts/PickupInventory.lua @ 5295

Last change on this file since 5295 was 3374, checked in by rgrieder, 15 years ago

Added most of the text based files of the media directory (the file I deleted in the previous commit of the media repo) with svn:eol-style=native

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