mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 19:08:55 -04:00
remove old play(), stop(), setFinalT() interval interface
This commit is contained in:
parent
ebc60ccce5
commit
5bd18eac4c
@ -4,6 +4,9 @@
|
|||||||
of the CInterval class
|
of the CInterval class
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from DirectNotifyGlobal import directNotify
|
||||||
|
notify = directNotify.newCategory("Interval")
|
||||||
|
|
||||||
def setT(self, t):
|
def setT(self, t):
|
||||||
# Overridden from the C++ function to call privPostEvent
|
# Overridden from the C++ function to call privPostEvent
|
||||||
# afterward. We do this by renaming the C++ function in
|
# afterward. We do this by renaming the C++ function in
|
||||||
@ -12,15 +15,18 @@
|
|||||||
self.privPostEvent()
|
self.privPostEvent()
|
||||||
|
|
||||||
def play(self, t0 = 0.0, duration = None, scale = 1.0):
|
def play(self, t0 = 0.0, duration = None, scale = 1.0):
|
||||||
|
self.notify.warning("using deprecated CInterval.play() interface")
|
||||||
if duration: # None or 0 implies full length
|
if duration: # None or 0 implies full length
|
||||||
self.start(t0, t0 + duration, scale)
|
self.start(t0, t0 + duration, scale)
|
||||||
else:
|
else:
|
||||||
self.start(t0, -1, scale)
|
self.start(t0, -1, scale)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
self.notify.warning("using deprecated CInterval.stop() interface")
|
||||||
self.finish()
|
self.finish()
|
||||||
|
|
||||||
def setFinalT(self):
|
def setFinalT(self):
|
||||||
|
self.notify.warning("using deprecated CInterval.setFinalT() interface")
|
||||||
self.finish()
|
self.finish()
|
||||||
|
|
||||||
def privPostEvent(self):
|
def privPostEvent(self):
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
from DirectObject import *
|
from DirectObject import *
|
||||||
from PandaModules import *
|
from PandaModules import *
|
||||||
import Task
|
import Task
|
||||||
|
import PythonUtil
|
||||||
import math
|
import math
|
||||||
|
|
||||||
class Interval(DirectObject):
|
class Interval(DirectObject):
|
||||||
@ -68,10 +69,8 @@ class Interval(DirectObject):
|
|||||||
self.privInitialize(t)
|
self.privInitialize(t)
|
||||||
if self.isPlaying():
|
if self.isPlaying():
|
||||||
self.setupResume()
|
self.setupResume()
|
||||||
elif state == CInterval.SFinal:
|
else:
|
||||||
self.privReverseInitialize(t)
|
self.privInterrupt()
|
||||||
if self.isPlaying():
|
|
||||||
self.setupResume()
|
|
||||||
elif state == CInterval.SStarted:
|
elif state == CInterval.SStarted:
|
||||||
# Support modifying t while the interval is playing. We
|
# Support modifying t while the interval is playing. We
|
||||||
# assume is_playing() will be true in this state.
|
# assume is_playing() will be true in this state.
|
||||||
@ -79,8 +78,22 @@ class Interval(DirectObject):
|
|||||||
self.privInterrupt()
|
self.privInterrupt()
|
||||||
self.privStep(t)
|
self.privStep(t)
|
||||||
self.setupResume()
|
self.setupResume()
|
||||||
else:
|
elif state == CInterval.SPaused:
|
||||||
|
# Support modifying t while the interval is paused. In
|
||||||
|
# this case, we simply step to the new value of t; but
|
||||||
|
# this will change the state to S_started, so we must then
|
||||||
|
# change it back to S_paused by hand (because we're still
|
||||||
|
# paused).
|
||||||
self.privStep(t)
|
self.privStep(t)
|
||||||
|
self.privInterrupt()
|
||||||
|
elif state == CInterval.SFinal:
|
||||||
|
self.privReverseInitialize(t)
|
||||||
|
if self.isPlaying():
|
||||||
|
self.setupResume()
|
||||||
|
else:
|
||||||
|
self.privInterrupt()
|
||||||
|
else:
|
||||||
|
self.notify.error("Invalid state: %s" % (state))
|
||||||
self.privPostEvent()
|
self.privPostEvent()
|
||||||
|
|
||||||
def getT(self):
|
def getT(self):
|
||||||
@ -274,11 +287,18 @@ class Interval(DirectObject):
|
|||||||
self.__clockStart += numLoops * timePerLoop
|
self.__clockStart += numLoops * timePerLoop
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Playing backwards.
|
# Playing backwards. Not supported at the moment for
|
||||||
# Not supported at the moment.
|
# Python-style intervals. To add support, copy the code
|
||||||
|
# from C++-style intervals in cInterval.cxx, and modify it
|
||||||
|
# for Python (as the above).
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return (self.__loopCount == 0 or self.__doLoop)
|
shouldContinue = (self.__loopCount == 0 or self.__doLoop)
|
||||||
|
|
||||||
|
if (not shouldContinue and self.getState() == CInterval.SStarted):
|
||||||
|
self.privInterrupt()
|
||||||
|
|
||||||
|
return shouldContinue
|
||||||
|
|
||||||
def __repr__(self, indent=0):
|
def __repr__(self, indent=0):
|
||||||
""" __repr__(indent)
|
""" __repr__(indent)
|
||||||
@ -293,12 +313,15 @@ class Interval(DirectObject):
|
|||||||
# for the CInterval class via the file CInterval-extensions.py.
|
# for the CInterval class via the file CInterval-extensions.py.
|
||||||
|
|
||||||
def play(self, *args, **kw):
|
def play(self, *args, **kw):
|
||||||
|
self.notify.warning("using deprecated Interval.play() interface")
|
||||||
self.start(*args, **kw)
|
self.start(*args, **kw)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
self.notify.warning("using deprecated Interval.stop() interface")
|
||||||
self.finish()
|
self.finish()
|
||||||
|
|
||||||
def setFinalT(self):
|
def setFinalT(self):
|
||||||
|
self.notify.warning("using deprecated Interval.setFinalT() interface")
|
||||||
self.finish()
|
self.finish()
|
||||||
|
|
||||||
def privPostEvent(self):
|
def privPostEvent(self):
|
||||||
|
@ -76,6 +76,8 @@ set_t(double t) {
|
|||||||
priv_initialize(t);
|
priv_initialize(t);
|
||||||
if (is_playing()) {
|
if (is_playing()) {
|
||||||
setup_resume();
|
setup_resume();
|
||||||
|
} else {
|
||||||
|
priv_interrupt();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -94,13 +96,15 @@ set_t(double t) {
|
|||||||
// change the state to S_started, so we must then change it back
|
// change the state to S_started, so we must then change it back
|
||||||
// to S_paused by hand (because we're still paused).
|
// to S_paused by hand (because we're still paused).
|
||||||
priv_step(t);
|
priv_step(t);
|
||||||
_state = S_paused;
|
priv_interrupt();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_final:
|
case S_final:
|
||||||
priv_reverse_initialize(t);
|
priv_reverse_initialize(t);
|
||||||
if (is_playing()) {
|
if (is_playing()) {
|
||||||
setup_resume();
|
setup_resume();
|
||||||
|
} else {
|
||||||
|
priv_interrupt();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -607,7 +611,13 @@ step_play() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (_loop_count == 0 || _do_loop);
|
bool should_continue = (_loop_count == 0 || _do_loop);
|
||||||
|
|
||||||
|
if (!should_continue && _state == S_started) {
|
||||||
|
priv_interrupt();
|
||||||
|
}
|
||||||
|
|
||||||
|
return should_continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user