use of com.kotcrab.vis.ui.widget.file.FileChooser in project gdx-graph by MarcinSc.
the class LibgdxGraphScreen method exportShader.
private void exportShader() {
FileChooser fileChooser = new FileChooser(FileChooser.Mode.SAVE);
fileChooser.setModal(true);
fileChooser.setSelectionMode(FileChooser.SelectionMode.FILES);
fileChooser.setListener(new FileChooserAdapter() {
@Override
public void selected(Array<FileHandle> file) {
FileHandle selectedFile = file.get(0);
if (!selectedFile.name().toLowerCase().endsWith(".json")) {
selectedFile = selectedFile.parent().child(selectedFile.name() + ".json");
}
writeGraph(selectedFile, ((GraphDesignTab) tabbedPane.getActiveTab()).serializeGraph());
}
});
getStage().addActor(fileChooser.fadeIn());
}
use of com.kotcrab.vis.ui.widget.file.FileChooser in project gdx-graph by MarcinSc.
the class LibgdxGraphScreen method saveAs.
private void saveAs() {
FileChooser fileChooser = new FileChooser(FileChooser.Mode.SAVE);
fileChooser.setModal(true);
fileChooser.setSelectionMode(FileChooser.SelectionMode.FILES);
fileChooser.setListener(new FileChooserAdapter() {
@Override
public void selected(Array<FileHandle> file) {
FileHandle selectedFile = file.get(0);
if (!selectedFile.name().toLowerCase().endsWith(".json")) {
selectedFile = selectedFile.parent().child(selectedFile.name() + ".json");
}
editedFile = selectedFile;
saveToFile(graphDesignTab, selectedFile);
}
});
getStage().addActor(fileChooser.fadeIn());
}
use of com.kotcrab.vis.ui.widget.file.FileChooser in project gdx-graph by MarcinSc.
the class LibgdxGraphScreen method open.
private void open() {
if (graphDesignTab != null && graphDesignTab.isDirty()) {
Dialogs.showErrorDialog(getStage(), "Current pipeline has been modified, close it or save it");
} else {
removeAllTabs();
FileChooser fileChooser = new FileChooser(FileChooser.Mode.OPEN);
fileChooser.setModal(true);
fileChooser.setSelectionMode(FileChooser.SelectionMode.FILES);
fileChooser.setListener(new FileChooserAdapter() {
@Override
public void selected(Array<FileHandle> file) {
FileHandle selectedFile = file.get(0);
loadPipelineFromFile(selectedFile);
editedFile = selectedFile;
graphDesignTab.setDirty(false);
}
});
getStage().addActor(fileChooser.fadeIn());
}
}
use of com.kotcrab.vis.ui.widget.file.FileChooser in project Mundus by jpooleycodes.
the class FileChooserField method setupListeners.
private void setupListeners() {
fcBtn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
FileChooser fileChooser = UI.INSTANCE.getFileChooser();
fileChooser.setSelectionMode(mode);
fileChooser.setListener(new SingleFileChooserListener() {
@Override
protected void selected(FileHandle file) {
fileHandle = file;
path = file.path();
textField.setText(file.path());
if (fileSelected != null) {
fileSelected.selected(file);
}
}
});
UI.INSTANCE.addActor(fileChooser.fadeIn());
}
});
}
use of com.kotcrab.vis.ui.widget.file.FileChooser 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() {
}
});
}
}
Aggregations