Browse Source

Add animation loop functions to Python

Florian Meißner 13 years ago
parent
commit
b6a371f49f
  1. 38
      Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp
  2. 18
      Sources/Plasma/FeatureLib/pfPython/cyAvatar.h
  3. 28
      Sources/Plasma/FeatureLib/pfPython/cyAvatarGlue.cpp

38
Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp

@ -1761,6 +1761,44 @@ bool cyAvatar::ExitPBMode()
return IExitTopmostGenericMode();
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : EnterAnimMode
// PARAMETERS : animName - string
//
// PURPOSE : Makes the avatar enter a custom anim loop.
//
void cyAvatar::EnterAnimMode(plString animName)
{
plArmatureMod *fAvMod = plAvatarMgr::GetInstance()->GetLocalAvatar();
if (!fAvMod->FindAnimInstance(animName)) {
plKey avKey = fAvMod->GetKey();
plAvAnimTask *animTask = new plAvAnimTask(animName, 0.0, 1.0, 1.0, 0.0, true, true, true);
plAvTaskMsg *taskMsg = new plAvTaskMsg(avKey, avKey, animTask);
taskMsg->SetBCastFlag(plMessage::kNetPropagate);
taskMsg->Send();
}
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : ExitAnimMode
// PARAMETERS : animName - string
//
// PURPOSE : Makes the avatar stop the custom anim loop.
//
void cyAvatar::ExitAnimMode(plString animName)
{
plArmatureMod *fAvMod = plAvatarMgr::GetInstance()->GetLocalAvatar();
if (fAvMod->FindAnimInstance(animName)) {
plKey avKey = fAvMod->GetKey();
plAvAnimTask *animTask = new plAvAnimTask(animName, -1.0);
plAvTaskMsg *taskMsg = new plAvTaskMsg(avKey, avKey, animTask);
taskMsg->SetBCastFlag(plMessage::kNetPropagate);
taskMsg->Send();
}
}
int cyAvatar::GetCurrentMode()
{

18
Sources/Plasma/FeatureLib/pfPython/cyAvatar.h

@ -511,6 +511,24 @@ public:
// : more specific in future version
//
static bool ExitPBMode();
/////////////////////////////////////////////////////////////////////////////
//
// Function : EnterAnimMode
// PARAMETERS : animName - string
//
// PURPOSE : Makes the avatar enter a custom anim loop.
//
static void EnterAnimMode(plString animName);
/////////////////////////////////////////////////////////////////////////////
//
// Function : ExitAnimMode
// PARAMETERS : animName - string
//
// PURPOSE : Makes the avatar stop the custom anim loop.
//
static void ExitAnimMode(plString animName);
/////////////////////////////////////////////////////////////////////////////
//

28
Sources/Plasma/FeatureLib/pfPython/cyAvatarGlue.cpp

@ -777,6 +777,32 @@ PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtAvatarExitAFK, "Tells the local avatar
PYTHON_RETURN_BOOL(cyAvatar::ExitAFKMode());
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtAvatarEnterAnimMode, args, "Params: animName\nEnter a custom anim loop (netpropagated)")
{
char* animName;
if (!PyArg_ParseTuple(args, "s", &animName))
{
PyErr_SetString(PyExc_TypeError, "PtAvatarEnterAnimMode expects a string");
PYTHON_RETURN_ERROR;
}
cyAvatar::EnterAnimMode(animName);
PYTHON_RETURN_NONE;
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtAvatarExitAnimMode, args, "Params: animName\nExit a custom anim loop (netpropagated)")
{
char* animName;
if (!PyArg_ParseTuple(args, "s", &animName))
{
PyErr_SetString(PyExc_TypeError, "PtAvatarExitAnimMode expects a string");
PYTHON_RETURN_ERROR;
}
cyAvatar::ExitAnimMode(animName);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_GLOBAL_METHOD_DEFINITION(PtDisableMovementKeys, cyAvatar::DisableMovementControls, "Disable avatar movement input")
PYTHON_BASIC_GLOBAL_METHOD_DEFINITION(PtEnableMovementKeys, cyAvatar::EnableMovementControls, "Enable avatar movement input")
PYTHON_BASIC_GLOBAL_METHOD_DEFINITION(PtDisableMouseMovement, cyAvatar::DisableMouseMovement, "Disable avatar mouse movement input")
@ -870,6 +896,8 @@ void cyAvatar::AddPlasmaMethods(std::vector<PyMethodDef> &methods)
PYTHON_GLOBAL_METHOD_NOARGS(methods, PtAvatarExitUsePersBook);
PYTHON_GLOBAL_METHOD_NOARGS(methods, PtAvatarEnterAFK);
PYTHON_GLOBAL_METHOD_NOARGS(methods, PtAvatarExitAFK);
PYTHON_GLOBAL_METHOD(methods, PtAvatarEnterAnimMode);
PYTHON_GLOBAL_METHOD(methods, PtAvatarExitAnimMode);
// Suspend avatar input
PYTHON_BASIC_GLOBAL_METHOD(methods, PtDisableMovementKeys);

Loading…
Cancel
Save