Normand Briere
2019-08-15 24a2a946b35279605e645349bd6b82e9e60aac88
GroupEditor.java
....@@ -31,7 +31,7 @@
3131 final String path = "cubemaps/" + f + "-skyboxes/" + s;
3232 row.add(skyboxButton = GetButton(path + "/preview.jpg", !Grafreed.NIMBUSLAF));
3333 //row.add(skyboxButton = GetButton(path + "/negx.jpg", !Grafreed.NIMBUSLAF));
34
- skyboxButton.setToolTipText(s);
34
+ skyboxButton.setToolTipText(s.equals("") ? "No background" : s);
3535 skyboxButton.addActionListener(new ActionListener()
3636 {
3737 @Override
....@@ -73,7 +73,7 @@
7373 cGridBag row5 = new cGridBag();
7474 cGridBag row6 = new cGridBag();
7575
76
- AddSkyboxButton("default", "rgb", row0);
76
+ AddSkyboxButton("default", "", row0);
7777 //AddSkyboxButton("default", "cornell", row0);
7878 AddSkyboxButton("penguins", "dust", row0);
7979 AddSkyboxButton("penguins", "tropic", row0);
....@@ -330,10 +330,19 @@
330330
331331 public void ChangeSkybox(String skybox)
332332 {
333
- //cameraView.envyoff = false;
334
- group.skyboxname = skybox;
335
- group.skyboxext = "jpg";
336
- cameraView.repaint();
333
+ if (skybox.endsWith("/"))
334
+ {
335
+ group.skyboxname = null;
336
+ group.skyboxext = null;
337
+ cameraView.repaint();
338
+ }
339
+ else
340
+ {
341
+ //cameraView.envyoff = false;
342
+ group.skyboxname = skybox;
343
+ group.skyboxext = "jpg";
344
+ cameraView.repaint();
345
+ }
337346 }
338347
339348 public void CreateSkyboxPanel(cGridBag skyboxPanel)
....@@ -531,32 +540,37 @@
531540 // menu.add("-");
532541 duplicateItem = oe.jTree.popup.add(new JMenuItem("Duplicate"));
533542 duplicateItem.addActionListener(this);
534
- cloneItem = menu.add(new MenuItem("Clone"));
543
+
544
+ cloneItem = oe.jTree.popup.add(new JMenuItem("Clone"));
535545 cloneItem.addActionListener(this);
536
- if (Globals.ADVANCED)
546
+ //if (Globals.ADVANCED)
537547 {
538548 cloneSupportItem = menu.add(new MenuItem("Clone (+supports)"));
539549 cloneSupportItem.addActionListener(this);
540550 }
551
+ oe.jTree.popup.addSeparator();
541552 menu.add("-");
542
- cutItem = menu.add(new MenuItem("Cut"));
553
+ cutItem = oe.jTree.popup.add(new JMenuItem("Cut"));
543554 cutItem.addActionListener(this);
544
- copyItem = menu.add(new MenuItem("Copy"));
555
+ copyItem = oe.jTree.popup.add(new JMenuItem("Copy"));
545556 copyItem.addActionListener(this);
546557 pasteItem = menu.add(new MenuItem("Paste"));
547558 pasteItem.addActionListener(this);
548559
549
- menu.add("-");
550
- pasteIntoItem = menu.add(new MenuItem("Paste into"));
560
+ oe.jTree.popup.addSeparator();
561
+ //menu.add("-");
562
+ pasteIntoItem = oe.jTree.popup.add(new JMenuItem("Paste into"));
551563 pasteIntoItem.addActionListener(this);
552
- pasteLinkItem = menu.add(new MenuItem("Paste link"));
564
+ pasteLinkItem = oe.jTree.popup.add(new JMenuItem("Paste link"));
553565 pasteLinkItem.addActionListener(this);
554
- pasteCloneItem = menu.add(new MenuItem("Paste clone"));
566
+ pasteCloneItem = oe.jTree.popup.add(new JMenuItem("Paste clone"));
555567 pasteCloneItem.addActionListener(this);
556
-// pasteExpandItem = menu.add(new MenuItem("Paste expand"));
568
+// CRASH pasteExpandItem = oe.jTree.popup.add(new JMenuItem("Paste expand"));
557569 // pasteExpandItem.addActionListener(this);
558
- menu.add("-");
559
- deleteItem = menu.add(new MenuItem("Delete"));
570
+ //menu.add("-");
571
+ oe.jTree.popup.addSeparator();
572
+
573
+ deleteItem = oe.jTree.popup.add(new JMenuItem("Delete"));
560574 deleteItem.addActionListener(this);
561575
562576 if (Globals.ADVANCED)
....@@ -707,7 +721,7 @@
707721 hideItem = menu.add(new MenuItem("Hidden Group"));
708722 hideItem.addActionListener(this);
709723 }
710
- ungroupItem = menu.add(new MenuItem("Ungroup"));
724
+ ungroupItem = oe.jTree.popup.add(new JMenuItem("Ungroup"));
711725 ungroupItem.addActionListener(this);
712726
713727 // menu.add("-");
....@@ -914,7 +928,7 @@
914928
915929 JTabbedPane resourcecontainer;
916930 cGridBag currenttab;
917
- boolean added; // patch for jar
931
+ //boolean added; // patch for jar
918932
919933 int tabcount = 0;
920934 int colcount = 0;
....@@ -931,12 +945,14 @@
931945 // System.out.println();
932946
933947 if (//rowcount == 0 ||
934
- path.length == 1)
948
+ path.length == 1 && !path[0].equals("") && !path[0].equals(".DS_Store"))
935949 {
936950 currenttab = new cGridBag();
937
- added = false;
938951 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
939952 currenttab.setName(tabname);
953
+ //added = false;
954
+ resourcecontainer.add(currenttab);
955
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
940956 rowcount = 1;
941957 colcount = 0;
942958 texturecount = 0;
....@@ -944,12 +960,11 @@
944960
945961 if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
946962 {
947
- if (!added)
963
+ //if (!added)
948964 {
949
- added = true;
950
- resourcecontainer.add(currenttab);
965
+ //added = true;
951966 String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
952
- resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
967
+ currenttab = (cGridBag)resourcecontainer.getComponentAt(resourcecontainer.indexOfTab(tabname));
953968 }
954969
955970 AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
....@@ -1034,8 +1049,8 @@
10341049 // maxButton.addActionListener(this);
10351050 }
10361051
1037
-// cButton gcButton;
1038
-//
1052
+ cButton gcButton;
1053
+
10391054 // oe.toolbarPanel.add(gcButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
10401055 // gcButton.setToolTipText("Garbage collect");
10411056 // gcButton.addActionListener(new ActionListener()
....@@ -1459,11 +1474,11 @@
14591474 {
14601475 assert(obj instanceof Composite);
14611476
1462
- if (obj.versionlist == null)
1463
- {
1464
- obj.versionlist = new Object3D[100];
1465
- obj.versionindex = -1;
1466
- }
1477
+// if (obj.versionlist == null)
1478
+// {
1479
+// obj.versionlist = new Object3D[100];
1480
+// obj.versionindex = -1;
1481
+// }
14671482
14681483 cRadio radioButton = new cRadio(obj.name);
14691484
....@@ -2671,27 +2686,35 @@
26712686 } else
26722687 if (source == loopItem || source == loopButton)
26732688 {
2689
+ if (!group.selection.isEmpty())
2690
+ {
26742691 Composite csg = new GroupLeaf();
26752692 csg.count = 5;
2676
- group(csg);
26772693 Composite child = new cGroup("Branch");
26782694 csg.addChild(child);
26792695 child.addChild(csg);
2696
+ group(csg);
2697
+ }
26802698 } else
26812699 if (source == doubleItem)
26822700 {
2701
+ if (!group.selection.isEmpty())
2702
+ {
26832703 Composite csg = new GroupLeaf("Fork");
26842704 csg.count = 5;
2685
- group(csg);
26862705 Composite child = new cGroup("Branch A");
26872706 csg.addChild(child);
26882707 child.addChild(csg);
26892708 child = new cGroup("Branch B");
26902709 csg.addChild(child);
26912710 child.addChild(csg);
2711
+ group(csg);
2712
+ }
26922713 } else
26932714 if (source == tripleItem)
26942715 {
2716
+ if (!group.selection.isEmpty())
2717
+ {
26952718 Composite csg = new GroupLeaf("Trident");
26962719 csg.count = 4;
26972720 group(csg);
....@@ -2704,6 +2727,7 @@
27042727 child = new cGroup();
27052728 csg.addChild(child);
27062729 child.addChild(csg);
2730
+ }
27072731 } else
27082732 if (source == computeAOItem)
27092733 {
....@@ -3339,22 +3363,34 @@
33393363 } else
33403364 if (source == ungroupItem || source == ungroupButton)
33413365 {
3342
- boolean hasRoot = false;
3366
+ boolean canUngroup = true;
33433367
33443368 for (int i=0; i<group.selection.size(); i++)
33453369 {
3346
- if (group.selection.get(i) == group)
3370
+ Object3D selectedItem = group.selection.get(i);
3371
+
3372
+ if (selectedItem.Size() == 0)
33473373 {
3348
- hasRoot = true;
3374
+ // Cannot ungroup leaves
3375
+ canUngroup = false;
3376
+ break;
3377
+ }
3378
+
3379
+ if (selectedItem == group)
3380
+ {
3381
+ // Cannot ungroup root
3382
+ canUngroup = false;
33493383 break;
33503384 }
33513385 }
33523386
3353
- if (!hasRoot)
3387
+ if (canUngroup)
33543388 {
33553389 for (int i=0; i<group.selection.size(); i++)
33563390 {
3357
- Ungroup(group.selection.get(i));
3391
+ Object3D selectedItem = group.selection.get(i);
3392
+
3393
+ Ungroup(selectedItem);
33583394 }
33593395
33603396 ClearSelection(false);
....@@ -4067,7 +4103,17 @@
40674103 */
40684104 radio.layout.doClick();
40694105
4070
- SetUndoStates();
4106
+ assert(copy instanceof Composite);
4107
+
4108
+ if (copy.versionlist == null)
4109
+ {
4110
+ copy.versionlist = new Object3D[100];
4111
+ copy.versionindex = -1;
4112
+
4113
+ Save(true);
4114
+ }
4115
+
4116
+ SetVersionStates();
40714117
40724118 ClearUnpinned();
40734119
....@@ -5306,6 +5352,7 @@
53065352
53075353 boolean allComposites = true;
53085354
5355
+ if (group.selection != null)
53095356 for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
53105357 {
53115358 if (!(e.nextElement() instanceof Composite))
....@@ -6213,11 +6260,11 @@
62136260 private MenuItem lookAtItem;
62146261 private MenuItem lookFromItem;
62156262 private MenuItem switchViewItem;
6216
- private MenuItem cutItem;
6263
+ private JMenuItem cutItem;
62176264 private MenuItem undoItem;
62186265 private MenuItem redoItem;
62196266 private JMenuItem duplicateItem;
6220
- private MenuItem cloneItem;
6267
+ private JMenuItem cloneItem;
62216268 private MenuItem cloneSupportItem;
62226269 private MenuItem overwriteGeoItem;
62236270 private MenuItem overwriteMatItem;
....@@ -6238,13 +6285,13 @@
62386285 private MenuItem cloneGeometriesItem;
62396286 private MenuItem shareGeometriesItem;
62406287 private MenuItem mergeGeometriesItem;
6241
- private MenuItem copyItem;
6288
+ private JMenuItem copyItem;
62426289 private MenuItem pasteItem;
6243
- private MenuItem pasteIntoItem;
6244
- private MenuItem pasteLinkItem;
6245
- private MenuItem pasteCloneItem;
6246
- private MenuItem pasteExpandItem;
6247
- private MenuItem deleteItem;
6290
+ private JMenuItem pasteIntoItem;
6291
+ private JMenuItem pasteLinkItem;
6292
+ private JMenuItem pasteCloneItem;
6293
+ private JMenuItem pasteExpandItem;
6294
+ private JMenuItem deleteItem;
62486295 private MenuItem clearAllItem;
62496296 private MenuItem genUVItem;
62506297 private MenuItem genNormalsMESHItem;
....@@ -6312,7 +6359,7 @@
63126359 private MenuItem switchTransfoItem;
63136360 private MenuItem morphItem;
63146361 private MenuItem linkerItem;
6315
- private MenuItem ungroupItem;
6362
+ private JMenuItem ungroupItem;
63166363 private MenuItem editItem;
63176364 private MenuItem openWindowItem;
63186365 private MenuItem editLeafItem;