mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04:00
Add clothing file functions to the Avatar Python API
This commit is contained in:
@ -1592,6 +1592,60 @@ void cyAvatar::PlaySimpleAnimation(const plString& animName)
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Function : SaveClothingToFile
|
||||
// PARAMETERS : filename - file to save to
|
||||
//
|
||||
// PURPOSE : Save the avatar's clothing to a file. If only a filename is
|
||||
// given, it will write to UserData/Avatars.
|
||||
//
|
||||
bool cyAvatar::SaveClothingToFile(plFileName filename)
|
||||
{
|
||||
if (fRecvr.Count() > 0) {
|
||||
plArmatureMod* avatar = plAvatarMgr::FindAvatar(fRecvr[0]);
|
||||
if (avatar) {
|
||||
plClothingOutfit* cl = avatar->GetClothingOutfit();
|
||||
if (cl) {
|
||||
// Save file in UserData/Avatars if only a filename is given
|
||||
if (!filename.StripFileName().IsValid()) {
|
||||
plFileName path = plFileName::Join(plFileSystem::GetUserDataPath(), "Avatars");
|
||||
plFileSystem::CreateDir(path, true);
|
||||
filename = plFileName::Join(path, filename);
|
||||
}
|
||||
return cl->WriteToFile(filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Function : LoadClothingFromFile
|
||||
// PARAMETERS : filename - file to load from
|
||||
//
|
||||
// PURPOSE : Load the avatar's clothing from a file. If only a filename is
|
||||
// given, it will read from UserData/Avatars.
|
||||
//
|
||||
bool cyAvatar::LoadClothingFromFile(plFileName filename)
|
||||
{
|
||||
if (fRecvr.Count() > 0) {
|
||||
plArmatureMod* avatar = plAvatarMgr::FindAvatar(fRecvr[0]);
|
||||
if (avatar) {
|
||||
plClothingOutfit* cl = avatar->GetClothingOutfit();
|
||||
if (cl) {
|
||||
// Search for file in UserData/Avatars if only a filename is given
|
||||
if (!filename.StripFileName().IsValid())
|
||||
filename = plFileName::Join(plFileSystem::GetUserDataPath(), "Avatars", filename);
|
||||
cl->SetClothingFile(filename);
|
||||
return cl->ReadClothing();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Function : ChangeAvatar
|
||||
|
@ -410,6 +410,9 @@ public:
|
||||
|
||||
virtual void PlaySimpleAnimation(const plString& animName);
|
||||
|
||||
virtual bool SaveClothingToFile(plFileName filename);
|
||||
virtual bool LoadClothingFromFile(plFileName filename);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Function : ChangeAvatar
|
||||
|
@ -597,6 +597,30 @@ PYTHON_METHOD_DEFINITION(ptAvatar, playSimpleAnimation, args)
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptAvatar, saveClothingToFile, args)
|
||||
{
|
||||
PyObject* filename;
|
||||
if (!PyArg_ParseTuple(args, "O", &filename) || !PyString_CheckEx(filename))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "saveClothingToFile expects a string object");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
PYTHON_RETURN_BOOL(self->fThis->SaveClothingToFile(PyString_AsStringEx(filename)));
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptAvatar, loadClothingFromFile, args)
|
||||
{
|
||||
PyObject* filename;
|
||||
if (!PyArg_ParseTuple(args, "O", &filename) || !PyString_CheckEx(filename))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "loadClothingFromFile expects a string object");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
PYTHON_RETURN_BOOL(self->fThis->LoadClothingFromFile(PyString_AsStringEx(filename)));
|
||||
}
|
||||
|
||||
PYTHON_START_METHODS_TABLE(ptAvatar)
|
||||
PYTHON_METHOD(ptAvatar, netForce, "Params: forceFlag\nSpecify whether this object needs to use messages that are forced to the network\n"
|
||||
"- This is to be used if your Python program is running on only one client\n"
|
||||
@ -651,6 +675,9 @@ PYTHON_START_METHODS_TABLE(ptAvatar)
|
||||
PYTHON_METHOD(ptAvatar, unRegisterForBehaviorNotify, "Params: selfKey\nThis will unregister behavior notifications"),
|
||||
|
||||
PYTHON_METHOD(ptAvatar, playSimpleAnimation, "Params: animName\nPlay simple animation on avatar"),
|
||||
|
||||
PYTHON_METHOD(ptAvatar, saveClothingToFile, "Params: filename\nSave avatar clothing to a file"),
|
||||
PYTHON_METHOD(ptAvatar, loadClothingFromFile, "Params: filename\nLoad avatar clothing from a file"),
|
||||
PYTHON_END_METHODS_TABLE;
|
||||
|
||||
PYTHON_GLOBAL_METHOD_DEFINITION(PtSetBehaviorLoopCount, args, "Params: behaviorKey,stage,loopCount,netForce\nThis will set the loop count for a particular stage in a multistage behavior")
|
||||
|
Reference in New Issue
Block a user