2
0
Эх сурвалжийг харах

*** empty log message ***

Jesse Schell 24 жил өмнө
parent
commit
96c5d0e10f

+ 15 - 6
direct/src/gui/DialogBox.py

@@ -23,7 +23,8 @@ class DialogBox(OnscreenPanel.OnscreenPanel):
     notify = DirectNotifyGlobal.directNotify.newCategory("DialogBox")
     notify = DirectNotifyGlobal.directNotify.newCategory("DialogBox")
 
 
     def __init__(self, message = "", doneEvent = None, style = NoButtons,
     def __init__(self, message = "", doneEvent = None, style = NoButtons,
-                 font = getDefaultFont(), wordwrap = 12):
+                 font = getDefaultFont(), wordwrap = 12, okButtonText = "OK",
+                 cancelButtonText = "Cancel"):
 	"""___init___(self, Event, string="", int, model, int=12)"""
 	"""___init___(self, Event, string="", int, model, int=12)"""
 
 
         # Sanity check
         # Sanity check
@@ -35,6 +36,8 @@ class DialogBox(OnscreenPanel.OnscreenPanel):
         self.style = style
         self.style = style
         self.font = font
         self.font = font
         self.wordwrap = wordwrap
         self.wordwrap = wordwrap
+        self.okButtonText = okButtonText
+        self.cancelButtonText = cancelButtonText
 
 
         # initialize our OnscreenPanel essence
         # initialize our OnscreenPanel essence
         # NOTE: all db's have the same name so we can kill them easily
         # NOTE: all db's have the same name so we can kill them easily
@@ -51,13 +54,19 @@ class DialogBox(OnscreenPanel.OnscreenPanel):
 
 
         if (self.style == TwoChoice):
         if (self.style == TwoChoice):
             # create OK and CANCEL buttons
             # create OK and CANCEL buttons
-            self.makeButton("OK", pos = (-0.325, -0.25),
-                            func = self.handleOk, event = "ok")
-            self.makeButton("Cancel", pos = (0.2, -0.25),
-                            func = self.handleCancel, event = "cancel")
+            self.makeButton(self.okButtonText,
+                            pos = (-0.325, -0.25),
+                            func = self.handleOk,
+                            event = "ok")
+            self.makeButton(self.cancelButtonText,
+                            pos = (0.2, -0.25),
+                            func = self.handleCancel,
+                            event = "cancel")
         elif (self.style == Acknowledge):
         elif (self.style == Acknowledge):
             # create a centered OK  button
             # create a centered OK  button
-            self.makeButton("OK", pos = (0.0, -0.25), func = self.handleOk,
+            self.makeButton(self.okButtonText,
+                            pos = (0.0, -0.25),
+                            func = self.handleOk,
                             event = "ok")
                             event = "ok")
         elif (self.style == NoButtons):
         elif (self.style == NoButtons):
             # No buttons at all
             # No buttons at all

+ 8 - 0
direct/src/interval/Interval.py

@@ -107,6 +107,11 @@ class Interval(DirectObject):
         # Spawn task
         # Spawn task
         taskMgr.spawnMethodNamed(self.__playTask, self.name + '-play')
         taskMgr.spawnMethodNamed(self.__playTask, self.name + '-play')
 
 
+    def loop(self, t0=0.0, duration=0.0, scale=1.0):
+        self.accept(self.name + '-loop', self.play, extraArgs=[t0, duration, scale])
+        self.play(t0, duration, scale)
+        return
+
     def stop(self):
     def stop(self):
         """ stop()
         """ stop()
         """
         """
@@ -115,6 +120,8 @@ class Interval(DirectObject):
             messenger.send(stopEvent)
             messenger.send(stopEvent)
         # Kill task
         # Kill task
         taskMgr.removeTasksNamed(self.name + '-play')
         taskMgr.removeTasksNamed(self.name + '-play')
+        # No more looping.
+        self.ignore(self.name + '-loop')
 	return self.curr_t
 	return self.curr_t
 
 
     def isPlaying(self):
     def isPlaying(self):
@@ -135,6 +142,7 @@ class Interval(DirectObject):
             return Task.cont
             return Task.cont
         else:
         else:
 	    self.setT(self.endTime)
 	    self.setT(self.endTime)
+            messenger.send(self.name + "-loop")
             return Task.done
             return Task.done
 
 
     def __repr__(self, indent=0):
     def __repr__(self, indent=0):

+ 1 - 1
direct/src/task/Task.py

@@ -431,7 +431,7 @@ class TaskManager:
             elif (ret == exit):
             elif (ret == exit):
                 self.removeTask(task)
                 self.removeTask(task)
             else:
             else:
-                raise 'invalid task state'
+                raise "Task named %s did not return cont, exit, or done" % task.name
         return len(self.taskList)
         return len(self.taskList)
 
 
     def run(self):
     def run(self):