Browse Source

Added support for Task.cont, etc, using Task as a class

Josh Yelon 19 years ago
parent
commit
e30cf6b193
1 changed files with 20 additions and 10 deletions
  1. 20 10
      direct/src/task/Task.py

+ 20 - 10
direct/src/task/Task.py

@@ -23,16 +23,6 @@ if __debug__:
     # For pstats
     # For pstats
     from pandac.PandaModules import PStatCollector
     from pandac.PandaModules import PStatCollector
 
 
-# MRM: Need to make internal task variables like time, name, index
-# more unique (less likely to have name clashes)
-
-exit = -1
-done = 0
-cont = 1
-again = 2  # return this when a doLater needs to be repeated (to be able to
-           # avoid having to remove and add a new doLater for continuously
-           # repeating tasks)
-
 # Task needs this because it might run before __builtin__.globalClock
 # Task needs this because it might run before __builtin__.globalClock
 # can be set.
 # can be set.
 globalClock = ClockObject.getGlobalClock()
 globalClock = ClockObject.getGlobalClock()
@@ -74,6 +64,13 @@ def print_exc_plus():
                 print "<ERROR WHILE PRINTING VALUE>"
                 print "<ERROR WHILE PRINTING VALUE>"
 
 
 class Task:
 class Task:
+
+    # This enum is a copy of the one at the top-level.
+    exit = -1
+    done = 0
+    cont = 1
+    again = 2
+
     if __debug__:
     if __debug__:
         debugTaskTraceback = 0 # base.config.GetBool('debug-task-traceback', 0)
         debugTaskTraceback = 0 # base.config.GetBool('debug-task-traceback', 0)
     count = 0
     count = 0
@@ -1039,6 +1036,19 @@ class TaskManager:
             fpformat.fix(totalDt*1000, 2).rjust(dtWidth),
             fpformat.fix(totalDt*1000, 2).rjust(dtWidth),
             fpformat.fix(totalAvgDt*1000, 2).rjust(dtWidth),))
             fpformat.fix(totalAvgDt*1000, 2).rjust(dtWidth),))
         return cont
         return cont
+
+
+
+# These constants are moved to the top level of the module,
+# to make it easier for legacy code.  In general though, putting
+# constants at the top level of a module is deprecated.
+
+exit  = Task.exit
+done  = Task.done
+cont  = Task.cont
+again = Task.again
+
+
 """
 """
 
 
 import Task
 import Task