Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11325 for code


Ignore:
Timestamp:
Dec 8, 2016, 6:34:27 PM (7 years ago)
Author:
patricwi
Message:

visualization finished, bug when ending or reloading the level

Location:
code/branches/HUD_HS16/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.cc

    r11323 r11325  
    5252
    5353        overlayElement_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", name ));
    54         // overlayElement_->setName(name);
    5554
    56         overlayElement_->setDimensions(0.1f,0.1f);
     55        overlayElement_->setDimensions(0.075f,0.1f);
    5756       
    5857    }
     
    7574    }
    7675
    77     void HUDPickupItem::hideMe(Pickupable* p)
     76    void HUDPickupItem::hideMe(Pickupable* p, bool repaint)
    7877    {
     78        if(!repaint) return;                     //dont do anything, if we are not allowed to repaint because the level is terminating
    7979        assert(overlayElement_);
    8080        assert(this->background_);
     
    9191        // orxout() << "after the call the element is visible: " << overlayElement_->isVisible() << endl;
    9292    }
    93 
    94     // void HUDWeapon::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    95     // {
    96     //     SUPER(HUDWeapon, XMLPort, xmlelement, mode);
    97 
    98     //     XMLPortParam(HUDWeapons, "sensitivity", setRadarSensitivity, getRadarSensitivity, xmlelement, mode);
    99     //     XMLPortParam(HUDWeapons, "halfDotSizeDistance", setHalfDotSizeDistance, getHalfDotSizeDistance, xmlelement, mode);
    100     // }
    101 
    102     // void HUDWeapon::tick(float dt)
    103     // {
    104     //     SUPER(HUDWeapon, tick, dt);
    105 
    106     //     if (!weapon_)
    107     //     {
    108     //         // TODO: destroy this HUD id the Weapon does no more exist. (Wehen the weak pointer is null)
    109     //     }
    110     // }   
    111 
    112     // void HUDWeapon::positionChanged()
    113     // {
    114     //     OrxonoxOverlay::positionChanged();
    115 
    116     //     positionHUDChilds();
    117     // }
    118 
    119     // void HUDWeapon::sizeChanged()
    120     // {
    121     //     OrxonoxOverlay::sizeChanged();
    122 
    123     //     positionHUDChilds();
    124     // }
    125 
    126     // void HUDWeapon::changedOwner()
    127     // {
    128     //     SUPER(HUDWeapon, changedOwner);
    129 
    130     //     this->owner_ = orxonox_cast<Pawn*>(this->getOwner());
    131 
    132     //     updateWeaponModeList();
    133     // }
    134 
    135     // void HUDWeapon::changedOverlayGroup()
    136     // {
    137     //     SUPER(HUDWeapon, changedOverlayGroup);
    138     // }   
    139 
    140     // void HUDWeapon::changedVisibility()
    141     // {
    142     //     SUPER(HUDWeapon, changedVisibility);
    143 
    144     //     bool visible = this->isVisible();
    145 
    146     //     for (HUDWeaponMode* hudWeaponMode : hudWeaponModes_)
    147     //     {
    148     //         hudWeaponMode->changedVisibility(); //inform all Child Overlays that our visibility has changed
    149     //         hudWeaponMode->setVisible(visible);
    150     //     }
    151     // }
    152 
    153     // void HUDWeapon::changedName()
    154     // {
    155     //     SUPER(HUDWeapon, changedName);
    156     // }
    157 
    158     // void HUDWeapon::setWeapon(Weapon* weapon)
    159     // {
    160     //     weapon_ = weapon;
    161 
    162     //     if (!weapon_)
    163     //     {
    164     //         return;
    165     //     }
    166 
    167     //     updateWeaponModeList();
    168     // }
    169 
    170     // void HUDWeapon::updateWeaponModeList()
    171     // {
    172     //     if (owner_ == nullptr || weapon_ == nullptr)
    173     //     {
    174     //         return;
    175     //     }
    176            
    177     //     destroyHUDChilds();
    178 
    179     //     updateSize();
    180     //     createHUDChilds();
    181     //     positionHUDChilds();
    182     // } 
    183 
    184     // void HUDWeapon::createHUDChilds()
    185     // {
    186     //     if (weapon_ == nullptr)
    187     //     {
    188     //         return;
    189     //     }
    190 
    191     //     int positionIndex = 0;
    192 
    193     //     for (const auto& mapEntry : weapon_->getAllWeaponmodes())
    194     //     {
    195     //         HUDWeaponMode* hudWeaponMode = new HUDWeaponMode(this->getContext());
    196     //         hudWeaponMode->setOwner(owner_);
    197     //         hudWeaponMode->setOverlayGroup(this->getOverlayGroup());
    198     //         hudWeaponMode->setVisible(this->isVisible());
    199     //         hudWeaponMode->setWeaponMode(mapEntry.second);
    200     //         hudWeaponMode->setWeaponIndex(this->weaponIndex_);                   
    201     //         hudWeaponMode->setAspectCorrection(false);
    202     //         hudWeaponMode->setPickPoint(Vector2(0.0f,0.0f));
    203 
    204     //         hudWeaponModes_.push_back(hudWeaponMode);
    205 
    206     //         ++ positionIndex;
    207     //     }
    208     // }     
    209 
    210     // void HUDWeapon::positionHUDChilds()
    211     // {
    212     //     int positionIndex = 0;
    213 
    214     //     for (HUDWeaponMode* hudWeaponMode : hudWeaponModes_)
    215     //     {
    216     //         hudWeaponMode->setPositionOffset(this->positionOffset_);
    217     //         hudWeaponMode->setWeaponModeIndex(positionIndex);
    218     //         hudWeaponMode->setWeaponIndex(this->weaponIndex_);
    219     //         hudWeaponMode->setWeaponModeHUDActualSize(this->weaponModeHUDActualSize_);
    220 
    221     //         ++ positionIndex;
    222     //     }
    223     // } 
    224 
    225     // void HUDWeapon::destroyHUDChilds()
    226     // {
    227     //     for (HUDWeaponMode* hudWeaponMode : hudWeaponModes_)
    228     //     {
    229     //         hudWeaponMode->destroy();
    230     //     }
    231 
    232     //     hudWeaponModes_.clear();
    233     // }
    234 
    235     // void HUDWeapon::updateSize()
    236     // {
    237     //     if (weapon_ != nullptr)
    238     //     {
    239     //         this->setSize(Vector2(weaponModeHUDActualSize_.x,weaponModeHUDActualSize_.y*weapon_->getAllWeaponmodes().size()));
    240     //         updatePosition();
    241     //     }       
    242     // }
    243 
    244     // void HUDWeapon::updatePosition()
    245     // {
    246     //     if (weapon_ != nullptr)
    247     //     {
    248     //         this->setPosition(Vector2(weaponModeHUDActualSize_.x*weaponIndex_,0.0f) + this->positionOffset_);
    249     //     }       
    250     // }       
    25193}
  • code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.h

    r11323 r11325  
    3838        // void setPickup(Pickup* pickup); 
    3939        void initializeMaterial(const std::string& s, float x, float y); 
    40         void hideMe(Pickupable* p);
     40        void hideMe(Pickupable* p, bool repaint);
    4141
    4242    private:
  • code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.cc

    r11323 r11325  
    5151        overlayElement_->setPosition(0.0f,0.0f);
    5252        overlayElement_->setDimensions(0.70f,0.15f);
    53         orxout() << "hello here is the HUDPickupSystem" << endl;
    5453        this->background_->addChild(overlayElement_);
    5554    }
     
    6362    }
    6463
    65    //TODO: XMLPort
    66 
    6764    void HUDPickupSystem::updatePickupList(std::vector<Pickupable*> picks)
    6865    {
    6966        int i=0;
    70         const float offsetX = 0.32f;
     67        const float offsetX = 0.335f;
    7168        float offsetY = 0.77f;
    7269        const float x = 0.1f;
     
    8885                {
    8986                    HUDPickupItem* item = new HUDPickupItem(this->getContext());
    90                     // item->initializeMaterial(((Pickup*)p)->getRepresentationName(), offsetX+i*x, offsetY);
    91                 if(i%2==0)
    92                     item->initializeMaterial("Shield", offsetX+i*x, offsetY);
    93                 else
    94                     item->initializeMaterial("ArrowUp", offsetX+i*x, offsetY);
    95                 item->setOverlayGroup(this->getOverlayGroup());
    96                 this->picks[p] = item;
     87                    item->initializeMaterial(this->getIcon(((Pickup*)p)->getRepresentationName()), offsetX+i*x, offsetY);
     88                    orxout() << ((Pickup*)p)->getRepresentationName() << endl;
     89               
     90                    item->setOverlayGroup(this->getOverlayGroup());
     91                    this->picks[p] = item;
    9792                }
    9893               
     
    113108        assert(item);
    114109        // item->setOverlayGroup(nullptr);
    115         item->hideMe(pickup);
     110        item->hideMe(pickup, repaint);
    116111        assert(overlayElement_);
    117112        // overlayElement_->_update();
     
    125120        this->background_->removeChild(overlayElement_->getName());
    126121    }
     122
     123    std::string HUDPickupSystem::getIcon(std::string repName)
     124    {
     125        if(repName.find("invisible", 0)!=std::string::npos) return "Eye";
     126        else if(repName.find("tri", 0)!=std::string::npos) return "Asterix";
     127        else if(repName.find("health", 0)!=std::string::npos || repName.find("Health", 0)!=std::string::npos) return "Cross";
     128        else if(repName.find("shield", 0)!=std::string::npos) return "Shield";
     129        else if(repName.find("munition", 0)!=std::string::npos) return "Munition";
     130        else if(repName.find("shrink", 0)!=std::string::npos) return "Shrink";
     131        else if(repName.find("boost", 0)!=std::string::npos) return "Flash";
     132        else if(repName.find("speed", 0)!=std::string::npos) return "3arrowsup";
     133        else if(repName.find("drone", 0)!=std::string::npos) return "Damage";
     134        //        else if(repName.find("xxxxxxx", 0)!=std::string::npos) return "Splash";
     135        else return "Unknown";
     136    }
    127137}
  • code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.h

    r11314 r11325  
    6666        void createPickupList(); 
    6767        void removePickup(Pickupable* pickup);
     68
     69        bool repaint=true;
     70
    6871    private:
    6972       
    7073        void destroyAll();
     74        std::string getIcon(std::string repName);
    7175
    7276        std::map<Pickupable*, HUDPickupItem*> picks;
  • code/branches/HUD_HS16/src/modules/pickup/PickupManager.cc

    r11323 r11325  
    314314
    315315            this->indexes_.erase(pickup);
    316             this->pickups_.find(index)->second=nullptr; //set to null, so that can be identified as free slot by getPickupIndex()
     316            this->pickups_.erase(index); //set to null, so that can be identified as free slot by getPickupIndex()
    317317
    318318
     
    355355        PickupManager& manager = PickupManager::getInstance();
    356356
     357        if(!manager.pickups_.count(index)) return; //if pickup is no longer here, dont do anything
     358
    357359        Pickupable* pickup=manager.pickups_.find(index)->second;
    358360        if(pickup==nullptr)
     
    364366        orxout() << "The pickup is being used: " << pickup->isUsed() << endl;
    365367
    366         pickup->drop(true);
     368        manager.dropPickup(index);
     369
    367370        // if(pickup->isUsed())
    368371        //     manager.usePickup(index, false);
     
    557560        for(uint32_t i=0; i<10; i++)
    558561        {
    559             if(pickups_.find(i)->second==nullptr) return i;
     562            if(!pickups_.count(i)) return i;
    560563        }
    561564        //all slots are full and we have to drop sth
  • code/branches/HUD_HS16/src/orxonox/CMakeLists.txt

    r11080 r11325  
    2020INCLUDE_DIRECTORIES(
    2121  ${CMAKE_SOURCE_DIR}/src/libraries
     22  ${CMAKE_SOURCE_DIR}/src/modules
    2223  ${CMAKE_CURRENT_SOURCE_DIR}
    2324)
Note: See TracChangeset for help on using the changeset viewer.