Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/data/gui/scripts/PickupInventory.lua @ 6486

Last change on this file since 6486 was 6417, checked in by rgrieder, 15 years ago

Merged presentation2 branch back to trunk.
Major new features:

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