Normand Briere
2019-08-09 912749d2520afedd9b56458d771400c261fe2b88
GroupEditor.java
....@@ -16,6 +16,7 @@
1616 //import buoy.widget.BFileChooser;
1717
1818 class GroupEditor extends ObjEditor implements //iParse, //iCallBack,
19
+ Grafreed.iResourceCallBack,
1920 ObjectUI,
2021 Runnable,
2122 ActionListener,
....@@ -41,6 +42,22 @@
4142 });
4243 }
4344
45
+ public void AddTextureButton(String f, String c, final String t, int count, cGridBag row)
46
+ {
47
+ cButton textureButton;
48
+ final String path = "textures/" + f + "/" + c + "/"; // + t;
49
+ row.add(textureButton = GetButton(path + "icons/" + t, !Grafreed.NIMBUSLAF));
50
+ textureButton.setToolTipText(c + count);
51
+ textureButton.addActionListener(new ActionListener()
52
+ {
53
+ @Override
54
+ public void actionPerformed(ActionEvent e)
55
+ {
56
+ ChangeTexture(path + t);
57
+ }
58
+ });
59
+ }
60
+
4461 public void AddSkyboxTab0(JTabbedPane skyboxpanel)
4562 {
4663 cGridBag tab0 = new cGridBag().setVertical(true);
....@@ -311,14 +328,37 @@
311328 }
312329 }
313330
314
- public void ChangeSkybox(String name)
331
+ public void ChangeSkybox(String skybox)
315332 {
316333 //cameraView.envyoff = false;
317
- group.skyboxname = name;
334
+ group.skyboxname = skybox;
318335 group.skyboxext = "jpg";
319336 cameraView.repaint();
320337 }
338
+
339
+ public void CreateSkyboxPanel(cGridBag skyboxPanel)
340
+ {
341
+ JTabbedPane skyboxpane = new JTabbedPane();
342
+
343
+ AddSkyboxTab0(skyboxpane);
344
+ AddSkyboxTab1(skyboxpane);
345
+ AddSkyboxTab2(skyboxpane);
346
+ AddSkyboxTab3(skyboxpane);
347
+
348
+ skyboxPanel.add(skyboxpane);
349
+ }
321350
351
+ public void ChangeTexture(String texture)
352
+ {
353
+ for (int i=0; i<group.selection.size(); i++)
354
+ {
355
+ Object3D obj = group.selection.get(i);
356
+ obj.SetPigmentTexture("@" + texture);
357
+ }
358
+
359
+ refreshContents();
360
+ }
361
+
322362 //ObjEditor objEditor;
323363 public void closeUI2()
324364 {
....@@ -356,9 +396,9 @@
356396 this.copy = this.group = group;
357397 //selectees = this.group.selectees;
358398
359
- if (copy.versions == null)
399
+ if (copy.versionlist == null)
360400 {
361
- copy.versions = new byte[100][];
401
+ copy.versionlist = new Object3D[100];
362402 copy.versionindex = -1;
363403 }
364404
....@@ -383,9 +423,9 @@
383423
384424 ((cRadio)radioPanel.getComponent(0)).SetCamera(cameraView.renderCamera, true);
385425
386
- if (copy.versions == null)
426
+ if (copy.versionlist == null)
387427 {
388
- copy.versions = new byte[100][];
428
+ copy.versionlist = new Object3D[100];
389429 copy.versionindex = -1;
390430
391431 Save(true);
....@@ -859,6 +899,73 @@
859899 buildToolsMenu(menu);
860900 }
861901
902
+ JTabbedPane resourcecontainer;
903
+ cGridBag currenttab;
904
+ boolean added; // patch for jar
905
+
906
+ int tabcount = 0;
907
+ int colcount = 0;
908
+ int rowcount = 0;
909
+ int texturecount = 0;
910
+
911
+ int columns = 5;
912
+ int rows = 7;
913
+
914
+ public void ResourceCallBack(String[] path)
915
+ {
916
+// for (int i = 0; i < path.length; i++)
917
+// System.out.print(path[i] + "/");
918
+// System.out.println();
919
+
920
+ if (//rowcount == 0 ||
921
+ path.length == 1)
922
+ {
923
+ currenttab = new cGridBag();
924
+ added = false;
925
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
926
+ currenttab.setName(tabname);
927
+ rowcount = 1;
928
+ colcount = 0;
929
+ texturecount = 0;
930
+ }
931
+
932
+ if (path.length > 2 && path[2].toLowerCase().endsWith(".jpg"))
933
+ {
934
+ if (!added)
935
+ {
936
+ added = true;
937
+ resourcecontainer.add(currenttab);
938
+ String tabname = path[0]; // String.valueOf((char)('A'+tabcount));
939
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
940
+ }
941
+
942
+ AddTextureButton(path[0], path[1], path[2], texturecount++, currenttab);
943
+
944
+ if (++colcount >= columns)
945
+ {
946
+ colcount = 0;
947
+ currenttab.Return();
948
+
949
+ if (rowcount++ >= rows)
950
+ {
951
+ rowcount = 0;
952
+ }
953
+ }
954
+ }
955
+ else
956
+ {
957
+// if (!path[path.length-1].equals("icons"))
958
+// resourcecontainer.Return();
959
+ }
960
+ }
961
+
962
+ void CreateTexturePanel(cGridBag container)
963
+ {
964
+ resourcecontainer = new JTabbedPane(JTabbedPane.LEFT);
965
+ container.add(resourcecontainer);
966
+
967
+ Grafreed.ParseResources("textures", this);
968
+ }
862969
863970 void SetupUI2(ObjEditor oe)
864971 {
....@@ -931,32 +1038,36 @@
9311038 restoreCameraButton.setToolTipText("Restore viewpoint");
9321039 restoreCameraButton.addActionListener(this);
9331040
934
- copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
935
- saveButton.setToolTipText("New version");
936
- saveButton.addActionListener(this);
1041
+ copyOptionsPanel.add(saveVersionButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1042
+ saveVersionButton.setToolTipText("Duplicate current version");
1043
+ saveVersionButton.addActionListener(this);
9371044
938
- copyOptionsPanel.add(undoButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
939
- undoButton.setToolTipText("Previous version");
940
- undoButton.addActionListener(this);
941
- undoButton.setEnabled(false);
1045
+ copyOptionsPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1046
+ deleteVersionButton.setToolTipText("Delete current version");
1047
+ deleteVersionButton.addActionListener(this);
1048
+
1049
+ copyOptionsPanel.add(previousVersionButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1050
+ previousVersionButton.setToolTipText("Previous version");
1051
+ previousVersionButton.addActionListener(this);
1052
+ previousVersionButton.setEnabled(false);
9421053
9431054 cGridBag updown = new cGridBag().setVertical(true);
9441055 updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
945
- restoreButton.setToolTipText("Restore current");
1056
+ restoreButton.setToolTipText("Undo (restore current version)");
9461057 restoreButton.addActionListener(this);
947
- restoreButton.setEnabled(false);
1058
+ //restoreButton.setEnabled(false);
9481059
9491060 updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
950
- replaceButton.setToolTipText("Replace current");
1061
+ replaceButton.setToolTipText("Save (replace current version)");
9511062 replaceButton.addActionListener(this);
952
- replaceButton.setEnabled(false);
1063
+ //replaceButton.setEnabled(false);
9531064
9541065 copyOptionsPanel.add(updown);
9551066
956
- copyOptionsPanel.add(redoButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
957
- redoButton.setToolTipText("Next version");
958
- redoButton.addActionListener(this);
959
- redoButton.setEnabled(false);
1067
+ copyOptionsPanel.add(nextVersionButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1068
+ nextVersionButton.setToolTipText("Next version");
1069
+ nextVersionButton.addActionListener(this);
1070
+ nextVersionButton.setEnabled(false);
9601071
9611072 oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
9621073 liveCB.setToolTipText("Enable animation");
....@@ -1090,19 +1201,15 @@
10901201
10911202 oe.toolboxPanel.add(row2);
10921203
1093
- // ENVYMAPS
1094
- cGridBag skyboxpane = new cGridBag();
1095
- skyboxpane.preferredHeight = 100;
1204
+ cGridBag textures = new cGridBag();
10961205
1097
- oe.toolboxPanel.add(skyboxpane);
1206
+ CreateTexturePanel(textures);
10981207
1099
- JTabbedPane skyboxpanel = new JTabbedPane();
1100
- skyboxpane.add(skyboxpanel);
1208
+ oe.toolboxPanel.add(textures);
11011209
1102
- AddSkyboxTab0(skyboxpanel);
1103
- AddSkyboxTab1(skyboxpanel);
1104
- AddSkyboxTab2(skyboxpanel);
1105
- AddSkyboxTab3(skyboxpanel);
1210
+ textures.preferredHeight = 100;
1211
+
1212
+ CreateSkyboxPanel(oe.skyboxPanel);
11061213
11071214 // EDIT panel
11081215 editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1110,20 +1217,20 @@
11101217 editButton.addActionListener(this);
11111218
11121219 editCommandsPanel.add(uneditButton = GetButton("icons/remove.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1113
- uneditButton.setToolTipText("Remove selection controls");
1220
+ uneditButton.setToolTipText("Unpin and remove selection controls");
11141221 uneditButton.addActionListener(this);
11151222
11161223 editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
1117
- allParamsButton.setToolTipText("Show all controle");
1224
+ allParamsButton.setToolTipText("Show all controls");
11181225 allParamsButton.addActionListener(this);
11191226
1120
- editCommandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1121
- clearPanelButton.setToolTipText("Clear edit panel");
1227
+ editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1228
+ clearPanelButton.setToolTipText("Clear all controls");
11221229 clearPanelButton.addActionListener(this);
11231230
1124
- editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1125
- unselectButton.setToolTipText("Unselect");
1126
- unselectButton.addActionListener(this);
1231
+ //editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1232
+ //unselectButton.setToolTipText("Unselect");
1233
+ //unselectButton.addActionListener(this);
11271234
11281235 editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11291236 flashSelectionButton.setToolTipText("Highlight selection");
....@@ -1183,7 +1290,7 @@
11831290 dgr.addDragGestureListener(this);
11841291 }catch(Exception e) {}
11851292 */
1186
- radio.layout = sixButton; // sevenButton;
1293
+ radio.layout = threeButton; // sixButton;
11871294 oe.toolbarPanel.add(radioPanel); //, oe.aConstraints);
11881295 }
11891296
....@@ -1328,7 +1435,7 @@
13281435 }
13291436
13301437 radioButton.SetObject(obj);
1331
- radioButton.layout = sixButton; // sevenButton;
1438
+ radioButton.layout = threeButton; // sixButton;
13321439 radioButton.SetCamera(cameraView.renderCamera, false);
13331440 radioButton.addActionListener(this);
13341441 radioPanel.add(radioButton);
....@@ -2571,7 +2678,7 @@
25712678 if (source == invariantsItem)
25722679 {
25732680 System.out.println("Invariants:");
2574
- Grafreed.grafreeD.universe.invariants();
2681
+ Grafreed.grafreed.universe.invariants();
25752682 } else
25762683 if (source == memoryItem)
25772684 {
....@@ -2602,33 +2709,40 @@
26022709 {
26032710 ToggleFullScreen();
26042711 } else
2605
- if (source == undoButton)
2712
+ if (source == previousVersionButton)
26062713 {
26072714 // Go to previous version
26082715 //if (!Undo())
26092716 //java.awt.Toolkit.getDefaultToolkit().beep();
2610
- Undo();
2717
+ PreviousVersion();
26112718 } else
26122719 if (source == restoreButton)
26132720 {
26142721 // Restore current version
26152722 Restore();
2723
+ //restoreButton.setEnabled(false);
26162724 } else
26172725 if (source == replaceButton)
26182726 {
26192727 // Overwrite current version
26202728 Replace();
2729
+ //replaceButton.setEnabled(false);
26212730 } else
2622
- if (source == redoButton)
2731
+ if (source == nextVersionButton)
26232732 {
26242733 // Go to next version
2625
- Redo();
2734
+ NextVersion();
26262735 } else
2627
- if (source == saveButton)
2736
+ if (source == saveVersionButton)
26282737 {
26292738 // Save a new version
26302739 if (!Save(true))
26312740 java.awt.Toolkit.getDefaultToolkit().beep();
2741
+ } else
2742
+ if (source == deleteVersionButton)
2743
+ {
2744
+ // Delete a new version
2745
+ DeleteVersion();
26322746 } else
26332747 if (source == oneStepButton)
26342748 {
....@@ -2683,11 +2797,11 @@
26832797 } else
26842798 if (source == undoItem)
26852799 {
2686
- Undo();
2800
+ PreviousVersion();
26872801 } else
26882802 if (source == redoItem)
26892803 {
2690
- Redo();
2804
+ NextVersion();
26912805 } else
26922806 if (source == duplicateItem)
26932807 {
....@@ -3820,10 +3934,10 @@
38203934 {
38213935 Object3D child = (Object3D)e.nextElement();
38223936 if(child.editWindow != null)
3823
- objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
38243937 child.pinned = false;
38253938 child.CloseUI();
38263939 listUI.remove(child);
3940
+// objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
38273941
38283942 //child.editWindow = null; // ???????????
38293943 }
....@@ -3842,6 +3956,7 @@
38423956 obj.CloseUI();
38433957 }
38443958 listUI.clear();
3959
+ SetPinStates(group.selection.size() > 0);
38453960 refreshContents(true);
38463961 } else
38473962 if (source == allParamsButton)
....@@ -3928,6 +4043,7 @@
39284043 radio.layout.doClick();
39294044
39304045 ClearUnpinned();
4046
+
39314047 //Grafreed.Assert(group != null);
39324048 //Grafreed.Assert(group.selection != null);
39334049 SetPinStates(group.selection == null || group.selection.size() > 0);
....@@ -3944,11 +4060,13 @@
39444060 } else if (event.getSource() == editCameraItem)
39454061 {
39464062 cameraView.ProtectCamera();
4063
+ cameraView.requestFocusInWindow();
39474064 cameraView.repaint();
39484065 return;
39494066 } else if (event.getSource() == restoreCameraItem || event.getSource() == restoreCameraButton)
39504067 {
39514068 cameraView.RevertCamera();
4069
+ cameraView.requestFocusInWindow();
39524070 cameraView.repaint();
39534071 return;
39544072 // } else if (event.getSource() == textureButton)
....@@ -5081,9 +5199,7 @@
50815199
50825200 freezemodel = false;
50835201 }
5084
-
5085
- boolean flashIt = true;
5086
-
5202
+
50875203 public void valueChanged(TreeSelectionEvent e)
50885204 //public boolean handleEvent(Event event)
50895205 {
....@@ -5156,13 +5272,15 @@
51565272 {
51575273 editButton.setEnabled(enabled);
51585274 uneditButton.setEnabled(enabled);
5159
- unselectButton.setEnabled(enabled);
5275
+ //unselectButton.setEnabled(enabled);
51605276 flashSelectionButton.setEnabled(enabled);
5277
+
5278
+ clearPanelButton.setEnabled(!listUI.isEmpty());
51615279 }
51625280
51635281 void refreshContents(boolean cp)
51645282 {
5165
- if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
5283
+ //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
51665284 if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
51675285 {
51685286 objEditor.ClearInfo(); // .GetMaterial());
....@@ -5998,7 +6116,6 @@
59986116
59996117 cButton restoreCameraButton;
60006118
6001
- cButton saveButton;
60026119 cButton oneStepButton;
60036120
60046121 cButton groupButton;