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 |  129 ++++++++++++++++++++++++++++++++++++------
 1 files changed, 110 insertions(+), 19 deletions(-)

diff --git a/GroupEditor.java b/GroupEditor.java
index 5698ae1..074be71 100644
--- a/GroupEditor.java
+++ b/GroupEditor.java
@@ -16,6 +16,7 @@
 //import buoy.widget.BFileChooser;
 
 class GroupEditor extends ObjEditor implements //iParse, //iCallBack,
+        Grafreed.iResourceCallBack,
         ObjectUI,
         Runnable,
         ActionListener,
@@ -41,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);
@@ -311,14 +328,31 @@
         }
     }
         
-    public void ChangeSkybox(String name)
+    public void ChangeSkybox(String skybox)
     {
         //cameraView.envyoff = false;
-        group.skyboxname = name;
+        group.skyboxname = skybox;
         group.skyboxext = "jpg";
         cameraView.repaint();
     }
+
+    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()
 	{
@@ -859,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)
 	{
@@ -1094,19 +1189,15 @@
 
                 oe.toolboxPanel.add(row2);
                 
-                // ENVYMAPS
-                cGridBag skyboxpane = new cGridBag();
-                skyboxpane.preferredHeight = 100;
+                cGridBag textures = new cGridBag();
                 
-                oe.toolboxPanel.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);
@@ -1118,16 +1209,16 @@
 		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);
-                unselectButton.setToolTipText("Unselect");
-		unselectButton.addActionListener(this);
+		//editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
+                //unselectButton.setToolTipText("Unselect");
+		//unselectButton.addActionListener(this);
 
 		editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
                 flashSelectionButton.setToolTipText("Highlight selection");
@@ -5169,7 +5260,7 @@
         {
             editButton.setEnabled(enabled);
             uneditButton.setEnabled(enabled);
-            unselectButton.setEnabled(enabled);
+            //unselectButton.setEnabled(enabled);
             flashSelectionButton.setEnabled(enabled);
             
             clearPanelButton.setEnabled(!listUI.isEmpty());
@@ -5177,7 +5268,7 @@
 
         void refreshContents(boolean cp)
         {
-            if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
+            //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
             if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
             {
                 objEditor.ClearInfo(); // .GetMaterial());

--
Gitblit v1.6.2