Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/media/gui/scripts/PickupInventory.lua @ 5559

Last change on this file since 5559 was 5559, checked in by bknecht, 15 years ago

some fixes for pickupinventory and whole gui implementation

File size: 2.0 KB
RevLine 
[5559]1gui = require("gui")
2local P = gui:new() --inherit everything from the gui package
3
4PickupInventory = P
5
6P.filename = "PickupInventory"
7P.layoutString = "PickupInventory.layout"
[5506]8
[5559]9P.lastEquipmentCount_ = 0
10P.lastUsableCount_ = 0
11P.currentUsableID_ = 0
[5529]12
[5506]13-- events
[5559]14function P:frmUpdate(e)
[5526]15    local equipCount = orxonox.PickupInventory:getEquipmentCount()
16    local usableCount = orxonox.PickupInventory:getUsableCount()
[5506]17   
[5559]18    if equipCount ~= self.lastEquipmentCount_ or usableCount ~= self.lastUsableCount_ then
19        self:updateTabs()
[5526]20    end
[5559]21end
22
23function P.update(e)
24    loadedGUIs["PickupInventory"]:frmUpdate(e)
25end
26
27function P.itemClicked(e)
28    loadedGUIs["PickupInventory"]:mItemClicked(e)
[5506]29end
30
[5559]31function P:mItemClicked(e)
[5526]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
[5559]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")
[5526]44        end
45        orxonox.PickupInventory:selectUsable(tonumber(i))
[5559]46        self.currentUsableID_ = tonumber(i)
[5526]47        winMgr:getWindow("orxonox/Inventory/Title/use/" .. i):setProperty("TextColours", "tl:FFFF4444 tr:FFFF4444 bl:FFFF4444 br:FFFF4444")
48    end
[5506]49end
[5526]50
51-- methods
[5559]52function P:updateTabs()
[5526]53    local eqWin = winMgr:getWindow("orxonox/Inventory/TabControl/TabEquipment")
54    local usWin = winMgr:getWindow("orxonox/Inventory/TabControl/TabUsable")
[5529]55    orxonox.PickupInventory:getSingleton():clearInventory(winMgr, eqWin, usWin)
56    orxonox.PickupInventory:getSingleton():updateTabs(winMgr, eqWin, usWin)
[5526]57   
[5559]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.