浏览代码

*** empty log message ***

Mark Mine 24 年之前
父节点
当前提交
ffee6d457b
共有 2 个文件被更改,包括 35 次插入11 次删除
  1. 3 5
      direct/src/directtools/DirectCameraControl.py
  2. 32 6
      direct/src/gui/DirectEntry.py

+ 3 - 5
direct/src/directtools/DirectCameraControl.py

@@ -114,8 +114,7 @@ class DirectCameraControl(PandaObject):
         # Spawn the new task
         t = Task.Task(self.XZTranslateOrHPanYZoomTask)
         # For HPanYZoom
-        coaDist = Vec3(self.coaMarker.getPos(direct.camera)).length()
-        t.zoomSF = (coaDist / direct.dr.near)
+        t.zoomSF = Vec3(self.coaMarker.getPos(direct.camera)).length()
         taskMgr.spawnTaskNamed(t, 'manipulateCamera')
 
     def spawnXZTranslateOrHPPan(self):
@@ -136,8 +135,7 @@ class DirectCameraControl(PandaObject):
         taskMgr.removeTasksNamed('manipulateCamera')
         # Spawn new task
         t = Task.Task(self.HPanYZoomTask)
-        coaDist = Vec3(self.coaMarker.getPos(direct.camera)).length()
-        t.zoomSF = (coaDist / direct.dr.near)
+        t.zoomSF = Vec3(self.coaMarker.getPos(direct.camera)).length()
         taskMgr.spawnTaskNamed(t, 'manipulateCamera')
 
     def spawnHPPan(self):
@@ -182,7 +180,7 @@ class DirectCameraControl(PandaObject):
             moveDir.normalize()
         else:
             moveDir = Vec3(Y_AXIS)
-        moveDir.assign(moveDir * (-2.0 * direct.dr.mouseDeltaY *
+        moveDir.assign(moveDir * (-1.0 * direct.dr.mouseDeltaY *
                                         state.zoomSF))
         if direct.dr.mouseDeltaY > 0.0:
             moveDir.setY(moveDir[1] * 1.0)

+ 32 - 6
direct/src/gui/DirectEntry.py

@@ -25,14 +25,15 @@ class DirectEntry(DirectFrame):
             # Define type of DirectGuiWidget
             ('pgFunc',          PGEntry,          None),
             ('numStates',       3,                None),
-            ('font',            getDefaultFont(), self.setFont),
             ('width',           10,               self.setup),
             ('numLines',        5,                self.setup),
             ('focus',           0,                self.setFocus),
+            # Text used for the PGEntry text node
+            # NOTE: This overrides the DirectFrame text option
             ('initialText',     '',               INITOPT),
             # Command to be called on hitting Enter
-            ('command',        None,       None),
-            ('extraArgs',      [],         None),
+            ('command',        None,              None),
+            ('extraArgs',      [],                None),
             # Sounds to be used for button events
             ('rolloverSound',   getDefaultRolloverSound(), self.setRolloverSound),
             )
@@ -42,21 +43,46 @@ class DirectEntry(DirectFrame):
         # Initialize superclasses
         DirectFrame.__init__(self, parent)
 
+        # Create Text Node Component
+        self.onscreenText = self.createcomponent(
+            'text', (), None,
+            OnscreenText.OnscreenText,
+            (), parent = hidden,
+            # Pass in empty text to avoid extra work, since its really
+            # The PGEntry which will use the TextNode to generate geometry
+            text = '',
+            # PGEntry assumes left alignment
+            align = TMALIGNLEFT,
+            font = getDefaultFont(),
+            scale = 1,
+            # Don't get rid of the text node
+            mayChange = 1)
+        # We want to keep this sucker frozen since its not
+        # in the scene graph
+        self.onscreenText.freeze()
+        # We can also get rid of the node path since we're just using the
+        # onscreenText as an easy way to access a text node as a component
+        self.onscreenText.removeNode()
+
         # Bind command function
         self.bind(ACCEPT, self.commandFunc)
 
         # Call option initialization functions
         self.initialiseoptions(DirectEntry)
 
-        # Update entry if init text specified
+        # Update TextNodes for each state
+        for i in range(self['numStates']):
+            self.guiItem.setTextDef(i, self.onscreenText.textNode)
+
+        # Update initial text
         if self['initialText']:
-            self.guiItem.setText(self['initialText'])
+            self.set(self['initialText'])
 
     def setup(self):
         self.node().setup(self['width'], self['numLines'])
 
     def setFont(self):
-        self.guiItem.getTextNode().setFont(self['font'])
+        self.onscreenText.setFont(self['font'])
 
     def setFocus(self):
         PGEntry.setFocus(self.guiItem, self['focus'])