mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04:00
Better object searching
This commit is contained in:
@ -222,6 +222,23 @@ PyObject* cyMisc::FindSceneObject(const plString& name, const char* ageName)
|
||||
return pySceneObject::New(key);
|
||||
}
|
||||
|
||||
PyObject* cyMisc::FindSceneObjects(const plString& name)
|
||||
{
|
||||
// assume that we won't find the sceneobject (key is equal to nil)
|
||||
std::vector<plKey> keys;
|
||||
|
||||
if ( !name.IsNull() )
|
||||
plKeyFinder::Instance().ReallyStupidSubstringSearch(name, plSceneObject::Index(), keys);
|
||||
|
||||
PyObject* result = PyList_New(keys.size());
|
||||
for (size_t i=0; i < keys.size(); i++)
|
||||
PyList_SET_ITEM(result, i, pySceneObject::New(keys[i]));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PyObject* cyMisc::FindActivator(const plString& name)
|
||||
{
|
||||
plKey key = nil;
|
||||
|
@ -147,6 +147,7 @@ public:
|
||||
// optionally propagate over the net
|
||||
//
|
||||
static PyObject* FindSceneObject(const plString& name, const char* ageName); // returns pySceneObject
|
||||
static PyObject* FindSceneObjects(const plString& name);
|
||||
static PyObject* FindActivator(const plString& name); // returns pyKey
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -190,6 +190,17 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtFindSceneobject, args, "Params: name,ageName\n
|
||||
return cyMisc::FindSceneObject(plString::FromUtf8(name), ageName);
|
||||
}
|
||||
|
||||
PYTHON_GLOBAL_METHOD_DEFINITION(PtFindSceneobjects, args, "Params: name\nThis will try to find a any sceneobject containing string in name")
|
||||
{
|
||||
char* name = NULL;
|
||||
if (!PyArg_ParseTuple(args, "s", &name))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "PtFindSceneobject expects string");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
return cyMisc::FindSceneObjects(plString::FromUtf8(name));
|
||||
}
|
||||
|
||||
PYTHON_GLOBAL_METHOD_DEFINITION(PtFindActivator, args, "Params: name\nThis will try to find an activator based on its name\n"
|
||||
"- it will return a ptKey if found"
|
||||
"- it will return None if not found")
|
||||
@ -700,6 +711,7 @@ void cyMisc::AddPlasmaMethods3(std::vector<PyMethodDef> &methods)
|
||||
PYTHON_GLOBAL_METHOD(methods, PtClearTimerCallbacks);
|
||||
|
||||
PYTHON_GLOBAL_METHOD(methods, PtFindSceneobject);
|
||||
PYTHON_GLOBAL_METHOD(methods, PtFindSceneobjects);
|
||||
PYTHON_GLOBAL_METHOD(methods, PtFindActivator);
|
||||
PYTHON_BASIC_GLOBAL_METHOD(methods, PtClearCameraStack);
|
||||
PYTHON_GLOBAL_METHOD(methods, PtWasLocallyNotified);
|
||||
|
Reference in New Issue
Block a user