Exemple #1
0
void MWSpell::createEffectWidgets(std::vector<MyGUI::Widget*> &effects, MyGUI::Widget* creator, MyGUI::IntCoord &coord, int flags)
{
    const MWWorld::ESMStore &store =
        MWBase::Environment::get().getWorld()->getStore();

    const ESM::Spell *spell = store.get<ESM::Spell>().search(mId);
    MYGUI_ASSERT(spell, "spell with id '" << mId << "' not found");

    MWSpellEffectPtr effect = NULL;
    std::vector<ESM::ENAMstruct>::const_iterator end = spell->mEffects.mList.end();
    for (std::vector<ESM::ENAMstruct>::const_iterator it = spell->mEffects.mList.begin(); it != end; ++it)
    {
        effect = creator->createWidget<MWSpellEffect>("MW_EffectImage", coord, MyGUI::Align::Default);
        effect->setWindowManager(mWindowManager);
        SpellEffectParams params;
        params.mEffectID = it->mEffectID;
        params.mSkill = it->mSkill;
        params.mAttribute = it->mAttribute;
        params.mDuration = it->mDuration;
        params.mMagnMin = it->mMagnMin;
        params.mMagnMax = it->mMagnMax;
        params.mRange = it->mRange;
        params.mIsConstant = (flags & MWEffectList::EF_Constant);
        params.mNoTarget = (flags & MWEffectList::EF_NoTarget);
        effect->setSpellEffect(params);
        effects.push_back(effect);
        coord.top += effect->getHeight();
        coord.width = std::max(coord.width, effect->getRequestedWidth());
    }
}
Exemple #2
0
void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord)
{
    ESMS::ESMStore &store = mWindowManager->getStore();
    const ESM::Spell *spell = store.spells.search(id);
    MYGUI_ASSERT(spell, "spell with id '" << id << "' not found");

    MWSpellEffectPtr effect = nullptr;
    std::vector<ESM::ENAMstruct>::const_iterator end = spell->effects.list.end();
    for (std::vector<ESM::ENAMstruct>::const_iterator it = spell->effects.list.begin(); it != end; ++it)
    {
        effect = creator->createWidget<MWSpellEffect>("MW_EffectImage", coord, MyGUI::Align::Default);
        effect->setWindowManager(mWindowManager);
        effect->setSpellEffect(*it);
        effects.push_back(effect);
        coord.top += effect->getHeight();
    }
}
Exemple #3
0
void MWEffectList::createEffectWidgets(std::vector<MyGUI::Widget*> &effects, MyGUI::Widget* creator, MyGUI::IntCoord &coord, bool center, int flags)
{
    // We don't know the width of all the elements beforehand, so we do it in
    // 2 steps: first, create all widgets and check their width....
    MWSpellEffectPtr effect = NULL;
    int maxwidth = coord.width;

    for (SpellEffectList::iterator it=mEffectList.begin();
            it != mEffectList.end(); ++it)
    {
        effect = creator->createWidget<MWSpellEffect>("MW_EffectImage", coord, MyGUI::Align::Default);
        effect->setWindowManager(mWindowManager);
        it->mIsConstant = (flags & EF_Constant) || it->mIsConstant;
        it->mNoTarget = (flags & EF_NoTarget) || it->mNoTarget;
        effect->setSpellEffect(*it);
        effects.push_back(effect);
        if (effect->getRequestedWidth() > maxwidth)
            maxwidth = effect->getRequestedWidth();

        coord.top += effect->getHeight();
    }

    // ... then adjust the size for all widgets
    for (std::vector<MyGUI::Widget*>::iterator it = effects.begin(); it != effects.end(); ++it)
    {
        effect = static_cast<MWSpellEffectPtr>(*it);
        bool needcenter = center && (maxwidth > effect->getRequestedWidth());
        int diff = maxwidth - effect->getRequestedWidth();
        if (needcenter)
        {
            effect->setCoord(diff/2, effect->getCoord().top, effect->getRequestedWidth(), effect->getCoord().height);
        }
        else
        {
            effect->setCoord(0, effect->getCoord().top, effect->getRequestedWidth(), effect->getCoord().height);
        }
    }

    // inform the parent about width
    coord.width = maxwidth;
}