mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-18 12:43:44 -04:00
a bit friendlier
This commit is contained in:
parent
76687fca8f
commit
277753ed2b
@ -211,7 +211,7 @@ class TaskManager:
|
|||||||
self.mgr.add(task)
|
self.mgr.add(task)
|
||||||
return task
|
return task
|
||||||
|
|
||||||
def add(self, funcOrTask, name, sort = None, extraArgs = None,
|
def add(self, funcOrTask, name = None, sort = None, extraArgs = None,
|
||||||
priority = None, uponDeath = None, appendTask = False,
|
priority = None, uponDeath = None, appendTask = False,
|
||||||
taskChain = None, owner = None):
|
taskChain = None, owner = None):
|
||||||
|
|
||||||
@ -275,13 +275,16 @@ class TaskManager:
|
|||||||
else:
|
else:
|
||||||
self.notify.error(
|
self.notify.error(
|
||||||
'add: Tried to add a task that was not a Task or a func')
|
'add: Tried to add a task that was not a Task or a func')
|
||||||
assert isinstance(name, types.StringTypes), 'Name must be a string type'
|
|
||||||
if extraArgs is None:
|
if extraArgs is None:
|
||||||
extraArgs = []
|
extraArgs = []
|
||||||
appendTask = True
|
appendTask = True
|
||||||
task.setArgs(extraArgs, appendTask)
|
task.setArgs(extraArgs, appendTask)
|
||||||
|
|
||||||
task.setName(name)
|
if name is not None:
|
||||||
|
assert isinstance(name, types.StringTypes), 'Name must be a string type'
|
||||||
|
task.setName(name)
|
||||||
|
assert task.hasName()
|
||||||
|
|
||||||
# For historical reasons, if priority is specified but not
|
# For historical reasons, if priority is specified but not
|
||||||
# sort, it really means sort.
|
# sort, it really means sort.
|
||||||
|
@ -49,8 +49,9 @@ get_manager() const {
|
|||||||
//
|
//
|
||||||
// Setting this value after the task has already been
|
// Setting this value after the task has already been
|
||||||
// added will not affect the task's wake time; it will
|
// added will not affect the task's wake time; it will
|
||||||
// only affect the task if the it is re-added to the
|
// only affect the task if it is re-added to the queue
|
||||||
// queue in the future.
|
// in the future, for instance if the task returns
|
||||||
|
// DS_again.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
INLINE void AsyncTask::
|
INLINE void AsyncTask::
|
||||||
set_delay(double delay) {
|
set_delay(double delay) {
|
||||||
|
@ -248,9 +248,13 @@ __setattr__(const string &attr_name, PyObject *v) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (attr_name == "delayTime") {
|
if (attr_name == "delayTime") {
|
||||||
double delay = PyFloat_AsDouble(v);
|
if (v == Py_None) {
|
||||||
if (!PyErr_Occurred()) {
|
clear_delay();
|
||||||
set_delay(delay);
|
} else {
|
||||||
|
double delay = PyFloat_AsDouble(v);
|
||||||
|
if (!PyErr_Occurred()) {
|
||||||
|
set_delay(delay);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (attr_name == "name") {
|
} else if (attr_name == "name") {
|
||||||
@ -259,7 +263,7 @@ __setattr__(const string &attr_name, PyObject *v) {
|
|||||||
set_name(name);
|
set_name(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (attr_name == "id") {
|
} else if (attr_name == "id" || attr_name == "wakeTime") {
|
||||||
nassert_raise("Cannot set constant value");
|
nassert_raise("Cannot set constant value");
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -300,7 +304,15 @@ __getattr__(const string &attr_name) const {
|
|||||||
} else if (attr_name == "name") {
|
} else if (attr_name == "name") {
|
||||||
return PyString_FromString(get_name().c_str());
|
return PyString_FromString(get_name().c_str());
|
||||||
} else if (attr_name == "wakeTime") {
|
} else if (attr_name == "wakeTime") {
|
||||||
|
if (get_state() != S_sleeping) {
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
}
|
||||||
return PyFloat_FromDouble(get_wake_time());
|
return PyFloat_FromDouble(get_wake_time());
|
||||||
|
} else if (attr_name == "delayTime") {
|
||||||
|
if (!has_delay()) {
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
}
|
||||||
|
return PyFloat_FromDouble(get_delay());
|
||||||
} else if (attr_name == "id") {
|
} else if (attr_name == "id") {
|
||||||
return PyInt_FromLong(_task_id);
|
return PyInt_FromLong(_task_id);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user