forked from mirror/openmw-tes3mp
Merge remote-tracking branch 'lgro/issue1887_equipped_items_doesnt_emit_sound'
Conflicts: apps/openmw/mwworld/class.cpp
This commit is contained in:
commit
aefe8cd4ae
8 changed files with 62 additions and 15 deletions
|
@ -297,4 +297,9 @@ namespace MWClass
|
|||
|
||||
state2.mTime = dynamic_cast<LightCustomData&> (*ptr.getRefData().getCustomData()).mTime;
|
||||
}
|
||||
|
||||
std::string Light::getSound(const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
return ptr.get<ESM::Light>()->mBase->mSound;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,6 +82,8 @@ namespace MWClass
|
|||
virtual void writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state)
|
||||
const;
|
||||
///< Write additional state from \a ptr into \a state.
|
||||
|
||||
virtual std::string getSound(const MWWorld::Ptr& ptr) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace MWRender
|
|||
mNode = renderRoot->createChildSceneNode();
|
||||
|
||||
mAnimation = new NpcAnimation(mCharacter, mNode,
|
||||
0, true, (renderHeadOnly() ? NpcAnimation::VM_HeadOnly : NpcAnimation::VM_Normal));
|
||||
0, true, true, (renderHeadOnly() ? NpcAnimation::VM_HeadOnly : NpcAnimation::VM_Normal));
|
||||
|
||||
Ogre::Vector3 scale = mNode->getScale();
|
||||
mCamera->setPosition(mPosition * scale);
|
||||
|
@ -118,7 +118,7 @@ namespace MWRender
|
|||
assert(mAnimation);
|
||||
delete mAnimation;
|
||||
mAnimation = new NpcAnimation(mCharacter, mNode,
|
||||
0, true, (renderHeadOnly() ? NpcAnimation::VM_HeadOnly : NpcAnimation::VM_Normal));
|
||||
0, true, true, (renderHeadOnly() ? NpcAnimation::VM_HeadOnly : NpcAnimation::VM_Normal));
|
||||
|
||||
float scale=1.f;
|
||||
mCharacter.getClass().adjustScale(mCharacter, scale);
|
||||
|
|
|
@ -177,7 +177,7 @@ NpcAnimation::~NpcAnimation()
|
|||
}
|
||||
|
||||
|
||||
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, int visibilityFlags, bool disableListener, ViewMode viewMode)
|
||||
NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, int visibilityFlags, bool disableListener, bool disableSounds, ViewMode viewMode)
|
||||
: Animation(ptr, node),
|
||||
mVisibilityFlags(visibilityFlags),
|
||||
mListenerDisabled(disableListener),
|
||||
|
@ -186,7 +186,8 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, int v
|
|||
mShowCarriedLeft(true),
|
||||
mFirstPersonOffset(0.f, 0.f, 0.f),
|
||||
mAlpha(1.f),
|
||||
mNpcType(Type_Normal)
|
||||
mNpcType(Type_Normal),
|
||||
mSoundsDisabled(disableSounds)
|
||||
{
|
||||
mNpc = mPtr.get<ESM::NPC>()->mBase;
|
||||
|
||||
|
@ -297,7 +298,6 @@ void NpcAnimation::updateParts()
|
|||
{
|
||||
mAlpha = 1.f;
|
||||
const MWWorld::Class &cls = mPtr.getClass();
|
||||
MWWorld::InventoryStore &inv = cls.getInventoryStore(mPtr);
|
||||
|
||||
NpcType curType = Type_Normal;
|
||||
if (cls.getCreatureStats(mPtr).getMagicEffects().get(ESM::MagicEffect::Vampirism).getMagnitude() > 0)
|
||||
|
@ -334,6 +334,7 @@ void NpcAnimation::updateParts()
|
|||
};
|
||||
static const size_t slotlistsize = sizeof(slotlist)/sizeof(slotlist[0]);
|
||||
|
||||
MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||
for(size_t i = 0;i < slotlistsize && mViewMode != VM_HeadOnly;i++)
|
||||
{
|
||||
MWWorld::ContainerStoreIterator store = inv.getSlot(slotlist[i].mSlot);
|
||||
|
@ -625,6 +626,11 @@ void NpcAnimation::removeIndividualPart(ESM::PartReferenceType type)
|
|||
mPartslots[type] = -1;
|
||||
|
||||
mObjectParts[type].setNull();
|
||||
if (!mSoundIds[type].empty() && !mSoundsDisabled)
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->stopSound3D(mPtr, mSoundIds[type]);
|
||||
mSoundIds[type].clear();
|
||||
}
|
||||
}
|
||||
|
||||
void NpcAnimation::reserveIndividualPart(ESM::PartReferenceType type, int group, int priority)
|
||||
|
@ -654,8 +660,22 @@ bool NpcAnimation::addOrReplaceIndividualPart(ESM::PartReferenceType type, int g
|
|||
removeIndividualPart(type);
|
||||
mPartslots[type] = group;
|
||||
mPartPriorities[type] = priority;
|
||||
|
||||
mObjectParts[type] = insertBoundedPart(mesh, group, sPartList.at(type), enchantedGlow, glowColor);
|
||||
|
||||
if (!mSoundsDisabled)
|
||||
{
|
||||
MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||
MWWorld::ContainerStoreIterator csi = inv.getSlot(group < 0 ? MWWorld::InventoryStore::Slot_Helmet : group);
|
||||
if (csi != inv.end())
|
||||
{
|
||||
mSoundIds[type] = csi->getClass().getSound(*csi);
|
||||
if (!mSoundIds[type].empty())
|
||||
{
|
||||
MWBase::Environment::get().getSoundManager()->playSound3D(mPtr, mSoundIds[type], 1.0f, 1.0f, MWBase::SoundManager::Play_TypeSfx,
|
||||
MWBase::SoundManager::Play_Loop);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(mObjectParts[type]->mSkelBase)
|
||||
{
|
||||
Ogre::SkeletonInstance *skel = mObjectParts[type]->mSkelBase->getSkeleton();
|
||||
|
@ -760,7 +780,7 @@ void NpcAnimation::showWeapons(bool showWeapon)
|
|||
mShowWeapons = showWeapon;
|
||||
if(showWeapon)
|
||||
{
|
||||
MWWorld::InventoryStore &inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||
MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||
MWWorld::ContainerStoreIterator weapon = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
if(weapon != inv.end())
|
||||
{
|
||||
|
@ -793,9 +813,8 @@ void NpcAnimation::showWeapons(bool showWeapon)
|
|||
void NpcAnimation::showCarriedLeft(bool show)
|
||||
{
|
||||
mShowCarriedLeft = show;
|
||||
MWWorld::InventoryStore &inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||
MWWorld::InventoryStore& inv = mPtr.getClass().getInventoryStore(mPtr);
|
||||
MWWorld::ContainerStoreIterator iter = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedLeft);
|
||||
|
||||
if(show && iter != inv.end())
|
||||
{
|
||||
Ogre::Vector3 glowColor = getEnchantmentColor(*iter);
|
||||
|
@ -928,4 +947,9 @@ void NpcAnimation::applyAlpha(float alpha, Ogre::Entity *ent, NifOgre::ObjectSce
|
|||
}
|
||||
}
|
||||
|
||||
void NpcAnimation::equipmentChanged()
|
||||
{
|
||||
updateParts();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
class NpcAnimation : public Animation, public WeaponAnimation, public MWWorld::InventoryStoreListener
|
||||
{
|
||||
public:
|
||||
virtual void equipmentChanged() { updateParts(); }
|
||||
virtual void equipmentChanged();
|
||||
virtual void permanentEffectAdded(const ESM::MagicEffect *magicEffect, bool isNew, bool playSound);
|
||||
|
||||
public:
|
||||
|
@ -70,6 +70,7 @@ private:
|
|||
|
||||
// Bounded Parts
|
||||
NifOgre::ObjectScenePtr mObjectParts[ESM::PRT_Count];
|
||||
std::string mSoundIds[ESM::PRT_Count];
|
||||
|
||||
const ESM::NPC *mNpc;
|
||||
std::string mHeadModel;
|
||||
|
@ -97,6 +98,7 @@ private:
|
|||
Ogre::SharedPtr<WeaponAnimationTime> mWeaponAnimationTime;
|
||||
|
||||
float mAlpha;
|
||||
bool mSoundsDisabled;
|
||||
|
||||
void updateNpcBase();
|
||||
|
||||
|
@ -123,10 +125,11 @@ public:
|
|||
* one listener at a time, so you shouldn't do this if creating several NpcAnimations
|
||||
* for the same Ptr, eg preview dolls for the player.
|
||||
* Those need to be manually rendered anyway.
|
||||
* @param disableSounds Same as \a disableListener but for playing items sounds
|
||||
* @param viewMode
|
||||
*/
|
||||
NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, int visibilityFlags, bool disableListener = false,
|
||||
ViewMode viewMode=VM_Normal);
|
||||
bool disableSounds = false, ViewMode viewMode=VM_Normal);
|
||||
virtual ~NpcAnimation();
|
||||
|
||||
virtual void enableHeadAnimation(bool enable);
|
||||
|
|
|
@ -429,4 +429,9 @@ namespace MWWorld
|
|||
|
||||
return getEncumbrance(ptr) / capacity;
|
||||
}
|
||||
|
||||
std::string Class::getSound(const MWWorld::Ptr&) const
|
||||
{
|
||||
return std::string();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -339,6 +339,9 @@ namespace MWWorld
|
|||
virtual void respawn (const MWWorld::Ptr& ptr) const {}
|
||||
|
||||
virtual void restock (const MWWorld::Ptr& ptr) const {}
|
||||
|
||||
/// Returns sound id
|
||||
virtual std::string getSound(const MWWorld::Ptr& ptr) const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -148,16 +148,18 @@ void MWWorld::InventoryStore::equip (int slot, const ContainerStoreIterator& ite
|
|||
flagAsModified();
|
||||
|
||||
fireEquipmentChangedEvent();
|
||||
|
||||
updateMagicEffects(actor);
|
||||
}
|
||||
|
||||
void MWWorld::InventoryStore::unequipAll(const MWWorld::Ptr& actor)
|
||||
{
|
||||
// Only *one* change event should be fired
|
||||
mUpdatesEnabled = false;
|
||||
for (int slot=0; slot < MWWorld::InventoryStore::Slots; ++slot)
|
||||
unequipSlot(slot, actor);
|
||||
|
||||
mUpdatesEnabled = true;
|
||||
|
||||
fireEquipmentChangedEvent();
|
||||
updateMagicEffects(actor);
|
||||
}
|
||||
|
@ -204,8 +206,9 @@ void MWWorld::InventoryStore::autoEquip (const MWWorld::Ptr& actor)
|
|||
if (!Misc::StringUtils::ciEqual(test.getCellRef().getOwner(), actor.getCellRef().getRefId()) &&
|
||||
(actor.getClass().getScript(actor).empty() ||
|
||||
!actor.getRefData().getLocals().getIntVar(actor.getClass().getScript(actor), "companion")))
|
||||
{
|
||||
continue;
|
||||
|
||||
}
|
||||
int testSkill = test.getClass().getEquipmentSkill (test);
|
||||
|
||||
std::pair<std::vector<int>, bool> itemsSlots =
|
||||
|
@ -277,11 +280,13 @@ void MWWorld::InventoryStore::autoEquip (const MWWorld::Ptr& actor)
|
|||
bool changed = false;
|
||||
|
||||
for (std::size_t i=0; i<slots_.size(); ++i)
|
||||
if (slots_[i]!=mSlots[i])
|
||||
{
|
||||
if (slots_[i] != mSlots[i])
|
||||
{
|
||||
changed = true;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
mUpdatesEnabled = true;
|
||||
|
||||
if (changed)
|
||||
|
|
Loading…
Reference in a new issue