Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6965


Ignore:
Timestamp:
May 24, 2010, 4:59:23 PM (14 years ago)
Author:
dafrick
Message:

Cleaned up in PickupInventory, to be able to improve it at a later stage.

Location:
code/branches/presentation3
Files:
6 edited

Legend:

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

    r6906 r6965  
    66P.wrapper = nil
    77P.detailsWindows = {}
     8P.pickupsList = {}
     9
     10P.showing = false
     11
     12-- Design parameters
     13P.imageHeight = 50
     14P.detailImageSize = 100
     15P.textHeight = 30
     16P.buttonWidth = 85
    817
    918function P.onLoad()
     
    1322function P.onShow()
    1423    P.createInventory()
     24    P.showing = true
    1525end
    1626
    1727function P.onHide()
     28    P.showing = false
    1829    P.cleanup()
    1930end
    2031
    2132function P.update()
     33    if P.showing == false then
     34        return
     35    end
     36   
    2237    P.cleanup()
    2338   
     
    2742function P.createInventory()
    2843    local pickupManager = orxonox.PickupManager:getInstance()
    29     local carrier = pickupManager:getPawn()
    3044   
    3145    local root = winMgr:getWindow("orxonox/PickupInventory/Inventory")
     
    3448    root:addChildWindow(P.wrapper)
    3549   
    36     P.carrierList = {}
    37    
    38     --Design parameters:
    39     local space = 15
    40    
    41     P.getCarrierList(carrier)
     50    P.pickupsList = {}
     51
     52    local numPickups = pickupManager:getNumPickups()
     53    local counter = 1
    4254    local offset = 0
    43     for k,v in pairs(P.carrierList) do
    44         local window = P.createCarrierBox(v,k)
     55    while counter <= numPickups do
     56        local pickup = pickupManager:popPickup()
     57        table.insert(P.pickupsList, pickup)
     58        local window = P.createPickupEntry(counter, pickup)
    4559        window:setYPosition(CEGUI.UDim(0,offset))
    46         offset = offset + window:getHeight():asAbsolute(1) + space
     60        offset = offset + window:getHeight():asAbsolute(1)
    4761        P.wrapper:addChildWindow(window)
    48     end
    49 end
    50 
    51 function P.getCarrierList(carrier)
    52 
    53     -- TODO: Test for nil or 0?
    54     if carrier == nil then
    55         return
    56     end
    57    
    58     table.insert(P.carrierList, carrier)
    59    
    60     local numCarriers = orxonox.PickupManager:getInstance():getNumCarrierChildren(carrier)
    61     if numCarriers == 0 then
    62         return
    63     end
    64    
    65     for i=0,numCarriers-1,1 do
    66         local child = orxonox.PickupManager:getInstance():getCarrierChild(i, carrier)
    67         if child ~= nil then
    68             P.getCarrierList(child)
    69         end
    70     end
    71 end
    72 
    73 function P.createCarrierBox(carrier, index)
    74 
    75     local name = "orxonox/PickupInventory/Carrier" .. index
    76    
    77     --Design parameters:
    78     local imageHeight = 50
    79     local textHeight = 30
    80     local horizontalOffset = 20
    81     local buttonWidth = 85
    82    
    83     local offset = 0
    84 
    85     local box = winMgr:createWindow("MenuWidgets/ScrollablePane", name .. "/Box")
    86     box:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horizontalOffset), CEGUI.UDim(0, 0)))
    87     box:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -horizontalOffset), CEGUI.UDim(1, 0)))
    88    
    89     local numPickups = orxonox.PickupManager:getInstance():getNumPickups(carrier)
    90     for i=0,numPickups-1,1 do
    91         local pickup = orxonox.PickupManager:getInstance():getPickupRepresentation(i, carrier)
    92        
    93         local item = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Box/Pickup" .. i)
    94         item:setSize(CEGUI.UVector2(CEGUI.UDim(1, -horizontalOffset), CEGUI.UDim(0, imageHeight)))
    95         item:setPosition(CEGUI.UVector2(CEGUI.UDim(0, horizontalOffset), CEGUI.UDim(0, offset)))
    96         box:addChildWindow(item)
    97         offset = offset + imageHeight+5
    98        
    99         local image = winMgr:createWindow("MenuWidgets/StaticImage", name .. "/Box/Pickup" .. i .. "/Image")
    100         image:setProperty("Image", "set:PickupInventory image:" .. pickup:getInventoryRepresentation())
    101         image:setProperty("BackgroundEnabled", "set:False")
    102         image:setProperty("FrameEnabled", "set:True")
    103         image:setSize(CEGUI.UVector2(CEGUI.UDim(0, imageHeight), CEGUI.UDim(0, imageHeight)))
    104         item:addChildWindow(image)
    105        
    106         local title = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Box/Pickup" .. i .. "/Title")
    107         title:setPosition(CEGUI.UVector2(CEGUI.UDim(0, imageHeight+5), CEGUI.UDim(0, (imageHeight-textHeight)/2)))
    108         title:setSize(CEGUI.UVector2(CEGUI.UDim(0.4, 0), CEGUI.UDim(0, textHeight)))
    109         title:setText(pickup:getPickupName())
    110         title:setProperty("FrameEnabled", "set:False")
    111         item:addChildWindow(title)
    112        
    113         local useButton = winMgr:createWindow("MenuWidgets/Button", name .. "/Box/Pickup" .. i .. "/UseButton")
    114         useButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, imageHeight+10),CEGUI.UDim(0, (imageHeight-textHeight)/2)))
    115         useButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0, textHeight)))
     62        counter = counter + 1
     63    end
     64
     65end
     66
     67function P.createPickupEntry(index, pickup)
     68    local representation = orxonox.PickupManager:getInstance():getPickupRepresentation(pickup)
     69
     70    local name = "orxonox/PickupInventory/Box/Pickup" .. index
     71
     72    local item = winMgr:createWindow("MenuWidgets/StaticText", name)
     73    item:setSize(CEGUI.UVector2(CEGUI.UDim(1, 0), CEGUI.UDim(0, P.imageHeight)))
     74    item:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, 0)))
     75
     76    local image = winMgr:createWindow("MenuWidgets/StaticImage", name .. "/Image")
     77    image:setProperty("Image", "set:PickupInventory image:" .. representation:getInventoryRepresentation())
     78    image:setProperty("BackgroundEnabled", "set:False")
     79    image:setProperty("FrameEnabled", "set:True")
     80    image:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.imageHeight), CEGUI.UDim(0, P.imageHeight)))
     81    item:addChildWindow(image)
     82
     83    local title = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Title")
     84    title:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.imageHeight+5), CEGUI.UDim(0, (P.imageHeight-P.textHeight)/2)))
     85    title:setSize(CEGUI.UVector2(CEGUI.UDim(0.4, 0), CEGUI.UDim(0, P.textHeight)))
     86    title:setText(representation:getPickupName())
     87    title:setProperty("FrameEnabled", "set:False")
     88    item:addChildWindow(title)
     89
     90    local useButton = winMgr:createWindow("MenuWidgets/Button", name .. "/UseButton")
     91    useButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, P.imageHeight+10),CEGUI.UDim(0, (P.imageHeight-P.textHeight)/2)))
     92    useButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
     93    if pickup:isUsed() == false then
    11694        useButton:setText("use")
    11795        orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUseButton_clicked")
    118         item:addChildWindow(useButton)
    119        
    120         local dropButton = winMgr:createWindow("MenuWidgets/Button", name .. "/Box/Pickup" .. i .. "/DropButton")
    121         dropButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, imageHeight+15+buttonWidth),CEGUI.UDim(0, (imageHeight-textHeight)/2)))
    122         dropButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0, textHeight)))
    123         dropButton:setText("drop")
    124         orxonox.GUIManager:subscribeEventHelper(dropButton, "Clicked", P.name .. ".InventoryDropButton_clicked")
    125         item:addChildWindow(dropButton)
    126        
    127         local detailsButton = winMgr:createWindow("MenuWidgets/Button", name .. "/Box/Pickup" .. i .. "/DetailsButton")
    128         detailsButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, imageHeight+20+2*buttonWidth),CEGUI.UDim(0, (imageHeight-textHeight)/2)))
    129         detailsButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0, textHeight)))
    130         detailsButton:setText("details")
    131         orxonox.GUIManager:subscribeEventHelper(detailsButton, "Clicked", P.name .. ".InventoryDetailsButton_clicked")
    132         item:addChildWindow(detailsButton)
    133     end
    134    
    135     box:setHeight(CEGUI.UDim(0,offset))
    136    
    137     return box
     96    else
     97        useButton:setText("unuse")
     98        orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUnuseButton_clicked")
     99    end
     100    item:addChildWindow(useButton)
     101
     102    local dropButton = winMgr:createWindow("MenuWidgets/Button", name .. "/DropButton")
     103    dropButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, P.imageHeight+15+P.buttonWidth),CEGUI.UDim(0, (P.imageHeight-P.textHeight)/2)))
     104    dropButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
     105    dropButton:setText("drop")
     106    orxonox.GUIManager:subscribeEventHelper(dropButton, "Clicked", P.name .. ".InventoryDropButton_clicked")
     107    item:addChildWindow(dropButton)
     108
     109    local detailsButton = winMgr:createWindow("MenuWidgets/Button", name .. "/DetailsButton")
     110    detailsButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, P.imageHeight+20+2*P.buttonWidth),CEGUI.UDim(0, (P.imageHeight-P.textHeight)/2)))
     111    detailsButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
     112    detailsButton:setText("details")
     113    orxonox.GUIManager:subscribeEventHelper(detailsButton, "Clicked", P.name .. ".InventoryDetailsButton_clicked")
     114    item:addChildWindow(detailsButton)
     115
     116    return item
    138117end
    139118
     
    151130end
    152131
    153 function P.windowToCarrierHelper(e)
     132function P.windowToPickupHelper(e)
    154133    local we = CEGUI.toWindowEventArgs(e)
    155134    local name = we.window:getName()
    156135
    157136    local match = string.gmatch(name, "%d+")
    158     local carrierNr = tonumber(match())
    159     local pickupNr = tonumber(match())
    160 
    161     local arguments = {}
    162     arguments[1] = carrierNr
    163     arguments[2] = pickupNr
    164     return arguments
    165 end
    166 
    167 function P.createDetailsWindow(pickupIndex, carrierIndex)
    168     local carrier = P.carrierList[carrierIndex]
    169     local pickup = orxonox.PickupManager:getInstance():getPickupRepresentation(pickupIndex, carrier)
     137    local pickupIndex = tonumber(match())
     138
     139    return pickupIndex
     140end
     141
     142function P.createDetailsWindow(pickupIndex)
     143    local pickup = P.pickupsList[pickupIndex]
     144    local representation = orxonox.PickupManager:getInstance():getPickupRepresentation(pickup)
    170145   
    171146    local headerOffset = 35
    172147    --Design parameters
    173     local titleHeight = 30
    174148    local imageSize = 100
    175     local buttonWidth = 85
    176    
    177     local name = "orxonox/PickupInventory/Carrier" .. carrierIndex .. "/Pickup" .. pickupIndex .. "/Details" .. P.getNewDetailNumber()
     149   
     150    local name = "orxonox/PickupInventory/Pickup" .. pickupIndex .. "/Details" .. P.getNewDetailNumber()
    178151   
    179152    local window = winMgr:createWindow("MenuWidgets/FrameWindow", name)
     
    190163   
    191164    local title = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Title")
    192     title:setText(pickup:getPickupName())
    193     title:setHeight(CEGUI.UDim(0, titleHeight))
     165    title:setText(representation:getPickupName())
     166    title:setHeight(CEGUI.UDim(0, P.textHeight))
    194167    title:setProperty("FrameEnabled", "set:False")
    195168    title:setProperty("BackgroundEnabled", "set:False")
     
    197170   
    198171    local image = winMgr:createWindow("MenuWidgets/StaticImage", name .. "/Image")
    199     image:setProperty("Image", "set:PickupInventory image:" .. pickup:getInventoryRepresentation())
     172    image:setProperty("Image", "set:PickupInventory image:" .. representation:getInventoryRepresentation())
    200173    image:setProperty("BackgroundEnabled", "set:False")
    201174    image:setProperty("FrameEnabled", "set:True")
    202     image:setSize(CEGUI.UVector2(CEGUI.UDim(0, imageSize), CEGUI.UDim(0, imageSize)))
    203     image:setYPosition(CEGUI.UDim(0, titleHeight + 5))
     175    image:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.detailImageSize), CEGUI.UDim(0, P.detailImageSize)))
     176    image:setYPosition(CEGUI.UDim(0, P.textHeight + 5))
    204177    wrapper:addChildWindow(image)
    205178   
    206179    local box = winMgr:createWindow("MenuWidgets/ScrollablePane", name .. "/Description")
    207     box:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -1*(imageSize + 10)),CEGUI.UDim(1, -(titleHeight + 5 + titleHeight + 20))))
    208     box:setPosition(CEGUI.UVector2(CEGUI.UDim(0, imageSize + 10),CEGUI.UDim(0, titleHeight + 5)))
    209     local description = winMgr:createWindow("TaharezLook/StaticText", name .. "/Description/Text")
    210     description:setText(pickup:getPickupDescription())
     180    box:setSize(CEGUI.UVector2(CEGUI.UDim(1.0, -1*(P.detailImageSize + 10)),CEGUI.UDim(1, -(P.textHeight + 5 + P.textHeight + 20))))
     181    box:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.detailImageSize + 10),CEGUI.UDim(0, P.textHeight + 5)))
     182    local description = winMgr:createWindow("MenuWidgets/StaticText", name .. "/Description/Text")
     183    description:setText(representation:getPickupDescription())
    211184    description:setProperty("HorzFormatting", "WordWrapLeftAligned")
    212185    description:setProperty("VertFormatting", "TopAligned")
    213186    box:addChildWindow(description)
    214187    wrapper:addChildWindow(box)
    215    
     188
    216189    local useButton = winMgr:createWindow("MenuWidgets/Button", name .. "/UseButton")
    217     useButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0, imageSize+10),CEGUI.UDim(1, -40)))
    218     useButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0, titleHeight)))
    219     useButton:setText("use")
    220     orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUseButton_clicked")
     190    useButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.detailImageSize+10),CEGUI.UDim(1, -40)))
     191    useButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
     192    if pickup:isUsed() == false then
     193        useButton:setText("use")
     194        orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUseButton_clicked")
     195    else
     196        useButton:setText("unuse")
     197        orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.name .. ".InventoryUnuseButton_clicked")
     198    end
    221199    wrapper:addChildWindow(useButton)
    222200   
    223201    local dropButton = winMgr:createWindow("MenuWidgets/Button", name .. "/DropButton")
    224     dropButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0, imageSize+10+buttonWidth+10),CEGUI.UDim(1, -40)))
    225     dropButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, buttonWidth), CEGUI.UDim(0, titleHeight)))
     202    dropButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0, P.detailImageSize+10+P.buttonWidth+10),CEGUI.UDim(1, -40)))
     203    dropButton:setSize(CEGUI.UVector2(CEGUI.UDim(0, P.buttonWidth), CEGUI.UDim(0, P.textHeight)))
    226204    dropButton:setText("drop")
    227205    orxonox.GUIManager:subscribeEventHelper(dropButton, "Clicked", P.name .. ".InventoryDropButton_clicked")
     
    243221
    244222function P.InventoryUseButton_clicked(e)
    245     local arguments = P.windowToCarrierHelper(e)
    246     orxonox.PickupManager:getInstance():usePickup(arguments[2], P.carrierList[arguments[1]], true)
     223    local pickupIndex = P.windowToPickupHelper(e)
     224    orxonox.PickupManager:getInstance():usePickup(P.pickupsList[pickupIndex], true)
     225end
     226
     227function P.InventoryUnuseButton_clicked(e)
     228    local pickupIndex = P.windowToPickupHelper(e)
     229    orxonox.PickupManager:getInstance():usePickup(P.pickupsList[pickupIndex], false)
    247230end
    248231
    249232function P.InventoryDropButton_clicked(e)
    250     local arguments = P.windowToCarrierHelper(e)
    251     orxonox.PickupManager:getInstance():dropPickup(arguments[2], P.carrierList[arguments[1]])
     233    local pickupIndex = P.windowToPickupHelper(e)
     234    orxonox.PickupManager:getInstance():dropPickup(P.pickupsList[pickupIndex])
    252235end
    253236
    254237function P.InventoryDetailsButton_clicked(e)
    255     local arguments = P.windowToCarrierHelper(e)
    256     P.createDetailsWindow(arguments[2], arguments[1])
     238    local pickupIndex = P.windowToPickupHelper(e)
     239    P.createDetailsWindow(pickupIndex)
    257240end
    258241
     
    262245    local name = we.window:getName()
    263246    local match = string.gmatch(name, "%d+")
    264     local carrierNr = tonumber(match())
    265247    local pickupNr = tonumber(match())
    266248    local detailNr = tonumber(match())
  • code/branches/presentation3/src/modules/pickup/PickupManager.cc

    r6752 r6965  
    6464       
    6565        this->defaultRepresentation_ = new PickupRepresentation();
     66        this->pickupsIndex_ = 0;
    6667       
    6768        COUT(3) << "PickupManager created." << std::endl;
     
    149150        return it->second;
    150151    }
    151    
    152     PickupCarrier* PickupManager::getPawn(void)
    153     {
     152
     153    int PickupManager::getNumPickups(void)
     154    {
     155        this->pickupsList_.clear();
     156        this->pickupsIndex_ = 0;
     157       
    154158        PlayerInfo* player = GUIManager::getInstance().getPlayer(PickupManager::guiName_s);
     159        PickupCarrier* carrier = NULL;
    155160        if (player != NULL)
    156             return dynamic_cast<PickupCarrier*>(player->getControllableEntity());
     161            carrier = dynamic_cast<PickupCarrier*>(player->getControllableEntity());
    157162        else
    158             return NULL;
    159     }
    160    
    161     int PickupManager::getNumCarrierChildren(PickupCarrier* carrier)
    162     {
    163         if(carrier == NULL)
    164163            return 0;
    165         return carrier->getNumCarrierChildren();
    166     }
    167            
    168     PickupCarrier* PickupManager::getCarrierChild(int index, PickupCarrier* carrier)
    169     {
    170         if(carrier == NULL)
    171             return NULL;
    172         return carrier->getCarrierChild(index);
    173     }
    174    
    175     const std::string& PickupManager::getCarrierName(orxonox::PickupCarrier* carrier)
    176     {
    177         if(carrier == NULL)
    178             return BLANKSTRING;
    179         return carrier->getCarrierName();
    180     }
    181    
    182     PickupRepresentation* PickupManager::getPickupRepresentation(int index, PickupCarrier* carrier)
    183     {
    184         Pickupable* pickup = carrier->getPickup(index);
    185         if(pickup == NULL)
    186             return NULL;
    187        
    188         return this->getRepresentation(pickup->getPickupIdentifier());
    189     }
    190    
    191     int PickupManager::getNumPickups(PickupCarrier* carrier)
    192     {
    193         if(carrier == NULL)
    194             return 0;
    195         return carrier->getNumPickups();
    196     }
    197    
    198     void PickupManager::dropPickup(int index, PickupCarrier* carrier)
    199     {
    200         Pickupable* pickup = carrier->getPickup(index);
    201         if(pickup != NULL)
     164
     165        std::vector<PickupCarrier*>* carriers = this->getAllCarriers(carrier);
     166        for(std::vector<PickupCarrier*>::iterator it = carriers->begin(); it != carriers->end(); it++)
     167        {
     168            std::set<Pickupable*> pickups = (*it)->getPickups();
     169            for(std::set<Pickupable*>::iterator pickup = pickups.begin(); pickup != pickups.end(); pickup++)
     170            {
     171                this->pickupsList_.insert(*pickup);
     172            }
     173        }
     174        delete carriers;
     175
     176        this->pickupsIterator_ = this->pickupsList_.begin();
     177        return this->pickupsList_.size();
     178    }
     179
     180    std::vector<PickupCarrier*>* PickupManager::getAllCarriers(PickupCarrier* carrier)
     181    {
     182        //TODO: More efficiently.
     183        std::vector<PickupCarrier*>* carriers = new std::vector<PickupCarrier*>();
     184        carriers->insert(carriers->end(), carrier);
     185        std::vector<PickupCarrier*>* children = carrier->getCarrierChildren();
     186        for(std::vector<PickupCarrier*>::iterator it = children->begin(); it != children->end(); it++)
     187        {
     188            std::vector<PickupCarrier*>* childrensChildren = this->getAllCarriers(*it);
     189            for(std::vector<PickupCarrier*>::iterator it2 = childrensChildren->begin(); it2 != childrensChildren->end(); it2++)
     190            {
     191                carriers->insert(carriers->end(), *it2);
     192            }
     193            delete childrensChildren;
     194        }
     195        delete children;
     196        return carriers;
     197    }
     198
     199    void PickupManager::dropPickup(orxonox::Pickupable* pickup)
     200    {
     201        if(!pickup->isPickedUp())
     202            return;
     203       
     204        PickupCarrier* carrier = pickup->getCarrier();
     205        if(pickup != NULL && carrier != NULL)
    202206            carrier->drop(pickup);
    203207    }
    204    
    205     void PickupManager::usePickup(int index, PickupCarrier* carrier, bool use)
    206     {
    207         Pickupable* pickup = carrier->getPickup(index);
    208         if(pickup != NULL)
     208
     209    void PickupManager::usePickup(orxonox::Pickupable* pickup, bool use)
     210    {
     211        if(!pickup->isPickedUp())
     212            return;
     213
     214        PickupCarrier* carrier = pickup->getCarrier();
     215        if(pickup != NULL && carrier != NULL)
    209216            pickup->setUsed(use);
    210217    }
  • code/branches/presentation3/src/modules/pickup/PickupManager.h

    r6725 r6965  
    7171           
    7272            // tolua_begin
    73             orxonox::PickupCarrier* getPawn(void);
    74            
    75             int getNumCarrierChildren(orxonox::PickupCarrier* carrier);
    76             orxonox::PickupCarrier* getCarrierChild(int index, orxonox::PickupCarrier* carrier);
    77            
    78             const std::string& getCarrierName(orxonox::PickupCarrier* carrier);
    79            
    80             int getNumPickups(orxonox::PickupCarrier* carrier);
    81             PickupRepresentation* getPickupRepresentation(int index, orxonox::PickupCarrier* carrier);
    82             void dropPickup(int index, orxonox::PickupCarrier* carrier);
    83             void usePickup(int index, orxonox::PickupCarrier* carrier, bool use);
     73            int getNumPickups(void);
     74            orxonox::Pickupable* popPickup(void) { this->pickupsIndex_++; return *(this->pickupsIterator_++); }
     75            int getPickupIndex(void) { return this->pickupsIndex_-1; }
     76            orxonox::PickupRepresentation* getPickupRepresentation(orxonox::Pickupable* pickup) { if(pickup != NULL) return this->getRepresentation(pickup->getPickupIdentifier()); return NULL; }
     77
     78            void dropPickup(orxonox::Pickupable* pickup);
     79            void usePickup(orxonox::Pickupable* pickup, bool use);
    8480            // tolua_end
    8581           
     
    9086            PickupRepresentation* defaultRepresentation_; //!< The default PickupRepresentation.
    9187            std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare> representations_; //!< Map linking PickupIdentifiers (representing types if Pickupables) and PickupRepresentations.
     88
     89            std::set<Pickupable*> pickupsList_;
     90            std::set<Pickupable*>::iterator pickupsIterator_;
     91            int pickupsIndex_;
     92
     93            std::vector<PickupCarrier*>* getAllCarriers(PickupCarrier* carrier);
    9294       
    9395    }; // tolua_export
  • code/branches/presentation3/src/orxonox/CMakeLists.txt

    r6928 r6965  
    6060    MoodManager.h
    6161    controllers/HumanController.h
    62     interfaces/PickupCarrier.h
     62    interfaces/Pickupable.h
    6363    sound/SoundManager.h
    6464  DEFINE_SYMBOL
  • code/branches/presentation3/src/orxonox/interfaces/PickupCarrier.h

    r6711 r6965  
    4545#include "core/OrxonoxClass.h"
    4646
    47 namespace orxonox // tolua_export
    48 { // tolua_export
     47namespace orxonox
     48{
    4949
    5050    //! Forward-declarations.
     
    6262        Damian 'Mozork' Frick
    6363    */
    64     class _OrxonoxExport PickupCarrier  // tolua_export
    65         : virtual public OrxonoxClass
    66     { // tolua_export
     64    class _OrxonoxExport PickupCarrier : virtual public OrxonoxClass
     65    {
    6766        //! So that the different Pickupables have full access to their PickupCarrier.
    6867        friend class Pickupable;
     
    259258                }
    260259           
    261     }; // tolua_export
    262 } // tolua_export
     260    };
     261}
    263262
    264263#endif /* _PickupCarrier_H__ */
  • code/branches/presentation3/src/orxonox/interfaces/Pickupable.h

    r6901 r6965  
    4242#include "core/OrxonoxClass.h"
    4343
    44 namespace orxonox
    45 {
     44namespace orxonox // tolua_export
     45{ // tolua_export
    4646   
    4747    /**
     
    5151        Damian 'Mozork' Frick
    5252    */
    53     class _OrxonoxExport Pickupable : virtual public OrxonoxClass
    54     {
     53    class _OrxonoxExport Pickupable  // tolua_export
     54        : virtual public OrxonoxClass
     55    {  // tolua_export
    5556        protected:
    5657            Pickupable(); //!< Default constructor.
     
    6364            @return Returns true if the pickup is currently in use.
    6465            */
    65             inline bool isUsed(void)
    66                 { return this->used_; }
     66            inline bool isUsed(void) { return this->used_; }  // tolua_export
    6767            /**
    6868            @brief  Should be called when the pickup has transited from used to unused or the other way around.
     
    8787            @return Returns true if the Pickupable is currently picked up, false if not.
    8888            */
    89             inline bool isPickedUp(void)
    90                 { return this->pickedUp_; }
     89            inline bool isPickedUp(void) { return this->pickedUp_; }  // tolua_export
    9190            /**
    9291            @brief  Should be called when the pickup has transited from picked up to dropped or the other way around.
     
    142141            std::list<Identifier*> targets_; //!< The possible targets of this pickup.
    143142
    144     };
     143    };  // tolua_export
    145144   
    146145    SUPER_FUNCTION(10, Pickupable, changedUsed, false);
    147146    SUPER_FUNCTION(12, Pickupable, changedCarrier, false);
    148147    SUPER_FUNCTION(13, Pickupable, changedPickedUp, false);
    149 }
     148}  // tolua_export
    150149
    151150#endif /* _Pickupable_H__ */
Note: See TracChangeset for help on using the changeset viewer.