Browse Source

add clearToInitial

David Rose 21 years ago
parent
commit
4ad4e2952e
3 changed files with 27 additions and 12 deletions
  1. 9 12
      direct/src/interval/Interval.py
  2. 17 0
      direct/src/interval/cInterval.cxx
  3. 1 0
      direct/src/interval/cInterval.h

+ 9 - 12
direct/src/interval/Interval.py

@@ -145,6 +145,15 @@ class Interval(DirectObject):
             self.privFinalize()
         self.privPostEvent()
         self.__removeTask()
+        
+    def clearToInitial(self):
+        # This method resets the interval's internal state to the
+        # initial state, abandoning any parts of the interval that
+        # have not yet been called.  Calling it is like pausing the
+        # interval and creating a new one in its place.
+        self.pause()
+        self.state = CInterval.SInitial
+        self.currT = 0.0
 
     def isPlaying(self):
         return taskMgr.hasTaskNamed(self.getName() + '-play')
@@ -326,18 +335,6 @@ class Interval(DirectObject):
     # The rest of these methods are duplicates of functions defined
     # for the CInterval class via the file CInterval-extensions.py.
 
-    def play(self, *args, **kw):
-        self.notify.error("using deprecated Interval.play() interface")
-        self.start(*args, **kw)
-
-    def stop(self):
-        self.notify.error("using deprecated Interval.stop() interface")
-        self.finish()
-
-    def setFinalT(self):
-        self.notify.error("using deprecated Interval.setFinalT() interface")
-        self.finish()
-
     def privPostEvent(self):
         # Call after calling any of the priv* methods to do any required
         # Python finishing steps.

+ 17 - 0
direct/src/interval/cInterval.cxx

@@ -246,6 +246,23 @@ finish() {
   }
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: CInterval::clear_to_initial
+//       Access: Published
+//  Description: Pauses the interval, if it is playing, and resets its
+//               state to its initial state, abandoning any state
+//               changes already in progress in the middle of the
+//               interval.  Calling this is like pausing the interval
+//               and discarding it, creating a new one in its place.
+////////////////////////////////////////////////////////////////////
+void CInterval::
+clear_to_initial() {
+  pause();
+
+  _state = S_initial;
+  _curr_t = 0.0;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: CInterval::is_playing
 //       Access: Published

+ 1 - 0
direct/src/interval/cInterval.h

@@ -94,6 +94,7 @@ PUBLISHED:
   void resume(double start_t);
   void resume_until(double end_t);
   void finish();
+  void clear_to_initial();
   bool is_playing() const;
 
   // These functions control the actual playback of the interval.