Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 29, 2015, 11:27:32 PM (9 years ago)
Author:
fvultier
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/fabienHS15/src/modules/overlays/hud/HUDWeaponMode.cc

    r10688 r10721  
    4949        RegisterObject(HUDWeaponMode);
    5050
     51        weaponIndex_ = 0;
     52        weaponModeIndex_ = 0;
     53
    5154        overlayElementIcon_ = static_cast<Ogre::PanelOverlayElement* >(Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "HUDWeaponMode" + getUniqueNumberString()));
    5255        overlayElementIcon_->setPosition(0.0f,0.0f);
     
    8083        textOverlayLeft_->setPickPoint(Vector2(0.0f,0.0f));
    8184        textOverlayLeft_->setVisible(true);
    82         textOverlayLeft_->setAlignment(OverlayText::Left);
     85        textOverlayLeft_->setAlignment(OverlayText::Center);
    8386        textOverlayLeft_->setTextSize(0.02f);
    8487        textOverlayLeft_->setColour(ColourValue(0.21,0.70,0.21,1.0));
    85         textOverlayLeft_->setPosition(getPosition());
    86         textOverlayLeft_->setAspectCorrection(this->getAspectCorrection());
     88        textOverlayLeft_->setAspectCorrection(false);
    8789       
    8890        this->textOverlayRight_ = new OverlayText(this->getContext());
     
    9193        textOverlayRight_->setPickPoint(Vector2(0.0f,0.0f));
    9294        textOverlayRight_->setVisible(true);
    93         textOverlayRight_->setAlignment(OverlayText::Left);
     95        textOverlayRight_->setAlignment(OverlayText::Center);
    9496        textOverlayRight_->setTextSize(0.02f);
    9597        textOverlayRight_->setColour(ColourValue(0.21,0.70,0.21,1.0));
    96         textOverlayRight_->setPosition(getPosition());
    97         textOverlayRight_->setAspectCorrection(this->getAspectCorrection());       
     98        textOverlayRight_->setAspectCorrection(false);
    9899
    99100        materialNameState_ = "Orxonox/WSHUD_Reloading";
     
    106107        if (this->isInitialized())
    107108        {
    108             //this->textOverlay_->destroy();           
    109         }
     109            //this->textOverlay_->destroy();
     110        }
     111    }
     112
     113    void HUDWeaponMode::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     114    {
     115        SUPER(HUDWeaponMode, XMLPort, xmlelement, mode);
    110116    }
    111117
     
    183189
    184190        positionHUDChilds();
    185     }   
     191    }
     192
     193    void HUDWeaponMode::sizeChanged()
     194    {
     195        OrxonoxOverlay::sizeChanged();
     196
     197        positionHUDChilds();
     198    }
    186199
    187200    void HUDWeaponMode::changedOwner()
     
    190203
    191204        this->owner_ = orxonox_cast<Pawn*>(this->getOwner());
    192 
    193         //updateWeaponsList();
    194205    }
    195206
     
    206217        SUPER(HUDWeaponMode, changedVisibility);
    207218
    208         //this->textOverlay_->setVisible(this->isVisible());
     219        this->textOverlayLeft_->setVisible(this->isVisible());
     220        this->textOverlayRight_->setVisible(this->isVisible());
    209221    }
    210222
     
    248260                overlayElementMunition_->setMaterialName("Orxonox/WSHUD_MunitionSeparate");
    249261            }
    250         }     
     262        }
    251263    }
    252264
    253265    void HUDWeaponMode::positionHUDChilds()
    254266    {
    255         textOverlayLeft_->setPosition(getPosition() + Vector2(0.06f,0.0f));
    256         textOverlayRight_->setPosition(getPosition() + Vector2(0.105f,0.0f));
    257     } 
     267        Vector2 size = Vector2(getSize().x*45.0f/150.0f, getSize().y);
     268        Vector2 offset1 = Vector2(getSize().x*82.5f/150.0f, 0.0f);
     269        Vector2 offset2 = Vector2(getSize().x*127.5f/150.0f, 0.0f);
     270
     271        textOverlayLeft_->setPosition(getPosition() + offset1);
     272        textOverlayRight_->setPosition(getPosition() + offset2);
     273
     274        textOverlayLeft_->setSize(size);
     275        textOverlayRight_->setSize(size);
     276
     277        textOverlayLeft_->setTextSize(getSize().y);
     278        textOverlayRight_->setTextSize(getSize().y);
     279    }
     280
     281    void HUDWeaponMode::updateSize()
     282    {
     283        this->setSize(weaponModeHUDActualSize_);
     284        updatePosition();
     285    }
     286
     287    void HUDWeaponMode::updatePosition()
     288    {
     289        this->setPosition(Vector2(weaponModeHUDActualSize_.x*weaponIndex_,weaponModeHUDActualSize_.y*weaponModeIndex_));
     290    }     
    258291}
Note: See TracChangeset for help on using the changeset viewer.