From 3d30e720e6f012f2d9996b136154dd551844998a Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Wed, 25 Dec 2019 16:54:14 -0500
Subject: [PATCH] Conditional key pressed to support print screen.

---
 iCameraPane.java |    2 
 CameraPane.java  |   44 +++++++++++++++-------
 Camera.java      |   24 +++++------
 GroupEditor.java |   17 +++++---
 Object3D.java    |    3 +
 5 files changed, 55 insertions(+), 35 deletions(-)

diff --git a/Camera.java b/Camera.java
index 2bb124c..1c1b718 100644
--- a/Camera.java
+++ b/Camera.java
@@ -99,6 +99,13 @@
 		perspective = true;
     }
 
+    private void Swap(cVector loc, cVector lat)
+    {
+        cStatic.point1.set(loc);
+        loc.set(lat);
+        lat.set(cStatic.point1);
+    }
+
     private void initCamera()
     {
         focalLength = 1;
@@ -326,32 +333,23 @@
 	{
             right.mul(-1);
             
-            cStatic.point1.set(location);
-            location.set(lookAt);
-            lookAt.set(cStatic.point1);
+            Swap(location, lookAt);
             
             if (viewCode == 0 && locationBuf != null)
             {
-                cStatic.point1.set(locationBuf);
-                locationBuf.set(lookAtBuf);
-                lookAtBuf.set(cStatic.point1);
+                Swap(locationBuf, lookAtBuf);
             }
-         //   UP.mul(-1);
             
             RotatePosition(dx,-dy);
             
          //   UP.mul(-1);
             right.mul(-1);
             
-            cStatic.point1.set(location);
-            location.set(lookAt);
-            lookAt.set(cStatic.point1);
+            Swap(location, lookAt);
             
             if (viewCode == 0 && locationBuf != null)
             {
-                cStatic.point1.set(locationBuf);
-                locationBuf.set(lookAtBuf);
-                lookAtBuf.set(cStatic.point1);
+                Swap(locationBuf, lookAtBuf);
             }
             
             computeTransform();
diff --git a/CameraPane.java b/CameraPane.java
index 3edc07b..376dc7c 100644
--- a/CameraPane.java
+++ b/CameraPane.java
@@ -15639,7 +15639,7 @@
      */
     }
 
-    void keyPressed(int key, int modifiers)
+    boolean keyPressed(int key, int modifiers)
     {
         //if(!isRenderer)
         //    return;
@@ -15651,7 +15651,7 @@
             SetMouseMode(0, modifiers);
         }
 
-        Globals.theRenderer.keyPressed(key);
+        return Globals.theRenderer.keyPressed(key);
     }
 
     int kompactbit = 4; // power bit
@@ -15669,7 +15669,7 @@
 static Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(
     cursorImg, new Point(0, 0), "blank cursor");
     
-    public void keyPressed(int key)
+    public boolean keyPressed(int key)
     {
 // Set the blank cursor to the JFrame.
 //object.editWindow.frame.
@@ -16146,18 +16146,20 @@
                 Globals.ONESTEP = true;
                 repaint();
                 break;
-            case BACKSPACE:
-                // almost working enablebackspace = true;
-                Globals.WALK ^= true;
-                
-   //             SwitchCameras(false);
-                repaint();
-                break;
+//            case BACKSPACE:
+//                // almost working enablebackspace = true;
+//                Globals.WALK ^= true;
+//                
+//   //             SwitchCameras(false);
+//                repaint();
+//                break;
 
             default:
-                break;
+                return (false);
         }
     //System.out.println("shaper_fovy = " + manipCamera.shaper_fovy);
+        
+        return (true);
     }
     
     static double OCCLUSIONBOOST = 1; // 0.5;
@@ -16180,6 +16182,7 @@
         switch (e.getID())
         {
             case KeyEvent.KEY_PRESSED:
+                boolean repaintit = false;
                 
                 if (capsLocked)
                 {
@@ -16187,6 +16190,7 @@
                     modifiers = e.getModifiersEx();
                     keyPressed(e.getKeyChar(), modifiers);
                     //Globals.theRenderer.keyPressed(e.getKeyChar());
+                    repaintit = true;
                 }
                 else
                 {
@@ -16196,17 +16200,23 @@
                         {
                             case DOWN_ARROW:
                                 lightCamera.DECAL /= 2;
+                                repaintit = true;
                                 break;
                             case UP_ARROW:
                                 lightCamera.DECAL *= 2;
+                                repaintit = true;
                                 break;
                             case LEFT_ARROW:
                                 lightCamera.SCALE /= 2;
+                                repaintit = true;
                                 break;
                             case RIGHT_ARROW:
                                 lightCamera.SCALE *= 2;
+                                repaintit = true;
                                 break;
                             default:
+                                modifiers = e.getModifiersEx();
+                                repaintit = keyPressed(e.getKeyChar(), modifiers);
                                 break;
                         }
 
@@ -16217,25 +16227,30 @@
                         {
                             case DOWN_ARROW:
                                 GoDown(e.getModifiersEx());
+                                repaintit = true;
                                 break;
                             case UP_ARROW:
                                 GoUp(e.getModifiersEx());
+                                repaintit = true;
                                 break;
                             case LEFT_ARROW:
                                 GoLeft(e.getModifiersEx());
+                                repaintit = true;
                                 break;
                             case RIGHT_ARROW:
                                 GoRight(e.getModifiersEx());
+                                repaintit = true;
                                 break;
                             default:
                                 modifiers = e.getModifiersEx();
-                                keyPressed(e.getKeyChar(), modifiers);
+                                repaintit = keyPressed(e.getKeyChar(), modifiers);
                                 break;
                         }
                     }
                 }
                 
-                repaint();
+                if (repaintit)
+                    repaint();
                 break;
 //                if (!autorepeat)
 //                {
@@ -16311,7 +16326,8 @@
                 keys[e.getKeyCode()] = false;
                 modifiers = e.getModifiersEx();
                 keyReleased(e.getKeyChar(), e.getModifiersEx());
-                repaint();
+                //if (e.getKeyCode() != 65535)
+                //    repaint();
                 break;
 //            {
 //                switch (e.getKeyCode())
diff --git a/GroupEditor.java b/GroupEditor.java
index 1cbbe20..558a072 100644
--- a/GroupEditor.java
+++ b/GroupEditor.java
@@ -1119,13 +1119,17 @@
                 antialiasCB.setToolTipText("Final render");
                                 antialiasCB.addItemListener(this);
                 
+		oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
+                restoreCameraButton.setToolTipText("Restore viewpoint");
+		restoreCameraButton.addActionListener(this);
+                
 		oe.toolbarPanel.add(screenfitButton = GetButton("icons/fit.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 screenfitButton.setToolTipText("Screen fit");
 		screenfitButton.addActionListener(this);
 
-		oe.toolbarPanel.add(restoreCameraButton = GetButton("icons/eye.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
-                restoreCameraButton.setToolTipText("Restore viewpoint");
-		restoreCameraButton.addActionListener(this);
+		oe.toolbarPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
+                flashSelectionButton.setToolTipText("Highlight selection");
+		flashSelectionButton.addActionListener(this);
                 
 		versionManagerPanel.add(saveVersionButton = GetButton("icons/down_arrow.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
                 saveVersionButton.setToolTipText("Duplicate current version");
@@ -1314,9 +1318,9 @@
                 //unselectButton.setToolTipText("Unselect");
 		//unselectButton.addActionListener(this);
 
-		editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
-                flashSelectionButton.setToolTipText("Highlight selection");
-		flashSelectionButton.addActionListener(this);
+//		editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Globals.NIMBUSLAF)); //, oe.aConstraints);
+//                flashSelectionButton.setToolTipText("Highlight selection");
+//		flashSelectionButton.addActionListener(this);
                 
                 editCommandsPanel.preferredHeight = 1;
                 
@@ -5587,6 +5591,7 @@
             editButton.setEnabled(enabled);
             uneditButton.setEnabled(enabled);
             //unselectButton.setEnabled(enabled);
+            screenfitButton.setEnabled(enabled);
             flashSelectionButton.setEnabled(enabled);
             
             clearPanelButton.setEnabled(!listUI.isEmpty());
diff --git a/Object3D.java b/Object3D.java
index bcefc4f..3fc728e 100644
--- a/Object3D.java
+++ b/Object3D.java
@@ -1204,7 +1204,8 @@
         if (maxcount == 0)
         {
             System.out.println("maxcount == 0");
-            System.exit(0); // maxcount = 128; // 2048; // 4;
+            //System.exit(0);
+            maxcount = 128; // 2048; // 4;
         }
 //        if (acceleration == 0)
 //            acceleration = 10;
diff --git a/iCameraPane.java b/iCameraPane.java
index 2fdab16..0682fe8 100644
--- a/iCameraPane.java
+++ b/iCameraPane.java
@@ -92,7 +92,7 @@
     
     void processKeyEvent(java.awt.event.KeyEvent e);
     
-    void keyPressed(int key);
+    boolean keyPressed(int key);
     
     // For scripts
     void ToggleLive();

--
Gitblit v1.6.2