Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6675


Ignore:
Timestamp:
Apr 2, 2010, 5:35:14 PM (15 years ago)
Author:
dafrick
Message:

Lua bugs fixed.
Renamed name and description in PickupRepresentation to pickupName and pickupDescription to avoid problems.
More work on PickupInventory.

Location:
code/branches/pickup4
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickup4/data/gui/schemes/OrxonoxGUIScheme.scheme

    r5951 r6675  
    22<GUIScheme Name="OrxonoxGUI">
    33    <Imageset Name="MainMenuBackground" Filename="MainMenuBackground.imageset"/>
     4    <Imageset Name="PickupInventory" Filename="PickupInventory.imageset"/>
    45</GUIScheme>
  • code/branches/pickup4/data/gui/scripts/InitialiseGUI.lua

    r6417 r6675  
    223223end
    224224
     225--TODO: Needed?
    225226function test(e)
    226227    debug(0, "Blubb")
  • code/branches/pickup4/data/gui/scripts/PickupInventory.lua

    r6669 r6675  
    2323    P.visible = true
    2424   
    25     table.insert(P.carrierList, 4)
    26    
    2725    local pickupManager = orxonox.PickupManager:getInstance()
    2826    local carrier = pickupManager:getPawn()
    29     P.getCarrierList(carrier)
    3027   
     28    local root = winMgr:getWindow("orxonox/PickupInventory/Inventory")
     29   
     30    P.getCarrierList(carrier)   
    3131    for k,v in pairs(P.carrierList) do
    32         local args = {}
    33         table.insert(args, v)
    34         table.insert(args, k)
    35         local window = P.createCarrierBox(args)
     32        local window = P.createCarrierBox(v,k)
     33        root:addChildWindow(window);
    3634    end
     35
    3736end
    3837
     
    5958end
    6059
    61 function P.createCarrierBox(args)
    62     local carrier = args[1]
    63     local index = args[2]
    64    
     60function P.createCarrierBox(carrier, index)
     61
    6562    local name = "orxonox/PickupInventory/Carrier" .. index
    6663    local window = winMgr:createWindow("TaharezLook/StaticText", name .. "/Title")
     64    --TODO: Align text to the top
    6765    window:setText(carrier:getCarrierName())
    68     -- TODO: Does this exist?
    69     local height = window:getHeight()
    7066   
    7167    local box = winMgr:createWindow("TaharezLook/ScrollablePane", name .. "/Box")
    72     box:setPosition(CEGUI.UVector2(CEGUI.UDim(0.05, 0), CEGUI.UDim(0, height)))
    73     box:setWidth(CEGUI.UDim(0.9, 0))
     68    box:setPosition(CEGUI.UVector2(CEGUI.UDim(0.05, 0), CEGUI.UDim(0, 35)))
     69    box:setSize(CEGUI.UVector2(CEGUI.UDim(0.9, 0), CEGUI.UDim(1, 0)))
     70    window:addChildWindow(box)
    7471   
    75     local numPickups = orxonox.PickupManager.getInstance():getNumPickups(carrier)
     72    --Design parameters:
     73    imageHeight = 50
     74    textHeight = 30
     75   
     76    local numPickups = orxonox.PickupManager:getInstance():getNumPickups(carrier)
    7677    for i=0,numPickups-1,1 do
     78        local pickup = orxonox.PickupManager:getInstance():getPickupRepresentation(i, carrier)
    7779       
     80        local item = winMgr:createWindow("TaharezLook/StaticText", name .. "/Box/Pickup" .. i)
     81        item:setSize(CEGUI.UVector2(CEGUI.UDim(1, 0), CEGUI.UDim(0, imageHeight)))
     82        item:setPosition(CEGUI.UVector2(CEGUI.UDim(0, 0), CEGUI.UDim(0, (imageHeight+5)*i)))
     83        box:addChildWindow(item)
     84       
     85        local image = winMgr:createWindow("TaharezLook/StaticImage", name .. "/Box/Pickup" .. i .. "/Image")
     86        image:setProperty("Image", "set:PickupInventory image:" .. pickup:getInventoryRepresentation())
     87        image:setProperty("BackgroundEnabled", "set:False")
     88        image:setProperty("FrameEnabled", "set:True")
     89        image:setSize(CEGUI.UVector2(CEGUI.UDim(0, imageHeight), CEGUI.UDim(0, imageHeight)))
     90        item:addChildWindow(image)
     91       
     92        local title = winMgr:createWindow("TaharezLook/StaticText", name .. "/Box/Pickup" .. i .. "/Title")
     93        title:setPosition(CEGUI.UVector2(CEGUI.UDim(0, imageHeight+5), CEGUI.UDim(0, (imageHeight-textHeight)/2)))
     94        title:setSize(CEGUI.UVector2(CEGUI.UDim(0.4, 0), CEGUI.UDim(0, textHeight)))
     95        title:setText(pickup:getPickupName())
     96        item:addChildWindow(title)
     97       
     98        local useButton = winMgr:createWindow("TaharezLook/Button", name .. "/Box/Pickup" .. i .. "/UseButton")
     99        useButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.4, imageHeight+10),CEGUI.UDim(0, (imageHeight-textHeight)/2)))
     100        useButton:setSize(CEGUI.UVector2(CEGUI.UDim(0.2, 0), CEGUI.UDim(0, textHeight)))
     101        useButton:setText("use")
     102        orxonox.GUIManager:subscribeEventHelper(useButton, "Clicked", P.filename .. ".InventoryUseButton_clicked")
     103        item:addChildWindow(useButton)
     104       
     105        local dropButton = winMgr:createWindow("TaharezLook/Button", name .. "/Box/Pickup" .. i .. "/DropButton")
     106        dropButton:setPosition(CEGUI.UVector2(CEGUI.UDim(0.6, imageHeight+15),CEGUI.UDim(0, (imageHeight-textHeight)/2)))
     107        dropButton:setSize(CEGUI.UVector2(CEGUI.UDim(0.2, 0), CEGUI.UDim(0, textHeight)))
     108        dropButton:setText("drop")
     109        orxonox.GUIManager:subscribeEventHelper(dropButton, "Clicked", P.filename .. ".InventoryDropButton_clicked")
     110        item:addChildWindow(dropButton)
    78111    end
    79112   
     
    81114end
    82115
     116function P.windowToCarrierHelper(e)
     117    local we = CEGUI.toWindowEventArgs(e)
     118    local name = we.window:getName()
     119    debug(0, "Name: " .. name)
     120
     121    local match = string.gmatch(name, "%d+")
     122    local carrierNr = tonumber(match())
     123    local pickupNr = tonumber(match())
     124
     125    local arguments = {}
     126    arguments[1] = carrierNr
     127    arguments[2] = pickupNr
     128    return arguments
     129end
     130
    83131function P.InventoryUseButton_clicked(e)
    84 
     132    local arguments = P.windowToCarrierHelper(e)
     133    debug(0, "(Buh: " .. arguments[1] .. "|" .. arguments[2] .. ")")
     134    orxonox.PickupManager:getInstance():usePickup(arguments[2], P.carrierList[arguments[1]], 1)
    85135end
    86136
    87137function P.InventoryDropButton_clicked(e)
    88 
     138    local arguments = P.windowToCarierHelper(e)
     139    orxonox.PickupManager:getInstance():dropPickup(arguments[2], P.carrierList[arguments[1]])
    89140end
    90141
  • code/branches/pickup4/data/levels/includes/pickups.oxi

    r6524 r6675  
    11<PickupRepresentation
    2     name = "Small Health Boost"
    3     description = "Adds a small amout of health to the ship."
     2    pickupName = "Small Health Boost"
     3    pickupDescription = "Adds a small amout of health to the ship."
    44    spawnerTemplate = "smallhealthpickupRepresentation"
    55>
     
    1010
    1111<PickupRepresentation
    12     name = "Medium Health Boost"
    13     description = "Adds a medium amout of health to the ship."
     12    pickupName = "Medium Health Boost"
     13    pickupDescription = "Adds a medium amout of health to the ship."
    1414    spawnerTemplate = "mediumhealthpickupRepresentation"
    1515>
     
    2020
    2121<PickupRepresentation
    22     name = "Huge Health Boost"
    23     description = "Adds a huge amout of health to the ship."
     22    pickupName = "Huge Health Boost"
     23    pickupDescription = "Adds a huge amout of health to the ship."
    2424    spawnerTemplate = "hugehealthpickupRepresentation"
    2525>
     
    3030
    3131<PickupRepresentation
    32     name = "Crazy Madness Health Boost"
    33     description = "Adds a crazy amout of health to the ship."
     32    pickupName = "Crazy Madness Health Boost"
     33    pickupDescription = "Adds a crazy amout of health to the ship."
    3434    spawnerTemplate = "crazyhealthpickupRepresentation"
    3535>
     
    4040
    4141<PickupRepresentation
    42     name = "Double Pickup"
    43     description = "Does stuff."
     42    pickupName = "Double Pickup"
     43    pickupDescription = "Does stuff."
    4444    spawnerTemplate = "crazyhealthpickupRepresentation"
    4545>
  • code/branches/pickup4/data/levels/pickup.oxw

    r6524 r6675  
    3737    <PickupSpawner position="-50,0,-100" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
    3838        <pickup>
    39             <HealthPickup health=50 healthRate=5 durationType=continuous activationType=immediate healthType=permanent />
     39            <HealthPickup health=50 healthRate=5 durationType=continuous activationType=onUse healthType=permanent />
     40        </pickup>
     41    </PickupSpawner>
     42   
     43    <PickupSpawner position="-50,0,-125" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
     44        <pickup>
     45            <HealthPickup health=50 healthRate=5 durationType=continuous activationType=onUse healthType=permanent />
    4046        </pickup>
    4147    </PickupSpawner>
  • code/branches/pickup4/src/modules/pickup/PickupManager.cc

    r6669 r6675  
    127127    }
    128128   
    129     unsigned int PickupManager::getNumCarrierChildren(PickupCarrier* carrier)
     129    int PickupManager::getNumCarrierChildren(PickupCarrier* carrier)
    130130    {
    131131        if(carrier == NULL)
     
    134134    }
    135135           
    136     PickupCarrier* PickupManager::getCarrierChild(unsigned int index, PickupCarrier* carrier)
     136    PickupCarrier* PickupManager::getCarrierChild(int index, PickupCarrier* carrier)
    137137    {
     138        if(carrier == NULL)
     139            return NULL;
    138140        return carrier->getCarrierChild(index);
    139141    }
    140142   
    141     PickupRepresentation* PickupManager::getPickupRepresentation(unsigned int index, PickupCarrier* carrier)
     143    const std::string& PickupManager::getCarrierName(orxonox::PickupCarrier* carrier)
     144    {
     145        if(carrier == NULL)
     146            return BLANKSTRING;
     147        return carrier->getCarrierName();
     148    }
     149   
     150    PickupRepresentation* PickupManager::getPickupRepresentation(int index, PickupCarrier* carrier)
    142151    {
    143152        Pickupable* pickup = carrier->getPickup(index);
     
    149158   
    150159
    151     unsigned int PickupManager::getNumPickups(PickupCarrier* carrier)
     160    int PickupManager::getNumPickups(PickupCarrier* carrier)
    152161    {
     162        if(carrier == NULL)
     163            return 0;
    153164        return carrier->getNumPickups();
    154165    }
    155166   
    156     void PickupManager::dropPickup(unsigned int index, PickupCarrier* carrier)
     167    void PickupManager::dropPickup(int index, PickupCarrier* carrier)
    157168    {
    158169        Pickupable* pickup = carrier->getPickup(index);
     
    160171    }
    161172   
    162     void PickupManager::usePickup(unsigned int index, PickupCarrier* carrier, bool use)
     173    void PickupManager::usePickup(int index, PickupCarrier* carrier, bool use)
    163174    {
    164175        Pickupable* pickup = carrier->getPickup(index);
  • code/branches/pickup4/src/modules/pickup/PickupManager.h

    r6669 r6675  
    7272            orxonox::PickupCarrier* getPawn(void);
    7373           
    74             unsigned int getNumCarrierChildren(orxonox::PickupCarrier* carrier);
    75             orxonox::PickupCarrier* getCarrierChild(unsigned int index, orxonox::PickupCarrier* carrier);
     74            int getNumCarrierChildren(orxonox::PickupCarrier* carrier);
     75            orxonox::PickupCarrier* getCarrierChild(int index, orxonox::PickupCarrier* carrier);
    7676           
    77             unsigned int getNumPickups(orxonox::PickupCarrier* carrier);
    78             PickupRepresentation* getPickupRepresentation(unsigned int index, orxonox::PickupCarrier* carrier);
    79             void dropPickup(unsigned int index, orxonox::PickupCarrier* carrier);
    80             void usePickup(unsigned int index, orxonox::PickupCarrier* carrier, bool use);
     77            const std::string& getCarrierName(orxonox::PickupCarrier* carrier);
     78           
     79            int getNumPickups(orxonox::PickupCarrier* carrier);
     80            PickupRepresentation* getPickupRepresentation(int index, orxonox::PickupCarrier* carrier);
     81            void dropPickup(int index, orxonox::PickupCarrier* carrier);
     82            void usePickup(int index, orxonox::PickupCarrier* carrier, bool use);
    8183            // tolua_end
    8284           
  • code/branches/pickup4/src/modules/pickup/PickupRepresentation.cc

    r6632 r6675  
    8686        this->name_ = "Pickup";
    8787        this->spawnerTemplate_ = "";
    88         this->inventoryRepresentation_ = "";
     88        this->inventoryRepresentation_ = "Default";
    8989        this->pickup_ = NULL;
    9090    }
     
    9898        SUPER(PickupRepresentation, XMLPort, xmlelement, mode);
    9999       
    100         XMLPortParam(PickupRepresentation, "name", setName, getName, xmlelement, mode);
    101         XMLPortParam(PickupRepresentation, "description", setDescription, getDescription, xmlelement, mode);
     100        XMLPortParam(PickupRepresentation, "pickupName", setPickupName, getPickupName, xmlelement, mode);
     101        XMLPortParam(PickupRepresentation, "pickupDescription", setPickupDescription, getPickupDescription, xmlelement, mode);
    102102        XMLPortParam(PickupRepresentation, "spawnerTemplate", setSpawnerTemplate, getSpawnerTemplate, xmlelement, mode);
    103103        XMLPortParam(PickupRepresentation, "inventoryRepresentation", setInventoryRepresentation, getInventoryRepresentation, xmlelement, mode);
  • code/branches/pickup4/src/modules/pickup/PickupRepresentation.h

    r6632 r6675  
    6868            @param name The name.
    6969            */
    70             inline void setName(const std::string& name)
     70            inline void setPickupName(const std::string& name)
    7171                { this->name_ = name; }
    7272            /**
     
    7474            @param description The Description.
    7575            */
    76             inline void setDescription(const std::string& description)
     76            inline void setPickupDescription(const std::string& description)
    7777                { this->description_ = description; }
    7878            /**
     
    107107            @return Returns the name.
    108108            */
    109             inline const std::string& getName(void) { return this->name_; } // tolua_export
     109            inline const std::string& getPickupName(void) { return this->name_; } // tolua_export
    110110            /**
    111111            @brief Get the description of the Pickupable represented by this PickupRepresentation.
    112112            @return Returns the description.
    113113            */
    114             inline const std::string& getDescription(void) { return this->description_; } // tolua_export
     114            inline const std::string& getPickupDescription(void) { return this->description_; } // tolua_export
    115115            /**
    116116            @brief Get the name of spawnerTemplate the Pickupable represented by this PickupRepresentation.
  • code/branches/pickup4/src/orxonox/worldentities/pawns/Pawn.cc

    r6540 r6675  
    7878        else
    7979            this->weaponSystem_ = 0;
     80       
     81        this->setCarrierName("Pawn");
    8082
    8183        this->setRadarObjectColour(ColourValue::Red);
Note: See TracChangeset for help on using the changeset viewer.