Normand Briere
2019-08-08 8294241adc5fe698b70e13ebd6780af46ab83f7e
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, final String t, cGridBag row)
46
+ {
47
+ cButton textureButton;
48
+ final String path = "textures/" + f + "/"; // + t;
49
+ row.add(textureButton = GetButton(path + "icons/" + t, !Grafreed.NIMBUSLAF));
50
+ textureButton.setToolTipText(f + "s");
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,31 @@
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
+ cameraView.repaint();
354
+ }
355
+
322356 //ObjEditor objEditor;
323357 public void closeUI2()
324358 {
....@@ -356,9 +390,9 @@
356390 this.copy = this.group = group;
357391 //selectees = this.group.selectees;
358392
359
- if (copy.versions == null)
393
+ if (copy.versionlist == null)
360394 {
361
- copy.versions = new Object3D[100];
395
+ copy.versionlist = new Object3D[100];
362396 copy.versionindex = -1;
363397 }
364398
....@@ -383,9 +417,9 @@
383417
384418 ((cRadio)radioPanel.getComponent(0)).SetCamera(cameraView.renderCamera, true);
385419
386
- if (copy.versions == null)
420
+ if (copy.versionlist == null)
387421 {
388
- copy.versions = new Object3D[100];
422
+ copy.versionlist = new Object3D[100];
389423 copy.versionindex = -1;
390424
391425 Save(true);
....@@ -859,6 +893,67 @@
859893 buildToolsMenu(menu);
860894 }
861895
896
+ JTabbedPane resourcecontainer;
897
+ cGridBag currenttab;
898
+ boolean added; // patch for jar
899
+
900
+ int tabcount = 0;
901
+ int colcount = 0;
902
+ int rowcount = 0;
903
+
904
+ int columns = 5;
905
+ int rows = 7;
906
+
907
+ public void ResourceCallBack(String[] path)
908
+ {
909
+ for (int i = 0; i < path.length; i++)
910
+ System.out.print(path[i] + "/");
911
+ System.out.println();
912
+ if (rowcount == 0)
913
+ {
914
+ currenttab = new cGridBag();
915
+ added = false;
916
+ String tabname = String.valueOf((char)('A'+tabcount));
917
+ currenttab.setName(tabname);
918
+ rowcount = 1;
919
+ }
920
+
921
+ if (path.length > 1 && path[1].toLowerCase().endsWith(".jpg"))
922
+ {
923
+ if (!added)
924
+ {
925
+ added = true;
926
+ resourcecontainer.add(currenttab);
927
+ String tabname = String.valueOf((char)('A'+tabcount));
928
+ resourcecontainer.setToolTipTextAt(tabcount++, "Texture Group " + tabname);
929
+ }
930
+
931
+ AddTextureButton(path[0], path[1], currenttab);
932
+ if (++colcount >= columns)
933
+ {
934
+ colcount = 0;
935
+ currenttab.Return();
936
+
937
+ if (rowcount++ >= rows)
938
+ {
939
+ rowcount = 0;
940
+ }
941
+ }
942
+ }
943
+ else
944
+ {
945
+// if (!path[path.length-1].equals("icons"))
946
+// resourcecontainer.Return();
947
+ }
948
+ }
949
+
950
+ void CreateTexturePanel(cGridBag container)
951
+ {
952
+ resourcecontainer = new JTabbedPane();
953
+ container.add(resourcecontainer);
954
+
955
+ Grafreed.ParseResources("textures", this);
956
+ }
862957
863958 void SetupUI2(ObjEditor oe)
864959 {
....@@ -931,32 +1026,36 @@
9311026 restoreCameraButton.setToolTipText("Restore viewpoint");
9321027 restoreCameraButton.addActionListener(this);
9331028
934
- copyOptionsPanel.add(saveButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
935
- saveButton.setToolTipText("Duplicate current version");
936
- saveButton.addActionListener(this);
1029
+ copyOptionsPanel.add(saveVersionButton = GetButton("icons/down_arrow.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1030
+ saveVersionButton.setToolTipText("Duplicate current version");
1031
+ saveVersionButton.addActionListener(this);
9371032
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);
1033
+ copyOptionsPanel.add(deleteVersionButton = GetButton("icons/trash.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1034
+ deleteVersionButton.setToolTipText("Delete current version");
1035
+ deleteVersionButton.addActionListener(this);
1036
+
1037
+ copyOptionsPanel.add(previousVersionButton = GetButton("icons/undo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1038
+ previousVersionButton.setToolTipText("Previous version");
1039
+ previousVersionButton.addActionListener(this);
1040
+ previousVersionButton.setEnabled(false);
9421041
9431042 cGridBag updown = new cGridBag().setVertical(true);
9441043 updown.add(restoreButton = GetButton("icons/restore.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
945
- restoreButton.setToolTipText("Restore current version (undo latest change)");
1044
+ restoreButton.setToolTipText("Undo (restore current version)");
9461045 restoreButton.addActionListener(this);
947
- restoreButton.setEnabled(false);
1046
+ //restoreButton.setEnabled(false);
9481047
9491048 updown.add(replaceButton = GetButton("icons/replace.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
950
- replaceButton.setToolTipText("Replace current version (save latest change)");
1049
+ replaceButton.setToolTipText("Save (replace current version)");
9511050 replaceButton.addActionListener(this);
952
- replaceButton.setEnabled(false);
1051
+ //replaceButton.setEnabled(false);
9531052
9541053 copyOptionsPanel.add(updown);
9551054
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);
1055
+ copyOptionsPanel.add(nextVersionButton = GetButton("icons/redo.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1056
+ nextVersionButton.setToolTipText("Next version");
1057
+ nextVersionButton.addActionListener(this);
1058
+ nextVersionButton.setEnabled(false);
9601059
9611060 oe.toolbarPanel.add(liveCB = GetToggleButton("icons/run.png", Globals.isLIVE())); //, oe.aConstraints);
9621061 liveCB.setToolTipText("Enable animation");
....@@ -1090,19 +1189,15 @@
10901189
10911190 oe.toolboxPanel.add(row2);
10921191
1093
- // ENVYMAPS
1094
- cGridBag skyboxpane = new cGridBag();
1095
- skyboxpane.preferredHeight = 100;
1192
+ cGridBag textures = new cGridBag();
10961193
1097
- oe.toolboxPanel.add(skyboxpane);
1194
+ CreateTexturePanel(textures);
10981195
1099
- JTabbedPane skyboxpanel = new JTabbedPane();
1100
- skyboxpane.add(skyboxpanel);
1196
+ oe.toolboxPanel.add(textures);
11011197
1102
- AddSkyboxTab0(skyboxpanel);
1103
- AddSkyboxTab1(skyboxpanel);
1104
- AddSkyboxTab2(skyboxpanel);
1105
- AddSkyboxTab3(skyboxpanel);
1198
+ textures.preferredHeight = 100;
1199
+
1200
+ CreateSkyboxPanel(oe.skyboxPanel);
11061201
11071202 // EDIT panel
11081203 editCommandsPanel.add(editButton = GetButton("icons/controls.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
....@@ -1110,20 +1205,20 @@
11101205 editButton.addActionListener(this);
11111206
11121207 editCommandsPanel.add(uneditButton = GetButton("icons/remove.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1113
- uneditButton.setToolTipText("Remove selection controls");
1208
+ uneditButton.setToolTipText("Unpin and remove selection controls");
11141209 uneditButton.addActionListener(this);
11151210
11161211 editCommandsPanel.add(allParamsButton = new JCheckBox("All", allparams)); //, oe.aConstraints);
1117
- allParamsButton.setToolTipText("Show all controle");
1212
+ allParamsButton.setToolTipText("Show all controls");
11181213 allParamsButton.addActionListener(this);
11191214
1120
- editCommandsPanel.add(clearPanelButton = new cButton("C", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1121
- clearPanelButton.setToolTipText("Clear edit panel");
1215
+ editCommandsPanel.add(clearPanelButton = GetButton("icons/clear.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1216
+ clearPanelButton.setToolTipText("Clear all controls");
11221217 clearPanelButton.addActionListener(this);
11231218
1124
- editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1125
- unselectButton.setToolTipText("Unselect");
1126
- unselectButton.addActionListener(this);
1219
+ //editCommandsPanel.add(unselectButton = new cButton("U", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
1220
+ //unselectButton.setToolTipText("Unselect");
1221
+ //unselectButton.addActionListener(this);
11271222
11281223 editCommandsPanel.add(flashSelectionButton = GetButton("icons/flash-light.png", !Grafreed.NIMBUSLAF)); //, oe.aConstraints);
11291224 flashSelectionButton.setToolTipText("Highlight selection");
....@@ -2571,7 +2666,7 @@
25712666 if (source == invariantsItem)
25722667 {
25732668 System.out.println("Invariants:");
2574
- Grafreed.grafreeD.universe.invariants();
2669
+ Grafreed.grafreed.universe.invariants();
25752670 } else
25762671 if (source == memoryItem)
25772672 {
....@@ -2602,33 +2697,40 @@
26022697 {
26032698 ToggleFullScreen();
26042699 } else
2605
- if (source == undoButton)
2700
+ if (source == previousVersionButton)
26062701 {
26072702 // Go to previous version
26082703 //if (!Undo())
26092704 //java.awt.Toolkit.getDefaultToolkit().beep();
2610
- Undo();
2705
+ PreviousVersion();
26112706 } else
26122707 if (source == restoreButton)
26132708 {
26142709 // Restore current version
26152710 Restore();
2711
+ //restoreButton.setEnabled(false);
26162712 } else
26172713 if (source == replaceButton)
26182714 {
26192715 // Overwrite current version
26202716 Replace();
2717
+ //replaceButton.setEnabled(false);
26212718 } else
2622
- if (source == redoButton)
2719
+ if (source == nextVersionButton)
26232720 {
26242721 // Go to next version
2625
- Redo();
2722
+ NextVersion();
26262723 } else
2627
- if (source == saveButton)
2724
+ if (source == saveVersionButton)
26282725 {
26292726 // Save a new version
26302727 if (!Save(true))
26312728 java.awt.Toolkit.getDefaultToolkit().beep();
2729
+ } else
2730
+ if (source == deleteVersionButton)
2731
+ {
2732
+ // Delete a new version
2733
+ DeleteVersion();
26322734 } else
26332735 if (source == oneStepButton)
26342736 {
....@@ -2683,11 +2785,11 @@
26832785 } else
26842786 if (source == undoItem)
26852787 {
2686
- Undo();
2788
+ PreviousVersion();
26872789 } else
26882790 if (source == redoItem)
26892791 {
2690
- Redo();
2792
+ NextVersion();
26912793 } else
26922794 if (source == duplicateItem)
26932795 {
....@@ -3820,10 +3922,10 @@
38203922 {
38213923 Object3D child = (Object3D)e.nextElement();
38223924 if(child.editWindow != null)
3823
- objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
38243925 child.pinned = false;
38253926 child.CloseUI();
38263927 listUI.remove(child);
3928
+// objectPanel.setSelectedIndex(objectPanel.indexOfTab("Edit"));
38273929
38283930 //child.editWindow = null; // ???????????
38293931 }
....@@ -3842,6 +3944,7 @@
38423944 obj.CloseUI();
38433945 }
38443946 listUI.clear();
3947
+ SetPinStates(group.selection.size() > 0);
38453948 refreshContents(true);
38463949 } else
38473950 if (source == allParamsButton)
....@@ -3928,6 +4031,7 @@
39284031 radio.layout.doClick();
39294032
39304033 ClearUnpinned();
4034
+
39314035 //Grafreed.Assert(group != null);
39324036 //Grafreed.Assert(group.selection != null);
39334037 SetPinStates(group.selection == null || group.selection.size() > 0);
....@@ -5083,9 +5187,7 @@
50835187
50845188 freezemodel = false;
50855189 }
5086
-
5087
- boolean flashIt = true;
5088
-
5190
+
50895191 public void valueChanged(TreeSelectionEvent e)
50905192 //public boolean handleEvent(Event event)
50915193 {
....@@ -5158,13 +5260,15 @@
51585260 {
51595261 editButton.setEnabled(enabled);
51605262 uneditButton.setEnabled(enabled);
5161
- unselectButton.setEnabled(enabled);
5263
+ //unselectButton.setEnabled(enabled);
51625264 flashSelectionButton.setEnabled(enabled);
5265
+
5266
+ clearPanelButton.setEnabled(!listUI.isEmpty());
51635267 }
51645268
51655269 void refreshContents(boolean cp)
51665270 {
5167
- if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
5271
+ //if (objectPanel.getSelectedIndex() == 2) // objectPanel.indexOfTab("Info"))
51685272 if (!Globals.MOUSEDRAGGED && group.selection != null) // && !Globals.TIMERRUNNING)
51695273 {
51705274 objEditor.ClearInfo(); // .GetMaterial());
....@@ -6000,7 +6104,6 @@
60006104
60016105 cButton restoreCameraButton;
60026106
6003
- cButton saveButton;
60046107 cButton oneStepButton;
60056108
60066109 cButton groupButton;