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 | 185 +++++++++++++++++++++++++++++++++++---------- 1 files changed, 142 insertions(+), 43 deletions(-) diff --git a/GroupEditor.java b/GroupEditor.java index 0efe0b9..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) { @@ -931,32 +1026,36 @@ restoreCameraButton.setToolTipText("Restore viewpoint"); restoreCameraButton.addActionListener(this); - copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - saveButton.setToolTipText("Duplicate current version"); - saveButton.addActionListener(this); + copyOptionsPanel.add(saveVersionButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + saveVersionButton.setToolTipText("Duplicate current version"); + saveVersionButton.addActionListener(this); - copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - undoButton.setToolTipText("Previous version"); - undoButton.addActionListener(this); - undoButton.setEnabled(false); + copyOptionsPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + deleteVersionButton.setToolTipText("Delete current version"); + deleteVersionButton.addActionListener(this); + + copyOptionsPanel.add(previousVersionButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + previousVersionButton.setToolTipText("Previous version"); + previousVersionButton.addActionListener(this); + previousVersionButton.setEnabled(false); cGridBag updown = new cGridBag().setVertical(true); updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); restoreButton.setToolTipText("Undo (restore current version)"); restoreButton.addActionListener(this); - restoreButton.setEnabled(false); + //restoreButton.setEnabled(false); updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); replaceButton.setToolTipText("Save (replace current version)"); replaceButton.addActionListener(this); - replaceButton.setEnabled(false); + //replaceButton.setEnabled(false); copyOptionsPanel.add(updown); - copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); - redoButton.setToolTipText("Next version"); - redoButton.addActionListener(this); - redoButton.setEnabled(false); + copyOptionsPanel.add(nextVersionButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); + nextVersionButton.setToolTipText("Next version"); + nextVersionButton.addActionListener(this); + nextVersionButton.setEnabled(false); oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints); liveCB.setToolTipText("Enable animation"); @@ -1090,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); @@ -1114,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"); @@ -2571,7 +2666,7 @@ if (source == invariantsItem) { System.out.println("Invariants:"); - Grafreed.grafreeD.universe.invariants(); + Grafreed.grafreed.universe.invariants(); } else if (source == memoryItem) { @@ -2602,35 +2697,40 @@ { ToggleFullScreen(); } else - if (source == undoButton) + if (source == previousVersionButton) { // Go to previous version //if (!Undo()) //java.awt.Toolkit.getDefaultToolkit().beep(); - Undo(); + PreviousVersion(); } else if (source == restoreButton) { // Restore current version Restore(); - restoreButton.setEnabled(false); + //restoreButton.setEnabled(false); } else if (source == replaceButton) { // Overwrite current version Replace(); - replaceButton.setEnabled(false); + //replaceButton.setEnabled(false); } else - if (source == redoButton) + if (source == nextVersionButton) { // Go to next version - Redo(); + NextVersion(); } else - if (source == saveButton) + if (source == saveVersionButton) { // Save a new version if (!Save(true)) java.awt.Toolkit.getDefaultToolkit().beep(); + } else + if (source == deleteVersionButton) + { + // Delete a new version + DeleteVersion(); } else if (source == oneStepButton) { @@ -2685,11 +2785,11 @@ } else if (source == undoItem) { - Undo(); + PreviousVersion(); } else if (source == redoItem) { - Redo(); + NextVersion(); } else if (source == duplicateItem) { @@ -5160,7 +5260,7 @@ { editButton.setEnabled(enabled); uneditButton.setEnabled(enabled); - unselectButton.setEnabled(enabled); + //unselectButton.setEnabled(enabled); flashSelectionButton.setEnabled(enabled); clearPanelButton.setEnabled(!listUI.isEmpty()); @@ -5168,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()); @@ -6004,7 +6104,6 @@ cButton restoreCameraButton; - cButton saveButton; cButton oneStepButton; cButton groupButton; -- Gitblit v1.6.2