use of com.kotcrab.vis.ui.widget.file.FileChooser in project bladecoder-adventure-engine by bladecoder.
the class ToolsWindow method exportUIImages.
protected void exportUIImages() {
FileChooser fileChooser = new FileChooser(Mode.OPEN);
fileChooser.setSize(Gdx.graphics.getWidth() * 0.7f, Gdx.graphics.getHeight() * 0.7f);
fileChooser.setViewMode(ViewMode.LIST);
fileChooser.setSelectionMode(SelectionMode.DIRECTORIES);
getStage().addActor(fileChooser);
fileChooser.setListener(new FileChooserListener() {
@Override
public void selected(Array<FileHandle> files) {
try {
// fileChooser.setTitle("Select the file to export the
// project texts");
ImageUtils.unpackAtlas(new File(Ctx.project.getAssetPath() + Project.UI_PATH + "/1/ui.atlas"), files.get(0).file());
Message.showMsg(getStage(), "UI Atlas images exported sucessfully.", 4);
} catch (Exception e) {
Message.showMsg(getStage(), "There was a problem exporting images from UI Atlas.", 4);
EditorLogger.printStackTrace(e);
}
}
@Override
public void canceled() {
}
});
}
use of com.kotcrab.vis.ui.widget.file.FileChooser in project bladecoder-adventure-engine by bladecoder.
the class ToolsWindow method importTSV.
private void importTSV() {
FileChooser fileChooser = new FileChooser(Mode.OPEN);
fileChooser.setSize(Gdx.graphics.getWidth() * 0.7f, Gdx.graphics.getHeight() * 0.7f);
fileChooser.setViewMode(ViewMode.LIST);
fileChooser.setSelectionMode(SelectionMode.FILES);
getStage().addActor(fileChooser);
fileChooser.setListener(new FileChooserListener() {
@Override
public void selected(Array<FileHandle> files) {
try {
// chooser.setTitle("Select the .tsv file to import");
I18NUtils.importTSV(Ctx.project.getAssetPath() + Project.MODEL_PATH, files.get(0).file().getAbsolutePath(), Ctx.project.getChapter().getId(), "default");
// Reload texts
Ctx.project.getI18N().load(Ctx.project.getChapter().getId());
Message.showMsg(getStage(), files.get(0).file().getName() + " imported sucessfully.", 4);
} catch (IOException e) {
Message.showMsg(getStage(), "There was a problem importing the .tsv file.", 4);
EditorLogger.printStackTrace(e);
}
}
@Override
public void canceled() {
}
});
}
use of com.kotcrab.vis.ui.widget.file.FileChooser in project gdx-graph by MarcinSc.
the class LibgdxGraphScreen method save.
private void save() {
if (graphDesignTab != null) {
if (editedFile == null) {
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());
} else {
saveToFile(graphDesignTab, editedFile);
}
}
}
use of com.kotcrab.vis.ui.widget.file.FileChooser 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());
}
use of com.kotcrab.vis.ui.widget.file.FileChooser in project gdx-graph by MarcinSc.
the class LoadFileGraphShaderTemplate method invokeTemplate.
@Override
public void invokeTemplate(Stage stage, final Callback callback) {
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);
JsonReader parser = new JsonReader();
try {
InputStream is = selectedFile.read();
try {
JsonValue shader = parser.parse(new InputStreamReader(is));
callback.addShader(selectedFile.nameWithoutExtension(), shader);
} finally {
is.close();
}
} catch (IOException exp) {
// Ignored
}
}
});
stage.addActor(fileChooser.fadeIn());
}
Aggregations