mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-29 17:45:34 +00:00
Merge branch 'it_isnt_theft_if_they_were_dead_when_you_started' into 'master'
Force the loot UI open if it was open while resurrecting the lootee Closes #6453 See merge request OpenMW/openmw!1452
This commit is contained in:
commit
694f697f61
6 changed files with 43 additions and 11 deletions
|
@ -355,6 +355,7 @@ namespace MWBase
|
|||
virtual const std::string& getVersionDescription() const = 0;
|
||||
|
||||
virtual void onDeleteCustomData(const MWWorld::Ptr& ptr) = 0;
|
||||
virtual void forceLootMode(const MWWorld::Ptr& ptr) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ namespace MWGui
|
|||
, mSortModel(nullptr)
|
||||
, mModel(nullptr)
|
||||
, mSelectedItem(-1)
|
||||
, mTreatNextOpenAsLoot(false)
|
||||
{
|
||||
getWidget(mDisposeCorpseButton, "DisposeCorpseButton");
|
||||
getWidget(mTakeButton, "TakeButton");
|
||||
|
@ -121,13 +122,15 @@ namespace MWGui
|
|||
|
||||
void ContainerWindow::setPtr(const MWWorld::Ptr& container)
|
||||
{
|
||||
bool lootAnyway = mTreatNextOpenAsLoot;
|
||||
mTreatNextOpenAsLoot = false;
|
||||
mPtr = container;
|
||||
|
||||
bool loot = mPtr.getClass().isActor() && mPtr.getClass().getCreatureStats(mPtr).isDead();
|
||||
|
||||
if (mPtr.getClass().hasInventoryStore(mPtr))
|
||||
{
|
||||
if (mPtr.getClass().isNpc() && !loot)
|
||||
if (mPtr.getClass().isNpc() && !loot && !lootAnyway)
|
||||
{
|
||||
// we are stealing stuff
|
||||
mModel = new PickpocketItemModel(mPtr, new InventoryItemModel(container),
|
||||
|
|
|
@ -37,6 +37,7 @@ namespace MWGui
|
|||
|
||||
void onDeleteCustomData(const MWWorld::Ptr& ptr) override;
|
||||
|
||||
void treatNextOpenAsLoot() { mTreatNextOpenAsLoot = true; };
|
||||
private:
|
||||
DragAndDrop* mDragAndDrop;
|
||||
|
||||
|
@ -44,7 +45,7 @@ namespace MWGui
|
|||
SortFilterItemModel* mSortModel;
|
||||
ItemModel* mModel;
|
||||
int mSelectedItem;
|
||||
|
||||
bool mTreatNextOpenAsLoot;
|
||||
MyGUI::Button* mDisposeCorpseButton;
|
||||
MyGUI::Button* mTakeButton;
|
||||
MyGUI::Button* mCloseButton;
|
||||
|
|
|
@ -165,6 +165,7 @@ namespace MWGui
|
|||
, mScreenFader(nullptr)
|
||||
, mDebugWindow(nullptr)
|
||||
, mJailScreen(nullptr)
|
||||
, mContainerWindow(nullptr)
|
||||
, mTranslationDataStorage (translationDataStorage)
|
||||
, mCharGen(nullptr)
|
||||
, mInputBlocker(nullptr)
|
||||
|
@ -360,10 +361,10 @@ namespace MWGui
|
|||
mGuiModeStates[GM_Dialogue] = GuiModeState(mDialogueWindow);
|
||||
mTradeWindow->eventTradeDone += MyGUI::newDelegate(mDialogueWindow, &DialogueWindow::onTradeComplete);
|
||||
|
||||
ContainerWindow* containerWindow = new ContainerWindow(mDragAndDrop);
|
||||
mWindows.push_back(containerWindow);
|
||||
trackWindow(containerWindow, "container");
|
||||
mGuiModeStates[GM_Container] = GuiModeState({containerWindow, mInventoryWindow});
|
||||
mContainerWindow = new ContainerWindow(mDragAndDrop);
|
||||
mWindows.push_back(mContainerWindow);
|
||||
trackWindow(mContainerWindow, "container");
|
||||
mGuiModeStates[GM_Container] = GuiModeState({mContainerWindow, mInventoryWindow});
|
||||
|
||||
mHud = new HUD(mCustomMarkers, mDragAndDrop, mLocalMapRender);
|
||||
mWindows.push_back(mHud);
|
||||
|
@ -1176,6 +1177,16 @@ namespace MWGui
|
|||
}
|
||||
|
||||
void WindowManager::pushGuiMode(GuiMode mode, const MWWorld::Ptr& arg)
|
||||
{
|
||||
pushGuiMode(mode, arg, false);
|
||||
}
|
||||
|
||||
void WindowManager::forceLootMode(const MWWorld::Ptr& ptr)
|
||||
{
|
||||
pushGuiMode(MWGui::GM_Container, ptr, true);
|
||||
}
|
||||
|
||||
void WindowManager::pushGuiMode(GuiMode mode, const MWWorld::Ptr& arg, bool force)
|
||||
{
|
||||
if (mode==GM_Inventory && mAllowed==GW_None)
|
||||
return;
|
||||
|
@ -1198,6 +1209,8 @@ namespace MWGui
|
|||
mGuiModeStates[mode].update(true);
|
||||
playSound(mGuiModeStates[mode].mOpenSound);
|
||||
}
|
||||
if(force)
|
||||
mContainerWindow->treatNextOpenAsLoot();
|
||||
for (WindowBase* window : mGuiModeStates[mode].mWindows)
|
||||
window->setPtr(arg);
|
||||
|
||||
|
|
|
@ -389,6 +389,7 @@ namespace MWGui
|
|||
const std::string& getVersionDescription() const override;
|
||||
|
||||
void onDeleteCustomData(const MWWorld::Ptr& ptr) override;
|
||||
void forceLootMode(const MWWorld::Ptr& ptr) override;
|
||||
|
||||
private:
|
||||
unsigned int mOldUpdateMask; unsigned int mOldCullMask;
|
||||
|
@ -447,6 +448,7 @@ namespace MWGui
|
|||
ScreenFader* mScreenFader;
|
||||
DebugWindow* mDebugWindow;
|
||||
JailScreen* mJailScreen;
|
||||
ContainerWindow* mContainerWindow;
|
||||
|
||||
std::vector<WindowBase*> mWindows;
|
||||
|
||||
|
@ -573,6 +575,8 @@ namespace MWGui
|
|||
void enableScene(bool enable);
|
||||
|
||||
void handleScheduledMessageBoxes();
|
||||
|
||||
void pushGuiMode(GuiMode mode, const MWWorld::Ptr& arg, bool force);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1194,13 +1194,23 @@ 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);
|
||||
|
||||
auto windowManager = MWBase::Environment::get().getWindowManager();
|
||||
bool wasOpen = windowManager->containsMode(MWGui::GM_Container);
|
||||
windowManager->onDeleteCustomData(ptr);
|
||||
// HACK: disable/enable object to re-add it to the scene properly (need a new Animation).
|
||||
MWBase::Environment::get().getWorld()->disable(ptr);
|
||||
// resets runtime state such as inventory, stats and AI. does not reset position in the world
|
||||
ptr.getRefData().setCustomData(nullptr);
|
||||
if (wasOpen && !windowManager->containsMode(MWGui::GM_Container))
|
||||
{
|
||||
// Reopen the loot GUI if it was closed because we resurrected the actor we were looting
|
||||
MWBase::Environment::get().getMechanicsManager()->resurrect(ptr);
|
||||
windowManager->forceLootMode(ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
MWBase::Environment::get().getWorld()->removeContainerScripts(ptr);
|
||||
// resets runtime state such as inventory, stats and AI. does not reset position in the world
|
||||
ptr.getRefData().setCustomData(nullptr);
|
||||
}
|
||||
if (wasEnabled)
|
||||
MWBase::Environment::get().getWorld()->enable(ptr);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue