.. | .. |
---|
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 | |
---|
.. | .. |
---|
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 |
---|
.. | .. |
---|
815 | 833 | } |
---|
816 | 834 | frame.validate(); |
---|
817 | 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 | + } |
---|
818 | 858 | |
---|
819 | 859 | private JTextPane createTextPane() |
---|
820 | 860 | { |
---|
.. | .. |
---|
3574 | 3614 | return null; |
---|
3575 | 3615 | } |
---|
3576 | 3616 | |
---|
3577 | | - java.util.Hashtable<java.util.UUID, Object3D> hashtable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
3578 | 3617 | |
---|
3579 | 3618 | public void Save() |
---|
3580 | 3619 | { |
---|
3581 | | - Save(true); |
---|
| 3620 | + //Save(true); |
---|
| 3621 | + Replace(); |
---|
3582 | 3622 | } |
---|
3583 | 3623 | |
---|
3584 | 3624 | private boolean Equal(byte[] compress, byte[] name) |
---|
.. | .. |
---|
3597 | 3637 | return true; |
---|
3598 | 3638 | } |
---|
3599 | 3639 | |
---|
| 3640 | + java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>(); |
---|
| 3641 | + |
---|
3600 | 3642 | public boolean Save(boolean user) |
---|
3601 | 3643 | { |
---|
3602 | 3644 | System.err.println("Save"); |
---|
3603 | 3645 | |
---|
3604 | 3646 | cRadio tab = GetCurrentTab(); |
---|
3605 | 3647 | |
---|
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; |
---|
| 3648 | + byte[] compress = CompressCopy(); |
---|
3614 | 3649 | |
---|
3615 | 3650 | boolean thesame = false; |
---|
3616 | 3651 | |
---|
3617 | 3652 | // 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])) |
---|
| 3653 | + if (copy.versionindex > 0 && copy.versions[copy.versionindex-1] != null && Equal(compress, copy.versions[copy.versionindex-1])) |
---|
3619 | 3654 | { |
---|
3620 | 3655 | thesame = true; |
---|
3621 | 3656 | } |
---|
.. | .. |
---|
3623 | 3658 | //EditorFrame.m_MainFrame.requestFocusInWindow(); |
---|
3624 | 3659 | if (!thesame) |
---|
3625 | 3660 | { |
---|
3626 | | - //tab.user[tab.undoindex] = user; |
---|
3627 | | - boolean increment = tab.graphs[tab.undoindex] == null; |
---|
| 3661 | + //tab.user[tab.versionindex] = user; |
---|
| 3662 | + //boolean increment = true; // tab.graphs[tab.versionindex] == null; |
---|
3628 | 3663 | |
---|
3629 | | - tab.graphs[tab.undoindex] = compress; |
---|
| 3664 | + copy.versions[++copy.versionindex] = compress; |
---|
3630 | 3665 | |
---|
3631 | | - if (increment) |
---|
3632 | | - tab.undoindex++; |
---|
| 3666 | + // if (increment) |
---|
| 3667 | + // tab.versionindex++; |
---|
3633 | 3668 | } |
---|
3634 | 3669 | |
---|
3635 | | - copy.RestoreBigData(hashtable); |
---|
| 3670 | + //copy.RestoreBigData(versiontable); |
---|
3636 | 3671 | |
---|
3637 | 3672 | //assert(hashtable.isEmpty()); |
---|
3638 | 3673 | |
---|
3639 | | - for (int i = tab.undoindex; i < tab.graphs.length; i++) |
---|
| 3674 | + for (int i = copy.versionindex+1; i < copy.versions.length; i++) |
---|
3640 | 3675 | { |
---|
3641 | 3676 | //tab.user[i] = false; |
---|
3642 | | - // tab.graphs[i] = null; |
---|
| 3677 | + copy.versions[i] = null; |
---|
3643 | 3678 | } |
---|
3644 | 3679 | |
---|
3645 | 3680 | SetUndoStates(); |
---|
.. | .. |
---|
3649 | 3684 | { |
---|
3650 | 3685 | try |
---|
3651 | 3686 | { |
---|
3652 | | - FileOutputStream ostream = new FileOutputStream("save" + tab.undoindex); |
---|
| 3687 | + FileOutputStream ostream = new FileOutputStream("save" + copy.versionindex); |
---|
3653 | 3688 | ObjectOutputStream p = new ObjectOutputStream(ostream); |
---|
3654 | 3689 | |
---|
3655 | 3690 | p.writeObject(copy); |
---|
.. | .. |
---|
3673 | 3708 | boolean temp = CameraPane.SWITCH; |
---|
3674 | 3709 | CameraPane.SWITCH = false; |
---|
3675 | 3710 | |
---|
3676 | | - copy.ExtractBigData(hashtable); |
---|
| 3711 | + copy.ExtractBigData(versiontable); |
---|
3677 | 3712 | |
---|
3678 | 3713 | copy.clear(); |
---|
3679 | 3714 | |
---|
.. | .. |
---|
3682 | 3717 | copy.add(obj.get(i)); |
---|
3683 | 3718 | } |
---|
3684 | 3719 | |
---|
3685 | | - copy.RestoreBigData(hashtable); |
---|
| 3720 | + copy.RestoreBigData(versiontable); |
---|
3686 | 3721 | |
---|
3687 | 3722 | CameraPane.SWITCH = temp; |
---|
3688 | 3723 | |
---|
.. | .. |
---|
3710 | 3745 | } |
---|
3711 | 3746 | |
---|
3712 | 3747 | cButton undoButton; |
---|
| 3748 | + cButton restoreButton; |
---|
| 3749 | + cButton replaceButton; |
---|
3713 | 3750 | cButton redoButton; |
---|
3714 | 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 | + |
---|
3715 | 3767 | void SetUndoStates() |
---|
3716 | 3768 | { |
---|
3717 | 3769 | cRadio tab = GetCurrentTab(); |
---|
3718 | 3770 | |
---|
3719 | | - undoButton.setEnabled(tab.undoindex > 0); |
---|
3720 | | - 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; |
---|
3721 | 3781 | } |
---|
3722 | 3782 | |
---|
3723 | 3783 | public boolean Undo() |
---|
3724 | 3784 | { |
---|
| 3785 | + // Option? |
---|
| 3786 | + Replace(); |
---|
| 3787 | + |
---|
3725 | 3788 | System.err.println("Undo"); |
---|
3726 | 3789 | |
---|
3727 | 3790 | cRadio tab = GetCurrentTab(); |
---|
3728 | 3791 | |
---|
3729 | | - if (tab.undoindex == 0) |
---|
| 3792 | + if (copy.versionindex == 0) |
---|
3730 | 3793 | { |
---|
3731 | 3794 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3732 | 3795 | return false; |
---|
3733 | 3796 | } |
---|
3734 | 3797 | |
---|
3735 | | - if (tab.graphs[tab.undoindex] == null) // || !tab.user[tab.undoindex]) |
---|
| 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) |
---|
3736 | 3825 | { |
---|
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 | | - } |
---|
| 3826 | + java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
| 3827 | + return false; |
---|
3746 | 3828 | } |
---|
3747 | 3829 | |
---|
3748 | | - tab.undoindex -= 1; |
---|
| 3830 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
| 3831 | + |
---|
| 3832 | + return true; |
---|
| 3833 | + } |
---|
3749 | 3834 | |
---|
3750 | | - 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(); |
---|
3751 | 3848 | |
---|
3752 | 3849 | return true; |
---|
3753 | 3850 | } |
---|
3754 | 3851 | |
---|
3755 | 3852 | public void Redo() |
---|
3756 | 3853 | { |
---|
| 3854 | + // Option? |
---|
| 3855 | + Replace(); |
---|
| 3856 | + |
---|
3757 | 3857 | cRadio tab = GetCurrentTab(); |
---|
3758 | 3858 | |
---|
3759 | | - if (tab.graphs[tab.undoindex + 1] == null) |
---|
| 3859 | + if (copy.versions[copy.versionindex + 1] == null) |
---|
3760 | 3860 | { |
---|
3761 | 3861 | java.awt.Toolkit.getDefaultToolkit().beep(); |
---|
3762 | 3862 | return; |
---|
3763 | 3863 | } |
---|
3764 | 3864 | |
---|
3765 | | - tab.undoindex += 1; |
---|
| 3865 | + copy.versionindex += 1; |
---|
3766 | 3866 | |
---|
3767 | | - CopyChanged((Object3D)Uncompress(tab.graphs[tab.undoindex])); |
---|
| 3867 | + CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); |
---|
3768 | 3868 | |
---|
3769 | | - //if (!tab.user[tab.undoindex]) |
---|
3770 | | - // tab.graphs[tab.undoindex] = null; |
---|
| 3869 | + //if (!tab.user[tab.versionindex]) |
---|
| 3870 | + // tab.graphs[tab.versionindex] = null; |
---|
3771 | 3871 | } |
---|
3772 | 3872 | |
---|
3773 | 3873 | void ImportGFD() |
---|
.. | .. |
---|
4063 | 4163 | //copy.Touch(); |
---|
4064 | 4164 | } |
---|
4065 | 4165 | |
---|
| 4166 | + cNumberSlider versionSlider; |
---|
| 4167 | + |
---|
4066 | 4168 | public void stateChanged(ChangeEvent e) |
---|
4067 | 4169 | { |
---|
4068 | 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 | + } |
---|
4069 | 4185 | |
---|
4070 | 4186 | if (freezematerial) |
---|
4071 | 4187 | { |
---|
.. | .. |
---|
4414 | 4530 | |
---|
4415 | 4531 | void makeSomething(Object3D thing, boolean resetmodel) // deselect) |
---|
4416 | 4532 | { |
---|
4417 | | - if (Globals.SAVEONMAKE) // && resetmodel) |
---|
| 4533 | + if (Globals.REPLACEONMAKE) // && resetmodel) |
---|
4418 | 4534 | Save(); |
---|
4419 | 4535 | //Tween.set(thing, 0).target(1).start(tweenManager); |
---|
4420 | 4536 | //Tween.to(thing, 0, 0.5f).target(0).start(tweenManager); |
---|
.. | .. |
---|
4786 | 4902 | c.addChild(csg); |
---|
4787 | 4903 | } |
---|
4788 | 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 | + |
---|
4789 | 4916 | ResetModel(); |
---|
4790 | 4917 | copy.HardTouch(); // recompile? |
---|
4791 | 4918 | refreshContents(); |
---|