From 6266c8a4b2485b29a7d5bcb217460d7aad3e1c4a Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Sun, 25 Aug 2019 20:58:10 -0400
Subject: [PATCH] Proto version slider.

---
 ObjEditor.java |  153 ++++++++++++++++++++++++++++----------------------
 1 files changed, 85 insertions(+), 68 deletions(-)

diff --git a/ObjEditor.java b/ObjEditor.java
index b28d50a..fd5504d 100644
--- a/ObjEditor.java
+++ b/ObjEditor.java
@@ -316,6 +316,8 @@
         objEditor.ctrlPanel.remove(setupPanel2);
         objEditor.ctrlPanel.remove(objectCommandsPanel);
         objEditor.ctrlPanel.remove(pushPanel);
+        if (versionPanel != null)
+            objEditor.ctrlPanel.remove(versionPanel);
         //objEditor.ctrlPanel.remove(fillPanel);
         
         //Remove(normalpushField);
@@ -383,14 +385,6 @@
         client = inClient;
         copy = client;
 
-        if (copy.versionlist == null)
-        {
-            copy.versionlist = new Object3D[100];
-            copy.versionindex = -1;
-            
-//            Save(true);
-        }
-        
         SetupUI2(callee.GetEditor());
     }
 
@@ -1171,6 +1165,7 @@
     cGridBag setupPanel2;
     cGridBag objectCommandsPanel;
     cGridBag pushPanel;
+    cGridBag versionPanel;
     cGridBag fillPanel;
 
     JCheckBox AddCheckBox(cGridBag panel, String label, boolean on)
@@ -1417,9 +1412,14 @@
         oe.ctrlPanel.add(objectCommandsPanel);
         oe.ctrlPanel.Return();
 
-    pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH, 1.1); // To have the buttons
+    pushPanel = AddSlider(oe.ctrlPanel, "Push", -1, 1, copy.NORMALPUSH * 100, 1.1); // To have the buttons
     normalpushField = (cNumberSlider)pushPanel.getComponent(1);
-    //Return();
+    if (false && copy.versionlist != null && copy.versionindex != -1)
+    {
+        oe.ctrlPanel.Return();
+        versionPanel = AddSlider(oe.ctrlPanel, "Version", 0, copy.VersionCount() - 1, copy.versionindex);
+        versionField = (cNumberSlider)versionPanel.getComponent(1);
+    }
 
         oe.ctrlPanel.Return();
             
@@ -1775,7 +1775,7 @@
         scrollpane.addMouseWheelListener(this); // Default not fast enough
 
         /*JTabbedPane*/ scenePanel = new cGridBag();
-        scenePanel.preferredWidth = 6;
+        scenePanel.preferredWidth = 5;
         
         JTabbedPane tabbedPane = new JTabbedPane();
         tabbedPane.add(scrollpane);
@@ -1884,9 +1884,9 @@
         
         if (Globals.ADVANCED)
         {
-            tabbedPane.add(infoPanel);
-            tabbedPane.setIconAt(4, GetIcon("icons/info.png"));
-            tabbedPane.setToolTipTextAt(4, "Information");
+            objectPanel.add(infoPanel);
+            objectPanel.setIconAt(5, GetIcon("icons/info.png"));
+            objectPanel.setToolTipTextAt(4, "Information");
         }
 
         /*
@@ -2370,7 +2370,7 @@
         {
             public void mouseClicked(MouseEvent e)
             {
-                borderfadeField.setFloat(0.5);
+                borderfadeField.setFloat(0.4);
                 opacityField.setFloat(0.75);
 
                 materialtouched = true;
@@ -2429,7 +2429,7 @@
                 cameraField.setFloat(0.001);
                 specularField.setFloat(0.001);
                 fakedepthField.setFloat(0.001);
-                opacityField.setFloat(0.6);
+                opacityField.setFloat(0.4);
 
                 materialtouched = true;
                 applySelf();
@@ -2443,7 +2443,7 @@
         {
             public void mouseClicked(MouseEvent e)
             {
-                parallaxField.setFloat(0.25);
+                parallaxField.setFloat(0.125);
 
                 materialtouched = true;
                 applySelf();
@@ -2457,7 +2457,7 @@
         {
             public void mouseClicked(MouseEvent e)
             {
-                parallaxField.setFloat(0.255);
+                parallaxField.setFloat(0.13);
 
                 materialtouched = true;
                 applySelf();
@@ -2471,7 +2471,7 @@
         {
             public void mouseClicked(MouseEvent e)
             {
-                parallaxField.setFloat(0.265);
+                parallaxField.setFloat(0.14);
 
                 materialtouched = true;
                 applySelf();
@@ -2727,7 +2727,7 @@
         cGridBag parallax = new cGridBag();
                 parallax.add(parallaxLabel = new JLabel("Parallax")); // , aConstraints);
                 parallaxLabel.setHorizontalAlignment(SwingConstants.TRAILING);
-                parallax.add(parallaxField = new cNumberSlider(this, 0.001, 0.5, -0.25)); // , aConstraints);
+                parallax.add(parallaxField = new cNumberSlider(this, 0.001, 0.25, -0.125)); // , aConstraints);
         colorSection.add(parallax);
         
         //panel.add(new JSeparator());
@@ -3781,7 +3781,7 @@
         shadowField.setFloat(mat.shadow);
         textureField.setFloat(mat.texture);
         opacityField.setFloat(mat.opacity);
-        parallaxField.setFloat(mat.parallax + 0.25f);
+        parallaxField.setFloat(mat.parallax + 0.125f);
         fakedepthField.setFloat(mat.fakedepth);
         shadowbiasField.setFloat(mat.shadowbias);
         bumpField.setInteger(1); // dec 2013
@@ -4075,6 +4075,7 @@
         } else if (event.getSource() == link2masterCB)
         {
             copy.link2master ^= true;
+            objEditor.refreshContents();
             return;
         }
         if (event.getSource() == randomCB)
@@ -4465,7 +4466,7 @@
             copy.versionindex -= 1;
         
         if (copy.versionindex != -1)
-            CopyChanged();
+            CopyChanged(copy);
         
         SetVersionStates();
     }
@@ -4475,7 +4476,11 @@
         System.err.println("Save");
         Replace();
         
-        //cRadio tab = GetCurrentTab();
+        if (copy.versionlist == null)
+        {
+            copy.versionlist = new Object3D[100];
+            copy.versionindex = -1;
+        }
         
         Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
         
@@ -4543,20 +4548,20 @@
     {
         Object3D selection = new Object3D();
         
-        for (int i = 0; i < copy.selection.size(); i++)
+        for (int i = 0; i < objEditor.copy.selection.size(); i++)
         {
-            Object3D elem = copy.selection.elementAt(i);
+            Object3D elem = objEditor.copy.selection.elementAt(i);
             
-            Object3D obj = copy.GetObject(elem.GetUUID());
+            Object3D obj = objEditor.copy.GetObject(elem.GetUUID());
             
             if (obj == null)
             {
-                copy.selection.remove(i--);
+                objEditor.copy.selection.remove(i--);
             }
             else
             {
                 selection.add(obj);
-                copy.selection.setElementAt(obj, i);
+                objEditor.copy.selection.setElementAt(obj, i);
             }
         }
         
@@ -4569,44 +4574,43 @@
         //refreshContents(false);
     }
 
-    void CopyChanged()
+    void CopyChanged(Object3D changed)
     {
-        Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
-        
-        SetVersionStates();
+        Object3D obj = (Object3D)Grafreed.clone(changed.versionlist[copy.versionindex]);
         
         boolean temp = CameraPane.SWITCH;
         CameraPane.SWITCH = false;
         
-        copy.ExtractBigData(Grafreed.grafreed.universe.versiontable);
+        changed.ExtractBigData(Grafreed.grafreed.universe.versiontable);
         
-        copy.clear();
+        changed.clear();
         
-        copy.skyboxname = obj.skyboxname;
-        copy.skyboxext = obj.skyboxext;
+        changed.skyboxname = obj.skyboxname;
+        changed.skyboxext = obj.skyboxext;
                 
         for (int i=0; i<obj.Size(); i++)
         {
-            copy.add(obj.get(i));
+            changed.add(obj.get(i));
         }
         
-        copy.RestoreBigData(Grafreed.grafreed.universe.versiontable);
+        changed.RestoreBigData(Grafreed.grafreed.universe.versiontable);
         
         CameraPane.SWITCH = temp;
         
-        RefreshSelection();
+        if (objEditor == this)
+            RefreshSelection();
         //assert(hashtable.isEmpty());
         
-        copy.Touch();
+        objEditor.copy.Touch();
         
         ResetModel();
-        copy.HardTouch(); // recompile?
+        objEditor.copy.HardTouch(); // recompile?
         
         cRadio ab;
-        for (java.util.Enumeration e = buttonGroup.getElements(); e.hasMoreElements();)
+        for (java.util.Enumeration e = objEditor.buttonGroup.getElements(); e.hasMoreElements();)
         {
             ab = (cRadio)e.nextElement();
-            Object3D test = copy.GetObject(ab.object.GetUUID());
+            Object3D test = objEditor.copy.GetObject(ab.object.GetUUID());
             //ab.camera = (Camera)copy.GetObject(ab.camera.GetUUID());
             if (test != null)
             {
@@ -4615,7 +4619,7 @@
             }
         }
         
-        refreshContents(true);
+        objEditor.refreshContents(true);
     }
     
     cButton previousVersionButton;
@@ -4629,15 +4633,7 @@
     
     int VersionCount()
     {
-        int count = 0;
-        
-        for (int i = copy.versionlist.length; --i >= 0;)
-        {
-            if (copy.versionlist[i] != null)
-                count++;
-        }
-        
-        return count;
+        return copy.VersionCount();
     }
     
     public cGridBag versionSliderPane;
@@ -4649,7 +4645,7 @@
                     
         //cRadio tab = GetCurrentTab();
         
-        if (copy.versionlist == null)
+        if (copy.versionindex == -2)
         {
             saveVersionButton.setEnabled(false);
             restoreButton.setEnabled(false);
@@ -4711,7 +4707,9 @@
 
         copy.versionindex -= 1;
 
-        CopyChanged();
+        CopyChanged(copy);
+        
+        SetVersionStates();
         
         return true;
     }
@@ -4729,7 +4727,9 @@
         }
 
         //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex]));
-        CopyChanged();
+        CopyChanged(copy);
+        
+        SetVersionStates();
         
         return true;
     }
@@ -4766,10 +4766,12 @@
 
         copy.versionindex += 1;
 
-        CopyChanged();
+        CopyChanged(copy);
         
         //if (!tab.user[tab.versionindex])
         //    tab.graphs[tab.versionindex] = null;
+        
+        SetVersionStates();        
     }
 
         void ImportGFD()
@@ -5006,7 +5008,7 @@
             current.shadow = (float) shadowField.getFloat();
             current.texture = (float) textureField.getFloat();
             current.opacity = (float) opacityField.getFloat();
-            current.parallax = (float) parallaxField.getFloat() - 0.25f;
+            current.parallax = (float) parallaxField.getFloat() - 0.125f;
             current.fakedepth = (float) fakedepthField.getFloat();
             current.shadowbias = (float) shadowbiasField.getFloat();
 
@@ -5098,6 +5100,7 @@
     }
 
     cNumberSlider versionSlider;
+    cNumberSlider versionField;
     
     public void stateChanged(ChangeEvent e)
     {
@@ -5114,12 +5117,26 @@
             if (version != -1 && copy.versionlist[version] != null)
             {
                 copy.versionindex = version;
-                CopyChanged();
+                CopyChanged(copy);
+                SetVersionStates();
             }
             
             return;
         }
 
+        if (e.getSource() == versionField)
+        {
+            int version = versionField.getInteger();
+            
+            if (version != -1 && copy.versionindex != version && copy.versionlist[version] != null)
+            {
+                copy.versionindex = version;
+                CopyChanged(copy);
+            }
+            
+            return;
+        }
+        
         if (freezematerial)
         {
             return;
@@ -5209,7 +5226,7 @@
         }
         
         if (normalpushField != null)
-                copy.NORMALPUSH = (float)normalpushField.getFloat()/100;
+                copy.NORMALPUSH = (float)normalpushField.getFloat() / 100;
     }
 
         void SnapObject()
@@ -5583,7 +5600,7 @@
     void ResetModel()
     {
         //assert(copy instanceof Composite);
-        Object3D /*Composite*/ group = (Object3D /*Composite*/) copy;
+        Object3D /*Composite*/ group = (Object3D /*Composite*/) objEditor.copy;
 
 // necessary?		group.selection = new Object3D(); // java.util.Vector();
 
@@ -5594,14 +5611,14 @@
         //group.refreshEditWindow();
         //refreshContents();
 
-        if (copy.selection == null)
+        if (objEditor.copy.selection == null)
         {
-            copy.selection = new Object3D();
+            objEditor.copy.selection = new Object3D();
         }
 
-        for (int j = 0; j < copy.selection.size(); j++)
+        for (int j = 0; j < objEditor.copy.selection.size(); j++)
         {
-            Object3D item = copy.selection.get(j);
+            Object3D item = objEditor.copy.selection.get(j);
 
             if (item instanceof cGroup && ((cGroup) item).transientlink)
             {
@@ -5610,15 +5627,15 @@
 
             if (item.count <= 1) // ??? == 0)
             {
-                copy.selection.remove(item);
+                objEditor.copy.selection.remove(item);
             }
         }
 
         boolean first = true;
 
-        for (int i = copy.selection.size(); --i >= 0;)
+        for (int i = objEditor.copy.selection.size(); --i >= 0;)
         {
-            Object3D item = copy.selection.get(i);
+            Object3D item = objEditor.copy.selection.get(i);
 
             if (item instanceof cGroup && ((cGroup) item).transientlink)
             {

--
Gitblit v1.6.2