mirror of
https://github.com/OpenMW/openmw.git
synced 2025-12-01 19:34:31 +00:00
Merge branch '8551-orang-kk' into 'master'
Fix loss of quick key bindings for temporary or missing items See merge request OpenMW/openmw!4780
This commit is contained in:
commit
8622dacaea
3 changed files with 36 additions and 14 deletions
|
|
@ -74,6 +74,8 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
unassign(&mKey[i]);
|
unassign(&mKey[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mTemp.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void QuickKeysMenu::validate(int index)
|
inline void QuickKeysMenu::validate(int index)
|
||||||
|
|
@ -397,11 +399,9 @@ namespace MWGui
|
||||||
if (*it == item)
|
if (*it == item)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (it == store.end())
|
|
||||||
item = nullptr;
|
|
||||||
|
|
||||||
// check the quickkey item is available
|
// Is the quickkey item not in the inventory?
|
||||||
if (item.isEmpty() || item.getCellRef().getCount() < 1)
|
if (it == store.end())
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox("#{sQuickMenu5} " + key->name);
|
MWBase::Environment::get().getWindowManager()->messageBox("#{sQuickMenu5} " + key->name);
|
||||||
return;
|
return;
|
||||||
|
|
@ -626,6 +626,13 @@ namespace MWGui
|
||||||
MWWorld::Ptr player = MWMechanics::getPlayer();
|
MWWorld::Ptr player = MWMechanics::getPlayer();
|
||||||
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
|
MWWorld::InventoryStore& store = player.getClass().getInventoryStore(player);
|
||||||
|
|
||||||
|
auto assign = [this](auto type, MWWorld::Ptr item) {
|
||||||
|
if (type == ESM::QuickKeys::Type::Item)
|
||||||
|
assignItem(item);
|
||||||
|
else // if (quickKey.mType == ESM::QuickKeys::Type::MagicItem)
|
||||||
|
onAssignMagicItem(item);
|
||||||
|
};
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (ESM::QuickKeys::QuickKey& quickKey : keys.mKeys)
|
for (ESM::QuickKeys::QuickKey& quickKey : keys.mKeys)
|
||||||
{
|
{
|
||||||
|
|
@ -646,16 +653,25 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
// Find the item by id
|
// Find the item by id
|
||||||
MWWorld::Ptr item = store.findReplacement(quickKey.mId);
|
MWWorld::Ptr item = store.findReplacement(quickKey.mId);
|
||||||
|
|
||||||
if (item.isEmpty())
|
if (item.isEmpty())
|
||||||
unassign(mSelected);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (quickKey.mType == ESM::QuickKeys::Type::Item)
|
unassign(mSelected);
|
||||||
assignItem(item);
|
if (!quickKey.mId.empty())
|
||||||
else // if (quickKey.mType == ESM::QuickKeys::Type::MagicItem)
|
{
|
||||||
onAssignMagicItem(item);
|
// Fallback to a temporary object for UI display purposes
|
||||||
|
if (MWBase::Environment::get().getESMStore()->find(quickKey.mId) != 0)
|
||||||
|
{
|
||||||
|
// Tie temporary item lifetime to this window
|
||||||
|
mTemp.emplace_back(*MWBase::Environment::get().getESMStore(), quickKey.mId, 0);
|
||||||
|
assign(quickKey.mType, mTemp.back().getPtr());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Log(Debug::Warning) << "Failed to load quick key " << (i + 1)
|
||||||
|
<< ": could not find object " << quickKey.mId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
assign(quickKey.mType, item);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
#include "components/esm3/quickkeys.hpp"
|
#include "components/esm3/quickkeys.hpp"
|
||||||
|
|
||||||
|
#include "../mwworld/manualref.hpp"
|
||||||
|
|
||||||
#include "itemselection.hpp"
|
#include "itemselection.hpp"
|
||||||
#include "spellmodel.hpp"
|
#include "spellmodel.hpp"
|
||||||
#include "windowbase.hpp"
|
#include "windowbase.hpp"
|
||||||
|
|
@ -57,6 +59,7 @@ namespace MWGui
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<keyData> mKey;
|
std::vector<keyData> mKey;
|
||||||
|
std::vector<MWWorld::ManualRef> mTemp;
|
||||||
keyData* mSelected;
|
keyData* mSelected;
|
||||||
keyData* mActivated;
|
keyData* mActivated;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,16 @@ namespace MWWorld
|
||||||
std::any mRef;
|
std::any mRef;
|
||||||
Ptr mPtr;
|
Ptr mPtr;
|
||||||
|
|
||||||
ManualRef(const ManualRef&);
|
|
||||||
ManualRef& operator=(const ManualRef&);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ManualRef(const MWWorld::ESMStore& store, const ESM::RefId& name, const int count = 1);
|
ManualRef(const MWWorld::ESMStore& store, const ESM::RefId& name, const int count = 1);
|
||||||
ManualRef(const MWWorld::ESMStore& store, const MWWorld::Ptr& template_, const int count = 1);
|
ManualRef(const MWWorld::ESMStore& store, const MWWorld::Ptr& template_, const int count = 1);
|
||||||
|
|
||||||
|
ManualRef(const ManualRef&) = delete;
|
||||||
|
ManualRef& operator=(const ManualRef&) = delete;
|
||||||
|
|
||||||
|
ManualRef(ManualRef&&) noexcept = default;
|
||||||
|
ManualRef& operator=(ManualRef&&) noexcept = default;
|
||||||
|
|
||||||
const Ptr& getPtr() const { return mPtr; }
|
const Ptr& getPtr() const { return mPtr; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue