forked from mirror/openmw-tes3mp
implemented player encumbrance bar
This commit is contained in:
parent
e9ea1fba4e
commit
3f4ce32727
5 changed files with 28 additions and 1 deletions
|
@ -297,6 +297,8 @@ void ContainerBase::drawItems()
|
|||
MyGUI::IntSize size = MyGUI::IntSize(std::max(mItemView->getSize().width, x+42), mItemView->getSize().height);
|
||||
mItemView->setCanvasSize(size);
|
||||
mContainerWidget->setSize(size);
|
||||
|
||||
notifyContentChanged();
|
||||
}
|
||||
|
||||
std::string ContainerBase::getCountString(const int count)
|
||||
|
|
|
@ -80,6 +80,7 @@ namespace MWGui
|
|||
void Update();
|
||||
void drawItems();
|
||||
|
||||
virtual void notifyContentChanged() { }
|
||||
|
||||
protected:
|
||||
MyGUI::ScrollView* mItemView;
|
||||
|
|
|
@ -281,6 +281,7 @@ void HUD::onWorldClicked(MyGUI::Widget* _sender)
|
|||
|
||||
// remove object from the container it was coming from
|
||||
object.getRefData().setCount(0);
|
||||
mDragAndDrop->mDraggedFrom->notifyContentChanged();
|
||||
|
||||
mDragAndDrop->mIsOnDragAndDrop = false;
|
||||
MyGUI::Gui::getInstance().destroyWidget(mDragAndDrop->mDraggedWidget);
|
||||
|
|
|
@ -95,9 +95,12 @@ namespace MWGui
|
|||
|
||||
void InventoryWindow::openInventory()
|
||||
{
|
||||
openContainer(MWBase::Environment::get().getWorld()->getPlayer().getPlayer());
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
openContainer(player);
|
||||
|
||||
onWindowResize(static_cast<MyGUI::Window*>(mMainWidget));
|
||||
|
||||
updateEncumbranceBar();
|
||||
}
|
||||
|
||||
void InventoryWindow::onWindowResize(MyGUI::Window* _sender)
|
||||
|
@ -236,4 +239,20 @@ namespace MWGui
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InventoryWindow::updateEncumbranceBar()
|
||||
{
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
|
||||
float capacity = MWWorld::Class::get(player).getCapacity(player);
|
||||
float encumbrance = MWWorld::Class::get(player).getEncumbrance(player);
|
||||
mEncumbranceBar->setProgressRange(capacity);
|
||||
mEncumbranceBar->setProgressPosition(encumbrance);
|
||||
mEncumbranceText->setCaption( boost::lexical_cast<std::string>(int(encumbrance)) + "/" + boost::lexical_cast<std::string>(int(capacity)) );
|
||||
}
|
||||
|
||||
void InventoryWindow::notifyContentChanged()
|
||||
{
|
||||
updateEncumbranceBar();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ namespace MWGui
|
|||
|
||||
void openInventory();
|
||||
|
||||
virtual void notifyContentChanged();
|
||||
|
||||
protected:
|
||||
MyGUI::Widget* mAvatar;
|
||||
MyGUI::TextBox* mArmorRating;
|
||||
|
@ -50,6 +52,8 @@ namespace MWGui
|
|||
void onAvatarClicked(MyGUI::Widget* _sender);
|
||||
void onPinToggled();
|
||||
|
||||
void updateEncumbranceBar();
|
||||
|
||||
virtual bool isInventory() { return true; }
|
||||
virtual std::vector<MWWorld::Ptr> getEquippedItems();
|
||||
virtual void _unequipItem(MWWorld::Ptr item);
|
||||
|
|
Loading…
Reference in a new issue