From 7d9121d2d429570c9de9cb55f089a193e26ff403 Mon Sep 17 00:00:00 2001 From: Josh Wilson Date: Thu, 13 Mar 2008 01:37:29 +0000 Subject: [PATCH] adding silenceInput() and reviveInput() for global disabling of all inputs at once --- direct/src/showbase/ShowBase.py | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 3c95380b40..837562033b 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -373,10 +373,12 @@ class ShowBase(DirectObject.DirectObject): if self.windowType != 'none': self.__doStartDirect() - + + self.__deadInputs = None + # Start IGLOOP self.restart() - + # add a collision traverser via pushCTrav and remove it via popCTrav # that way the owner of the new cTrav doesn't need to hold onto the # previous one in order to put it back @@ -1177,14 +1179,13 @@ class ShowBase(DirectObject.DirectObject): self.dataRootNode = self.dataRoot.node() self.dataUnused = NodePath('dataUnused') - def setupMouse(self, win): """ Creates the structures necessary to monitor the mouse input, using the indicated window. If the mouse has already been set up for a different window, those structures are deleted first. """ - + self.reviveInput() if self.buttonThrowers != None: for bt in self.buttonThrowers: mw = bt.getParent() @@ -1192,7 +1193,6 @@ class ShowBase(DirectObject.DirectObject): bt.removeNode() mw.removeNode() mk.removeNode() - # For each mouse/keyboard device, we create # - MouseAndKeyboard # - MouseWatcher @@ -1692,6 +1692,26 @@ class ShowBase(DirectObject.DirectObject): if self.mouse2cam: self.mouse2cam.reparentTo(self.mouseInterface) + def silenceInput(self): + """ + This is a heavy-handed way of temporarily turning off + all inputs. Bring them back with reviveInput(). + """ + if not self.__deadInputs: + self.__deadInputs = self.dataRoot.getChildren() + self.dataRoot.removeChildren() + + def reviveInput(self): + """ + Restores inputs after a previous call to silenceInput. + """ + if self.__deadInputs: + self.eventMgr.doEvents() + self.__deadInputs.reparentTo(self.dataRoot) + self.__deadInputs = None + self.dgTrav.traverse(base.dataRootNode) + self.eventMgr.eventQueue.clear() + def setMouseOnNode(self, newNode): if self.mouse2cam: self.mouse2cam.node().setNode(newNode)