use of com.kotcrab.vis.ui.widget.file.FileTypeFilter in project bladecoder-adventure-engine by bladecoder.
the class AssetsList method create.
private void create() {
final String type = assetTypes.getSelected();
if (type.equals("atlases")) {
new CreateAtlasDialog(skin).show(getStage());
// addAssets();
} else if (type.equals("particles")) {
// Open the particle editor
List<String> cp = new ArrayList<String>();
cp.add(System.getProperty("java.class.path"));
try {
RunProccess.runJavaProccess("com.badlogic.gdx.tools.particleeditor.ParticleEditor", cp, null);
} catch (IOException e) {
Message.showMsgDialog(getStage(), "Error", "Error launching Particle Editor.");
EditorLogger.printStackTrace(e);
}
} else {
FileChooser fileChooser = new FileChooser(Mode.OPEN);
fileChooser.setSelectionMode(SelectionMode.FILES);
fileChooser.setMultiSelectionEnabled(true);
fileChooser.setSize(Gdx.graphics.getWidth() * 0.7f, Gdx.graphics.getHeight() * 0.7f);
fileChooser.setViewMode(ViewMode.LIST);
getStage().addActor(fileChooser);
if (lastDir != null)
fileChooser.setDirectory(lastDir);
// chooser.setTitle("Select the '" + type + "' asset files");
// allow "All Types" mode where all files are shown
FileTypeFilter typeFilter = new FileTypeFilter(true);
switch(type) {
case "images":
typeFilter.addRule("Images (*.png, *.jpg, *.etc1)", "jpg", "png", "etc1");
break;
case "music":
case "sounds":
case "voices":
typeFilter.addRule("Sound (*.mp3, *.wav, *.ogg)", "wav", "mp3", "ogg");
break;
case "spine":
typeFilter.addRule("Spine (*.skel, *.json)", "skel", "json");
break;
default:
typeFilter.addRule("All", "");
break;
}
fileChooser.setFileTypeFilter(typeFilter);
fileChooser.setListener(new FileChooserListener() {
@Override
public void selected(Array<FileHandle> files) {
try {
String dirName = getAssetDir(type);
lastDir = files.get(0).parent().file();
// Si no existe la carpeta la creamos
File dir = new File(dirName);
if (!dir.exists())
dir.mkdir();
for (FileHandle f : files) {
if (type.equals("images")) {
List<String> res = Ctx.project.getResolutions();
for (String r : res) {
File destFile = new File(dirName + "/" + r + "/" + f.file().getName());
float scale = Float.parseFloat(r);
if (scale != 1.0f) {
ImageUtils.scaleImageFile(f.file(), destFile, scale);
} else {
Files.copy(f.file().toPath(), destFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
}
}
} else {
File destFile = new File(dir, f.file().getName());
Files.copy(f.file().toPath(), destFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
}
}
addAssets();
} catch (Exception ex) {
String msg = "Something went wrong while getting the assets.\n\n" + ex.getClass().getSimpleName() + " - " + ex.getMessage();
Message.showMsgDialog(getStage(), "Error", msg);
EditorLogger.printStackTrace(ex);
}
}
@Override
public void canceled() {
}
});
}
}
use of com.kotcrab.vis.ui.widget.file.FileTypeFilter in project gdx-graph by MarcinSc.
the class PluginsDialog method addPlugin.
private void addPlugin() {
FileTypeFilter filter = new FileTypeFilter(true);
filter.addRule("Plugin File (*.jar, *.json)", "jar", "json");
FileChooser fileChooser = new FileChooser(FileChooser.Mode.OPEN);
fileChooser.setModal(true);
fileChooser.setSelectionMode(FileChooser.SelectionMode.FILES);
fileChooser.setFileTypeFilter(filter);
fileChooser.setListener(new FileChooserAdapter() {
@Override
public void selected(Array<FileHandle> file) {
FileHandle selectedFile = file.get(0);
processPlugin(selectedFile);
}
});
getStage().addActor(fileChooser.fadeIn());
}
Aggregations