mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:53:51 +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)
|
||||
{
|
||||
if (!mSoundId.empty())
|
||||
if (!mSoundId.empty() && executeImp (actor))
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
executeImp (actor);
|
||||
}
|
||||
|
||||
void MWWorld::Action::setSound (const std::string& id)
|
||||
|
|
|
@ -18,7 +18,8 @@ namespace MWWorld
|
|||
Action (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:
|
||||
|
||||
|
|
|
@ -5,8 +5,9 @@
|
|||
|
||||
namespace MWWorld
|
||||
{
|
||||
void ActionAlchemy::executeImp (const Ptr& actor)
|
||||
bool ActionAlchemy::executeImp (const Ptr& actor)
|
||||
{
|
||||
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Alchemy);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace MWWorld
|
|||
{
|
||||
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)
|
||||
{}
|
||||
|
||||
void ActionApply::executeImp (const Ptr& actor)
|
||||
bool ActionApply::executeImp (const Ptr& 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)
|
||||
{}
|
||||
|
||||
void ActionApplyWithSkill::executeImp (const Ptr& actor)
|
||||
bool ActionApplyWithSkill::executeImp (const Ptr& actor)
|
||||
{
|
||||
if (MWWorld::Class::get (getTarget()).apply (getTarget(), mId, actor) && mUsageType!=-1)
|
||||
MWWorld::Class::get (getTarget()).skillUsageSucceeded (actor, mSkillIndex, mUsageType);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace MWWorld
|
|||
{
|
||||
std::string mId;
|
||||
|
||||
virtual void executeImp (const Ptr& actor);
|
||||
virtual bool executeImp (const Ptr& actor);
|
||||
|
||||
public:
|
||||
|
||||
|
@ -26,7 +26,7 @@ namespace MWWorld
|
|||
int mSkillIndex;
|
||||
int mUsageType;
|
||||
|
||||
virtual void executeImp (const Ptr& actor);
|
||||
virtual bool executeImp (const Ptr& actor);
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
namespace MWWorld
|
||||
{
|
||||
void ActionEat::executeImp (const Ptr& actor)
|
||||
bool ActionEat::executeImp (const Ptr& actor)
|
||||
{
|
||||
// remove used item
|
||||
getTarget().getRefData().setCount (getTarget().getRefData().getCount()-1);
|
||||
|
@ -42,6 +42,8 @@ namespace MWWorld
|
|||
// increase skill
|
||||
Class::get (actor).skillUsageSucceeded (actor, ESM::Skill::Alchemy, 1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ActionEat::ActionEat (const MWWorld::Ptr& object) : Action (false, object) {}
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace MWWorld
|
|||
{
|
||||
class ActionEat : public Action
|
||||
{
|
||||
virtual void executeImp (const Ptr& actor);
|
||||
virtual bool executeImp (const Ptr& actor);
|
||||
|
||||
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);
|
||||
|
||||
|
@ -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 */
|
||||
if(equipped && actor == MWBase::Environment::get().getWorld()->getPlayer().getPlayer() && script != "")
|
||||
(*it).mRefData->getLocals().setVarByInt(script, "onpcequip", 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace MWWorld
|
|||
{
|
||||
class ActionEquip : public Action
|
||||
{
|
||||
virtual void executeImp (const Ptr& actor);
|
||||
virtual bool executeImp (const Ptr& actor);
|
||||
|
||||
public:
|
||||
/// @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))
|
||||
return;
|
||||
return false;
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Container);
|
||||
MWBase::Environment::get().getWindowManager()->getContainerWindow()->open(getTarget());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace MWWorld
|
|||
{
|
||||
class ActionOpen : public Action
|
||||
{
|
||||
virtual void executeImp (const MWWorld::Ptr& actor);
|
||||
virtual bool executeImp (const MWWorld::Ptr& actor);
|
||||
|
||||
public:
|
||||
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>();
|
||||
|
||||
|
@ -53,5 +53,6 @@ namespace MWWorld
|
|||
npcStats.flagAsUsed (ref->mBase->mId);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace MWWorld
|
|||
{
|
||||
class ActionRead : public Action
|
||||
{
|
||||
virtual void executeImp (const MWWorld::Ptr& actor);
|
||||
virtual bool executeImp (const MWWorld::Ptr& actor);
|
||||
|
||||
public:
|
||||
/// @param book or scroll to read
|
||||
|
|
|
@ -12,10 +12,10 @@ namespace MWWorld
|
|||
{
|
||||
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))
|
||||
return;
|
||||
return false;
|
||||
|
||||
// insert into player's inventory
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPtr ("player", true);
|
||||
|
@ -23,5 +23,7 @@ namespace MWWorld
|
|||
MWWorld::Class::get (player).getContainerStore (player).add (getTarget());
|
||||
|
||||
MWBase::Environment::get().getWorld()->deleteObject (getTarget());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace MWWorld
|
|||
{
|
||||
class ActionTake : public Action
|
||||
{
|
||||
virtual void executeImp (const Ptr& actor);
|
||||
virtual bool executeImp (const Ptr& actor);
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
@ -9,9 +9,13 @@ namespace MWWorld
|
|||
{
|
||||
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"))
|
||||
{
|
||||
MWBase::Environment::get().getDialogueManager()->startDialogue (getTarget());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace MWWorld
|
|||
{
|
||||
class ActionTalk : public Action
|
||||
{
|
||||
virtual void executeImp (const Ptr& actor);
|
||||
virtual bool executeImp (const Ptr& actor);
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
@ -12,11 +12,12 @@ namespace MWWorld
|
|||
{
|
||||
}
|
||||
|
||||
void ActionTeleport::executeImp (const Ptr& actor)
|
||||
bool ActionTeleport::executeImp (const Ptr& actor)
|
||||
{
|
||||
if (mCellName.empty())
|
||||
MWBase::Environment::get().getWorld()->changeToExteriorCell (mPosition);
|
||||
else
|
||||
MWBase::Environment::get().getWorld()->changeToInteriorCell (mCellName, mPosition);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace MWWorld
|
|||
std::string mCellName;
|
||||
ESM::Position mPosition;
|
||||
|
||||
virtual void executeImp (const Ptr& actor);
|
||||
virtual bool executeImp (const Ptr& actor);
|
||||
|
||||
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()))
|
||||
{
|
||||
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;
|
||||
|
||||
virtual void executeImp (const Ptr& actor);
|
||||
virtual bool executeImp (const Ptr& actor);
|
||||
|
||||
public:
|
||||
FailedAction (const std::string& message = std::string());
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace MWWorld
|
|||
/// \brief Action: do nothing
|
||||
class NullAction : public Action
|
||||
{
|
||||
virtual void executeImp (const Ptr& actor) {}
|
||||
virtual bool executeImp (const Ptr& actor) {return false;}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue