From 24a2a946b35279605e645349bd6b82e9e60aac88 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Wed, 14 Aug 2019 23:35:34 -0400 Subject: [PATCH] Fix textures in jar. --- GroupEditor.java | 102 ++++++++++++++++++++++++++++++++------------------ 1 files changed, 65 insertions(+), 37 deletions(-) diff --git a/GroupEditor.java b/GroupEditor.java index 4faf49e..651e8a8 100644 --- a/GroupEditor.java +++ b/GroupEditor.java @@ -540,32 +540,37 @@ // menu.add("-"); duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate")); duplicateItem.addActionListener(this); - cloneItem = menu.add(new MenuItem("Clone")); + + cloneItem = oe.jTree.popup.add(new JMenuItem("Clone")); cloneItem.addActionListener(this); - if (Globals.ADVANCED) + //if (Globals.ADVANCED) { cloneSupportItem = menu.add(new MenuItem("Clone (+supports)")); cloneSupportItem.addActionListener(this); } + oe.jTree.popup.addSeparator(); menu.add("-"); - cutItem = menu.add(new MenuItem("Cut")); + cutItem = oe.jTree.popup.add(new JMenuItem("Cut")); cutItem.addActionListener(this); - copyItem = menu.add(new MenuItem("Copy")); + copyItem = oe.jTree.popup.add(new JMenuItem("Copy")); copyItem.addActionListener(this); pasteItem = menu.add(new MenuItem("Paste")); pasteItem.addActionListener(this); - menu.add("-"); - pasteIntoItem = menu.add(new MenuItem("Paste into")); + oe.jTree.popup.addSeparator(); + //menu.add("-"); + pasteIntoItem = oe.jTree.popup.add(new JMenuItem("Paste into")); pasteIntoItem.addActionListener(this); - pasteLinkItem = menu.add(new MenuItem("Paste link")); + pasteLinkItem = oe.jTree.popup.add(new JMenuItem("Paste link")); pasteLinkItem.addActionListener(this); - pasteCloneItem = menu.add(new MenuItem("Paste clone")); + pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone")); pasteCloneItem.addActionListener(this); -// pasteExpandItem = menu.add(new MenuItem("Paste expand")); +// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand")); // pasteExpandItem.addActionListener(this); - menu.add("-"); - deleteItem = menu.add(new MenuItem("Delete")); + //menu.add("-"); + oe.jTree.popup.addSeparator(); + + deleteItem = oe.jTree.popup.add(new JMenuItem("Delete")); deleteItem.addActionListener(this); if (Globals.ADVANCED) @@ -716,7 +721,7 @@ hideItem = menu.add(new MenuItem("Hidden Group")); hideItem.addActionListener(this); } - ungroupItem = menu.add(new MenuItem("Ungroup")); + ungroupItem = oe.jTree.popup.add(new JMenuItem("Ungroup")); ungroupItem.addActionListener(this); // menu.add("-"); @@ -923,7 +928,7 @@ JTabbedPane resourcecontainer; cGridBag currenttab; - boolean added; // patch for jar + //boolean added; // patch for jar int tabcount = 0; int colcount = 0; @@ -940,12 +945,14 @@ // System.out.println(); if (//rowcount == 0 || - path.length == 1) + path.length == 1 && !path[0].equals("") && !path[0].equals(".DS_Store")) { currenttab = new cGridBag(); - added = false; String tabname = path[0]; // String.valueOf((char)('A'+tabcount)); currenttab.setName(tabname); + //added = false; + resourcecontainer.add(currenttab); + resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname); rowcount = 1; colcount = 0; texturecount = 0; @@ -953,12 +960,11 @@ if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg")) { - if (!added) + //if (!added) { - added = true; - resourcecontainer.add(currenttab); + //added = true; String tabname = path[0]; // String.valueOf((char)('A'+tabcount)); - resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname); + currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname)); } AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab); @@ -1043,8 +1049,8 @@ // maxButton.addActionListener(this); } -// cButton gcButton; -// + cButton gcButton; + // oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints); // gcButton.setToolTipText("Garbage collect"); // gcButton.addActionListener(new ActionListener() @@ -2680,27 +2686,35 @@ } else if (source == loopItem || source == loopButton) { + if (!group.selection.isEmpty()) + { Composite csg = new GroupLeaf(); csg.count = 5; - group(csg); Composite child = new cGroup("Branch"); csg.addChild(child); child.addChild(csg); + group(csg); + } } else if (source == doubleItem) { + if (!group.selection.isEmpty()) + { Composite csg = new GroupLeaf("Fork"); csg.count = 5; - group(csg); Composite child = new cGroup("Branch A"); csg.addChild(child); child.addChild(csg); child = new cGroup("Branch B"); csg.addChild(child); child.addChild(csg); + group(csg); + } } else if (source == tripleItem) { + if (!group.selection.isEmpty()) + { Composite csg = new GroupLeaf("Trident"); csg.count = 4; group(csg); @@ -2713,6 +2727,7 @@ child = new cGroup(); csg.addChild(child); child.addChild(csg); + } } else if (source == computeAOItem) { @@ -3348,22 +3363,34 @@ } else if (source == ungroupItem || source == ungroupButton) { - boolean hasRoot = false; + boolean canUngroup = true; for (int i=0; i<group.selection.size(); i++) { - if (group.selection.get(i) == group) + Object3D selectedItem = group.selection.get(i); + + if (selectedItem.Size() == 0) { - hasRoot = true; + // Cannot ungroup leaves + canUngroup = false; + break; + } + + if (selectedItem == group) + { + // Cannot ungroup root + canUngroup = false; break; } } - if (!hasRoot) + if (canUngroup) { for (int i=0; i<group.selection.size(); i++) { - Ungroup(group.selection.get(i)); + Object3D selectedItem = group.selection.get(i); + + Ungroup(selectedItem); } ClearSelection(false); @@ -5325,6 +5352,7 @@ boolean allComposites = true; + if (group.selection != null) for (Enumeration e = group.selection.elements(); e.hasMoreElements();) { if (!(e.nextElement() instanceof Composite)) @@ -6232,11 +6260,11 @@ private MenuItem lookAtItem; private MenuItem lookFromItem; private MenuItem switchViewItem; - private MenuItem cutItem; + private JMenuItem cutItem; private MenuItem undoItem; private MenuItem redoItem; private JMenuItem duplicateItem; - private MenuItem cloneItem; + private JMenuItem cloneItem; private MenuItem cloneSupportItem; private MenuItem overwriteGeoItem; private MenuItem overwriteMatItem; @@ -6257,13 +6285,13 @@ private MenuItem cloneGeometriesItem; private MenuItem shareGeometriesItem; private MenuItem mergeGeometriesItem; - private MenuItem copyItem; + private JMenuItem copyItem; private MenuItem pasteItem; - private MenuItem pasteIntoItem; - private MenuItem pasteLinkItem; - private MenuItem pasteCloneItem; - private MenuItem pasteExpandItem; - private MenuItem deleteItem; + private JMenuItem pasteIntoItem; + private JMenuItem pasteLinkItem; + private JMenuItem pasteCloneItem; + private JMenuItem pasteExpandItem; + private JMenuItem deleteItem; private MenuItem clearAllItem; private MenuItem genUVItem; private MenuItem genNormalsMESHItem; @@ -6331,7 +6359,7 @@ private MenuItem switchTransfoItem; private MenuItem morphItem; private MenuItem linkerItem; - private MenuItem ungroupItem; + private JMenuItem ungroupItem; private MenuItem editItem; private MenuItem openWindowItem; private MenuItem editLeafItem; -- Gitblit v1.6.2