mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 13: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 const std::string& getVersionDescription() const = 0;
|
||||||
|
|
||||||
virtual void onDeleteCustomData(const MWWorld::Ptr& ptr) = 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)
|
, mSortModel(nullptr)
|
||||||
, mModel(nullptr)
|
, mModel(nullptr)
|
||||||
, mSelectedItem(-1)
|
, mSelectedItem(-1)
|
||||||
|
, mTreatNextOpenAsLoot(false)
|
||||||
{
|
{
|
||||||
getWidget(mDisposeCorpseButton, "DisposeCorpseButton");
|
getWidget(mDisposeCorpseButton, "DisposeCorpseButton");
|
||||||
getWidget(mTakeButton, "TakeButton");
|
getWidget(mTakeButton, "TakeButton");
|
||||||
|
@ -121,13 +122,15 @@ namespace MWGui
|
||||||
|
|
||||||
void ContainerWindow::setPtr(const MWWorld::Ptr& container)
|
void ContainerWindow::setPtr(const MWWorld::Ptr& container)
|
||||||
{
|
{
|
||||||
|
bool lootAnyway = mTreatNextOpenAsLoot;
|
||||||
|
mTreatNextOpenAsLoot = false;
|
||||||
mPtr = container;
|
mPtr = container;
|
||||||
|
|
||||||
bool loot = mPtr.getClass().isActor() && mPtr.getClass().getCreatureStats(mPtr).isDead();
|
bool loot = mPtr.getClass().isActor() && mPtr.getClass().getCreatureStats(mPtr).isDead();
|
||||||
|
|
||||||
if (mPtr.getClass().hasInventoryStore(mPtr))
|
if (mPtr.getClass().hasInventoryStore(mPtr))
|
||||||
{
|
{
|
||||||
if (mPtr.getClass().isNpc() && !loot)
|
if (mPtr.getClass().isNpc() && !loot && !lootAnyway)
|
||||||
{
|
{
|
||||||
// we are stealing stuff
|
// we are stealing stuff
|
||||||
mModel = new PickpocketItemModel(mPtr, new InventoryItemModel(container),
|
mModel = new PickpocketItemModel(mPtr, new InventoryItemModel(container),
|
||||||
|
|
|
@ -37,6 +37,7 @@ namespace MWGui
|
||||||
|
|
||||||
void onDeleteCustomData(const MWWorld::Ptr& ptr) override;
|
void onDeleteCustomData(const MWWorld::Ptr& ptr) override;
|
||||||
|
|
||||||
|
void treatNextOpenAsLoot() { mTreatNextOpenAsLoot = true; };
|
||||||
private:
|
private:
|
||||||
DragAndDrop* mDragAndDrop;
|
DragAndDrop* mDragAndDrop;
|
||||||
|
|
||||||
|
@ -44,7 +45,7 @@ namespace MWGui
|
||||||
SortFilterItemModel* mSortModel;
|
SortFilterItemModel* mSortModel;
|
||||||
ItemModel* mModel;
|
ItemModel* mModel;
|
||||||
int mSelectedItem;
|
int mSelectedItem;
|
||||||
|
bool mTreatNextOpenAsLoot;
|
||||||
MyGUI::Button* mDisposeCorpseButton;
|
MyGUI::Button* mDisposeCorpseButton;
|
||||||
MyGUI::Button* mTakeButton;
|
MyGUI::Button* mTakeButton;
|
||||||
MyGUI::Button* mCloseButton;
|
MyGUI::Button* mCloseButton;
|
||||||
|
|
|
@ -165,6 +165,7 @@ namespace MWGui
|
||||||
, mScreenFader(nullptr)
|
, mScreenFader(nullptr)
|
||||||
, mDebugWindow(nullptr)
|
, mDebugWindow(nullptr)
|
||||||
, mJailScreen(nullptr)
|
, mJailScreen(nullptr)
|
||||||
|
, mContainerWindow(nullptr)
|
||||||
, mTranslationDataStorage (translationDataStorage)
|
, mTranslationDataStorage (translationDataStorage)
|
||||||
, mCharGen(nullptr)
|
, mCharGen(nullptr)
|
||||||
, mInputBlocker(nullptr)
|
, mInputBlocker(nullptr)
|
||||||
|
@ -360,10 +361,10 @@ namespace MWGui
|
||||||
mGuiModeStates[GM_Dialogue] = GuiModeState(mDialogueWindow);
|
mGuiModeStates[GM_Dialogue] = GuiModeState(mDialogueWindow);
|
||||||
mTradeWindow->eventTradeDone += MyGUI::newDelegate(mDialogueWindow, &DialogueWindow::onTradeComplete);
|
mTradeWindow->eventTradeDone += MyGUI::newDelegate(mDialogueWindow, &DialogueWindow::onTradeComplete);
|
||||||
|
|
||||||
ContainerWindow* containerWindow = new ContainerWindow(mDragAndDrop);
|
mContainerWindow = new ContainerWindow(mDragAndDrop);
|
||||||
mWindows.push_back(containerWindow);
|
mWindows.push_back(mContainerWindow);
|
||||||
trackWindow(containerWindow, "container");
|
trackWindow(mContainerWindow, "container");
|
||||||
mGuiModeStates[GM_Container] = GuiModeState({containerWindow, mInventoryWindow});
|
mGuiModeStates[GM_Container] = GuiModeState({mContainerWindow, mInventoryWindow});
|
||||||
|
|
||||||
mHud = new HUD(mCustomMarkers, mDragAndDrop, mLocalMapRender);
|
mHud = new HUD(mCustomMarkers, mDragAndDrop, mLocalMapRender);
|
||||||
mWindows.push_back(mHud);
|
mWindows.push_back(mHud);
|
||||||
|
@ -1176,6 +1177,16 @@ namespace MWGui
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::pushGuiMode(GuiMode mode, const MWWorld::Ptr& arg)
|
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)
|
if (mode==GM_Inventory && mAllowed==GW_None)
|
||||||
return;
|
return;
|
||||||
|
@ -1198,6 +1209,8 @@ namespace MWGui
|
||||||
mGuiModeStates[mode].update(true);
|
mGuiModeStates[mode].update(true);
|
||||||
playSound(mGuiModeStates[mode].mOpenSound);
|
playSound(mGuiModeStates[mode].mOpenSound);
|
||||||
}
|
}
|
||||||
|
if(force)
|
||||||
|
mContainerWindow->treatNextOpenAsLoot();
|
||||||
for (WindowBase* window : mGuiModeStates[mode].mWindows)
|
for (WindowBase* window : mGuiModeStates[mode].mWindows)
|
||||||
window->setPtr(arg);
|
window->setPtr(arg);
|
||||||
|
|
||||||
|
|
|
@ -389,6 +389,7 @@ namespace MWGui
|
||||||
const std::string& getVersionDescription() const override;
|
const std::string& getVersionDescription() const override;
|
||||||
|
|
||||||
void onDeleteCustomData(const MWWorld::Ptr& ptr) override;
|
void onDeleteCustomData(const MWWorld::Ptr& ptr) override;
|
||||||
|
void forceLootMode(const MWWorld::Ptr& ptr) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned int mOldUpdateMask; unsigned int mOldCullMask;
|
unsigned int mOldUpdateMask; unsigned int mOldCullMask;
|
||||||
|
@ -447,6 +448,7 @@ namespace MWGui
|
||||||
ScreenFader* mScreenFader;
|
ScreenFader* mScreenFader;
|
||||||
DebugWindow* mDebugWindow;
|
DebugWindow* mDebugWindow;
|
||||||
JailScreen* mJailScreen;
|
JailScreen* mJailScreen;
|
||||||
|
ContainerWindow* mContainerWindow;
|
||||||
|
|
||||||
std::vector<WindowBase*> mWindows;
|
std::vector<WindowBase*> mWindows;
|
||||||
|
|
||||||
|
@ -573,6 +575,8 @@ namespace MWGui
|
||||||
void enableScene(bool enable);
|
void enableScene(bool enable);
|
||||||
|
|
||||||
void handleScheduledMessageBoxes();
|
void handleScheduledMessageBoxes();
|
||||||
|
|
||||||
|
void pushGuiMode(GuiMode mode, const MWWorld::Ptr& arg, bool force);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1194,13 +1194,23 @@ 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);
|
auto windowManager = MWBase::Environment::get().getWindowManager();
|
||||||
MWBase::Environment::get().getWindowManager()->onDeleteCustomData(ptr);
|
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).
|
// 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);
|
||||||
// resets runtime state such as inventory, stats and AI. does not reset position in the world
|
if (wasOpen && !windowManager->containsMode(MWGui::GM_Container))
|
||||||
ptr.getRefData().setCustomData(nullptr);
|
{
|
||||||
|
// 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)
|
if (wasEnabled)
|
||||||
MWBase::Environment::get().getWorld()->enable(ptr);
|
MWBase::Environment::get().getWorld()->enable(ptr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue