Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 26, 2008, 7:00:59 PM (17 years ago)
Author:
rgrieder
Message:

some adjustment to the default value setting in the overlay files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/overlays/hud/HUDBar.cc

    r1626 r1627  
    5555        BaseObject::XMLPort(xmlElement, mode);
    5656
    57         XMLPortParam(BarColour, "colour", setColour, getColour, xmlElement, mode);
    58         XMLPortParam(BarColour, "position", setPosition, getPosition, xmlElement, mode);
     57        if (mode == XMLPort::LoadObject)
     58        {
     59            this->setColour(ColourValue(1.0, 1.0, 1.0, 1.0));
     60            this->setPosition(0.0f);
     61        }
     62
     63        XMLPortParam(BarColour, "colour", setColour, getColour, xmlElement, mode)
     64            .defaultValues(ColourValue(1.0, 1.0, 1.0, 1.0));
     65        XMLPortParam(BarColour, "position", setPosition, getPosition, xmlElement, mode).defaultValues(0.0f);
    5966    }
    6067
     
    9097            this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, ColourValue(0.2, 0.7, 0.2));
    9198
    92             // create bar
    93             barWidth_s = 0.88f;
    94             barHeight_s = 1.0f;
    95             barOffsetLeft_s = 0.06f;
    96             barOffsetTop_s = 0.0f;
    97 
    9899            this->bar_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
    99100                .createOverlayElement("Panel", "HUDBar_bar_" + getUniqueNumberStr()));
     
    101102            this->background_->addChild(bar_);
    102103
    103             this->setValue(0);
    104             this->autoColour_ = true;
    105             this->right2Left_ = false; // default is left to right progress
     104            this->setValue(0.0f);
     105            this->setRightToLeft(false);
     106            this->setAutoColour(true);
    106107        }
    107108
    108         XMLPortParamLoadOnly(HUDBar, "value", setValue, xmlElement, mode);
    109         XMLPortParam(HUDBar, "right2left", setRightToLeft, getRightToLeft, xmlElement, mode);
     109        XMLPortParam(HUDBar, "initialValue", setValue,       getValue,       xmlElement, mode).defaultValues(0.0f);
     110        XMLPortParam(HUDBar, "rightToLeft",   setRightToLeft, getRightToLeft, xmlElement, mode).defaultValues(false);
     111        XMLPortParam(HUDBar, "autoColour",   setAutoColour,  getAutoColour,  xmlElement, mode).defaultValues(true);
    110112        XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xmlElement, mode, false, true);
    111113    }
    112114
    113     void HUDBar::setValue(float value)
     115    void HUDBar::valueChanged()
    114116    {
    115         this->value_ = clamp<float>(value, 0, 1);
    116117        if (this->autoColour_ && this->textureUnitState_)
    117118        {
     
    153154        {
    154155            // backward casew
    155             this->bar_->setPosition(barOffsetLeft_s + barWidth_s * (1 - this->value_), barOffsetTop_s);
    156             this->bar_->setDimensions(barWidth_s * this->value_, barHeight_s);
     156            this->bar_->setPosition(0.06f + 0.88f * (1 - this->value_), 0.0f);
     157            this->bar_->setDimensions(0.88f * this->value_, 1.0f);
    157158        }
    158159        else
    159160        {
    160161            // default case
    161             this->bar_->setPosition(barOffsetLeft_s, barOffsetTop_s);
    162             this->bar_->setDimensions(barWidth_s * this->value_, barHeight_s);
     162            this->bar_->setPosition(0.06f, 0.0f);
     163            this->bar_->setDimensions(0.88f * this->value_, 1.0f);
    163164        }
    164165        if (this->value_ != 0)
Note: See TracChangeset for help on using the changeset viewer.