diff --git a/direct/src/gui/DialogBox.py b/direct/src/gui/DialogBox.py index ed3b13188d..bdcb013e87 100644 --- a/direct/src/gui/DialogBox.py +++ b/direct/src/gui/DialogBox.py @@ -23,7 +23,8 @@ class DialogBox(OnscreenPanel.OnscreenPanel): notify = DirectNotifyGlobal.directNotify.newCategory("DialogBox") 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)""" # Sanity check @@ -35,6 +36,8 @@ class DialogBox(OnscreenPanel.OnscreenPanel): self.style = style self.font = font self.wordwrap = wordwrap + self.okButtonText = okButtonText + self.cancelButtonText = cancelButtonText # initialize our OnscreenPanel essence # 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): # 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): # 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") elif (self.style == NoButtons): # No buttons at all diff --git a/direct/src/interval/Interval.py b/direct/src/interval/Interval.py index 994b305028..d2a9d51be4 100644 --- a/direct/src/interval/Interval.py +++ b/direct/src/interval/Interval.py @@ -107,6 +107,11 @@ class Interval(DirectObject): # Spawn task 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): """ stop() """ @@ -115,6 +120,8 @@ class Interval(DirectObject): messenger.send(stopEvent) # Kill task taskMgr.removeTasksNamed(self.name + '-play') + # No more looping. + self.ignore(self.name + '-loop') return self.curr_t def isPlaying(self): @@ -135,6 +142,7 @@ class Interval(DirectObject): return Task.cont else: self.setT(self.endTime) + messenger.send(self.name + "-loop") return Task.done def __repr__(self, indent=0): diff --git a/direct/src/task/Task.py b/direct/src/task/Task.py index a037413845..85edd7d855 100644 --- a/direct/src/task/Task.py +++ b/direct/src/task/Task.py @@ -431,7 +431,7 @@ class TaskManager: elif (ret == exit): self.removeTask(task) else: - raise 'invalid task state' + raise "Task named %s did not return cont, exit, or done" % task.name return len(self.taskList) def run(self):