Changeset 11325 for code/branches/HUD_HS16
- Timestamp:
- Dec 8, 2016, 6:34:27 PM (8 years ago)
- 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 52 52 53 53 overlayElement_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", name )); 54 // overlayElement_->setName(name);55 54 56 overlayElement_->setDimensions(0. 1f,0.1f);55 overlayElement_->setDimensions(0.075f,0.1f); 57 56 58 57 } … … 75 74 } 76 75 77 void HUDPickupItem::hideMe(Pickupable* p )76 void HUDPickupItem::hideMe(Pickupable* p, bool repaint) 78 77 { 78 if(!repaint) return; //dont do anything, if we are not allowed to repaint because the level is terminating 79 79 assert(overlayElement_); 80 80 assert(this->background_); … … 91 91 // orxout() << "after the call the element is visible: " << overlayElement_->isVisible() << endl; 92 92 } 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 changed149 // 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 // }251 93 } -
code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupItem.h
r11323 r11325 38 38 // void setPickup(Pickup* pickup); 39 39 void initializeMaterial(const std::string& s, float x, float y); 40 void hideMe(Pickupable* p );40 void hideMe(Pickupable* p, bool repaint); 41 41 42 42 private: -
code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.cc
r11323 r11325 51 51 overlayElement_->setPosition(0.0f,0.0f); 52 52 overlayElement_->setDimensions(0.70f,0.15f); 53 orxout() << "hello here is the HUDPickupSystem" << endl;54 53 this->background_->addChild(overlayElement_); 55 54 } … … 63 62 } 64 63 65 //TODO: XMLPort66 67 64 void HUDPickupSystem::updatePickupList(std::vector<Pickupable*> picks) 68 65 { 69 66 int i=0; 70 const float offsetX = 0.3 2f;67 const float offsetX = 0.335f; 71 68 float offsetY = 0.77f; 72 69 const float x = 0.1f; … … 88 85 { 89 86 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; 97 92 } 98 93 … … 113 108 assert(item); 114 109 // item->setOverlayGroup(nullptr); 115 item->hideMe(pickup );110 item->hideMe(pickup, repaint); 116 111 assert(overlayElement_); 117 112 // overlayElement_->_update(); … … 125 120 this->background_->removeChild(overlayElement_->getName()); 126 121 } 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 } 127 137 } -
code/branches/HUD_HS16/src/modules/overlays/hud/HUDPickupSystem.h
r11314 r11325 66 66 void createPickupList(); 67 67 void removePickup(Pickupable* pickup); 68 69 bool repaint=true; 70 68 71 private: 69 72 70 73 void destroyAll(); 74 std::string getIcon(std::string repName); 71 75 72 76 std::map<Pickupable*, HUDPickupItem*> picks; -
code/branches/HUD_HS16/src/modules/pickup/PickupManager.cc
r11323 r11325 314 314 315 315 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() 317 317 318 318 … … 355 355 PickupManager& manager = PickupManager::getInstance(); 356 356 357 if(!manager.pickups_.count(index)) return; //if pickup is no longer here, dont do anything 358 357 359 Pickupable* pickup=manager.pickups_.find(index)->second; 358 360 if(pickup==nullptr) … … 364 366 orxout() << "The pickup is being used: " << pickup->isUsed() << endl; 365 367 366 pickup->drop(true); 368 manager.dropPickup(index); 369 367 370 // if(pickup->isUsed()) 368 371 // manager.usePickup(index, false); … … 557 560 for(uint32_t i=0; i<10; i++) 558 561 { 559 if( pickups_.find(i)->second==nullptr) return i;562 if(!pickups_.count(i)) return i; 560 563 } 561 564 //all slots are full and we have to drop sth -
code/branches/HUD_HS16/src/orxonox/CMakeLists.txt
r11080 r11325 20 20 INCLUDE_DIRECTORIES( 21 21 ${CMAKE_SOURCE_DIR}/src/libraries 22 ${CMAKE_SOURCE_DIR}/src/modules 22 23 ${CMAKE_CURRENT_SOURCE_DIR} 23 24 )
Note: See TracChangeset
for help on using the changeset viewer.