From 8ea95d663327776412e7d11716e595ba8cdd3b8f Mon Sep 17 00:00:00 2001 From: Mark Mine Date: Tue, 14 Nov 2000 23:23:12 +0000 Subject: [PATCH] *** empty log message *** --- direct/src/directutil/DirectSelection.py | 8 +- direct/src/extensions/NodePath-extensions.py | 6 +- direct/src/leveleditor/LevelEditor.py | 80 ++++++++++++++++++-- direct/src/tkwidgets/SceneGraphExplorer.py | 3 + direct/src/tkwidgets/Tree.py | 7 +- 5 files changed, 89 insertions(+), 15 deletions(-) diff --git a/direct/src/directutil/DirectSelection.py b/direct/src/directutil/DirectSelection.py index d8de061d63..5cefae500f 100644 --- a/direct/src/directutil/DirectSelection.py +++ b/direct/src/directutil/DirectSelection.py @@ -197,8 +197,12 @@ class DirectBoundingBox: def computeBounds(self): self.bounds = self.nodePath.getBounds() - self.center = self.bounds.getCenter() - self.radius = self.bounds.getRadius() + if self.bounds.isEmpty(): + self.center = Point3(0) + self.radius = 1.0 + else: + self.center = self.bounds.getCenter() + self.radius = self.bounds.getRadius() self.min = Point3(self.center - Point3(self.radius)) self.max = Point3(self.center + Point3(self.radius)) diff --git a/direct/src/extensions/NodePath-extensions.py b/direct/src/extensions/NodePath-extensions.py index 792620d8b3..3b34d51def 100644 --- a/direct/src/extensions/NodePath-extensions.py +++ b/direct/src/extensions/NodePath-extensions.py @@ -37,18 +37,18 @@ def showSiblings(self): for sib in self.getParent().getChildrenAsList(): - if sib != self: + if sib.node() != self.node(): sib.show() def hideSiblings(self): for sib in self.getParent().getChildrenAsList(): - if sib != aNodePath: + if sib.node() != self.node(): sib.hide() def showAllDescendants(self): self.show() for child in self.getChildrenAsList(): - self.showAllDescendants(child) + child.showAllDescendants() def isolate(self): self.showAllDescendants() diff --git a/direct/src/leveleditor/LevelEditor.py b/direct/src/leveleditor/LevelEditor.py index 1742abfd92..3e5362d890 100644 --- a/direct/src/leveleditor/LevelEditor.py +++ b/direct/src/leveleditor/LevelEditor.py @@ -475,6 +475,36 @@ class LevelEditor(NodePath, PandaObject): self.accept('handleMouse3',self.levelHandleMouse3) self.accept('handleMouse3Up',self.levelHandleMouse3Up) + def useDriveMode(self): + pos = base.camera.getPos() + pos.setZ(4.0) + hpr = base.camera.getHpr() + hpr.set(hpr[0], 0.0, 0.0) + t = base.camera.lerpPosHpr(pos, hpr, 1.0, blendType = 'easeInOut', + task = 'manipulateCamera') + # Note, if this dies an unatural death, this could screw things up + t.uponDeath = self.switchToDriveMode + + def switchToDriveMode(self,state): + self.direct.minimumConfiguration() + self.disableManipulation() + base.useDrive() + # Make sure we're where we want to be + pos = base.camera.getPos() + pos.setZ(4.0) + hpr = base.camera.getHpr() + hpr.set(hpr[0], 0.0, 0.0) + # Fine tune the drive mode + base.mouseInterface.getBottomNode().setPos(pos) + base.mouseInterface.getBottomNode().setHpr(hpr) + base.mouseInterface.getBottomNode().setForwardSpeed(20.0) + base.mouseInterface.getBottomNode().setReverseSpeed(20.0) + + def useDirectFly(self): + base.disableMouse() + self.enableManipulation() + self.direct.enable() + def useToontownCentralColors(self): self.attributeDictionary['wallColors'] = ( self.colorPaletteDictionary['toontownCentralWallColors']) @@ -613,6 +643,10 @@ class LevelEditor(NodePath, PandaObject): def setHprSnap(self,flag): self.hprSnap = flag + def isolateSelectedNodePath(self): + if self.direct.selected.last: + self.isolateNodePath(self.direct.selected.last) + def isolateNodePath(self,aNodePath): # First show everything in level self.levelObjects.showAllDescendants() @@ -1477,7 +1511,8 @@ class LevelEditor(NodePath, PandaObject): dictionary = self.createStyleDictionaryFromFile( 'level_editor/minniesMelodyLandStyles.txt') # Store this dictionary in the self.attributeDictionary - self.attributeDictionary['minniesMelodyLandStyleDictionary'] = dictionary + self.attributeDictionary['minniesMelodyLandStyleDictionary'] = ( + dictionary) # Record active style dictionary self.styleDictionary = ( @@ -2241,7 +2276,8 @@ class LevelEditor(NodePath, PandaObject): def outputDNA(self,filename): print 'Saving DNA to: ', filename - self.levelObjectsDNA.writeDna(Filename(filename),Notify.out(),self.dnaStore) + self.levelObjectsDNA.writeDna(Filename(filename), + Notify.out(),self.dnaStore) def preRemoveNodePath(self, aNodePath): # Remove nodePath's DNA from its parent @@ -2951,7 +2987,8 @@ class LevelEditorPanel(Pmw.MegaToplevel): command = self.toggleBalloon) self.editMenu = Pmw.ComboBox( - menuFrame, labelpos = W, label_text = 'Edit:', entry_width = 12, + menuFrame, labelpos = W, + label_text = 'Edit Mode:', entry_width = 12, selectioncommand = self.chooseNeighborhood, history = 0, scrolledlist_items = ['Toontown Central', 'Donalds Dock', 'The Burrrgh', 'Minnies Melody Land']) @@ -3119,18 +3156,49 @@ class LevelEditorPanel(Pmw.MegaToplevel): buttonFrame2 = Frame(hull) self.groupButton = Button( buttonFrame2, - text = 'New level group', + text = 'New group', command = self.levelEditor.createNewLevelGroup) self.groupButton.pack(side = 'left', expand = 1, fill = 'x') self.saveButton = Button( buttonFrame2, - text = 'Set Group Parent', - command = self.levelEditor.setGroupParentToSelected()) + text = 'Set Parent', + command = self.levelEditor.setGroupParentToSelected) self.saveButton.pack(side = 'left', expand = 1, fill = 'x') + self.isolateButton = Button( + buttonFrame2, + text = 'Isolate Selected', + command = self.levelEditor.isolateSelectedNodePath) + self.isolateButton.pack(side = 'left', expand = 1, fill = 'x') + + self.showAllButton = Button( + buttonFrame2, + text = 'Show All', + command = self.levelEditor.showAll) + self.showAllButton.pack(side = 'left', expand = 1, fill = 'x') + buttonFrame2.pack(fill = 'x') + buttonFrame3 = Frame(hull) + self.driveMode = IntVar() + self.driveMode.set(1) + self.driveModeButton = Radiobutton( + buttonFrame3, + text = 'Drive Mode', + value = 0, + variable = self.driveMode, + command = self.levelEditor.useDriveMode) + self.driveModeButton.pack(side = 'left', expand = 1, fill = 'x') + self.directModeButton = Radiobutton( + buttonFrame3, + text = 'DIRECT Fly', + value = 1, + variable = self.driveMode, + command = self.levelEditor.useDirectFly) + self.directModeButton.pack(side = 'left', expand = 1, fill = 'x') + buttonFrame3.pack(fill = 'x') + self.sceneGraphExplorer = SceneGraphExplorer( parent = sceneGraphPage, root = self.levelEditor.getLevelObjects()) diff --git a/direct/src/tkwidgets/SceneGraphExplorer.py b/direct/src/tkwidgets/SceneGraphExplorer.py index e23eea0296..6c4f0c55f3 100644 --- a/direct/src/tkwidgets/SceneGraphExplorer.py +++ b/direct/src/tkwidgets/SceneGraphExplorer.py @@ -109,6 +109,9 @@ class SceneGraphExplorerItem(TreeItem): sublist.append(item) return sublist + def OnSelect(self): + messenger.send('SGESelectNodePath', [self.nodePath]) + def MenuCommand(self, command): if (command == 'Select Node'): messenger.send('SGESelectNodePath', [self.nodePath]) diff --git a/direct/src/tkwidgets/Tree.py b/direct/src/tkwidgets/Tree.py index 83bd33cd61..7311d4b3fc 100644 --- a/direct/src/tkwidgets/Tree.py +++ b/direct/src/tkwidgets/Tree.py @@ -113,8 +113,7 @@ class TreeNode: self.item.OnDoubleClick() return "break" - def selectAndPopupMenu(self, event=None): - self.select() + def popupMenu(self, event=None): if self._popupMenu: self._popupMenu.post(event.widget.winfo_pointerx(), event.widget.winfo_pointery()) @@ -233,7 +232,7 @@ class TreeNode: self.image_id = id self.canvas.tag_bind(id, "<1>", self.select) self.canvas.tag_bind(id, "", self.flip) - self.canvas.tag_bind(id, "<3>", self.selectAndPopupMenu) + self.canvas.tag_bind(id, "<3>", self.popupMenu) def drawtext(self): textx = self.x+20-1 @@ -244,7 +243,6 @@ class TreeNode: text=labeltext) self.canvas.tag_bind(id, "<1>", self.select) self.canvas.tag_bind(id, "", self.flip) - self.canvas.tag_bind(id, "<3>", self.selectAndPopupMenu) x0, y0, x1, y1 = self.canvas.bbox(id) textx = max(x1, 200) + 10 text = self.item.GetText() or "" @@ -267,6 +265,7 @@ class TreeNode: anchor="nw", window=self.label) self.label.bind("<1>", self.select_or_edit) self.label.bind("", self.flip) + self.label.bind("<3>", self.popupMenu) self.text_id = id def select_or_edit(self, event=None):