Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7504 for code/trunk/data/gui


Ignore:
Timestamp:
Oct 6, 2010, 8:00:40 AM (14 years ago)
Author:
dafrick
Message:

Pickups module is now (from what I can tell after some basic testing) fully functional over the network.
However it's still a little messy, needs some cleanup and documentation.
I introduced a new class, the PickupListener, which allows reacting to pickups becoming used, unused, picked up or dropped.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/data/gui/scripts/PickupInventory.lua

    r7163 r7504  
    4545                local useButton = winMgr:getWindow("orxonox/PickupInventory/Details" .. k .. "/UseButton")
    4646                local dropButton = winMgr:getWindow("orxonox/PickupInventory/Details" .. k .. "/DropButton")
    47                 if orxonox.PickupManager:getInstance():isValidPickup(pickup) == false then
     47                if orxonox.PickupManager:getInstance():isValidPickup(pickup.pickup) == false then
    4848                    useButton:setEnabled(false)
    4949                    dropButton:setEnabled(false)
     
    5151                else
    5252                    useButton:setEnabled(true)
    53                     if pickup:isUsed() == true then
     53                    if pickup.inUse == true then
    5454                        useButton:setText("unuse")
    5555                        orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUseDetailButton_clicked")
    56                         if pickup:isUsable() == false then
     56                        if pickup.usable == false then
    5757                            useButton:setEnabled(false)
    5858                        end
     
    6060                        useButton:setText("use")
    6161                        orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUnuseDetailButton_clicked")
    62                         if pickup:isUnusable() == false then
     62                        if pickup.unusable == false then
    6363                            useButton:setEnabled(false)
    6464                        end
    6565                    end
    6666
    67                     if pickup:isPickedUp() == false then
     67                    if pickup.pickedUp == false then
    6868                        useButton:setEnabled(false)
    6969                        dropButton:setEnabled(false)
     
    108108
    109109function P.createPickupEntry(index, pickup)
    110     local representation = orxonox.PickupManager:getInstance():getPickupRepresentation(pickup)
     110    local representation = orxonox.PickupManager:getInstance():getPickupRepresentation(pickup.pickup)
    111111
    112112    local name = "orxonox/PickupInventory/Box/Pickup" .. index
     
    133133    useButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.3, P.imageHeight+10),CEGUI.UDim(0, (P.imageHeight-P.textHeight)/2)))
    134134    useButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
    135     if pickup:isUsed() == false then
     135    if pickup.inUse == false then
    136136        useButton:setText("use")
    137137        orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUseButton_clicked")
    138         if pickup:isUsable() == false then
     138        if pickup.usable == false then
    139139            useButton:setEnabled(false)
    140140        end
     
    142142        useButton:setText("unuse")
    143143        orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUnuseButton_clicked")
    144         if pickup:isUnusable() == false then
     144        if pickup.unusable == false then
    145145            useButton:setEnabled(false)
    146146        end
     
    193193function P.createDetailsWindow(pickupIndex)
    194194    local pickup = P.pickupsList[pickupIndex]
    195     local representation = orxonox.PickupManager:getInstance():getPickupRepresentation(pickup)
     195    local representation = orxonox.PickupManager:getInstance():getPickupRepresentation(pickup.pickup)
    196196
    197197    local index = P.getNewDetailNumber()
     
    238238    useButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.detailImageSize+10),CEGUI.UDim(1, -40)))
    239239    useButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
    240     if pickup:isUsed() == false then
     240    if pickup.inUse == false then
    241241        useButton:setText("use")
    242242        orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUseDetailButton_clicked")
    243         if pickup:isUsable() == false then
     243        if pickup.usable == false then
    244244            useButton:setEnabled(false)
    245245        end
     
    247247        useButton:setText("unuse")
    248248        orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUnuseDetailButton_clicked")
    249         if pickup:isUnusable() == false then
     249        if pickup.unusable == false then
    250250            useButton:setEnabled(false)
    251251        end
     
    277277function P.InventoryUseButton_clicked(e)
    278278    local pickupIndex = P.windowToPickupHelper(e)
    279     orxonox.PickupManager:getInstance():usePickup(P.pickupsList[pickupIndex], true)
     279    local pickup = P.pickupsList[pickupIndex]
     280    orxonox.PickupManager:getInstance():usePickup(pickup.pickup, true)
    280281end
    281282
    282283function P.InventoryUnuseButton_clicked(e)
    283284    local pickupIndex = P.windowToPickupHelper(e)
    284     orxonox.PickupManager:getInstance():usePickup(P.pickupsList[pickupIndex], false)
     285    local pickup = P.pickupsList[pickupIndex]
     286    orxonox.PickupManager:getInstance():usePickup(pickup.pickup, false)
    285287end
    286288
    287289function P.InventoryDropButton_clicked(e)
    288290    local pickupIndex = P.windowToPickupHelper(e)
    289     orxonox.PickupManager:getInstance():dropPickup(P.pickupsList[pickupIndex])
     291    local pickup = P.pickupsList[pickupIndex]
     292    orxonox.PickupManager:getInstance():dropPickup(pickup.pickup)
    290293end
    291294
     
    297300function P.InventoryUseDetailButton_clicked(e)
    298301    local pickupIndex = P.windowToPickupHelper(e)
    299     orxonox.PickupManager:getInstance():usePickup(P.detailPickups[pickupIndex], true)
     302    local pickup = P.detailPickups[pickupIndex]
     303    orxonox.PickupManager:getInstance():usePickup(pickup.pickup, true)
    300304end
    301305
    302306function P.InventoryUnuseDetailButton_clicked(e)
    303307    local pickupIndex = P.windowToPickupHelper(e)
    304     orxonox.PickupManager:getInstance():usePickup(P.detailPickups[pickupIndex], false)
     308    local pickup = P.detailPickups[pickupIndex]
     309    orxonox.PickupManager:getInstance():usePickup(pickup.pickup, false)
    305310end
    306311
    307312function P.InventoryDropDetailButton_clicked(e)
    308313    local pickupIndex = P.windowToPickupHelper(e)
    309     orxonox.PickupManager:getInstance():dropPickup(P.detailPickups[pickupIndex])
     314    local pickup = P.detailPickups[pickupIndex]
     315    orxonox.PickupManager:getInstance():dropPickup(pickup.pickup)
    310316end
    311317
Note: See TracChangeset for help on using the changeset viewer.