.. | .. |
---|
282 | 282 | client = inClient; |
---|
283 | 283 | copy = client; |
---|
284 | 284 | |
---|
| 285 | + if (copy.versions == null) |
---|
| 286 | + { |
---|
| 287 | + copy.versions = new byte[100][]; |
---|
| 288 | + copy.versionindex = -1; |
---|
| 289 | + } |
---|
| 290 | + |
---|
285 | 291 | // "this" is not called: SetupUI2(objEditor); |
---|
286 | 292 | } |
---|
287 | 293 | |
---|
.. | .. |
---|
295 | 301 | client = inClient; |
---|
296 | 302 | copy = client; |
---|
297 | 303 | |
---|
| 304 | + if (copy.versions == null) |
---|
| 305 | + { |
---|
| 306 | + copy.versions = new byte[100][]; |
---|
| 307 | + copy.versionindex = -1; |
---|
| 308 | + } |
---|
| 309 | + |
---|
298 | 310 | SetupUI2(callee.GetEditor()); |
---|
299 | 311 | } |
---|
300 | 312 | |
---|
.. | .. |
---|
309 | 321 | //localCopy.parent = null; |
---|
310 | 322 | |
---|
311 | 323 | frame = new JFrame(); |
---|
312 | | - frame.setUndecorated(true); |
---|
| 324 | + frame.setUndecorated(false); |
---|
313 | 325 | objEditor = this; |
---|
314 | 326 | this.callee = callee; |
---|
315 | 327 | |
---|
.. | .. |
---|
327 | 339 | copy = localCopy; |
---|
328 | 340 | copy.editWindow = this; |
---|
329 | 341 | |
---|
| 342 | + if (copy.versions == null) |
---|
| 343 | + { |
---|
| 344 | + copy.versions = new byte[100][]; |
---|
| 345 | + copy.versionindex = -1; |
---|
| 346 | + } |
---|
| 347 | + |
---|
330 | 348 | SetupMenu(); |
---|
331 | 349 | |
---|
332 | 350 | //SetupName(objEditor); // new |
---|
.. | .. |
---|
350 | 368 | frame.setMenuBar(menuBar = new MenuBar()); |
---|
351 | 369 | menuBar.add(fileMenu = new Menu("File")); |
---|
352 | 370 | fileMenu.add(newItem = new MenuItem("New")); |
---|
353 | | - fileMenu.add(loadItem = new MenuItem("Open...")); |
---|
| 371 | + fileMenu.add(openItem = new MenuItem("Open...")); |
---|
354 | 372 | |
---|
355 | 373 | //oe.menuBar.add(menu = new Menu("Include")); |
---|
356 | 374 | Menu menu = new Menu("Import"); |
---|
.. | .. |
---|
382 | 400 | } |
---|
383 | 401 | |
---|
384 | 402 | newItem.addActionListener(this); |
---|
385 | | - loadItem.addActionListener(this); |
---|
| 403 | + openItem.addActionListener(this); |
---|
386 | 404 | saveItem.addActionListener(this); |
---|
387 | 405 | saveAsItem.addActionListener(this); |
---|
388 | 406 | exportAsItem.addActionListener(this); |
---|
.. | .. |
---|
449 | 467 | // TEXTAREA infoarea.setLineWrap(true); |
---|
450 | 468 | // TEXTAREA infoarea.setWrapStyleWord(true); |
---|
451 | 469 | infoPanel = new JScrollPane(infoarea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); //AS_NEEDED); |
---|
452 | | - //infoPanel.setPreferredSize(new Dimension(50, 200)); |
---|
| 470 | + infoPanel.setPreferredSize(new Dimension(1, 1)); |
---|
453 | 471 | infoPanel.setName("Info"); |
---|
454 | 472 | //infoPanel.setLayout(new BorderLayout()); |
---|
455 | 473 | //infoPanel.add(createTextPane()); |
---|
.. | .. |
---|
699 | 717 | } |
---|
700 | 718 | } |
---|
701 | 719 | |
---|
702 | | -static GraphicsDevice device = GraphicsEnvironment |
---|
703 | | - .getLocalGraphicsEnvironment().getScreenDevices()[0]; |
---|
| 720 | +//static GraphicsDevice device = GraphicsEnvironment |
---|
| 721 | +// .getLocalGraphicsEnvironment().getScreenDevices()[0]; |
---|
704 | 722 | |
---|
705 | 723 | Rectangle keeprect; |
---|
706 | 724 | cRadio radio; |
---|
.. | .. |
---|
741 | 759 | else |
---|
742 | 760 | { |
---|
743 | 761 | keeprect = frame.getBounds(); |
---|
744 | | - Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); |
---|
745 | | - Dimension rect2 = frame.getToolkit().getScreenSize(); |
---|
746 | | - frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height); |
---|
| 762 | +// Rectangle rect = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds(); |
---|
| 763 | +// Dimension rect2 = frame.getToolkit().getScreenSize(); |
---|
| 764 | +// frame.setBounds(0, rect2.height - rect.height, rect.width, rect.height); |
---|
747 | 765 | // frame.setState(Frame.MAXIMIZED_BOTH); |
---|
| 766 | + frame.setBounds(frame.getGraphicsConfiguration().getBounds()); |
---|
748 | 767 | } |
---|
749 | 768 | |
---|
750 | 769 | maximized ^= true; |
---|
.. | .. |
---|
758 | 777 | |
---|
759 | 778 | void ToggleFullScreen() |
---|
760 | 779 | { |
---|
| 780 | +GraphicsDevice device = frame.getGraphicsConfiguration().getDevice(); |
---|
| 781 | + |
---|
761 | 782 | cameraView.ToggleFullScreen(); |
---|
762 | 783 | |
---|
763 | 784 | if (!CameraPane.FULLSCREEN) |
---|
764 | 785 | { |
---|
765 | 786 | device.setFullScreenWindow(null); |
---|
| 787 | + frame.dispose(); |
---|
| 788 | + frame.setUndecorated(false); |
---|
766 | 789 | frame.validate(); |
---|
| 790 | + frame.setVisible(true); |
---|
767 | 791 | |
---|
768 | 792 | //frame.setVisible(false); |
---|
769 | 793 | // frame.removeNotify(); |
---|
.. | .. |
---|
774 | 798 | // X frame.getContentPane().remove(/*"Center",*/bigThree); |
---|
775 | 799 | // X framePanel.add(bigThree); |
---|
776 | 800 | // X frame.getContentPane().add(/*"Center",*/framePanel); |
---|
777 | | - framePanel.setDividerLocation(1); |
---|
| 801 | + framePanel.setDividerLocation(46); |
---|
778 | 802 | |
---|
779 | 803 | //frame.setVisible(true); |
---|
780 | 804 | radio.layout = keepButton; |
---|
.. | .. |
---|
789 | 813 | // frame.setBounds(0, 0, frame.getToolkit().getScreenSize().width, |
---|
790 | 814 | // frame.getToolkit().getScreenSize().height); |
---|
791 | 815 | //frame.setVisible(false); |
---|
| 816 | + |
---|
| 817 | + frame.dispose(); |
---|
| 818 | + frame.setUndecorated(true); |
---|
792 | 819 | device.setFullScreenWindow(frame); |
---|
793 | 820 | frame.validate(); |
---|
| 821 | + frame.setVisible(true); |
---|
794 | 822 | // frame.removeNotify(); |
---|
795 | 823 | // frame.setUndecorated(true); |
---|
796 | 824 | // frame.addNotify(); |
---|
.. | .. |
---|
805 | 833 | } |
---|
806 | 834 | frame.validate(); |
---|
807 | 835 | } |
---|
| 836 | + |
---|
| 837 | + private byte[] CompressCopy() |
---|
| 838 | + { |
---|
| 839 | + boolean temp = CameraPane.SWITCH; |
---|
| 840 | + CameraPane.SWITCH = false; |
---|
| 841 | + |
---|
| 842 | + copy.ExtractBigData(versiontable); |
---|
| 843 | + // if (copy == client) |
---|
| 844 | + |
---|
| 845 | + byte[] versions[] = copy.versions; |
---|
| 846 | + copy.versions = null; |
---|
| 847 | + |
---|
| 848 | + byte[] compress = Compress(copy); |
---|
| 849 | + |
---|
| 850 | + copy.versions = versions; |
---|
| 851 | + |
---|
| 852 | + copy.RestoreBigData(versiontable); |
---|
| 853 | + |
---|
| 854 | + CameraPane.SWITCH = temp; |
---|
| 855 | + |
---|
| 856 | + return compress; |
---|
| 857 | + } |
---|
808 | 858 | |
---|
809 | 859 | private JTextPane createTextPane() |
---|
810 | 860 | { |
---|
.. | .. |
---|
1164 | 1214 | randomCB = AddCheckBox(setupPanel2, "Random", copy.random); |
---|
1165 | 1215 | randomCB.setToolTipText("Randomly Rewind (or Go back and forth)"); |
---|
1166 | 1216 | |
---|
| 1217 | + link2masterCB = AddCheckBox(setupPanel2, "Support", copy.link2master); |
---|
| 1218 | + link2masterCB.setToolTipText("Attach to support"); |
---|
| 1219 | + |
---|
1167 | 1220 | if (Globals.ADVANCED) |
---|
1168 | 1221 | { |
---|
1169 | | - link2masterCB = AddCheckBox(setupPanel2, "Supp", copy.link2master); |
---|
1170 | | - link2masterCB.setToolTipText("Attach to support"); |
---|
1171 | 1222 | speedupCB = AddCheckBox(setupPanel2, "Speed", copy.speedup); |
---|
1172 | 1223 | speedupCB.setToolTipText("Option motion capture"); |
---|
1173 | 1224 | } |
---|
.. | .. |
---|
1483 | 1534 | // north.add(ctrlPanel, BorderLayout.NORTH); |
---|
1484 | 1535 | // objectPanel.add(north); |
---|
1485 | 1536 | objectPanel.add(editPanel); |
---|
1486 | | - objectPanel.add(infoPanel); |
---|
| 1537 | + |
---|
| 1538 | + //if (Globals.ADVANCED) |
---|
| 1539 | + objectPanel.add(infoPanel); |
---|
| 1540 | + |
---|
1487 | 1541 | objectPanel.add(toolboxPanel); |
---|
1488 | 1542 | |
---|
1489 | 1543 | /* |
---|
.. | .. |
---|
1592 | 1646 | // aConstraints.gridheight = 1; |
---|
1593 | 1647 | |
---|
1594 | 1648 | framePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, toolbarPanel, bigThree); |
---|
1595 | | - framePanel.setContinuousLayout(true); |
---|
1596 | | - framePanel.setOneTouchExpandable(true); |
---|
1597 | | - framePanel.setDividerLocation(0.8); |
---|
| 1649 | + framePanel.setContinuousLayout(false); |
---|
| 1650 | + framePanel.setOneTouchExpandable(false); |
---|
| 1651 | + //.setDividerLocation(0.8); |
---|
1598 | 1652 | //framePanel.setDividerSize(15); |
---|
1599 | 1653 | //framePanel.setResizeWeight(0.15); |
---|
1600 | 1654 | framePanel.setName("Frame"); |
---|
.. | .. |
---|
1613 | 1667 | |
---|
1614 | 1668 | frame.setSize(1280, 860); |
---|
1615 | 1669 | |
---|
1616 | | - frame.validate(); |
---|
1617 | | - frame.setVisible(true); |
---|
1618 | | - |
---|
1619 | 1670 | cameraView.requestFocusInWindow(); |
---|
1620 | 1671 | |
---|
1621 | 1672 | gridPanel.setDividerLocation(1.0); |
---|
| 1673 | + |
---|
| 1674 | + frame.validate(); |
---|
| 1675 | + |
---|
| 1676 | + frame.setVisible(true); |
---|
1622 | 1677 | |
---|
1623 | 1678 | frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); |
---|
1624 | 1679 | frame.addWindowListener(new WindowAdapter() |
---|
.. | .. |
---|
1965 | 2020 | // 3D models |
---|
1966 | 2021 | if (filename.endsWith(".3ds") || filename.endsWith(".3DS")) |
---|
1967 | 2022 | { |
---|
1968 | | - lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
1969 | | - LoadFile(filename, lastConverter); |
---|
| 2023 | + //lastConverter = new com.jmex.model.converters.MaxToJme(); |
---|
| 2024 | + //LoadFile(filename, lastConverter); |
---|
| 2025 | + LoadObjFile(filename); // New 3ds loader |
---|
1970 | 2026 | continue; |
---|
1971 | 2027 | } |
---|
1972 | 2028 | if (filename.endsWith(".dae") || filename.endsWith(".DAE")) |
---|
.. | .. |
---|
2692 | 2748 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).toParent, -Math.PI / 2); |
---|
2693 | 2749 | LA.matXRotate(((Object3D) group.get(group.size() - 1)).fromParent, Math.PI / 2); |
---|
2694 | 2750 | } |
---|
| 2751 | + |
---|
2695 | 2752 | //cJME.count++; |
---|
2696 | 2753 | //cJME.count %= 12; |
---|
2697 | 2754 | if (gc) |
---|
.. | .. |
---|
2875 | 2932 | } |
---|
2876 | 2933 | } |
---|
2877 | 2934 | } |
---|
| 2935 | + |
---|
2878 | 2936 | cFileSystemPane FSPane; |
---|
2879 | 2937 | |
---|
2880 | 2938 | void SetMaterial(cMaterial mat, Object3D.cVector2[] others) |
---|
.. | .. |
---|
2928 | 2986 | } |
---|
2929 | 2987 | } |
---|
2930 | 2988 | } |
---|
| 2989 | + |
---|
2931 | 2990 | freezematerial = false; |
---|
2932 | 2991 | } |
---|
2933 | 2992 | |
---|
.. | .. |
---|
3380 | 3439 | { |
---|
3381 | 3440 | Close(); |
---|
3382 | 3441 | //return true; |
---|
3383 | | - } else if (source == loadItem) |
---|
| 3442 | + } else if (source == openItem) |
---|
3384 | 3443 | { |
---|
3385 | | - load(); |
---|
| 3444 | + Open(); |
---|
3386 | 3445 | //return true; |
---|
3387 | 3446 | } else if (source == newItem) |
---|
3388 | 3447 | { |
---|
.. | .. |
---|
3407 | 3466 | { |
---|
3408 | 3467 | generatePOV(); |
---|
3409 | 3468 | //return true; |
---|
| 3469 | + } else if (event.getSource() == archiveItem) |
---|
| 3470 | + { |
---|
| 3471 | + cTools.Archive(frame); |
---|
| 3472 | + return; |
---|
3410 | 3473 | } else if (source == zBufferItem) |
---|
3411 | 3474 | { |
---|
3412 | 3475 | try |
---|
.. | .. |
---|
3458 | 3521 | try |
---|
3459 | 3522 | { |
---|
3460 | 3523 | ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
3461 | | - java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
3462 | | - ObjectOutputStream out = new ObjectOutputStream(zstream); |
---|
| 3524 | +// java.util.zip.GZIPOutputStream zstream = new java.util.zip.GZIPOutputStream(baos); |
---|
| 3525 | + ObjectOutputStream out = new ObjectOutputStream(baos); //zstream); |
---|
3463 | 3526 | |
---|
3464 | 3527 | Object3D parent = o.parent; |
---|
3465 | 3528 | o.parent = null; |
---|
.. | .. |
---|
3470 | 3533 | |
---|
3471 | 3534 | out.flush(); |
---|
3472 | 3535 | |
---|
3473 | | - zstream.close(); |
---|
| 3536 | + baos //zstream |
---|
| 3537 | + .close(); |
---|
3474 | 3538 | out.close(); |
---|
3475 | 3539 | |
---|
3476 | | - return baos.toByteArray(); |
---|
| 3540 | + byte[] bytes = baos.toByteArray(); |
---|
| 3541 | + |
---|
| 3542 | + System.out.println("save #bytes = " + bytes.length); |
---|
| 3543 | + return bytes; |
---|
3477 | 3544 | } catch (Exception e) |
---|
3478 | 3545 | { |
---|
3479 | 3546 | System.err.println(e); |
---|
.. | .. |
---|
3483 | 3550 | |
---|
3484 | 3551 | static public Object Uncompress(byte[] bytes) |
---|
3485 | 3552 | { |
---|
3486 | | - System.out.println("#bytes = " + bytes.length); |
---|
| 3553 | + System.out.println("restore #bytes = " + bytes.length); |
---|
3487 | 3554 | try |
---|
3488 | 3555 | { |
---|
3489 | 3556 | ByteArrayInputStream bais = new ByteArrayInputStream(bytes); |
---|
3490 | | - java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
3491 | | - ObjectInputStream in = new ObjectInputStream(istream); |
---|
| 3557 | + //java.util.zip.GZIPInputStream istream = new java.util.zip.GZIPInputStream(bais); |
---|
| 3558 | + ObjectInputStream in = new ObjectInputStream(bais); // istream); |
---|
3492 | 3559 | Object obj = in.readObject(); |
---|
| 3560 | + |
---|
| 3561 | + bais //istream |
---|
| 3562 | + .close(); |
---|
3493 | 3563 | in.close(); |
---|
3494 | 3564 | |
---|
3495 | 3565 | return obj; |
---|
.. | .. |
---|
3544 | 3614 | return null; |
---|
3545 | 3615 | } |
---|
3546 | 3616 | |
---|
3547 | | - java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
3548 | 3617 | |
---|
3549 | 3618 | public void Save() |
---|
| 3619 | + { |
---|
| 3620 | + //Save(true); |
---|
| 3621 | + Replace(); |
---|
| 3622 | + } |
---|
| 3623 | + |
---|
| 3624 | + private boolean Equal(byte[] compress, byte[] name) |
---|
| 3625 | + { |
---|
| 3626 | + if (compress.length != name.length) |
---|
| 3627 | + { |
---|
| 3628 | + return false; |
---|
| 3629 | + } |
---|
| 3630 | + |
---|
| 3631 | + for (int i=compress.length; --i>=0;) |
---|
| 3632 | + { |
---|
| 3633 | + if (compress[i] != name[i]) |
---|
| 3634 | + return false; |
---|
| 3635 | + } |
---|
| 3636 | + |
---|
| 3637 | + return true; |
---|
| 3638 | + } |
---|
| 3639 | + |
---|
| 3640 | + java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
| 3641 | + |
---|
| 3642 | + public boolean Save(boolean user) |
---|
3550 | 3643 | { |
---|
3551 | 3644 | System.err.println("Save"); |
---|
3552 | 3645 | |
---|
3553 | 3646 | cRadio tab = GetCurrentTab(); |
---|
3554 | 3647 | |
---|
3555 | | - boolean temp = CameraPane.SWITCH; |
---|
3556 | | - CameraPane.SWITCH = false; |
---|
| 3648 | + byte[] compress = CompressCopy(); |
---|
3557 | 3649 | |
---|
3558 | | - copy.ExtractBigData(hashtable); |
---|
| 3650 | + boolean thesame = false; |
---|
3559 | 3651 | |
---|
3560 | | - byte[] compress = Compress(copy); |
---|
| 3652 | + // Quick heuristic using length. Works only when stream is compressed. |
---|
| 3653 | + if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1])) |
---|
| 3654 | + { |
---|
| 3655 | + thesame = true; |
---|
| 3656 | + } |
---|
3561 | 3657 | |
---|
3562 | 3658 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3563 | | - tab.graphs[tab.undoindex++] = compress; |
---|
| 3659 | + if (!thesame) |
---|
| 3660 | + { |
---|
| 3661 | + //tab.user[tab.versionindex] = user; |
---|
| 3662 | + //boolean increment = true; // tab.graphs[tab.versionindex] == null; |
---|
| 3663 | + |
---|
| 3664 | + copy.versions[++copy.versionindex] = compress; |
---|
| 3665 | + |
---|
| 3666 | + // if (increment) |
---|
| 3667 | + // tab.versionindex++; |
---|
| 3668 | + } |
---|
3564 | 3669 | |
---|
3565 | | - copy.RestoreBigData(hashtable); |
---|
| 3670 | + //copy.RestoreBigData(versiontable); |
---|
3566 | 3671 | |
---|
3567 | | - CameraPane.SWITCH = temp; |
---|
3568 | | - |
---|
3569 | 3672 | //assert(hashtable.isEmpty()); |
---|
3570 | 3673 | |
---|
3571 | | - for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
| 3674 | + for (int i = copy.versionindex+1; i < copy.versions.length; i++) |
---|
3572 | 3675 | { |
---|
3573 | | - tab.graphs[i] = null; |
---|
| 3676 | + //tab.user[i] = false; |
---|
| 3677 | + copy.versions[i] = null; |
---|
3574 | 3678 | } |
---|
3575 | 3679 | |
---|
3576 | 3680 | SetUndoStates(); |
---|
.. | .. |
---|
3580 | 3684 | { |
---|
3581 | 3685 | try |
---|
3582 | 3686 | { |
---|
3583 | | - FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); |
---|
| 3687 | + FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex); |
---|
3584 | 3688 | ObjectOutputStream p = new ObjectOutputStream(ostream); |
---|
3585 | 3689 | |
---|
3586 | 3690 | p.writeObject(copy); |
---|
.. | .. |
---|
3593 | 3697 | e.printStackTrace(); |
---|
3594 | 3698 | } |
---|
3595 | 3699 | } |
---|
| 3700 | + |
---|
| 3701 | + return !thesame; |
---|
3596 | 3702 | } |
---|
3597 | 3703 | |
---|
3598 | 3704 | void CopyChanged(Object3D obj) |
---|
.. | .. |
---|
3602 | 3708 | boolean temp = CameraPane.SWITCH; |
---|
3603 | 3709 | CameraPane.SWITCH = false; |
---|
3604 | 3710 | |
---|
3605 | | - copy.ExtractBigData(hashtable); |
---|
| 3711 | + copy.ExtractBigData(versiontable); |
---|
3606 | 3712 | |
---|
3607 | 3713 | copy.clear(); |
---|
3608 | 3714 | |
---|
.. | .. |
---|
3611 | 3717 | copy.add(obj.get(i)); |
---|
3612 | 3718 | } |
---|
3613 | 3719 | |
---|
3614 | | - copy.RestoreBigData(hashtable); |
---|
| 3720 | + copy.RestoreBigData(versiontable); |
---|
3615 | 3721 | |
---|
3616 | 3722 | CameraPane.SWITCH = temp; |
---|
3617 | 3723 | |
---|
.. | .. |
---|
3639 | 3745 | } |
---|
3640 | 3746 | |
---|
3641 | 3747 | cButton undoButton; |
---|
| 3748 | + cButton restoreButton; |
---|
| 3749 | + cButton replaceButton; |
---|
3642 | 3750 | cButton redoButton; |
---|
3643 | 3751 | |
---|
| 3752 | + boolean muteSlider; |
---|
| 3753 | + |
---|
| 3754 | + int VersionCount() |
---|
| 3755 | + { |
---|
| 3756 | + int count = 0; |
---|
| 3757 | + |
---|
| 3758 | + for (int i = copy.versions.length; --i >= 0;) |
---|
| 3759 | + { |
---|
| 3760 | + if (copy.versions[i] != null) |
---|
| 3761 | + count++; |
---|
| 3762 | + } |
---|
| 3763 | + |
---|
| 3764 | + return count; |
---|
| 3765 | + } |
---|
| 3766 | + |
---|
3644 | 3767 | void SetUndoStates() |
---|
3645 | 3768 | { |
---|
3646 | 3769 | cRadio tab = GetCurrentTab(); |
---|
3647 | 3770 | |
---|
3648 | | - undoButton.setEnabled(tab.undoindex > 0); |
---|
3649 | | - redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null); |
---|
| 3771 | + restoreButton.setEnabled(copy.versionindex != -1); |
---|
| 3772 | + replaceButton.setEnabled(copy.versionindex != -1); |
---|
| 3773 | + |
---|
| 3774 | + undoButton.setEnabled(copy.versionindex > 0); |
---|
| 3775 | + redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null); |
---|
| 3776 | + |
---|
| 3777 | + muteSlider = true; |
---|
| 3778 | + versionSlider.setMaximum(VersionCount() - 1); |
---|
| 3779 | + versionSlider.setInteger(copy.versionindex); |
---|
| 3780 | + muteSlider = false; |
---|
3650 | 3781 | } |
---|
3651 | 3782 | |
---|
3652 | | - public void Undo() |
---|
| 3783 | + public boolean Undo() |
---|
3653 | 3784 | { |
---|
| 3785 | + // Option? |
---|
| 3786 | + Replace(); |
---|
| 3787 | + |
---|
3654 | 3788 | System.err.println("Undo"); |
---|
3655 | 3789 | |
---|
3656 | 3790 | cRadio tab = GetCurrentTab(); |
---|
3657 | 3791 | |
---|
3658 | | - if (tab.undoindex == 0) |
---|
| 3792 | + if (copy.versionindex == 0) |
---|
3659 | 3793 | { |
---|
3660 | 3794 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3661 | | - return; |
---|
| 3795 | + return false; |
---|
3662 | 3796 | } |
---|
3663 | 3797 | |
---|
3664 | | - if (tab.graphs[tab.undoindex] == null) |
---|
| 3798 | +// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex]) |
---|
| 3799 | +// { |
---|
| 3800 | +// if (Save(false)) |
---|
| 3801 | +// tab.versionindex -= 1; |
---|
| 3802 | +// else |
---|
| 3803 | +// { |
---|
| 3804 | +// if (tab.versionindex <= 0) |
---|
| 3805 | +// return false; |
---|
| 3806 | +// else |
---|
| 3807 | +// tab.versionindex -= 1; |
---|
| 3808 | +// } |
---|
| 3809 | +// } |
---|
| 3810 | + |
---|
| 3811 | + copy.versionindex -= 1; |
---|
| 3812 | + |
---|
| 3813 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3814 | + |
---|
| 3815 | + return true; |
---|
| 3816 | + } |
---|
| 3817 | + |
---|
| 3818 | + public boolean Restore() |
---|
| 3819 | + { |
---|
| 3820 | + System.err.println("Restore"); |
---|
| 3821 | + |
---|
| 3822 | + cRadio tab = GetCurrentTab(); |
---|
| 3823 | + |
---|
| 3824 | + if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null) |
---|
3665 | 3825 | { |
---|
3666 | | - Save(); |
---|
3667 | | - tab.undoindex -= 1; |
---|
| 3826 | + java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3827 | + return false; |
---|
3668 | 3828 | } |
---|
3669 | 3829 | |
---|
3670 | | - tab.undoindex -= 1; |
---|
| 3830 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3831 | + |
---|
| 3832 | + return true; |
---|
| 3833 | + } |
---|
3671 | 3834 | |
---|
3672 | | - CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3835 | + public boolean Replace() |
---|
| 3836 | + { |
---|
| 3837 | + System.err.println("Replace"); |
---|
| 3838 | + |
---|
| 3839 | + cRadio tab = GetCurrentTab(); |
---|
| 3840 | + |
---|
| 3841 | + if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null) |
---|
| 3842 | + { |
---|
| 3843 | + // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3844 | + return false; |
---|
| 3845 | + } |
---|
| 3846 | + |
---|
| 3847 | + copy.versions[copy.versionindex] = CompressCopy(); |
---|
| 3848 | + |
---|
| 3849 | + return true; |
---|
3673 | 3850 | } |
---|
3674 | 3851 | |
---|
3675 | 3852 | public void Redo() |
---|
3676 | 3853 | { |
---|
| 3854 | + // Option? |
---|
| 3855 | + Replace(); |
---|
| 3856 | + |
---|
3677 | 3857 | cRadio tab = GetCurrentTab(); |
---|
3678 | 3858 | |
---|
3679 | | - if (tab.graphs[tab.undoindex + 1] == null) |
---|
| 3859 | + if (copy.versions[copy.versionindex + 1] == null) |
---|
3680 | 3860 | { |
---|
3681 | 3861 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3682 | 3862 | return; |
---|
3683 | 3863 | } |
---|
3684 | 3864 | |
---|
3685 | | - tab.undoindex += 1; |
---|
| 3865 | + copy.versionindex += 1; |
---|
3686 | 3866 | |
---|
3687 | | - CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3867 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3868 | + |
---|
| 3869 | + //if (!tab.user[tab.versionindex]) |
---|
| 3870 | + // tab.graphs[tab.versionindex] = null; |
---|
3688 | 3871 | } |
---|
3689 | 3872 | |
---|
3690 | 3873 | void ImportGFD() |
---|
.. | .. |
---|
3980 | 4163 | //copy.Touch(); |
---|
3981 | 4164 | } |
---|
3982 | 4165 | |
---|
| 4166 | + cNumberSlider versionSlider; |
---|
| 4167 | + |
---|
3983 | 4168 | public void stateChanged(ChangeEvent e) |
---|
3984 | 4169 | { |
---|
3985 | 4170 | // assert(false); |
---|
| 4171 | + if (e.getSource() == versionSlider) |
---|
| 4172 | + { |
---|
| 4173 | + if (muteSlider) |
---|
| 4174 | + return; |
---|
| 4175 | + |
---|
| 4176 | + int version = versionSlider.getInteger(); |
---|
| 4177 | + |
---|
| 4178 | + if (copy.versions[version] != null) |
---|
| 4179 | + { |
---|
| 4180 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version])); |
---|
| 4181 | + } |
---|
| 4182 | + |
---|
| 4183 | + return; |
---|
| 4184 | + } |
---|
3986 | 4185 | |
---|
3987 | 4186 | if (freezematerial) |
---|
3988 | 4187 | { |
---|
.. | .. |
---|
4331 | 4530 | |
---|
4332 | 4531 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
4333 | 4532 | { |
---|
4334 | | - if (Globals.SAVEONMAKE) // && resetmodel) |
---|
| 4533 | + if (Globals.REPLACEONMAKE) // && resetmodel) |
---|
4335 | 4534 | Save(); |
---|
4336 | 4535 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
4337 | 4536 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
.. | .. |
---|
4647 | 4846 | |
---|
4648 | 4847 | if (readobj != null) |
---|
4649 | 4848 | { |
---|
4650 | | - if (Globals.SAVEONMAKE) |
---|
4651 | | - Save(); |
---|
| 4849 | + //if (Globals.SAVEONMAKE) // A new object cannot share meshes |
---|
| 4850 | + // Save(); |
---|
4652 | 4851 | try |
---|
4653 | 4852 | { |
---|
4654 | 4853 | //readobj.deepCopySelf(copy); |
---|
.. | .. |
---|
4703 | 4902 | c.addChild(csg); |
---|
4704 | 4903 | } |
---|
4705 | 4904 | |
---|
| 4905 | + copy.versions = readobj.versions; |
---|
| 4906 | + copy.versionindex = readobj.versionindex; |
---|
| 4907 | + |
---|
| 4908 | + if (copy.versions == null) |
---|
| 4909 | + { |
---|
| 4910 | + copy.versions = new byte[100][]; |
---|
| 4911 | + copy.versionindex = -1; |
---|
| 4912 | + } |
---|
| 4913 | + |
---|
| 4914 | + //? SetUndoStates(); |
---|
| 4915 | + |
---|
4706 | 4916 | ResetModel(); |
---|
4707 | 4917 | copy.HardTouch(); // recompile? |
---|
4708 | 4918 | refreshContents(); |
---|
4709 | 4919 | } |
---|
4710 | 4920 | } |
---|
4711 | 4921 | |
---|
4712 | | - void load() // throws ClassNotFoundException |
---|
| 4922 | + void Open() // throws ClassNotFoundException |
---|
4713 | 4923 | { |
---|
4714 | 4924 | if (Grafreed.standAlone) |
---|
4715 | 4925 | { |
---|
.. | .. |
---|
4994 | 5204 | MenuBar menuBar; |
---|
4995 | 5205 | Menu fileMenu; |
---|
4996 | 5206 | MenuItem newItem; |
---|
4997 | | - MenuItem loadItem; |
---|
| 5207 | + MenuItem openItem; |
---|
4998 | 5208 | MenuItem saveItem; |
---|
4999 | 5209 | MenuItem saveAsItem; |
---|
5000 | 5210 | MenuItem exportAsItem; |
---|
.. | .. |
---|
5017 | 5227 | CheckboxMenuItem toggleSwitchItem; |
---|
5018 | 5228 | CheckboxMenuItem toggleRootItem; |
---|
5019 | 5229 | CheckboxMenuItem animationItem; |
---|
| 5230 | + MenuItem archiveItem; |
---|
5020 | 5231 | CheckboxMenuItem toggleHandleItem; |
---|
5021 | 5232 | CheckboxMenuItem togglePaintItem; |
---|
5022 | 5233 | JSplitPane mainPanel; |
---|