Пример #1
0
        void MWList::redraw(bool scrollbarShown)
        {
            const int _scrollBarWidth = 20; // fetch this from skin?
            const int scrollBarWidth = scrollbarShown ? _scrollBarWidth : 0;
            const int spacing = 3;
            size_t viewPosition = -mScrollView->getViewOffset().top;

            while (mScrollView->getChildCount())
            {
                MyGUI::Gui::getInstance().destroyWidget(mScrollView->getChildAt(0));
            }

            mItemHeight = 0;
            int i=0;
            for (std::vector<std::string>::const_iterator it=mItems.begin();
                it!=mItems.end(); ++it)
            {
                if (*it != "")
                {
                    MyGUI::Button* button = mScrollView->createWidget<MyGUI::Button>(
                        "MW_ListLine", MyGUI::IntCoord(0, mItemHeight, mScrollView->getSize().width - scrollBarWidth - 2, 24),
                        MyGUI::Align::Left | MyGUI::Align::Top, getName() + "_item_" + (*it));
                    button->setCaption((*it));
                    button->getSubWidgetText()->setWordWrap(true);
                    button->getSubWidgetText()->setTextAlign(MyGUI::Align::Left);
                    button->eventMouseWheel += MyGUI::newDelegate(this, &MWList::onMouseWheel);
                    button->eventMouseButtonClick += MyGUI::newDelegate(this, &MWList::onItemSelected);

                    int height = button->getTextSize().height;
                    button->setSize(MyGUI::IntSize(button->getSize().width, height));
                    button->setUserData(i);

                    mItemHeight += height + spacing;
                }
                else
                {
                    MyGUI::ImageBox* separator = mScrollView->createWidget<MyGUI::ImageBox>("MW_HLine",
                        MyGUI::IntCoord(2, mItemHeight, mScrollView->getWidth() - scrollBarWidth - 4, 18),
                        MyGUI::Align::Left | MyGUI::Align::Top | MyGUI::Align::HStretch);
                    separator->setNeedMouseFocus(false);

                    mItemHeight += 18 + spacing;
                }
                ++i;
            }
            mScrollView->setCanvasSize(mClient->getSize().width, std::max(mItemHeight, mClient->getSize().height));

            if (!scrollbarShown && mItemHeight > mClient->getSize().height)
                redraw(true);

            size_t viewRange = mScrollView->getCanvasSize().height;
            if(viewPosition > viewRange)
                viewPosition = viewRange;
            mScrollView->setViewOffset(MyGUI::IntPoint(0, -viewPosition));
        }
Пример #2
0
    void TrainingWindow::startTraining (MWWorld::Ptr actor)
    {
        mPtr = actor;

        MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
        int playerGold = player.getClass().getContainerStore(player).count(MWWorld::ContainerStore::sGoldId);

        mPlayerGold->setCaptionWithReplacing("#{sGold}: " + boost::lexical_cast<std::string>(playerGold));

        MWMechanics::NpcStats& npcStats = actor.getClass().getNpcStats (actor);

        // NPC can train you in his best 3 skills
        std::vector< std::pair<int, int> > skills;

        for (int i=0; i<ESM::Skill::Length; ++i)
        {
            int value = npcStats.getSkill (i).getBase ();

            skills.push_back(std::make_pair(i, value));
        }

        std::sort(skills.begin(), skills.end(), sortSkills);

        MyGUI::EnumeratorWidgetPtr widgets = mTrainingOptions->getEnumerator ();
        MyGUI::Gui::getInstance ().destroyWidgets (widgets);

        MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats (player);

        const MWWorld::Store<ESM::GameSetting> &gmst =
            MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();

        for (int i=0; i<3; ++i)
        {
            int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer
                    (mPtr,pcStats.getSkill (skills[i].first).getBase() * gmst.find("iTrainingMod")->getInt (),true);

            MyGUI::Button* button = mTrainingOptions->createWidget<MyGUI::Button>("SandTextButton",
                MyGUI::IntCoord(5, 5+i*18, mTrainingOptions->getWidth()-10, 18), MyGUI::Align::Default);

            button->setEnabled(price <= playerGold);
            button->setUserData(skills[i].first);
            button->eventMouseButtonClick += MyGUI::newDelegate(this, &TrainingWindow::onTrainingSelected);

            button->setCaptionWithReplacing("#{" + ESM::Skill::sSkillNameIds[skills[i].first] + "} - " + boost::lexical_cast<std::string>(price));

            button->setSize(button->getTextSize ().width+12, button->getSize().height);

            ToolTips::createSkillToolTip (button, skills[i].first);
        }

        center();
    }
Пример #3
0
	void ListBox::notifyDrawItem(MyGUI::ListCtrl* _sender, MyGUI::Widget* _item, const MyGUI::IBDrawItemInfo& _info, MyGUI::IntCoord& _coord)
	{
		MyGUI::Button* text = *_item->getUserData<MyGUI::Button*>();

		if (_info.update)
		{
			text->setCaption(mItemsInfo[_info.index]);

			MyGUI::IntSize size = text->getTextSize() + (text->getSize() - text->getTextRegion().size());
			size.height = mHeightLine;
			_coord.set(0, 0, size.width, size.height);
		}

		text->setButtonPressed(_info.select);
		text->_setMouseFocus(_info.active);
	}
Пример #4
0
    void TrainingWindow::startTraining (MWWorld::Ptr actor)
    {
        mPtr = actor;

        mPlayerGold->setCaptionWithReplacing("#{sGold}: " + boost::lexical_cast<std::string>(MWBase::Environment::get().getWindowManager()->getInventoryWindow()->getPlayerGold()));

        MWMechanics::NpcStats& npcStats = MWWorld::Class::get(actor).getNpcStats (actor);

        // NPC can train you in his best 3 skills
        std::vector< std::pair<int, int> > bestSkills;
        bestSkills.push_back (std::make_pair(-1, -1));
        bestSkills.push_back (std::make_pair(-1, -1));
        bestSkills.push_back (std::make_pair(-1, -1));

        for (int i=0; i<ESM::Skill::Length; ++i)
        {
            int value = npcStats.getSkill (i).getBase ();

            for (int j=0; j<3; ++j)
            {
                if (value > bestSkills[j].second)
                {
                    if (j<2)
                    {
                        bestSkills[j+1] = bestSkills[j];
                    }
                    bestSkills[j] = std::make_pair(i, value);
                    break;
                }
            }
        }

        MyGUI::EnumeratorWidgetPtr widgets = mTrainingOptions->getEnumerator ();
        MyGUI::Gui::getInstance ().destroyWidgets (widgets);

        MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer ();
        MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player);

        const MWWorld::Store<ESM::GameSetting> &gmst =
            MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>();

        for (int i=0; i<3; ++i)
        {
            int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer
                    (mPtr,pcStats.getSkill (bestSkills[i].first).getBase() * gmst.find("iTrainingMod")->getInt (),true);

            std::string skin = (price > MWBase::Environment::get().getWindowManager()->getInventoryWindow ()->getPlayerGold ()) ? "SandTextGreyedOut" : "SandTextButton";

            MyGUI::Button* button = mTrainingOptions->createWidget<MyGUI::Button>(skin,
                MyGUI::IntCoord(5, 5+i*18, mTrainingOptions->getWidth()-10, 18), MyGUI::Align::Default);

            button->setUserData(bestSkills[i].first);
            button->eventMouseButtonClick += MyGUI::newDelegate(this, &TrainingWindow::onTrainingSelected);

            button->setCaptionWithReplacing("#{" + ESM::Skill::sSkillNameIds[bestSkills[i].first] + "} - " + boost::lexical_cast<std::string>(price));

            button->setSize(button->getTextSize ().width+12, button->getSize().height);

            ToolTips::createSkillToolTip (button, bestSkills[i].first);
        }

        center();
    }