浏览代码

add pauseIntervalsMatching(), getIntervalsMatching()

David Rose 18 年之前
父节点
当前提交
150f9411ce
共有 1 个文件被更改,包括 18 次插入5 次删除
  1. 18 5
      direct/src/interval/IntervalManager.py

+ 18 - 5
direct/src/interval/IntervalManager.py

@@ -55,7 +55,9 @@ class IntervalManager(CIntervalManager):
             return self.getCInterval(index)
         return None
 
-    def finishIntervalsMatching(self, pattern):
+    def getIntervalsMatching(self, pattern):
+        ivals = []
+        
         count = 0
         maxIndex = self.getMaxIndex()
         for index in range(maxIndex):
@@ -66,14 +68,25 @@ class IntervalManager(CIntervalManager):
                 # automatically removes it.
                 count += 1
                 if index < len(self.ivals) and self.ivals[index]:
-                    # Finish the python version if we have it
-                    self.ivals[index].finish()
+                    # Get the python version if we have it
+                    ivals.append(self.ivals[index])
                 else:
                     # Otherwise, it's a C-only interval.
-                    ival.finish()
+                    ivals.append(ival)
 
-        return count
+        return ivals
 
+    def finishIntervalsMatching(self, pattern):
+        ivals = self.getIntervalsMatching(pattern)
+        for ival in ivals:
+            ival.finish()
+        return len(ivals)
+
+    def pauseIntervalsMatching(self, pattern):
+        ivals = self.getIntervalsMatching(pattern)
+        for ival in ivals:
+            ival.pause()
+        return len(ivals)
 
     def step(self):
         # This method should be called once per frame to perform all