From 24a2a946b35279605e645349bd6b82e9e60aac88 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Wed, 14 Aug 2019 23:35:34 -0400 Subject: [PATCH] Fix textures in jar. --- ObjEditor.java | 120 +++++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 91 insertions(+), 29 deletions(-) diff --git a/ObjEditor.java b/ObjEditor.java index 389e50d..9f18912 100644 --- a/ObjEditor.java +++ b/ObjEditor.java @@ -75,8 +75,16 @@ return new cCheckBox(icon, border); } + static java.util.Hashtable<String, javax.swing.ImageIcon> icons = new java.util.Hashtable<String, javax.swing.ImageIcon>(); + ImageIcon GetIcon(String name) { + javax.swing.ImageIcon iconCache = icons.get(name); + if (iconCache != null) + { + return iconCache; + } + try { BufferedImage image = javax.imageio.ImageIO.read(getClass().getClassLoader().getResourceAsStream(name)); @@ -94,10 +102,14 @@ // } javax.swing.ImageIcon icon = new javax.swing.ImageIcon(image); + + icons.put(name, icon); + return icon; } catch (Exception e) { + //icons.put(name, null); return null; } } @@ -297,11 +309,13 @@ client = inClient; copy = client; - if (copy.versionlist == null) - { - copy.versionlist = new Object3D[100]; - copy.versionindex = -1; - } +// if (copy.versionlist == null) +// { +// copy.versionlist = new Object3D[100]; +// copy.versionindex = -1; +// +// callee.Save(true); +// } // "this" is not called: SetupUI2(objEditor); } @@ -320,6 +334,8 @@ { copy.versionlist = new Object3D[100]; copy.versionindex = -1; + +// Save(true); } SetupUI2(callee.GetEditor()); @@ -354,11 +370,13 @@ copy = localCopy; copy.editWindow = this; - if (copy.versionlist == null) - { -// copy.versions = new byte[100][]; +// if (copy.versionlist == null) +// { +// copy.versionlist = new Object3D[100]; // copy.versionindex = -1; - } +// +// Save(true); +// } SetupMenu(); @@ -427,6 +445,8 @@ ChangeListener changeListener = new ChangeListener() { + //String name; + public void stateChanged(ChangeEvent changeEvent) { // if (objectPanel.getSelectedIndex() == objectPanel.indexOfTab("Material") && !materialFlushed) @@ -445,7 +465,37 @@ // EditSelection(false); // } - refreshContents(false); // To refresh Info tab +// if (objectPanel.getSelectedIndex() == 4) +// { +// name = copy.skyboxname; +// +// if (name == null) +// { +// name = ""; +// } +// +// copy.skyboxname = "cubemaps/default-skyboxes/rgb"; +// copy.skyboxext = "jpg"; +// } +// else +// { +// if (name != null) +// { +// if (name.equals("")) +// { +// copy.skyboxname = null; +// copy.skyboxext = null; +// } +// else +// { +// copy.skyboxname = name; +// } +// } +// } + cameraView.transformMode = objectPanel.getSelectedIndex() == 4; + +// refreshContents(false); // To refresh Info tab + cameraView.repaint(); } }; objectPanel.addChangeListener(changeListener); @@ -1639,9 +1689,9 @@ scenePanel.add(tabbedPane); //if (Globals.ADVANCED) - tabbedPane.add(infoPanel); - tabbedPane.setIconAt(3, GetIcon("icons/info.png")); - tabbedPane.setToolTipTextAt(3, "Information"); +// tabbedPane.add(infoPanel); +// tabbedPane.setIconAt(3, GetIcon("icons/info.png")); +// tabbedPane.setToolTipTextAt(3, "Information"); /* cTree jTree = new cTree(null); @@ -1739,7 +1789,7 @@ frame.getContentPane().setLayout(new BorderLayout()); /**/ - JTabbedPane worldPane = new JTabbedPane(); + //JTabbedPane worldPane = new JTabbedPane(); //worldPane.add(bigPanel); //worldPane.add(worldPanel); /**/ @@ -4123,7 +4173,7 @@ { //Save(true); Replace(); - SetUndoStates(); + SetVersionStates(); } private boolean Equal(byte[] compress, byte[] name) @@ -4153,7 +4203,7 @@ CopyChanged(); - SetUndoStates(); + SetVersionStates(); } public boolean Save(boolean user) @@ -4161,7 +4211,7 @@ System.err.println("Save"); Replace(); - cRadio tab = GetCurrentTab(); + //cRadio tab = GetCurrentTab(); Object3D compress = Duplicate(copy); // Saved version. No need for "Replace"? @@ -4199,7 +4249,7 @@ // copy.versionlist[i] = null; // } - SetUndoStates(); + SetVersionStates(); // test save if (false) @@ -4259,7 +4309,7 @@ { Object3D obj = (Object3D)Grafreed.clone(copy.versionlist[copy.versionindex]); - SetUndoStates(); + SetVersionStates(); boolean temp = CameraPane.SWITCH; CameraPane.SWITCH = false; @@ -4326,12 +4376,15 @@ return count; } - void SetUndoStates() + void SetVersionStates() { - cRadio tab = GetCurrentTab(); + //if (true) + // return; + + //cRadio tab = GetCurrentTab(); - restoreButton.setEnabled(true); // copy.versionindex != -1); - replaceButton.setEnabled(true); // copy.versionindex != -1); + restoreButton.setEnabled(copy.versionindex != -1); + replaceButton.setEnabled(copy.versionindex != -1); previousVersionButton.setEnabled(copy.versionindex > 0); nextVersionButton.setEnabled(copy.versionlist[copy.versionindex + 1] != null); @@ -4340,8 +4393,10 @@ copy.versionlist[copy.versionindex + 1] != null); muteSlider = true; + versionSlider.setMinimum(0); versionSlider.setMaximum(VersionCount() - 1); versionSlider.setInteger(copy.versionindex); + versionSlider.setEnabled(copy.versionindex != -1); muteSlider = false; } @@ -4352,7 +4407,7 @@ System.err.println("Undo"); - cRadio tab = GetCurrentTab(); + //cRadio tab = GetCurrentTab(); if (copy.versionindex == 0) { @@ -4384,7 +4439,7 @@ { System.err.println("Restore"); - cRadio tab = GetCurrentTab(); + //cRadio tab = GetCurrentTab(); if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null) { @@ -4402,7 +4457,7 @@ { System.err.println("Replace"); - cRadio tab = GetCurrentTab(); + //cRadio tab = GetCurrentTab(); if (copy.versionindex == -1 || copy.versionlist[copy.versionindex] == null) { @@ -4420,7 +4475,7 @@ // Option? Replace(); - cRadio tab = GetCurrentTab(); + //cRadio tab = GetCurrentTab(); if (copy.versionlist[copy.versionindex + 1] == null) { @@ -4739,9 +4794,11 @@ if (muteSlider) return; + Replace(); + int version = versionSlider.getInteger(); - if (copy.versionlist[version] != null) + if (version != -1 && copy.versionlist[version] != null) { copy.versionindex = version; CopyChanged(); @@ -5100,7 +5157,7 @@ } if (previousVersionButton != null && copy.versionlist != null) - SetUndoStates(); + SetVersionStates(); } static TweenManager tweenManager = new TweenManager(); @@ -5489,8 +5546,11 @@ if (copy.versionlist == null) { + // Backward compatibility copy.versionlist = new Object3D[100]; copy.versionindex = -1; + + //Save(true); } //? SetUndoStates(); @@ -5582,6 +5642,8 @@ void save() { + Replace(); + if (lastname == null) { return; -- Gitblit v1.6.2