Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 25, 2009, 10:08:48 PM (15 years ago)
Author:
bknecht
Message:

some fixes for pickupinventory and whole gui implementation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • data/media/gui/scripts/PickupInventory.lua

    r5529 r5559  
    1 layoutPath = "PickupInventory.layout"
     1gui = require("gui")
     2local P = gui:new() --inherit everything from the gui package
    23
    3 -- variables
    4 local winMgr = CEGUI.WindowManager:getSingleton()
     4PickupInventory = P
    55
    6 local lastEquipmentCount_ = 0
    7 local lastUsableCount_ = 0
    8 local currentUsableID_ = 0
     6P.filename = "PickupInventory"
     7P.layoutString = "PickupInventory.layout"
     8
     9P.lastEquipmentCount_ = 0
     10P.lastUsableCount_ = 0
     11P.currentUsableID_ = 0
    912
    1013-- events
    11 function frmUpdate(e)
     14function P:frmUpdate(e)
    1215    local equipCount = orxonox.PickupInventory:getEquipmentCount()
    1316    local usableCount = orxonox.PickupInventory:getUsableCount()
    1417   
    15     if equipCount ~= lastEquipmentCount_ or usableCount ~= lastUsableCount_ then
    16         updateTabs()
     18    if equipCount ~= self.lastEquipmentCount_ or usableCount ~= self.lastUsableCount_ then
     19        self:updateTabs()
    1720    end
    1821end
    1922
    20 function itemClicked(e)
     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)
    2132    local w = CEGUI.toWindowEventArgs(e).window
    2233    local name = w:getName()
     
    2940   
    3041    if t == "use" then
    31         if currentUsableID_ >= 0 then
    32             winMgr:getWindow("orxonox/Inventory/Title/use/" .. currentUsableID_):setProperty("TextColours", "tl:FFFFFFFF tr:FFFFFFFF bl:FFFFFFFF br:FFFFFFFF")
     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")
    3344        end
    3445        orxonox.PickupInventory:selectUsable(tonumber(i))
    35         currentUsableID_ = tonumber(i)
     46        self.currentUsableID_ = tonumber(i)
    3647        winMgr:getWindow("orxonox/Inventory/Title/use/" .. i):setProperty("TextColours", "tl:FFFF4444 tr:FFFF4444 bl:FFFF4444 br:FFFF4444")
    3748    end
     
    3950
    4051-- methods
    41 function updateTabs()
     52function P:updateTabs()
    4253    local eqWin = winMgr:getWindow("orxonox/Inventory/TabControl/TabEquipment")
    4354    local usWin = winMgr:getWindow("orxonox/Inventory/TabControl/TabUsable")
     
    4556    orxonox.PickupInventory:getSingleton():updateTabs(winMgr, eqWin, usWin)
    4657   
    47     currentUsableID_ = orxonox.PickupInventory:getCurrentUsableIndex()
    48     lastEquipmentCount_ = orxonox.PickupInventory:getEquipmentCount()
    49     lastUsableCount_ = orxonox.PickupInventory:getUsableCount()
     58    self.currentUsableID_ = orxonox.PickupInventory:getCurrentUsableIndex()
     59    self.lastEquipmentCount_ = orxonox.PickupInventory:getEquipmentCount()
     60    self.lastUsableCount_ = orxonox.PickupInventory:getUsableCount()
    5061end
     62
     63return PickupInventory
Note: See TracChangeset for help on using the changeset viewer.