From de0d8d87447fea5faea469ccf8072a7aead35b6d Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sun, 04 Aug 2019 20:56:22 -0400 Subject: [PATCH] Delete version. --- ObjEditor.java | 129 +++++++++++++++++++++++++++++++----------- 1 files changed, 94 insertions(+), 35 deletions(-) diff --git a/ObjEditor.java b/ObjEditor.java index 4f2f437..996442d 100644 --- a/ObjEditor.java +++ b/ObjEditor.java @@ -848,6 +848,8 @@ //frame.setVisible(true); } frame.validate(); + + cameraView.requestFocusInWindow(); } private Object3D CompressCopy() @@ -1738,20 +1740,52 @@ void SetupMaterial(cGridBag materialpanel) { cGridBag presetpanel = new cGridBag().setVertical(true); - cLabel label = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF); - label.addMouseListener(new MouseAdapter() + cLabel skin = GetLabel("icons/shadericons/shadericon00000.png", !Grafreed.NIMBUSLAF); + skin.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { - colorField.setFloat(0); - saturationField.setFloat(1); + Object3D object = Grafreed.materials.versionlist[0].get(0); + cMaterial material = object.material; + + // Skin + colorField.setFloat(material.color); + saturationField.setFloat(material.modulation); + subsurfaceField.setFloat(material.subsurface); + selfshadowField.setFloat(material.diffuseness); + diffusenessField.setFloat(material.factor); + shininessField.setFloat(material.shininess); + shadowbiasField.setFloat(material.shadowbias); + diffuseField.setFloat(material.diffuse); + specularField.setFloat(material.specular); + + bumpField.setFloat(object.projectedVertices[0].x / 1000.0); + noiseField.setFloat(object.projectedVertices[0].y / 1000.0); + powerField.setFloat(object.projectedVertices[2].x / 1000.0); + materialtouched = true; applySelf(); } }); - presetpanel.add(label); + presetpanel.add(skin); - presetpanel.add(GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF)); + cLabel rough2 = GetLabel("icons/shadericons/shadericon00001.png", !Grafreed.NIMBUSLAF); + rough2.addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent e) + { + Object3D object = Grafreed.materials.versionlist[1].get(0); + cMaterial material = object.material; + + shininessField.setFloat(material.shininess); + velvetField.setFloat(material.velvet); + + materialtouched = true; + applySelf(); + } + }); + presetpanel.add(rough2); + presetpanel.add(GetLabel("icons/shadericons/shadericon00002.png", !Grafreed.NIMBUSLAF)); presetpanel.add(GetLabel("icons/shadericons/shadericon00003.png", !Grafreed.NIMBUSLAF)); presetpanel.add(GetLabel("icons/shadericons/shadericon00004.png", !Grafreed.NIMBUSLAF)); @@ -1768,9 +1802,6 @@ presetpanel.add(GetLabel("icons/shadericons/shadericon00015.png", !Grafreed.NIMBUSLAF)); presetpanel.add(GetLabel("icons/shadericons/shadericon00016.png", !Grafreed.NIMBUSLAF)); presetpanel.add(GetLabel("icons/shadericons/shadericon00017.png", !Grafreed.NIMBUSLAF)); - presetpanel.add(GetLabel("icons/shadericons/shadericon00018.png", !Grafreed.NIMBUSLAF)); - presetpanel.add(GetLabel("icons/shadericons/shadericon00019.png", !Grafreed.NIMBUSLAF)); - presetpanel.add(GetLabel("icons/shadericons/shadericon00020.png", !Grafreed.NIMBUSLAF)); cGridBag panel = new cGridBag().setVertical(true); @@ -1821,9 +1852,9 @@ cGridBag huepanel = new cGridBag(); cGridBag huelabel = new cGridBag(); - label = GetLabel("icons/hue.png", false); - label.fit = true; - huelabel.add(label); + skin = GetLabel("icons/hue.png", false); + skin.fit = true; + huelabel.add(skin); huelabel.preferredWidth = 20; huepanel.add(new cGridBag()); // Label huepanel.add(huelabel); // Field/slider @@ -3737,14 +3768,26 @@ java.util.Hashtable<java.util.UUID, Object3D> versiontable = new java.util.Hashtable<java.util.UUID, Object3D>(); + void DeleteVersion() + { + for (int i = copy.versionindex; i < copy.versionlist.length-1; i++) + { + copy.versionlist[i] = copy.versionlist[i+1]; + } + + CopyChanged(); + + SetUndoStates(); + } + public boolean Save(boolean user) { System.err.println("Save"); - Replace(); + //Replace(); cRadio tab = GetCurrentTab(); - Object3D compress = CompressCopy(); // Saved version. No need for "Replace". + Object3D compress = CompressCopy(); // Saved version. No need for "Replace"? boolean thesame = false; @@ -3756,6 +3799,11 @@ //EditorFrame.m_MainFrame.requestFocusInWindow(); if (!thesame) { + for (int i = copy.versionlist.length; --i > copy.versionindex+1;) + { + copy.versionlist[i] = copy.versionlist[i-1]; + } + //tab.user[tab.versionindex] = user; //boolean increment = true; // tab.graphs[tab.versionindex] == null; @@ -3769,11 +3817,11 @@ //assert(hashtable.isEmpty()); - for (int i = copy.versionindex+1; i < copy.versionlist.length; i++) - { - //tab.user[i] = false; - copy.versionlist[i] = null; - } +// for (int i = copy.versionindex+1; i < copy.versionlist.length; i++) +// { +// //tab.user[i] = false; +// copy.versionlist[i] = null; +// } SetUndoStates(); @@ -3828,11 +3876,13 @@ GetTree().addSelectionPath(selection.elementAt(i).GetTreePath().GetTreePath()); flashIt = true; - refreshContents(false); + //refreshContents(false); } - void CopyChanged(Object3D obj) + void CopyChanged() { + Object3D obj = copy.versionlist[copy.versionindex]; + SetUndoStates(); boolean temp = CameraPane.SWITCH; @@ -3875,13 +3925,15 @@ } } - refreshContents(); + refreshContents(true); } - cButton undoButton; + cButton previousVersionButton; cButton restoreButton; cButton replaceButton; - cButton redoButton; + cButton nextVersionButton; + cButton saveVersionButton; + cButton deleteVersionButton; boolean muteSlider; @@ -3902,11 +3954,14 @@ { cRadio tab = GetCurrentTab(); - restoreButton.setEnabled(copy.versionindex != -1); - replaceButton.setEnabled(copy.versionindex != -1); + restoreButton.setEnabled(true); // copy.versionindex != -1); + replaceButton.setEnabled(true); // copy.versionindex != -1); - undoButton.setEnabled(copy.versionindex > 0); - redoButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null); + previousVersionButton.setEnabled(copy.versionindex > 0); + nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null); + + deleteVersionButton.setEnabled(//copy.versionindex > 0 && + copy.versionlist[copy.versionindex + 1] != null); muteSlider = true; versionSlider.setMaximum(VersionCount() - 1); @@ -3914,7 +3969,7 @@ muteSlider = false; } - public boolean Undo() + public boolean PreviousVersion() { // Option? Replace(); @@ -3944,7 +3999,7 @@ copy.versionindex -= 1; - CopyChanged((Object3D)copy.versionlist[copy.versionindex]); + CopyChanged(); return true; } @@ -3962,7 +4017,7 @@ } //CopyChanged((Object3D)Uncompress(copy.versions[copy.versionindex])); - CopyChanged(copy.versionlist[copy.versionindex]); + CopyChanged(); return true; } @@ -3984,7 +4039,7 @@ return true; } - public void Redo() + public void NextVersion() { // Option? Replace(); @@ -3999,7 +4054,7 @@ copy.versionindex += 1; - CopyChanged(copy.versionlist[copy.versionindex]); + CopyChanged(); //if (!tab.user[tab.versionindex]) // tab.graphs[tab.versionindex] = null; @@ -4312,7 +4367,8 @@ if (copy.versionlist[version] != null) { - CopyChanged(copy.versionlist[copy.versionindex = version]); + copy.versionindex = version; + CopyChanged(); } return; @@ -4666,6 +4722,9 @@ ctrlPanel.validate(); // ? new ctrlPanel.repaint(); } + + if (previousVersionButton != null && copy.versionlist != null) + SetUndoStates(); } static TweenManager tweenManager = new TweenManager(); @@ -5070,7 +5129,7 @@ { if (Grafreed.standAlone) { - FileDialog browser = new FileDialog(frame, "Load", FileDialog.LOAD); + FileDialog browser = new FileDialog(frame, "Open", FileDialog.LOAD); browser.show(); String filename = browser.getFile(); if (filename != null && filename.length() > 0) -- Gitblit v1.6.2