mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 03:53:52 +00:00
Action::executeImp returns a bool value to indicate if the sound should be played.
This commit is contained in:
parent
7d918caa93
commit
0bc34c1c0d
23 changed files with 49 additions and 33 deletions
|
@ -18,7 +18,7 @@ MWWorld::Action::~Action() {}
|
||||||
|
|
||||||
void MWWorld::Action::execute (const Ptr& actor)
|
void MWWorld::Action::execute (const Ptr& actor)
|
||||||
{
|
{
|
||||||
if (!mSoundId.empty())
|
if (!mSoundId.empty() && executeImp (actor))
|
||||||
{
|
{
|
||||||
if (mKeepSound && actor.getRefData().getHandle()=="player")
|
if (mKeepSound && actor.getRefData().getHandle()=="player")
|
||||||
{
|
{
|
||||||
|
@ -35,8 +35,6 @@ void MWWorld::Action::execute (const Ptr& actor)
|
||||||
mKeepSound ? MWBase::SoundManager::Play_NoTrack : MWBase::SoundManager::Play_Normal);
|
mKeepSound ? MWBase::SoundManager::Play_NoTrack : MWBase::SoundManager::Play_Normal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
executeImp (actor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWWorld::Action::setSound (const std::string& id)
|
void MWWorld::Action::setSound (const std::string& id)
|
||||||
|
|
|
@ -18,7 +18,8 @@ namespace MWWorld
|
||||||
Action (const Action& action);
|
Action (const Action& action);
|
||||||
Action& operator= (const Action& action);
|
Action& operator= (const Action& action);
|
||||||
|
|
||||||
virtual void executeImp (const Ptr& actor) = 0;
|
/// @return true if the sound should be played, false if not (e.g. if the action is not allowed)
|
||||||
|
virtual bool executeImp (const Ptr& actor) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,9 @@
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
void ActionAlchemy::executeImp (const Ptr& actor)
|
bool ActionAlchemy::executeImp (const Ptr& actor)
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Alchemy);
|
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Alchemy);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
class ActionAlchemy : public Action
|
class ActionAlchemy : public Action
|
||||||
{
|
{
|
||||||
virtual void executeImp (const Ptr& actor);
|
virtual bool executeImp (const Ptr& actor);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,10 @@ namespace MWWorld
|
||||||
: Action (false, target), mId (id)
|
: Action (false, target), mId (id)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void ActionApply::executeImp (const Ptr& actor)
|
bool ActionApply::executeImp (const Ptr& actor)
|
||||||
{
|
{
|
||||||
MWWorld::Class::get (getTarget()).apply (getTarget(), mId, actor);
|
MWWorld::Class::get (getTarget()).apply (getTarget(), mId, actor);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,9 +21,10 @@ namespace MWWorld
|
||||||
: Action (false, target), mId (id), mSkillIndex (skillIndex), mUsageType (usageType)
|
: Action (false, target), mId (id), mSkillIndex (skillIndex), mUsageType (usageType)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void ActionApplyWithSkill::executeImp (const Ptr& actor)
|
bool ActionApplyWithSkill::executeImp (const Ptr& actor)
|
||||||
{
|
{
|
||||||
if (MWWorld::Class::get (getTarget()).apply (getTarget(), mId, actor) && mUsageType!=-1)
|
if (MWWorld::Class::get (getTarget()).apply (getTarget(), mId, actor) && mUsageType!=-1)
|
||||||
MWWorld::Class::get (getTarget()).skillUsageSucceeded (actor, mSkillIndex, mUsageType);
|
MWWorld::Class::get (getTarget()).skillUsageSucceeded (actor, mSkillIndex, mUsageType);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
std::string mId;
|
std::string mId;
|
||||||
|
|
||||||
virtual void executeImp (const Ptr& actor);
|
virtual bool executeImp (const Ptr& actor);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ namespace MWWorld
|
||||||
int mSkillIndex;
|
int mSkillIndex;
|
||||||
int mUsageType;
|
int mUsageType;
|
||||||
|
|
||||||
virtual void executeImp (const Ptr& actor);
|
virtual bool executeImp (const Ptr& actor);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
void ActionEat::executeImp (const Ptr& actor)
|
bool ActionEat::executeImp (const Ptr& actor)
|
||||||
{
|
{
|
||||||
// remove used item
|
// remove used item
|
||||||
getTarget().getRefData().setCount (getTarget().getRefData().getCount()-1);
|
getTarget().getRefData().setCount (getTarget().getRefData().getCount()-1);
|
||||||
|
@ -42,6 +42,8 @@ namespace MWWorld
|
||||||
// increase skill
|
// increase skill
|
||||||
Class::get (actor).skillUsageSucceeded (actor, ESM::Skill::Alchemy, 1);
|
Class::get (actor).skillUsageSucceeded (actor, ESM::Skill::Alchemy, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionEat::ActionEat (const MWWorld::Ptr& object) : Action (false, object) {}
|
ActionEat::ActionEat (const MWWorld::Ptr& object) : Action (false, object) {}
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
class ActionEat : public Action
|
class ActionEat : public Action
|
||||||
{
|
{
|
||||||
virtual void executeImp (const Ptr& actor);
|
virtual bool executeImp (const Ptr& actor);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionEquip::executeImp (const Ptr& actor)
|
bool ActionEquip::executeImp (const Ptr& actor)
|
||||||
{
|
{
|
||||||
MWWorld::InventoryStore& invStore = MWWorld::Class::get(actor).getInventoryStore(actor);
|
MWWorld::InventoryStore& invStore = MWWorld::Class::get(actor).getInventoryStore(actor);
|
||||||
|
|
||||||
|
@ -113,5 +113,7 @@ namespace MWWorld
|
||||||
/* Set OnPCEquip Variable on item's script, if the player is equipping it, and it has a script with that variable declared */
|
/* Set OnPCEquip Variable on item's script, if the player is equipping it, and it has a script with that variable declared */
|
||||||
if(equipped && actor == MWBase::Environment::get().getWorld()->getPlayer().getPlayer() && script != "")
|
if(equipped && actor == MWBase::Environment::get().getWorld()->getPlayer().getPlayer() && script != "")
|
||||||
(*it).mRefData->getLocals().setVarByInt(script, "onpcequip", 1);
|
(*it).mRefData->getLocals().setVarByInt(script, "onpcequip", 1);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
class ActionEquip : public Action
|
class ActionEquip : public Action
|
||||||
{
|
{
|
||||||
virtual void executeImp (const Ptr& actor);
|
virtual bool executeImp (const Ptr& actor);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// @param item to equip
|
/// @param item to equip
|
||||||
|
|
|
@ -14,12 +14,13 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionOpen::executeImp (const MWWorld::Ptr& actor)
|
bool ActionOpen::executeImp (const MWWorld::Ptr& actor)
|
||||||
{
|
{
|
||||||
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
|
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Container);
|
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Container);
|
||||||
MWBase::Environment::get().getWindowManager()->getContainerWindow()->open(getTarget());
|
MWBase::Environment::get().getWindowManager()->getContainerWindow()->open(getTarget());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
class ActionOpen : public Action
|
class ActionOpen : public Action
|
||||||
{
|
{
|
||||||
virtual void executeImp (const MWWorld::Ptr& actor);
|
virtual bool executeImp (const MWWorld::Ptr& actor);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ActionOpen (const Ptr& container);
|
ActionOpen (const Ptr& container);
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionRead::executeImp (const MWWorld::Ptr& actor)
|
bool ActionRead::executeImp (const MWWorld::Ptr& actor)
|
||||||
{
|
{
|
||||||
LiveCellRef<ESM::Book> *ref = getTarget().get<ESM::Book>();
|
LiveCellRef<ESM::Book> *ref = getTarget().get<ESM::Book>();
|
||||||
|
|
||||||
|
@ -53,5 +53,6 @@ namespace MWWorld
|
||||||
npcStats.flagAsUsed (ref->mBase->mId);
|
npcStats.flagAsUsed (ref->mBase->mId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
class ActionRead : public Action
|
class ActionRead : public Action
|
||||||
{
|
{
|
||||||
virtual void executeImp (const MWWorld::Ptr& actor);
|
virtual bool executeImp (const MWWorld::Ptr& actor);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// @param book or scroll to read
|
/// @param book or scroll to read
|
||||||
|
|
|
@ -12,10 +12,10 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
ActionTake::ActionTake (const MWWorld::Ptr& object) : Action (true, object) {}
|
ActionTake::ActionTake (const MWWorld::Ptr& object) : Action (true, object) {}
|
||||||
|
|
||||||
void ActionTake::executeImp (const Ptr& actor)
|
bool ActionTake::executeImp (const Ptr& actor)
|
||||||
{
|
{
|
||||||
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
|
if (!MWBase::Environment::get().getWindowManager()->isAllowed(MWGui::GW_Inventory))
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
// insert into player's inventory
|
// insert into player's inventory
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPtr ("player", true);
|
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPtr ("player", true);
|
||||||
|
@ -23,5 +23,7 @@ namespace MWWorld
|
||||||
MWWorld::Class::get (player).getContainerStore (player).add (getTarget());
|
MWWorld::Class::get (player).getContainerStore (player).add (getTarget());
|
||||||
|
|
||||||
MWBase::Environment::get().getWorld()->deleteObject (getTarget());
|
MWBase::Environment::get().getWorld()->deleteObject (getTarget());
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
class ActionTake : public Action
|
class ActionTake : public Action
|
||||||
{
|
{
|
||||||
virtual void executeImp (const Ptr& actor);
|
virtual bool executeImp (const Ptr& actor);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,13 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
ActionTalk::ActionTalk (const Ptr& actor) : Action (false, actor) {}
|
ActionTalk::ActionTalk (const Ptr& actor) : Action (false, actor) {}
|
||||||
|
|
||||||
void ActionTalk::executeImp (const Ptr& actor)
|
bool ActionTalk::executeImp (const Ptr& actor)
|
||||||
{
|
{
|
||||||
if (MWBase::Environment::get().getInputManager ()->getControlSwitch ("playercontrols"))
|
if (MWBase::Environment::get().getInputManager ()->getControlSwitch ("playercontrols"))
|
||||||
|
{
|
||||||
MWBase::Environment::get().getDialogueManager()->startDialogue (getTarget());
|
MWBase::Environment::get().getDialogueManager()->startDialogue (getTarget());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
class ActionTalk : public Action
|
class ActionTalk : public Action
|
||||||
{
|
{
|
||||||
virtual void executeImp (const Ptr& actor);
|
virtual bool executeImp (const Ptr& actor);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,12 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionTeleport::executeImp (const Ptr& actor)
|
bool ActionTeleport::executeImp (const Ptr& actor)
|
||||||
{
|
{
|
||||||
if (mCellName.empty())
|
if (mCellName.empty())
|
||||||
MWBase::Environment::get().getWorld()->changeToExteriorCell (mPosition);
|
MWBase::Environment::get().getWorld()->changeToExteriorCell (mPosition);
|
||||||
else
|
else
|
||||||
MWBase::Environment::get().getWorld()->changeToInteriorCell (mCellName, mPosition);
|
MWBase::Environment::get().getWorld()->changeToInteriorCell (mCellName, mPosition);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace MWWorld
|
||||||
std::string mCellName;
|
std::string mCellName;
|
||||||
ESM::Position mPosition;
|
ESM::Position mPosition;
|
||||||
|
|
||||||
virtual void executeImp (const Ptr& actor);
|
virtual bool executeImp (const Ptr& actor);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,12 @@ namespace MWWorld
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
|
||||||
void FailedAction::executeImp (const Ptr& actor)
|
bool FailedAction::executeImp (const Ptr& actor)
|
||||||
{
|
{
|
||||||
if ( actor.getRefData().getHandle()=="player" && !(message.empty()))
|
if ( actor.getRefData().getHandle()=="player" && !(message.empty()))
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWindowManager() ->messageBox(message, std::vector<std::string>());
|
MWBase::Environment::get().getWindowManager() ->messageBox(message, std::vector<std::string>());
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,11 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
std::string message;
|
std::string message;
|
||||||
|
|
||||||
virtual void executeImp (const Ptr& actor);
|
virtual bool executeImp (const Ptr& actor);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FailedAction (const std::string& message = std::string());
|
FailedAction (const std::string& message = std::string());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace MWWorld
|
||||||
/// \brief Action: do nothing
|
/// \brief Action: do nothing
|
||||||
class NullAction : public Action
|
class NullAction : public Action
|
||||||
{
|
{
|
||||||
virtual void executeImp (const Ptr& actor) {}
|
virtual bool executeImp (const Ptr& actor) {return false;}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue