From b6a371f49fe242ba1da6a74fb60e713a48c5d928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20Mei=C3=9Fner?= Date: Wed, 30 Nov 2011 15:20:12 +0100 Subject: [PATCH] Add animation loop functions to Python --- .../Plasma/FeatureLib/pfPython/cyAvatar.cpp | 38 +++++++++++++++++++ Sources/Plasma/FeatureLib/pfPython/cyAvatar.h | 18 +++++++++ .../FeatureLib/pfPython/cyAvatarGlue.cpp | 28 ++++++++++++++ 3 files changed, 84 insertions(+) diff --git a/Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp b/Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp index f656d75e..a4e00c5c 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyAvatar.cpp +++ b/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() { diff --git a/Sources/Plasma/FeatureLib/pfPython/cyAvatar.h b/Sources/Plasma/FeatureLib/pfPython/cyAvatar.h index f35d3df2..fa7973df 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyAvatar.h +++ b/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); ///////////////////////////////////////////////////////////////////////////// // diff --git a/Sources/Plasma/FeatureLib/pfPython/cyAvatarGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/cyAvatarGlue.cpp index cac713c6..605eb562 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyAvatarGlue.cpp +++ b/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 &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);