Close windows using Ptrs that are about to be deleted

dont-compose-content
Evil Eye 4 years ago
parent f403b464f0
commit 087e933326

@ -4,6 +4,7 @@
Bug #3737: Scripts from The Underground 2 .esp do not play (all patched versions) 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 #3846: Strings starting with "-" fail to compile if not enclosed in quotes
Bug #3905: Great House Dagoth issues 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 #5100: Persuasion doesn't always clamp the resulting disposition
Bug #5120: Scripted object spawning updates physics system Bug #5120: Scripted object spawning updates physics system
Bug #5379: Wandering NPCs falling through cantons Bug #5379: Wandering NPCs falling through cantons

@ -353,6 +353,8 @@ namespace MWBase
virtual MWWorld::Ptr getWatchedActor() const = 0; virtual MWWorld::Ptr getWatchedActor() const = 0;
virtual const std::string& getVersionDescription() const = 0; virtual const std::string& getVersionDescription() const = 0;
virtual void onDeleteCustomData(const MWWorld::Ptr& ptr) = 0;
}; };
} }

@ -830,6 +830,7 @@ namespace MWClass
} }
MWBase::Environment::get().getWorld()->removeContainerScripts(ptr); MWBase::Environment::get().getWorld()->removeContainerScripts(ptr);
MWBase::Environment::get().getWindowManager()->onDeleteCustomData(ptr);
ptr.getRefData().setCustomData(nullptr); ptr.getRefData().setCustomData(nullptr);
// Reset to original position // Reset to original position

@ -1384,6 +1384,7 @@ namespace MWClass
} }
MWBase::Environment::get().getWorld()->removeContainerScripts(ptr); MWBase::Environment::get().getWorld()->removeContainerScripts(ptr);
MWBase::Environment::get().getWindowManager()->onDeleteCustomData(ptr);
ptr.getRefData().setCustomData(nullptr); ptr.getRefData().setCustomData(nullptr);
// Reset to original position // Reset to original position

@ -302,4 +302,9 @@ namespace MWGui
return mModel->onTakeItem(item.mBase, count); 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);
}
} }

@ -35,6 +35,8 @@ namespace MWGui
void resetReference() override; void resetReference() override;
void onDeleteCustomData(const MWWorld::Ptr& ptr) override;
private: private:
DragAndDrop* mDragAndDrop; DragAndDrop* mDragAndDrop;

@ -249,4 +249,14 @@ bool ContainerItemModel::onTakeItem(const MWWorld::Ptr &item, int count)
return true; return true;
} }
bool ContainerItemModel::usesContainer(const MWWorld::Ptr& container)
{
for(const auto& source : mItemSources)
{
if(source.first == container)
return true;
}
return false;
}
} }

@ -36,6 +36,8 @@ namespace MWGui
void update() override; void update() override;
bool usesContainer(const MWWorld::Ptr& container) override;
private: private:
std::vector<std::pair<MWWorld::Ptr, MWWorld::ResolutionHandle>> mItemSources; std::vector<std::pair<MWWorld::Ptr, MWWorld::ResolutionHandle>> mItemSources;
std::vector<MWWorld::Ptr> mWorldItems; std::vector<MWWorld::Ptr> mWorldItems;

@ -57,6 +57,7 @@ namespace MWGui
void update() override {} void update() override {}
size_t getItemCount() override { return 0; } size_t getItemCount() override { return 0; }
ItemStack getItem (ModelIndex index) override { throw std::runtime_error("getItem not implemented"); } ItemStack getItem (ModelIndex index) override { throw std::runtime_error("getItem not implemented"); }
bool usesContainer(const MWWorld::Ptr&) override { return false; }
private: private:
// Where to drop the item // Where to drop the item

@ -131,4 +131,9 @@ bool InventoryItemModel::onTakeItem(const MWWorld::Ptr &item, int count)
return true; return true;
} }
bool InventoryItemModel::usesContainer(const MWWorld::Ptr& container)
{
return mActor == container;
}
} }

@ -25,6 +25,8 @@ namespace MWGui
void update() override; void update() override;
bool usesContainer(const MWWorld::Ptr& container) override;
protected: protected:
MWWorld::Ptr mActor; MWWorld::Ptr mActor;
private: private:

@ -162,4 +162,9 @@ namespace MWGui
{ {
return mSourceModel->onTakeItem(item, count); return mSourceModel->onTakeItem(item, count);
} }
bool ProxyItemModel::usesContainer(const MWWorld::Ptr& container)
{
return mSourceModel->usesContainer(container);
}
} }

@ -75,6 +75,8 @@ namespace MWGui
virtual bool onDropItem(const MWWorld::Ptr &item, int count); virtual bool onDropItem(const MWWorld::Ptr &item, int count);
virtual bool onTakeItem(const MWWorld::Ptr &item, int count); virtual bool onTakeItem(const MWWorld::Ptr &item, int count);
virtual bool usesContainer(const MWWorld::Ptr& container) = 0;
private: private:
ItemModel(const ItemModel&); ItemModel(const ItemModel&);
ItemModel& operator=(const ItemModel&); ItemModel& operator=(const ItemModel&);
@ -103,6 +105,8 @@ namespace MWGui
ModelIndex mapToSource (ModelIndex index); ModelIndex mapToSource (ModelIndex index);
ModelIndex mapFromSource (ModelIndex index); ModelIndex mapFromSource (ModelIndex index);
bool usesContainer(const MWWorld::Ptr& container) override;
protected: protected:
ItemModel* mSourceModel; ItemModel* mSourceModel;
}; };

@ -523,4 +523,10 @@ namespace MWGui
return; return;
resetReference(); resetReference();
} }
void TradeWindow::onDeleteCustomData(const MWWorld::Ptr& ptr)
{
if(mTradeModel && mTradeModel->usesContainer(ptr))
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Barter);
}
} }

@ -42,6 +42,8 @@ namespace MWGui
void resetReference() override; void resetReference() override;
void onDeleteCustomData(const MWWorld::Ptr& ptr) override;
typedef MyGUI::delegates::CMultiDelegate0 EventHandle_TradeDone; typedef MyGUI::delegates::CMultiDelegate0 EventHandle_TradeDone;
EventHandle_TradeDone eventTradeDone; EventHandle_TradeDone eventTradeDone;

@ -47,6 +47,8 @@ namespace MWGui
/// Called when GUI viewport changes size /// Called when GUI viewport changes size
virtual void onResChange(int width, int height) {} virtual void onResChange(int width, int height) {}
virtual void onDeleteCustomData(const MWWorld::Ptr& ptr) {}
protected: protected:
virtual void onTitleDoubleClicked(); virtual void onTitleDoubleClicked();

@ -2220,4 +2220,10 @@ namespace MWGui
messageBox(v.mMessage, v.mShowInDialogueMode); messageBox(v.mMessage, v.mShowInDialogueMode);
scheduledMessageBoxes->clear(); scheduledMessageBoxes->clear();
} }
void WindowManager::onDeleteCustomData(const MWWorld::Ptr& ptr)
{
for(auto* window : mWindows)
window->onDeleteCustomData(ptr);
}
} }

@ -388,6 +388,8 @@ namespace MWGui
const std::string& getVersionDescription() const override; const std::string& getVersionDescription() const override;
void onDeleteCustomData(const MWWorld::Ptr& ptr) override;
private: private:
unsigned int mOldUpdateMask; unsigned int mOldCullMask; unsigned int mOldUpdateMask; unsigned int mOldCullMask;

@ -1205,6 +1205,7 @@ namespace MWScript
bool wasEnabled = ptr.getRefData().isEnabled(); bool wasEnabled = ptr.getRefData().isEnabled();
MWBase::Environment::get().getWorld()->undeleteObject(ptr); MWBase::Environment::get().getWorld()->undeleteObject(ptr);
MWBase::Environment::get().getWorld()->removeContainerScripts(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). // HACK: disable/enable object to re-add it to the scene properly (need a new Animation).
MWBase::Environment::get().getWorld()->disable(ptr); MWBase::Environment::get().getWorld()->disable(ptr);

Loading…
Cancel
Save