- sanitize geometry name when creating j3m file

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8583 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 13 years ago
parent f15dfe3011
commit b27a0ae7fb
  1. 8
      sdk/jme3-materialeditor/src/com/jme3/gde/materials/MaterialPropertyEditor.java

@ -109,11 +109,11 @@ public class MaterialPropertyEditor implements PropertyEditor, SceneExplorerProp
FileObject currentFolder = currentFile.getParent();
int i = 0;
String newFileName = currentFile.getName() + "-" + geom.getName();
String newFileName = currentFile.getName() + "-" + sanitizeFileName(geom.getName());
FileObject newFile = currentFolder.getFileObject(newFileName, "j3m");
while (newFile != null) {
i++;
newFileName = currentFile.getName() + "-" + geom.getName() + "-" + i;
newFileName = currentFile.getName() + "-" + sanitizeFileName(geom.getName()) + "-" + i;
newFile = currentFolder.getFileObject(newFileName, "j3m");
}
newFile = currentFolder.createData(newFileName, "j3m");
@ -131,6 +131,10 @@ public class MaterialPropertyEditor implements PropertyEditor, SceneExplorerProp
applyMaterial(text);
}
}
private String sanitizeFileName(String input){
return input.replaceAll("[^A-Za-z0-9 ]", "_");
}
private void applyMaterial(final String text) {
try {

Loading…
Cancel
Save