Make enableLight persistent through subsequent disable/enables

This commit is contained in:
Mark Mine 2003-11-12 04:36:30 +00:00
parent 1b729fb229
commit d4dd191c05
2 changed files with 14 additions and 24 deletions

View File

@ -27,6 +27,7 @@ class DirectSession(PandaObject):
self.group = render.attachNewNode('DIRECT') self.group = render.attachNewNode('DIRECT')
self.font = TextNode.getDefaultFont() self.font = TextNode.getDefaultFont()
self.fEnabled = 0 self.fEnabled = 0
self.fEnabledLight = 0
self.drList = DisplayRegionList() self.drList = DisplayRegionList()
self.iRayList = map(lambda x: x.iRay, self.drList) self.iRayList = map(lambda x: x.iRay, self.drList)
self.dr = self.drList[0] self.dr = self.drList[0]
@ -194,45 +195,34 @@ class DirectSession(PandaObject):
self.disable() self.disable()
# Start all display region context tasks # Start all display region context tasks
self.drList.spawnContextTask() self.drList.spawnContextTask()
# Turn on mouse Flying if not self.fEnabledLight:
self.cameraControl.enableMouseFly() # Turn on mouse Flying
self.cameraControl.enableMouseFly()
# Turn on object manipulation # Turn on object manipulation
self.manipulationControl.enableManipulation() self.manipulationControl.enableManipulation()
# Make sure list of selected items is reset # Make sure list of selected items is reset
self.selected.reset() self.selected.reset()
# Accept appropriate hooks # Accept appropriate hooks
self.enableKeyEvents() if not self.fEnabledLight:
self.enableModifierEvents() self.enableKeyEvents()
self.enableMouseEvents() self.enableMouseEvents()
self.enableActionEvents() self.enableActionEvents()
self.enableModifierEvents()
# Set flag # Set flag
self.fEnabled = 1 self.fEnabled = 1
def enableLight(self): def enableLight(self):
if self.fEnabled: self.fEnabledLight = 1
return self.enable()
# Make sure old tasks are shut down
self.disable()
# Start all display region context tasks
self.drList.spawnContextTask()
# Turn on object manipulation
self.manipulationControl.enableManipulation()
# Make sure list of selected items is reset
self.deselectAll()
self.selected.reset()
# Accept appropriate hooks
self.enableMouseEvents()
self.enableActionEvents()
self.enableModifierEvents()
# Set flag
self.fEnabled = 1
def disable(self): def disable(self):
# Shut down all display region context tasks # Shut down all display region context tasks
self.drList.removeContextTask() self.drList.removeContextTask()
# Turn off camera fly if not self.fEnabledLight:
self.cameraControl.disableMouseFly() # Turn off camera fly
self.cameraControl.disableMouseFly()
# Turn off object manipulation # Turn off object manipulation
self.deselectAll()
self.manipulationControl.disableManipulation() self.manipulationControl.disableManipulation()
self.disableKeyEvents() self.disableKeyEvents()
self.disableModifierEvents() self.disableModifierEvents()

View File

@ -88,7 +88,7 @@ class DirectSessionPanel(AppShell):
self.menuBar.addmenu('DIRECT', 'Direct Session Panel Operations') self.menuBar.addmenu('DIRECT', 'Direct Session Panel Operations')
self.directEnabled = BooleanVar() self.directEnabled = BooleanVar()
self.directEnabled.set(direct.isEnabled()) self.directEnabled.set(1)
self.menuBar.addmenuitem('DIRECT', 'checkbutton', self.menuBar.addmenuitem('DIRECT', 'checkbutton',
'DIRECT Enabled', 'DIRECT Enabled',
label = 'Enable', label = 'Enable',