Normand Briere
2019-08-14 0c1f740dd6ddd6432dc29266e42ef851e26027bb
ObjEditor.java
....@@ -75,8 +75,16 @@
7575 return new cCheckBox(icon, border);
7676 }
7777
78
+ static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>();
79
+
7880 ImageIcon GetIcon(String name)
7981 {
82
+ javax.swing.ImageIcon iconCache = icons.get(name);
83
+ if (iconCache != null)
84
+ {
85
+ return iconCache;
86
+ }
87
+
8088 try
8189 {
8290 BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name));
....@@ -94,10 +102,14 @@
94102 // }
95103
96104 javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image);
105
+
106
+ icons.put(name, icon);
107
+
97108 return icon;
98109 }
99110 catch (Exception e)
100111 {
112
+ //icons.put(name, null);
101113 return null;
102114 }
103115 }
....@@ -297,11 +309,13 @@
297309 client = inClient;
298310 copy = client;
299311
300
- if (copy.versionlist == null)
301
- {
302
- copy.versionlist = new Object3D[100];
303
- copy.versionindex = -1;
304
- }
312
+// if (copy.versionlist == null)
313
+// {
314
+// copy.versionlist = new Object3D[100];
315
+// copy.versionindex = -1;
316
+//
317
+// callee.Save(true);
318
+// }
305319
306320 // "this" is not called: SetupUI2(objEditor);
307321 }
....@@ -320,6 +334,8 @@
320334 {
321335 copy.versionlist = new Object3D[100];
322336 copy.versionindex = -1;
337
+
338
+// Save(true);
323339 }
324340
325341 SetupUI2(callee.GetEditor());
....@@ -354,11 +370,13 @@
354370 copy = localCopy;
355371 copy.editWindow = this;
356372
357
- if (copy.versionlist == null)
358
- {
359
-// copy.versions = new byte[100][];
373
+// if (copy.versionlist == null)
374
+// {
375
+// copy.versionlist = new Object3D[100];
360376 // copy.versionindex = -1;
361
- }
377
+//
378
+// Save(true);
379
+// }
362380
363381 SetupMenu();
364382
....@@ -427,6 +445,8 @@
427445
428446 ChangeListener changeListener = new ChangeListener()
429447 {
448
+ //String name;
449
+
430450 public void stateChanged(ChangeEvent changeEvent)
431451 {
432452 // if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed)
....@@ -445,7 +465,37 @@
445465 // EditSelection(false);
446466 // }
447467
448
- refreshContents(false); // To refresh Info tab
468
+// if (objectPanel.getSelectedIndex() == 4)
469
+// {
470
+// name = copy.skyboxname;
471
+//
472
+// if (name == null)
473
+// {
474
+// name = "";
475
+// }
476
+//
477
+// copy.skyboxname = "cubemaps/default-skyboxes/rgb";
478
+// copy.skyboxext = "jpg";
479
+// }
480
+// else
481
+// {
482
+// if (name != null)
483
+// {
484
+// if (name.equals(""))
485
+// {
486
+// copy.skyboxname = null;
487
+// copy.skyboxext = null;
488
+// }
489
+// else
490
+// {
491
+// copy.skyboxname = name;
492
+// }
493
+// }
494
+// }
495
+ cameraView.transformMode = objectPanel.getSelectedIndex() == 4;
496
+
497
+// refreshContents(false); // To refresh Info tab
498
+ cameraView.repaint();
449499 }
450500 };
451501 objectPanel.addChangeListener(changeListener);
....@@ -1639,9 +1689,9 @@
16391689 scenePanel.add(tabbedPane);
16401690
16411691 //if (Globals.ADVANCED)
1642
- tabbedPane.add(infoPanel);
1643
- tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1644
- tabbedPane.setToolTipTextAt(3, "Information");
1692
+// tabbedPane.add(infoPanel);
1693
+// tabbedPane.setIconAt(3, GetIcon("icons/info.png"));
1694
+// tabbedPane.setToolTipTextAt(3, "Information");
16451695
16461696 /*
16471697 cTree jTree = new cTree(null);
....@@ -4123,7 +4173,7 @@
41234173 {
41244174 //Save(true);
41254175 Replace();
4126
- SetUndoStates();
4176
+ SetVersionStates();
41274177 }
41284178
41294179 private boolean Equal(byte[] compress, byte[] name)
....@@ -4153,7 +4203,7 @@
41534203
41544204 CopyChanged();
41554205
4156
- SetUndoStates();
4206
+ SetVersionStates();
41574207 }
41584208
41594209 public boolean Save(boolean user)
....@@ -4161,7 +4211,7 @@
41614211 System.err.println("Save");
41624212 Replace();
41634213
4164
- cRadio tab = GetCurrentTab();
4214
+ //cRadio tab = GetCurrentTab();
41654215
41664216 Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"?
41674217
....@@ -4199,7 +4249,7 @@
41994249 // copy.versionlist[i] = null;
42004250 // }
42014251
4202
- SetUndoStates();
4252
+ SetVersionStates();
42034253
42044254 // test save
42054255 if (false)
....@@ -4259,7 +4309,7 @@
42594309 {
42604310 Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]);
42614311
4262
- SetUndoStates();
4312
+ SetVersionStates();
42634313
42644314 boolean temp = CameraPane.SWITCH;
42654315 CameraPane.SWITCH = false;
....@@ -4326,12 +4376,15 @@
43264376 return count;
43274377 }
43284378
4329
- void SetUndoStates()
4379
+ void SetVersionStates()
43304380 {
4331
- cRadio tab = GetCurrentTab();
4381
+ //if (true)
4382
+ // return;
4383
+
4384
+ //cRadio tab = GetCurrentTab();
43324385
4333
- restoreButton.setEnabled(true); // copy.versionindex != -1);
4334
- replaceButton.setEnabled(true); // copy.versionindex != -1);
4386
+ restoreButton.setEnabled(copy.versionindex != -1);
4387
+ replaceButton.setEnabled(copy.versionindex != -1);
43354388
43364389 previousVersionButton.setEnabled(copy.versionindex > 0);
43374390 nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null);
....@@ -4340,8 +4393,10 @@
43404393 copy.versionlist[copy.versionindex + 1] != null);
43414394
43424395 muteSlider = true;
4396
+ versionSlider.setMinimum(0);
43434397 versionSlider.setMaximum(VersionCount() - 1);
43444398 versionSlider.setInteger(copy.versionindex);
4399
+ versionSlider.setEnabled(copy.versionindex != -1);
43454400 muteSlider = false;
43464401 }
43474402
....@@ -4352,7 +4407,7 @@
43524407
43534408 System.err.println("Undo");
43544409
4355
- cRadio tab = GetCurrentTab();
4410
+ //cRadio tab = GetCurrentTab();
43564411
43574412 if (copy.versionindex == 0)
43584413 {
....@@ -4384,7 +4439,7 @@
43844439 {
43854440 System.err.println("Restore");
43864441
4387
- cRadio tab = GetCurrentTab();
4442
+ //cRadio tab = GetCurrentTab();
43884443
43894444 if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
43904445 {
....@@ -4402,7 +4457,7 @@
44024457 {
44034458 System.err.println("Replace");
44044459
4405
- cRadio tab = GetCurrentTab();
4460
+ //cRadio tab = GetCurrentTab();
44064461
44074462 if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null)
44084463 {
....@@ -4420,7 +4475,7 @@
44204475 // Option?
44214476 Replace();
44224477
4423
- cRadio tab = GetCurrentTab();
4478
+ //cRadio tab = GetCurrentTab();
44244479
44254480 if (copy.versionlist[copy.versionindex + 1] == null)
44264481 {
....@@ -4739,9 +4794,11 @@
47394794 if (muteSlider)
47404795 return;
47414796
4797
+ Replace();
4798
+
47424799 int version = versionSlider.getInteger();
47434800
4744
- if (copy.versionlist[version] != null)
4801
+ if (version != -1 && copy.versionlist[version] != null)
47454802 {
47464803 copy.versionindex = version;
47474804 CopyChanged();
....@@ -5100,7 +5157,7 @@
51005157 }
51015158
51025159 if (previousVersionButton != null && copy.versionlist != null)
5103
- SetUndoStates();
5160
+ SetVersionStates();
51045161 }
51055162
51065163 static TweenManager tweenManager = new TweenManager();
....@@ -5489,8 +5546,11 @@
54895546
54905547 if (copy.versionlist == null)
54915548 {
5549
+ // Backward compatibility
54925550 copy.versionlist = new Object3D[100];
54935551 copy.versionindex = -1;
5552
+
5553
+ Save(true);
54945554 }
54955555
54965556 //? SetUndoStates();
....@@ -5582,6 +5642,8 @@
55825642
55835643 void save()
55845644 {
5645
+ Replace();
5646
+
55855647 if (lastname == null)
55865648 {
55875649 return;