Пример #1
0
    void SpellWindow::cycle(bool next)
    {
        MWWorld::Ptr player = MWMechanics::getPlayer();

        if (MWBase::Environment::get().getMechanicsManager()->isAttackingOrSpell(player))
            return;

        const MWMechanics::CreatureStats &stats = player.getClass().getCreatureStats(player);
        if (stats.isParalyzed() || stats.getKnockedDown() || stats.isDead() || stats.getHitRecovery())
            return;

        mSpellView->setModel(new SpellModel(MWMechanics::getPlayer(), ""));

        SpellModel::ModelIndex selected = 0;
        for (SpellModel::ModelIndex i = 0; i<int(mSpellView->getModel()->getItemCount()); ++i)
        {
            if (mSpellView->getModel()->getItem(i).mSelected)
                selected = i;
        }

        selected += next ? 1 : -1;
        int itemcount = mSpellView->getModel()->getItemCount();
        if (itemcount == 0)
            return;
        selected = (selected + itemcount) % itemcount;

        const Spell& spell = mSpellView->getModel()->getItem(selected);
        if (spell.mType == Spell::Type_EnchantedItem)
            onEnchantedItemSelected(spell.mItem, spell.mActive);
        else
            onSpellSelected(spell.mId);
    }
Пример #2
0
 void SpellWindow::onModelIndexSelected(SpellModel::ModelIndex index)
 {
     const Spell& spell = mSpellView->getModel()->getItem(index);
     if (spell.mType == Spell::Type_EnchantedItem)
     {
         onEnchantedItemSelected(spell.mItem, spell.mActive);
     }
     else
     {
         onSpellSelected(spell.mId);
     }
 }
Пример #3
0
 void SpellWindow::onModelIndexSelected(SpellModel::ModelIndex index)
 {
     const Spell& spell = mSpellView->getModel()->getItem(index);
     if (spell.mType == Spell::Type_EnchantedItem)
     {
         onEnchantedItemSelected(spell.mItem, spell.mActive);
     }
     else
     {
         if (MyGUI::InputManager::getInstance().isShiftPressed())
             askDeleteSpell(spell.mId);
         else
             onSpellSelected(spell.mId);
     }
 }
Пример #4
0
    void SpellWindow::cycle(bool next)
    {
        mSpellView->setModel(new SpellModel(MWMechanics::getPlayer()));

        SpellModel::ModelIndex selected = 0;
        for (SpellModel::ModelIndex i = 0; i<int(mSpellView->getModel()->getItemCount()); ++i)
        {
            if (mSpellView->getModel()->getItem(i).mSelected)
                selected = i;
        }

        selected += next ? 1 : -1;
        int itemcount = mSpellView->getModel()->getItemCount();
        if (itemcount == 0)
            return;
        selected = (selected + itemcount) % itemcount;

        const Spell& spell = mSpellView->getModel()->getItem(selected);
        if (spell.mType == Spell::Type_EnchantedItem)
            onEnchantedItemSelected(spell.mItem, spell.mActive);
        else
            onSpellSelected(spell.mId);
    }