void Repair::updateRepairView() { MWWorld::LiveCellRef<ESM::Repair> *ref = mRepair.getTool().get<ESM::Repair>(); int uses = (mRepair.getTool().getCellRef().mCharge != -1) ? mRepair.getTool().getCellRef().mCharge : ref->mBase->mData.mUses; float quality = ref->mBase->mData.mQuality; std::stringstream qualityStr; qualityStr << std::setprecision(3) << quality; mUsesLabel->setCaptionWithReplacing("#{sUses} " + boost::lexical_cast<std::string>(uses)); mQualityLabel->setCaptionWithReplacing("#{sQuality} " + qualityStr.str()); bool toolBoxVisible = (mRepair.getTool().getRefData().getCount() != 0); mToolBox->setVisible(toolBoxVisible); bool toolBoxWasVisible = (mRepairBox->getPosition().top != mToolBox->getPosition().top); if (toolBoxVisible && !toolBoxWasVisible) { // shrink mRepairBox->setPosition(mRepairBox->getPosition() + MyGUI::IntPoint(0,mToolBox->getSize().height)); mRepairBox->setSize(mRepairBox->getSize() - MyGUI::IntSize(0,mToolBox->getSize().height)); } else if (!toolBoxVisible && toolBoxWasVisible) { // expand mRepairBox->setPosition(MyGUI::IntPoint (mRepairBox->getPosition().left, mToolBox->getPosition().top)); mRepairBox->setSize(mRepairBox->getSize() + MyGUI::IntSize(0,mToolBox->getSize().height)); } while (mRepairView->getChildCount()) MyGUI::Gui::getInstance().destroyWidget(mRepairView->getChildAt(0)); int currentY = 0; MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::ContainerStore& store = MWWorld::Class::get(player).getContainerStore(player); int categories = MWWorld::ContainerStore::Type_Weapon | MWWorld::ContainerStore::Type_Armor; for (MWWorld::ContainerStoreIterator iter (store.begin(categories)); iter!=store.end(); ++iter) { if (MWWorld::Class::get(*iter).hasItemHealth(*iter)) { int maxDurability = MWWorld::Class::get(*iter).getItemMaxHealth(*iter); int durability = (iter->getCellRef().mCharge == -1) ? maxDurability : iter->getCellRef().mCharge; if (maxDurability == durability) continue; MyGUI::TextBox* text = mRepairView->createWidget<MyGUI::TextBox> ( "SandText", MyGUI::IntCoord(8, currentY, mRepairView->getWidth()-8, 18), MyGUI::Align::Default); text->setCaption(MWWorld::Class::get(*iter).getName(*iter)); text->setNeedMouseFocus(false); currentY += 19; MyGUI::ImageBox* icon = mRepairView->createWidget<MyGUI::ImageBox> ( "ImageBox", MyGUI::IntCoord(16, currentY, 32, 32), MyGUI::Align::Default); std::string path = std::string("icons\\"); path += MWWorld::Class::get(*iter).getInventoryIcon(*iter); int pos = path.rfind("."); path.erase(pos); path.append(".dds"); icon->setImageTexture (path); icon->setUserString("ToolTipType", "ItemPtr"); icon->setUserData(*iter); icon->eventMouseButtonClick += MyGUI::newDelegate(this, &Repair::onRepairItem); icon->eventMouseWheel += MyGUI::newDelegate(this, &Repair::onMouseWheel); Widgets::MWDynamicStatPtr chargeWidget = mRepairView->createWidget<Widgets::MWDynamicStat> ("MW_ChargeBar", MyGUI::IntCoord(72, currentY+2, 199, 20), MyGUI::Align::Default); chargeWidget->setValue(durability, maxDurability); chargeWidget->setNeedMouseFocus(false); currentY += 32 + 4; } } mRepairView->setCanvasSize (MyGUI::IntSize(mRepairView->getWidth(), std::max(mRepairView->getHeight(), currentY))); }
void Repair::updateRepairView() { MWWorld::LiveCellRef<ESM::Repair> *ref = mRepair.getTool().get<ESM::Repair>(); int uses = mRepair.getTool().getClass().getItemHealth(mRepair.getTool()); float quality = ref->mBase->mData.mQuality; std::stringstream qualityStr; qualityStr << std::setprecision(3) << quality; mUsesLabel->setCaptionWithReplacing("#{sUses} " + boost::lexical_cast<std::string>(uses)); mQualityLabel->setCaptionWithReplacing("#{sQuality} " + qualityStr.str()); bool toolBoxVisible = (mRepair.getTool().getRefData().getCount() != 0); mToolBox->setVisible(toolBoxVisible); bool toolBoxWasVisible = (mRepairBox->getPosition().top != mToolBox->getPosition().top); if (toolBoxVisible && !toolBoxWasVisible) { // shrink mRepairBox->setPosition(mRepairBox->getPosition() + MyGUI::IntPoint(0,mToolBox->getSize().height)); mRepairBox->setSize(mRepairBox->getSize() - MyGUI::IntSize(0,mToolBox->getSize().height)); } else if (!toolBoxVisible && toolBoxWasVisible) { // expand mRepairBox->setPosition(MyGUI::IntPoint (mRepairBox->getPosition().left, mToolBox->getPosition().top)); mRepairBox->setSize(mRepairBox->getSize() + MyGUI::IntSize(0,mToolBox->getSize().height)); } while (mRepairView->getChildCount()) MyGUI::Gui::getInstance().destroyWidget(mRepairView->getChildAt(0)); int currentY = 0; MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWWorld::ContainerStore& store = player.getClass().getContainerStore(player); int categories = MWWorld::ContainerStore::Type_Weapon | MWWorld::ContainerStore::Type_Armor; for (MWWorld::ContainerStoreIterator iter (store.begin(categories)); iter!=store.end(); ++iter) { if (iter->getClass().hasItemHealth(*iter)) { int maxDurability = iter->getClass().getItemMaxHealth(*iter); int durability = iter->getClass().getItemHealth(*iter); if (maxDurability == durability) continue; MyGUI::TextBox* text = mRepairView->createWidget<MyGUI::TextBox> ( "SandText", MyGUI::IntCoord(8, currentY, mRepairView->getWidth()-8, 18), MyGUI::Align::Default); text->setCaption(iter->getClass().getName(*iter)); text->setNeedMouseFocus(false); currentY += 19; ItemWidget* icon = mRepairView->createWidget<ItemWidget> ( "MW_ItemIconSmall", MyGUI::IntCoord(16, currentY, 32, 32), MyGUI::Align::Default); icon->setItem(*iter); icon->setUserString("ToolTipType", "ItemPtr"); icon->setUserData(*iter); icon->eventMouseButtonClick += MyGUI::newDelegate(this, &Repair::onRepairItem); icon->eventMouseWheel += MyGUI::newDelegate(this, &Repair::onMouseWheel); Widgets::MWDynamicStatPtr chargeWidget = mRepairView->createWidget<Widgets::MWDynamicStat> ("MW_ChargeBar", MyGUI::IntCoord(72, currentY+2, 199, 20), MyGUI::Align::Default); chargeWidget->setValue(durability, maxDurability); chargeWidget->setNeedMouseFocus(false); currentY += 32 + 4; } } // Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the scrollbar is hidden mRepairView->setVisibleVScroll(false); mRepairView->setCanvasSize (MyGUI::IntSize(mRepairView->getWidth(), std::max(mRepairView->getHeight(), currentY))); mRepairView->setVisibleVScroll(true); }
void Recharge::updateView() { MWWorld::Ptr gem = *mGemIcon->getUserData<MWWorld::Ptr>(); std::string soul = gem.getCellRef().getSoul(); const ESM::Creature *creature = MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().find(soul); mChargeLabel->setCaptionWithReplacing("#{sCharges} " + MyGUI::utility::toString(creature->mData.mSoul)); bool toolBoxVisible = (gem.getRefData().getCount() != 0); mGemBox->setVisible(toolBoxVisible); bool toolBoxWasVisible = (mBox->getPosition().top != mGemBox->getPosition().top); if (toolBoxVisible && !toolBoxWasVisible) { // shrink mBox->setPosition(mBox->getPosition() + MyGUI::IntPoint(0, mGemBox->getSize().height)); mBox->setSize(mBox->getSize() - MyGUI::IntSize(0,mGemBox->getSize().height)); } else if (!toolBoxVisible && toolBoxWasVisible) { // expand mBox->setPosition(MyGUI::IntPoint (mBox->getPosition().left, mGemBox->getPosition().top)); mBox->setSize(mBox->getSize() + MyGUI::IntSize(0,mGemBox->getSize().height)); } while (mView->getChildCount()) MyGUI::Gui::getInstance().destroyWidget(mView->getChildAt(0)); int currentY = 0; MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWWorld::ContainerStore& store = player.getClass().getContainerStore(player); for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end(); ++iter) { std::string enchantmentName = iter->getClass().getEnchantment(*iter); if (enchantmentName.empty()) continue; const ESM::Enchantment* enchantment = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find(enchantmentName); if (iter->getCellRef().getEnchantmentCharge() >= enchantment->mData.mCharge || iter->getCellRef().getEnchantmentCharge() == -1) continue; MyGUI::TextBox* text = mView->createWidget<MyGUI::TextBox> ( "SandText", MyGUI::IntCoord(8, currentY, mView->getWidth()-8, 18), MyGUI::Align::Default); text->setCaption(iter->getClass().getName(*iter)); text->setNeedMouseFocus(false); currentY += 19; ItemWidget* icon = mView->createWidget<ItemWidget> ( "MW_ItemIconSmall", MyGUI::IntCoord(16, currentY, 32, 32), MyGUI::Align::Default); icon->setItem(*iter); icon->setUserString("ToolTipType", "ItemPtr"); icon->setUserData(*iter); icon->eventMouseButtonClick += MyGUI::newDelegate(this, &Recharge::onItemClicked); icon->eventMouseWheel += MyGUI::newDelegate(this, &Recharge::onMouseWheel); Widgets::MWDynamicStatPtr chargeWidget = mView->createWidget<Widgets::MWDynamicStat> ("MW_ChargeBar", MyGUI::IntCoord(72, currentY+2, 199, 20), MyGUI::Align::Default); chargeWidget->setValue(static_cast<int>(iter->getCellRef().getEnchantmentCharge()), enchantment->mData.mCharge); chargeWidget->setNeedMouseFocus(false); currentY += 32 + 4; } // Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the scrollbar is hidden mView->setVisibleVScroll(false); mView->setCanvasSize (MyGUI::IntSize(mView->getWidth(), std::max(mView->getHeight(), currentY))); mView->setVisibleVScroll(true); }
void Recharge::updateView() { MWWorld::Ptr gem = *mGemIcon->getUserData<MWWorld::Ptr>(); std::string soul = gem.getCellRef().mSoul; const ESM::Creature *creature = MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().find(soul); mChargeLabel->setCaptionWithReplacing("#{sCharges} " + boost::lexical_cast<std::string>(creature->mData.mSoul)); bool toolBoxVisible = (gem.getRefData().getCount() != 0); mGemBox->setVisible(toolBoxVisible); bool toolBoxWasVisible = (mBox->getPosition().top != mGemBox->getPosition().top); if (toolBoxVisible && !toolBoxWasVisible) { // shrink mBox->setPosition(mBox->getPosition() + MyGUI::IntPoint(0, mGemBox->getSize().height)); mBox->setSize(mBox->getSize() - MyGUI::IntSize(0,mGemBox->getSize().height)); } else if (!toolBoxVisible && toolBoxWasVisible) { // expand mBox->setPosition(MyGUI::IntPoint (mBox->getPosition().left, mGemBox->getPosition().top)); mBox->setSize(mBox->getSize() + MyGUI::IntSize(0,mGemBox->getSize().height)); } while (mView->getChildCount()) MyGUI::Gui::getInstance().destroyWidget(mView->getChildAt(0)); int currentY = 0; MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::ContainerStore& store = MWWorld::Class::get(player).getContainerStore(player); for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end(); ++iter) { std::string enchantmentName = iter->getClass().getEnchantment(*iter); if (enchantmentName.empty()) continue; const ESM::Enchantment* enchantment = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find(enchantmentName); if (iter->getCellRef().mEnchantmentCharge >= enchantment->mData.mCharge || iter->getCellRef().mEnchantmentCharge == -1) continue; MyGUI::TextBox* text = mView->createWidget<MyGUI::TextBox> ( "SandText", MyGUI::IntCoord(8, currentY, mView->getWidth()-8, 18), MyGUI::Align::Default); text->setCaption(MWWorld::Class::get(*iter).getName(*iter)); text->setNeedMouseFocus(false); currentY += 19; MyGUI::ImageBox* icon = mView->createWidget<MyGUI::ImageBox> ( "ImageBox", MyGUI::IntCoord(16, currentY, 32, 32), MyGUI::Align::Default); std::string path = std::string("icons\\"); path += MWWorld::Class::get(*iter).getInventoryIcon(*iter); int pos = path.rfind("."); path.erase(pos); path.append(".dds"); icon->setImageTexture (path); icon->setUserString("ToolTipType", "ItemPtr"); icon->setUserData(*iter); icon->eventMouseButtonClick += MyGUI::newDelegate(this, &Recharge::onItemClicked); icon->eventMouseWheel += MyGUI::newDelegate(this, &Recharge::onMouseWheel); Widgets::MWDynamicStatPtr chargeWidget = mView->createWidget<Widgets::MWDynamicStat> ("MW_ChargeBar", MyGUI::IntCoord(72, currentY+2, 199, 20), MyGUI::Align::Default); chargeWidget->setValue(iter->getCellRef().mEnchantmentCharge, enchantment->mData.mCharge); chargeWidget->setNeedMouseFocus(false); currentY += 32 + 4; } mView->setCanvasSize (MyGUI::IntSize(mView->getWidth(), std::max(mView->getHeight(), currentY))); }