From 8294241adc5fe698b70e13ebd6780af46ab83f7e Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Wed, 07 Aug 2019 22:00:52 -0400
Subject: [PATCH] Textures pane.

---
 GroupEditor.java |  126 ++++++++++++++++++++++++++++++++++--------
 1 files changed, 102 insertions(+), 24 deletions(-)

diff --git a/GroupEditor.java b/GroupEditor.java
index 00a0f61..074be71 100644
--- a/GroupEditor.java
+++ b/GroupEditor.java
@@ -16,7 +16,7 @@
 //import buoy.widget.BFileChooser;
 
 class GroupEditor extends ObjEditor implements //iParse, //iCallBack,
-    Grafreed.iResourceCallBack,
+        Grafreed.iResourceCallBack,
         ObjectUI,
         Runnable,
         ActionListener,
@@ -42,6 +42,22 @@
         });
     }
 
+    public void AddTextureButton(String f, final String t, cGridBag row)
+    {
+        cButton textureButton;
+        final String path = "textures/" + f + "/"; // + t;
+        row.add(textureButton = GetButton(path + "icons/" + t, !Grafreed.NIMBUSLAF));
+        textureButton.setToolTipText(f + "s");
+        textureButton.addActionListener(new ActionListener()
+        {
+                @Override
+                public void actionPerformed(ActionEvent e)
+                {
+                    ChangeTexture(path + t);
+                }
+        });
+    }
+    
     public void AddSkyboxTab0(JTabbedPane skyboxpanel)
     {
         cGridBag tab0 = new cGridBag().setVertical(true);
@@ -312,26 +328,31 @@
         }
     }
         
-    public void CallBack(String[] path)
-    {
-        for (int i = 0; i < path.length; i++)
-        {
-            System.out.print(path[i] + "/");
-        }
-        
-        System.out.println();
-    }
-    
     public void ChangeSkybox(String skybox)
     {
         //cameraView.envyoff = false;
         group.skyboxname = skybox;
         group.skyboxext = "jpg";
         cameraView.repaint();
+    }
 
-        Grafreed.ParseResources("textures", this);
+    public void CreateSkyboxPanel(cGridBag skyboxPanel)
+    {
+        JTabbedPane skyboxpane = new JTabbedPane();
+        
+        AddSkyboxTab0(skyboxpane);
+        AddSkyboxTab1(skyboxpane);
+        AddSkyboxTab2(skyboxpane);
+        AddSkyboxTab3(skyboxpane);
+        
+        skyboxPanel.add(skyboxpane);
     }
     
+    public void ChangeTexture(String texture)
+    {
+        cameraView.repaint();
+    }
+
     //ObjEditor objEditor;
 	public void closeUI2()
 	{
@@ -872,6 +893,67 @@
 		buildToolsMenu(menu);
 	}
 	
+        JTabbedPane resourcecontainer;
+        cGridBag currenttab;
+        boolean added; // patch for jar
+                
+        int tabcount = 0;
+        int colcount = 0;
+        int rowcount = 0;
+        
+        int columns = 5;
+        int rows = 7;
+        
+    public void ResourceCallBack(String[] path)
+    {
+        for (int i = 0; i < path.length; i++)
+            System.out.print(path[i] + "/");
+        System.out.println();
+        if (rowcount == 0)
+        {
+            currenttab = new cGridBag();
+            added = false;
+            String tabname = String.valueOf((char)('A'+tabcount));
+            currenttab.setName(tabname);
+            rowcount = 1;
+        }
+        
+        if (path.length > 1 && path[1].toLowerCase().endsWith(".jpg"))
+        {
+            if (!added)
+            {
+                added = true;
+                resourcecontainer.add(currenttab);
+                String tabname = String.valueOf((char)('A'+tabcount));
+                resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
+            }
+            
+            AddTextureButton(path[0], path[1], currenttab);
+            if (++colcount >= columns)
+            {
+                colcount = 0;
+                currenttab.Return();
+                
+                if (rowcount++ >= rows)
+                {
+                    rowcount = 0;
+                }
+            }
+        }
+        else
+        {
+//            if (!path[path.length-1].equals("icons"))
+//                resourcecontainer.Return();
+        }
+    }
+    
+        void CreateTexturePanel(cGridBag container)
+        {
+            resourcecontainer = new JTabbedPane();
+            container.add(resourcecontainer);
+            
+            Grafreed.ParseResources("textures", this);
+        }
         
 	void SetupUI2(ObjEditor oe)
 	{
@@ -1107,19 +1189,15 @@
 
                 oe.toolboxPanel.add(row2);
                 
-                // ENVYMAPS
-                cGridBag skyboxpane = new cGridBag();
-                skyboxpane.preferredHeight = 100;
+                cGridBag textures = new cGridBag();
                 
-                oe.skyboxPanel.add(skyboxpane);
+                CreateTexturePanel(textures);
                 
-                JTabbedPane skyboxpanel = new JTabbedPane();
-                skyboxpane.add(skyboxpanel);
+                oe.toolboxPanel.add(textures);
                 
-                AddSkyboxTab0(skyboxpanel);
-                AddSkyboxTab1(skyboxpanel);
-                AddSkyboxTab2(skyboxpanel);
-                AddSkyboxTab3(skyboxpanel);
+                textures.preferredHeight = 100;
+                
+                CreateSkyboxPanel(oe.skyboxPanel);
                 
                 // EDIT panel
 		editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
@@ -1131,11 +1209,11 @@
 		uneditButton.addActionListener(this);
 
 		editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
-                allParamsButton.setToolTipText("Show all controle");
+                allParamsButton.setToolTipText("Show all controls");
 		allParamsButton.addActionListener(this);
 
 		editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
-                clearPanelButton.setToolTipText("Clear edit panel");
+                clearPanelButton.setToolTipText("Clear all controls");
 		clearPanelButton.addActionListener(this);
 
 		//editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);

--
Gitblit v1.6.2