mirror of
https://github.com/OpenMW/openmw.git
synced 2025-10-22 19:26:36 +00:00
update container window when item is added or removed
This commit is contained in:
parent
e20d52d23c
commit
0547f09bf0
5 changed files with 23 additions and 2 deletions
|
@ -160,6 +160,12 @@ namespace MWGui
|
|||
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(mCloseButton);
|
||||
|
||||
setTitle(container.getClass().getName(container));
|
||||
mPtr.getClass().getContainerStore(mPtr).setContListener(this);
|
||||
}
|
||||
|
||||
void ContainerWindow::updateItemView()
|
||||
{
|
||||
mItemView->update();
|
||||
}
|
||||
|
||||
void ContainerWindow::resetReference()
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#include "itemmodel.hpp"
|
||||
|
||||
#include "../mwworld/containerstore.hpp"
|
||||
|
||||
namespace MyGUI
|
||||
{
|
||||
class Gui;
|
||||
|
@ -21,7 +23,7 @@ namespace MWGui
|
|||
|
||||
namespace MWGui
|
||||
{
|
||||
class ContainerWindow : public WindowBase, public ReferenceInterface
|
||||
class ContainerWindow : public WindowBase, public ReferenceInterface, public MWWorld::ContainerStoreListener
|
||||
{
|
||||
public:
|
||||
ContainerWindow(DragAndDrop* dragAndDrop);
|
||||
|
@ -38,6 +40,11 @@ namespace MWGui
|
|||
|
||||
void treatNextOpenAsLoot() { mTreatNextOpenAsLoot = true; }
|
||||
|
||||
void updateItemView();
|
||||
|
||||
void itemAdded(const MWWorld::ConstPtr& item, int count) override { updateItemView(); }
|
||||
void itemRemoved(const MWWorld::ConstPtr& item, int count) override { updateItemView(); }
|
||||
|
||||
std::string_view getWindowIdForLua() const override { return "Container"; }
|
||||
|
||||
private:
|
||||
|
|
|
@ -91,6 +91,8 @@ namespace MWGui
|
|||
MWBase::Environment::get().getWindowManager()->setDragDrop(true);
|
||||
|
||||
mIsOnDragAndDrop = true;
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->getInventoryWindow()->updateItemView();
|
||||
}
|
||||
|
||||
void DragAndDrop::drop(ItemModel* targetModel, ItemView* targetView)
|
||||
|
|
|
@ -145,6 +145,8 @@ namespace MWGui
|
|||
auto tradeModel = std::make_unique<TradeItemModel>(std::make_unique<InventoryItemModel>(mPtr), MWWorld::Ptr());
|
||||
mTradeModel = tradeModel.get();
|
||||
|
||||
mPtr.getClass().getInventoryStore(mPtr).setContListener(this);
|
||||
|
||||
if (mSortModel) // reuse existing SortModel when possible to keep previous category/filter settings
|
||||
mSortModel->setSourceModel(std::move(tradeModel));
|
||||
else
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "windowpinnablebase.hpp"
|
||||
|
||||
#include "../mwrender/characterpreview.hpp"
|
||||
#include "../mwworld/containerstore.hpp"
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace osg
|
||||
|
@ -30,7 +31,7 @@ namespace MWGui
|
|||
class DragAndDrop;
|
||||
class ItemModel;
|
||||
|
||||
class InventoryWindow : public WindowPinnableBase
|
||||
class InventoryWindow : public WindowPinnableBase, public MWWorld::ContainerStoreListener
|
||||
{
|
||||
public:
|
||||
InventoryWindow(DragAndDrop* dragAndDrop, osg::Group* parent, Resource::ResourceSystem* resourceSystem);
|
||||
|
@ -62,6 +63,9 @@ namespace MWGui
|
|||
|
||||
void setGuiMode(GuiMode mode);
|
||||
|
||||
void itemAdded(const MWWorld::ConstPtr& item, int count) override { updateItemView(); }
|
||||
void itemRemoved(const MWWorld::ConstPtr& item, int count) override { updateItemView(); }
|
||||
|
||||
/// Cycle to previous/next weapon
|
||||
void cycle(bool next);
|
||||
|
||||
|
|
Loading…
Reference in a new issue