|
@@ -12,6 +12,7 @@ package com.jme3.gde.materials.multiview.widgets;
|
|
|
|
|
|
import com.jme3.gde.core.assets.ProjectAssetManager;
|
|
import com.jme3.gde.core.assets.ProjectAssetManager;
|
|
import com.jme3.gde.core.properties.TexturePropertyEditor;
|
|
import com.jme3.gde.core.properties.TexturePropertyEditor;
|
|
|
|
+import com.jme3.gde.core.properties.preview.DDSPreview;
|
|
import com.jme3.gde.materials.MaterialProperty;
|
|
import com.jme3.gde.materials.MaterialProperty;
|
|
import com.jme3.texture.Texture;
|
|
import com.jme3.texture.Texture;
|
|
import java.awt.Component;
|
|
import java.awt.Component;
|
|
@@ -32,6 +33,7 @@ public class TexturePanel extends MaterialPropertyWidget {
|
|
private boolean flip = false;
|
|
private boolean flip = false;
|
|
private boolean repeat = false;
|
|
private boolean repeat = false;
|
|
private String textureName = null;
|
|
private String textureName = null;
|
|
|
|
+ private DDSPreview ddsPreview;
|
|
|
|
|
|
/** Creates new form SelectionPanel */
|
|
/** Creates new form SelectionPanel */
|
|
public TexturePanel(ProjectAssetManager manager) {
|
|
public TexturePanel(ProjectAssetManager manager) {
|
|
@@ -45,7 +47,10 @@ public class TexturePanel extends MaterialPropertyWidget {
|
|
Texture tex = manager.loadTexture(textureName);
|
|
Texture tex = manager.loadTexture(textureName);
|
|
Icon newicon = null;
|
|
Icon newicon = null;
|
|
if (textureName.endsWith(".dds") || textureName.endsWith(".DDS")) {
|
|
if (textureName.endsWith(".dds") || textureName.endsWith(".DDS")) {
|
|
- texturePreview.setIcon(null);
|
|
|
|
|
|
+ if (ddsPreview == null) {
|
|
|
|
+ ddsPreview = new DDSPreview(manager);
|
|
|
|
+ }
|
|
|
|
+ ddsPreview.requestPreview(textureName, "", 80, 80, texturePreview, null);
|
|
} else {
|
|
} else {
|
|
newicon = ImageUtilities.image2Icon(resizeImage(ImageToAwt.convert(tex.getImage(), false, true, 0)));
|
|
newicon = ImageUtilities.image2Icon(resizeImage(ImageToAwt.convert(tex.getImage(), false, true, 0)));
|
|
}
|
|
}
|
|
@@ -80,8 +85,6 @@ public class TexturePanel extends MaterialPropertyWidget {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
private static BufferedImage resizeImage(BufferedImage originalImage) {
|
|
private static BufferedImage resizeImage(BufferedImage originalImage) {
|
|
int type = originalImage.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : originalImage.getType();
|
|
int type = originalImage.getType() == 0 ? BufferedImage.TYPE_INT_ARGB : originalImage.getType();
|
|
float ratio = (float) originalImage.getWidth() / (float) originalImage.getHeight();
|
|
float ratio = (float) originalImage.getWidth() / (float) originalImage.getHeight();
|
|
@@ -251,7 +254,7 @@ public class TexturePanel extends MaterialPropertyWidget {
|
|
view.setVisible(true);
|
|
view.setVisible(true);
|
|
if (editor.getValue() != null) {
|
|
if (editor.getValue() != null) {
|
|
textureName = editor.getAsText();
|
|
textureName = editor.getAsText();
|
|
- displayPreview();
|
|
|
|
|
|
+ displayPreview();
|
|
updateFlipRepeat();
|
|
updateFlipRepeat();
|
|
fireChanged();
|
|
fireChanged();
|
|
}
|
|
}
|
|
@@ -259,7 +262,7 @@ public class TexturePanel extends MaterialPropertyWidget {
|
|
|
|
|
|
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
|
|
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
|
|
textureName = "";
|
|
textureName = "";
|
|
- texturePreview.setIcon(null);
|
|
|
|
|
|
+ texturePreview.setIcon(null);
|
|
texturePreview.setToolTipText("");
|
|
texturePreview.setToolTipText("");
|
|
property.setValue("");
|
|
property.setValue("");
|
|
fireChanged();
|
|
fireChanged();
|
|
@@ -303,7 +306,7 @@ public class TexturePanel extends MaterialPropertyWidget {
|
|
}
|
|
}
|
|
jLabel1.setText(property.getName());
|
|
jLabel1.setText(property.getName());
|
|
jLabel1.setToolTipText(property.getName());
|
|
jLabel1.setToolTipText(property.getName());
|
|
- displayPreview();
|
|
|
|
|
|
+ displayPreview();
|
|
texturePreview.setToolTipText(property.getValue());
|
|
texturePreview.setToolTipText(property.getValue());
|
|
MaterialProperty prop = property;
|
|
MaterialProperty prop = property;
|
|
property = null;
|
|
property = null;
|
|
@@ -313,6 +316,13 @@ public class TexturePanel extends MaterialPropertyWidget {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void cleanUp() {
|
|
|
|
+ if (ddsPreview != null) {
|
|
|
|
+ ddsPreview.cleanUp();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
|
private javax.swing.JButton jButton1;
|
|
private javax.swing.JButton jButton1;
|
|
private javax.swing.JButton jButton2;
|
|
private javax.swing.JButton jButton2;
|