.. | .. |
---|
816 | 816 | frame.validate(); |
---|
817 | 817 | } |
---|
818 | 818 | |
---|
| 819 | + private byte[] CompressCopy() |
---|
| 820 | + { |
---|
| 821 | + boolean temp = CameraPane.SWITCH; |
---|
| 822 | + CameraPane.SWITCH = false; |
---|
| 823 | + |
---|
| 824 | + copy.ExtractBigData(versiontable); |
---|
| 825 | + // if (copy == client) |
---|
| 826 | + |
---|
| 827 | + byte[] versions[] = copy.versions; |
---|
| 828 | + copy.versions = null; |
---|
| 829 | + |
---|
| 830 | + byte[] compress = Compress(copy); |
---|
| 831 | + |
---|
| 832 | + copy.versions = versions; |
---|
| 833 | + |
---|
| 834 | + copy.RestoreBigData(versiontable); |
---|
| 835 | + |
---|
| 836 | + CameraPane.SWITCH = temp; |
---|
| 837 | + |
---|
| 838 | + return compress; |
---|
| 839 | + } |
---|
| 840 | + |
---|
819 | 841 | private JTextPane createTextPane() |
---|
820 | 842 | { |
---|
821 | 843 | // TEXTAREA String[] initString = |
---|
.. | .. |
---|
3574 | 3596 | return null; |
---|
3575 | 3597 | } |
---|
3576 | 3598 | |
---|
3577 | | - java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
3578 | 3599 | |
---|
3579 | 3600 | public void Save() |
---|
3580 | 3601 | { |
---|
3581 | | - Save(true); |
---|
| 3602 | + //Save(true); |
---|
| 3603 | + Replace(); |
---|
3582 | 3604 | } |
---|
3583 | 3605 | |
---|
3584 | 3606 | private boolean Equal(byte[] compress, byte[] name) |
---|
.. | .. |
---|
3597 | 3619 | return true; |
---|
3598 | 3620 | } |
---|
3599 | 3621 | |
---|
| 3622 | + java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
| 3623 | + |
---|
3600 | 3624 | public boolean Save(boolean user) |
---|
3601 | 3625 | { |
---|
3602 | 3626 | System.err.println("Save"); |
---|
3603 | 3627 | |
---|
3604 | 3628 | cRadio tab = GetCurrentTab(); |
---|
3605 | 3629 | |
---|
3606 | | - boolean temp = CameraPane.SWITCH; |
---|
3607 | | - CameraPane.SWITCH = false; |
---|
3608 | | - |
---|
3609 | | - copy.ExtractBigData(hashtable); |
---|
3610 | | - |
---|
3611 | | - byte[] compress = Compress(copy); |
---|
3612 | | - |
---|
3613 | | - CameraPane.SWITCH = temp; |
---|
| 3630 | + byte[] compress = CompressCopy(); |
---|
3614 | 3631 | |
---|
3615 | 3632 | boolean thesame = false; |
---|
3616 | 3633 | |
---|
3617 | 3634 | // Quick heuristic using length. Works only when stream is compressed. |
---|
3618 | | - if (tab.undoindex > 0 && tab.graphs[tab.undoindex-1] != null && Equal(compress, tab.graphs[tab.undoindex-1])) |
---|
| 3635 | + if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1])) |
---|
3619 | 3636 | { |
---|
3620 | 3637 | thesame = true; |
---|
3621 | 3638 | } |
---|
.. | .. |
---|
3623 | 3640 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3624 | 3641 | if (!thesame) |
---|
3625 | 3642 | { |
---|
3626 | | - //tab.user[tab.undoindex] = user; |
---|
3627 | | - boolean increment = tab.graphs[tab.undoindex] == null; |
---|
| 3643 | + //tab.user[tab.versionindex] = user; |
---|
| 3644 | + //boolean increment = true; // tab.graphs[tab.versionindex] == null; |
---|
3628 | 3645 | |
---|
3629 | | - tab.graphs[tab.undoindex] = compress; |
---|
| 3646 | + copy.versions[++copy.versionindex] = compress; |
---|
3630 | 3647 | |
---|
3631 | | - if (increment) |
---|
3632 | | - tab.undoindex++; |
---|
| 3648 | + // if (increment) |
---|
| 3649 | + // tab.versionindex++; |
---|
3633 | 3650 | } |
---|
3634 | 3651 | |
---|
3635 | | - copy.RestoreBigData(hashtable); |
---|
| 3652 | + //copy.RestoreBigData(versiontable); |
---|
3636 | 3653 | |
---|
3637 | 3654 | //assert(hashtable.isEmpty()); |
---|
3638 | 3655 | |
---|
3639 | | - for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
| 3656 | + for (int i = copy.versionindex+1; i < copy.versions.length; i++) |
---|
3640 | 3657 | { |
---|
3641 | 3658 | //tab.user[i] = false; |
---|
3642 | | - // tab.graphs[i] = null; |
---|
| 3659 | + copy.versions[i] = null; |
---|
3643 | 3660 | } |
---|
3644 | 3661 | |
---|
3645 | 3662 | SetUndoStates(); |
---|
.. | .. |
---|
3649 | 3666 | { |
---|
3650 | 3667 | try |
---|
3651 | 3668 | { |
---|
3652 | | - FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); |
---|
| 3669 | + FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex); |
---|
3653 | 3670 | ObjectOutputStream p = new ObjectOutputStream(ostream); |
---|
3654 | 3671 | |
---|
3655 | 3672 | p.writeObject(copy); |
---|
.. | .. |
---|
3673 | 3690 | boolean temp = CameraPane.SWITCH; |
---|
3674 | 3691 | CameraPane.SWITCH = false; |
---|
3675 | 3692 | |
---|
3676 | | - copy.ExtractBigData(hashtable); |
---|
| 3693 | + copy.ExtractBigData(versiontable); |
---|
3677 | 3694 | |
---|
3678 | 3695 | copy.clear(); |
---|
3679 | 3696 | |
---|
.. | .. |
---|
3682 | 3699 | copy.add(obj.get(i)); |
---|
3683 | 3700 | } |
---|
3684 | 3701 | |
---|
3685 | | - copy.RestoreBigData(hashtable); |
---|
| 3702 | + copy.RestoreBigData(versiontable); |
---|
3686 | 3703 | |
---|
3687 | 3704 | CameraPane.SWITCH = temp; |
---|
3688 | 3705 | |
---|
.. | .. |
---|
3710 | 3727 | } |
---|
3711 | 3728 | |
---|
3712 | 3729 | cButton undoButton; |
---|
| 3730 | + cButton restoreButton; |
---|
| 3731 | + cButton replaceButton; |
---|
3713 | 3732 | cButton redoButton; |
---|
3714 | 3733 | |
---|
3715 | 3734 | void SetUndoStates() |
---|
3716 | 3735 | { |
---|
3717 | 3736 | cRadio tab = GetCurrentTab(); |
---|
3718 | 3737 | |
---|
3719 | | - undoButton.setEnabled(tab.undoindex > 0); |
---|
3720 | | - redoButton.setEnabled(tab.graphs[tab.undoindex + 1] != null); |
---|
| 3738 | + restoreButton.setEnabled(copy.versionindex != -1); |
---|
| 3739 | + replaceButton.setEnabled(copy.versionindex != -1); |
---|
| 3740 | + undoButton.setEnabled(copy.versionindex > 0); |
---|
| 3741 | + redoButton.setEnabled(copy.versions[copy.versionindex + 1] != null); |
---|
3721 | 3742 | } |
---|
3722 | 3743 | |
---|
3723 | 3744 | public boolean Undo() |
---|
.. | .. |
---|
3726 | 3747 | |
---|
3727 | 3748 | cRadio tab = GetCurrentTab(); |
---|
3728 | 3749 | |
---|
3729 | | - if (tab.undoindex == 0) |
---|
| 3750 | + if (copy.versionindex == 0) |
---|
3730 | 3751 | { |
---|
3731 | 3752 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3732 | 3753 | return false; |
---|
3733 | 3754 | } |
---|
3734 | 3755 | |
---|
3735 | | - if (tab.graphs[tab.undoindex] == null) // || !tab.user[tab.undoindex]) |
---|
| 3756 | +// if (tab.graphs[tab.versionindex] == null) // || !tab.user[tab.versionindex]) |
---|
| 3757 | +// { |
---|
| 3758 | +// if (Save(false)) |
---|
| 3759 | +// tab.versionindex -= 1; |
---|
| 3760 | +// else |
---|
| 3761 | +// { |
---|
| 3762 | +// if (tab.versionindex <= 0) |
---|
| 3763 | +// return false; |
---|
| 3764 | +// else |
---|
| 3765 | +// tab.versionindex -= 1; |
---|
| 3766 | +// } |
---|
| 3767 | +// } |
---|
| 3768 | + |
---|
| 3769 | + copy.versionindex -= 1; |
---|
| 3770 | + |
---|
| 3771 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3772 | + |
---|
| 3773 | + return true; |
---|
| 3774 | + } |
---|
| 3775 | + |
---|
| 3776 | + public boolean Restore() |
---|
| 3777 | + { |
---|
| 3778 | + System.err.println("Restore"); |
---|
| 3779 | + |
---|
| 3780 | + cRadio tab = GetCurrentTab(); |
---|
| 3781 | + |
---|
| 3782 | + if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null) |
---|
3736 | 3783 | { |
---|
3737 | | - if (Save(false)) |
---|
3738 | | - tab.undoindex -= 1; |
---|
3739 | | - else |
---|
3740 | | - { |
---|
3741 | | - if (tab.undoindex <= 0) |
---|
3742 | | - return false; |
---|
3743 | | - else |
---|
3744 | | - tab.undoindex -= 1; |
---|
3745 | | - } |
---|
| 3784 | + java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3785 | + return false; |
---|
3746 | 3786 | } |
---|
3747 | 3787 | |
---|
3748 | | - tab.undoindex -= 1; |
---|
| 3788 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3789 | + |
---|
| 3790 | + return true; |
---|
| 3791 | + } |
---|
3749 | 3792 | |
---|
3750 | | - CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3793 | + public boolean Replace() |
---|
| 3794 | + { |
---|
| 3795 | + System.err.println("Replace"); |
---|
| 3796 | + |
---|
| 3797 | + cRadio tab = GetCurrentTab(); |
---|
| 3798 | + |
---|
| 3799 | + if (copy.versionindex == -1 || copy.versions[copy.versionindex] == null) |
---|
| 3800 | + { |
---|
| 3801 | + // No version yet. OK. java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3802 | + return false; |
---|
| 3803 | + } |
---|
| 3804 | + |
---|
| 3805 | + copy.versions[copy.versionindex] = CompressCopy(); |
---|
3751 | 3806 | |
---|
3752 | 3807 | return true; |
---|
3753 | 3808 | } |
---|
.. | .. |
---|
3756 | 3811 | { |
---|
3757 | 3812 | cRadio tab = GetCurrentTab(); |
---|
3758 | 3813 | |
---|
3759 | | - if (tab.graphs[tab.undoindex + 1] == null) |
---|
| 3814 | + if (copy.versions[copy.versionindex + 1] == null) |
---|
3760 | 3815 | { |
---|
3761 | 3816 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3762 | 3817 | return; |
---|
3763 | 3818 | } |
---|
3764 | 3819 | |
---|
3765 | | - tab.undoindex += 1; |
---|
| 3820 | + copy.versionindex += 1; |
---|
3766 | 3821 | |
---|
3767 | | - CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3822 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
3768 | 3823 | |
---|
3769 | | - //if (!tab.user[tab.undoindex]) |
---|
3770 | | - // tab.graphs[tab.undoindex] = null; |
---|
| 3824 | + //if (!tab.user[tab.versionindex]) |
---|
| 3825 | + // tab.graphs[tab.versionindex] = null; |
---|
3771 | 3826 | } |
---|
3772 | 3827 | |
---|
3773 | 3828 | void ImportGFD() |
---|
.. | .. |
---|
4063 | 4118 | //copy.Touch(); |
---|
4064 | 4119 | } |
---|
4065 | 4120 | |
---|
| 4121 | + cNumberSlider versionField; |
---|
| 4122 | + |
---|
4066 | 4123 | public void stateChanged(ChangeEvent e) |
---|
4067 | 4124 | { |
---|
4068 | 4125 | // assert(false); |
---|
| 4126 | + if (e.getSource() == versionField) |
---|
| 4127 | + { |
---|
| 4128 | + int version = versionField.getInteger(); |
---|
| 4129 | + |
---|
| 4130 | + if (copy.versions[version] != null) |
---|
| 4131 | + { |
---|
| 4132 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex = version])); |
---|
| 4133 | + } |
---|
| 4134 | + |
---|
| 4135 | + return; |
---|
| 4136 | + } |
---|
4069 | 4137 | |
---|
4070 | 4138 | if (freezematerial) |
---|
4071 | 4139 | { |
---|
.. | .. |
---|
4414 | 4482 | |
---|
4415 | 4483 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
4416 | 4484 | { |
---|
4417 | | - if (Globals.SAVEONMAKE) // && resetmodel) |
---|
| 4485 | + if (Globals.REPLACEONMAKE) // && resetmodel) |
---|
4418 | 4486 | Save(); |
---|
4419 | 4487 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
4420 | 4488 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
.. | .. |
---|
4786 | 4854 | c.addChild(csg); |
---|
4787 | 4855 | } |
---|
4788 | 4856 | |
---|
| 4857 | + copy.versions = readobj.versions; |
---|
| 4858 | + copy.versionindex = readobj.versionindex; |
---|
| 4859 | + |
---|
| 4860 | + SetUndoStates(); |
---|
| 4861 | + |
---|
4789 | 4862 | ResetModel(); |
---|
4790 | 4863 | copy.HardTouch(); // recompile? |
---|
4791 | 4864 | refreshContents(); |
---|