diff --git a/CHANGELOG.md b/CHANGELOG.md index 801b48a1a3..e45b808771 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Bug #3737: Scripts from The Underground 2 .esp do not play (all patched versions) Bug #3846: Strings starting with "-" fail to compile if not enclosed in quotes Bug #3905: Great House Dagoth issues + Bug #4203: Resurrecting an actor should close the loot GUI Bug #5100: Persuasion doesn't always clamp the resulting disposition Bug #5120: Scripted object spawning updates physics system Bug #5379: Wandering NPCs falling through cantons diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index f256cc387e..961a63ac79 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -353,6 +353,8 @@ namespace MWBase virtual MWWorld::Ptr getWatchedActor() const = 0; virtual const std::string& getVersionDescription() const = 0; + + virtual void onDeleteCustomData(const MWWorld::Ptr& ptr) = 0; }; } diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 141bf99e92..7e231c60fe 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -830,6 +830,7 @@ namespace MWClass } MWBase::Environment::get().getWorld()->removeContainerScripts(ptr); + MWBase::Environment::get().getWindowManager()->onDeleteCustomData(ptr); ptr.getRefData().setCustomData(nullptr); // Reset to original position diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 5bf81caf9d..f7e78a299f 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -1384,6 +1384,7 @@ namespace MWClass } MWBase::Environment::get().getWorld()->removeContainerScripts(ptr); + MWBase::Environment::get().getWindowManager()->onDeleteCustomData(ptr); ptr.getRefData().setCustomData(nullptr); // Reset to original position diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 4cdd8b137f..b649e41b0f 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -302,4 +302,9 @@ namespace MWGui return mModel->onTakeItem(item.mBase, count); } + void ContainerWindow::onDeleteCustomData(const MWWorld::Ptr& ptr) + { + if(mModel && mModel->usesContainer(ptr)) + MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Container); + } } diff --git a/apps/openmw/mwgui/container.hpp b/apps/openmw/mwgui/container.hpp index 85c0dddc67..2a0dee44e2 100644 --- a/apps/openmw/mwgui/container.hpp +++ b/apps/openmw/mwgui/container.hpp @@ -35,6 +35,8 @@ namespace MWGui void resetReference() override; + void onDeleteCustomData(const MWWorld::Ptr& ptr) override; + private: DragAndDrop* mDragAndDrop; diff --git a/apps/openmw/mwgui/containeritemmodel.cpp b/apps/openmw/mwgui/containeritemmodel.cpp index 56f084bb9d..a1e42ba45f 100644 --- a/apps/openmw/mwgui/containeritemmodel.cpp +++ b/apps/openmw/mwgui/containeritemmodel.cpp @@ -249,4 +249,14 @@ bool ContainerItemModel::onTakeItem(const MWWorld::Ptr &item, int count) return true; } +bool ContainerItemModel::usesContainer(const MWWorld::Ptr& container) +{ + for(const auto& source : mItemSources) + { + if(source.first == container) + return true; + } + return false; +} + } diff --git a/apps/openmw/mwgui/containeritemmodel.hpp b/apps/openmw/mwgui/containeritemmodel.hpp index c54f113147..df2eebea22 100644 --- a/apps/openmw/mwgui/containeritemmodel.hpp +++ b/apps/openmw/mwgui/containeritemmodel.hpp @@ -36,6 +36,8 @@ namespace MWGui void update() override; + bool usesContainer(const MWWorld::Ptr& container) override; + private: std::vector> mItemSources; std::vector mWorldItems; diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index 45defe9a56..7e999bd582 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -57,6 +57,7 @@ namespace MWGui void update() override {} size_t getItemCount() override { return 0; } ItemStack getItem (ModelIndex index) override { throw std::runtime_error("getItem not implemented"); } + bool usesContainer(const MWWorld::Ptr&) override { return false; } private: // Where to drop the item diff --git a/apps/openmw/mwgui/inventoryitemmodel.cpp b/apps/openmw/mwgui/inventoryitemmodel.cpp index f2ff64aa16..91d2fdbf76 100644 --- a/apps/openmw/mwgui/inventoryitemmodel.cpp +++ b/apps/openmw/mwgui/inventoryitemmodel.cpp @@ -131,4 +131,9 @@ bool InventoryItemModel::onTakeItem(const MWWorld::Ptr &item, int count) return true; } +bool InventoryItemModel::usesContainer(const MWWorld::Ptr& container) +{ + return mActor == container; +} + } diff --git a/apps/openmw/mwgui/inventoryitemmodel.hpp b/apps/openmw/mwgui/inventoryitemmodel.hpp index 30d17f3e6c..85e2a5a8d2 100644 --- a/apps/openmw/mwgui/inventoryitemmodel.hpp +++ b/apps/openmw/mwgui/inventoryitemmodel.hpp @@ -25,6 +25,8 @@ namespace MWGui void update() override; + bool usesContainer(const MWWorld::Ptr& container) override; + protected: MWWorld::Ptr mActor; private: diff --git a/apps/openmw/mwgui/itemmodel.cpp b/apps/openmw/mwgui/itemmodel.cpp index 4e4d77da47..3db74916e5 100644 --- a/apps/openmw/mwgui/itemmodel.cpp +++ b/apps/openmw/mwgui/itemmodel.cpp @@ -162,4 +162,9 @@ namespace MWGui { return mSourceModel->onTakeItem(item, count); } + + bool ProxyItemModel::usesContainer(const MWWorld::Ptr& container) + { + return mSourceModel->usesContainer(container); + } } diff --git a/apps/openmw/mwgui/itemmodel.hpp b/apps/openmw/mwgui/itemmodel.hpp index e120dde0fa..6ead0f8d1f 100644 --- a/apps/openmw/mwgui/itemmodel.hpp +++ b/apps/openmw/mwgui/itemmodel.hpp @@ -75,6 +75,8 @@ namespace MWGui virtual bool onDropItem(const MWWorld::Ptr &item, int count); virtual bool onTakeItem(const MWWorld::Ptr &item, int count); + virtual bool usesContainer(const MWWorld::Ptr& container) = 0; + private: ItemModel(const ItemModel&); ItemModel& operator=(const ItemModel&); @@ -103,6 +105,8 @@ namespace MWGui ModelIndex mapToSource (ModelIndex index); ModelIndex mapFromSource (ModelIndex index); + + bool usesContainer(const MWWorld::Ptr& container) override; protected: ItemModel* mSourceModel; }; diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index 19ea383483..7c68798f91 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -523,4 +523,10 @@ namespace MWGui return; resetReference(); } + + void TradeWindow::onDeleteCustomData(const MWWorld::Ptr& ptr) + { + if(mTradeModel && mTradeModel->usesContainer(ptr)) + MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Barter); + } } diff --git a/apps/openmw/mwgui/tradewindow.hpp b/apps/openmw/mwgui/tradewindow.hpp index f82d7b0f72..5ace09e8e2 100644 --- a/apps/openmw/mwgui/tradewindow.hpp +++ b/apps/openmw/mwgui/tradewindow.hpp @@ -42,6 +42,8 @@ namespace MWGui void resetReference() override; + void onDeleteCustomData(const MWWorld::Ptr& ptr) override; + typedef MyGUI::delegates::CMultiDelegate0 EventHandle_TradeDone; EventHandle_TradeDone eventTradeDone; diff --git a/apps/openmw/mwgui/windowbase.hpp b/apps/openmw/mwgui/windowbase.hpp index 90ef2118de..395bb8414f 100644 --- a/apps/openmw/mwgui/windowbase.hpp +++ b/apps/openmw/mwgui/windowbase.hpp @@ -47,6 +47,8 @@ namespace MWGui /// Called when GUI viewport changes size virtual void onResChange(int width, int height) {} + virtual void onDeleteCustomData(const MWWorld::Ptr& ptr) {} + protected: virtual void onTitleDoubleClicked(); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 544a0927e7..96aee5297c 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -2220,4 +2220,10 @@ namespace MWGui messageBox(v.mMessage, v.mShowInDialogueMode); scheduledMessageBoxes->clear(); } + + void WindowManager::onDeleteCustomData(const MWWorld::Ptr& ptr) + { + for(auto* window : mWindows) + window->onDeleteCustomData(ptr); + } } diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 8c7e365ec7..a213bd8a45 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -388,6 +388,8 @@ namespace MWGui const std::string& getVersionDescription() const override; + void onDeleteCustomData(const MWWorld::Ptr& ptr) override; + private: unsigned int mOldUpdateMask; unsigned int mOldCullMask; diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 073312f538..fe2df68473 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -1205,6 +1205,7 @@ namespace MWScript bool wasEnabled = ptr.getRefData().isEnabled(); MWBase::Environment::get().getWorld()->undeleteObject(ptr); MWBase::Environment::get().getWorld()->removeContainerScripts(ptr); + MWBase::Environment::get().getWindowManager()->onDeleteCustomData(ptr); // HACK: disable/enable object to re-add it to the scene properly (need a new Animation). MWBase::Environment::get().getWorld()->disable(ptr);