use of com.kotcrab.vis.ui.widget.file.FileChooserAdapter in project talos by rockbite.
the class SettingsDialog method addScriptPathSetting.
public void addScriptPathSetting(Table container) {
Table inputTable = new Table();
String sceneEditorExportScriptPath = TalosMain.Instance().Prefs().getString("sceneEditorExportScriptPath", null);
inputTable.add(new Label("BuildScript location (JS)", getSkin())).width(180);
exportScriptPathField = new TextField(sceneEditorExportScriptPath, getSkin());
inputTable.add(exportScriptPathField).padLeft(13).width(130);
TextButton browseInputBtn = new TextButton("Browse", getSkin());
inputTable.add(browseInputBtn).padLeft(3);
FileChooser fileChooser = new FileChooser(FileChooser.Mode.SAVE);
fileChooser.setBackground(getSkin().getDrawable("window-noborder"));
browseInputBtn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
fileChooser.setMode(FileChooser.Mode.SAVE);
fileChooser.setMultiSelectionEnabled(false);
fileChooser.setSelectionMode(FileChooser.SelectionMode.FILES);
String currentProjectPath = TalosMain.Instance().ProjectController().getCurrentProjectPath();
String sceneEditorExportScriptPath = TalosMain.Instance().Prefs().getString("sceneEditorExportScriptPath", null);
if (sceneEditorExportScriptPath != null) {
FileHandle path = Gdx.files.absolute(sceneEditorExportScriptPath);
fileChooser.setDirectory(path.parent().file());
fileChooser.setDefaultFileName(path.name());
exportScriptPathField.setText(path.path());
} else {
fileChooser.setDirectory(Gdx.files.absolute(currentProjectPath).parent().file());
fileChooser.setDefaultFileName("buildscript.js");
}
fileChooser.setListener(new FileChooserAdapter() {
@Override
public void selected(Array<FileHandle> files) {
FileHandle file = files.first();
exportScriptPathField.setText(file.path());
}
});
getStage().addActor(fileChooser.fadeIn());
}
});
container.add(inputTable).pad(10).expand().growX().left();
container.row();
}
use of com.kotcrab.vis.ui.widget.file.FileChooserAdapter in project talos by rockbite.
the class UIStage method openProjectAction.
public void openProjectAction(final IProject projectType) {
String defaultLocation = TalosMain.Instance().ProjectController().getLastDir("Open", projectType);
if (defaultLocation.equals("")) {
TalosMain.Instance().ProjectController().getLastDir("Save", projectType);
}
fileChooser.setDirectory(defaultLocation);
fileChooser.setMode(FileChooser.Mode.OPEN);
fileChooser.setMultiSelectionEnabled(false);
fileChooser.setFileFilter(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isDirectory() || pathname.getAbsolutePath().endsWith(projectType.getExtension());
}
});
fileChooser.setSelectionMode(FileChooser.SelectionMode.FILES);
fileChooser.setListener(new FileChooserAdapter() {
@Override
public void selected(Array<FileHandle> file) {
String path = file.first().file().getAbsolutePath();
TalosMain.Instance().ProjectController().setProject(projectType);
TalosMain.Instance().ProjectController().loadProject(Gdx.files.absolute(path));
}
});
stage.addActor(fileChooser.fadeIn());
}
use of com.kotcrab.vis.ui.widget.file.FileChooserAdapter in project talos by rockbite.
the class UIStage method legacyImportAction.
public void legacyImportAction() {
fileChooser.setMode(FileChooser.Mode.OPEN);
fileChooser.setMultiSelectionEnabled(false);
fileChooser.setFileFilter(new FileChooser.DefaultFileFilter(fileChooser));
fileChooser.setSelectionMode(FileChooser.SelectionMode.FILES);
fileChooser.setListener(new FileChooserAdapter() {
@Override
public void selected(Array<FileHandle> file) {
TalosMain.Instance().TalosProject().importFromLegacyFormat(file.get(0));
TalosMain.Instance().ProjectController().unbindFromFile();
}
});
stage.addActor(fileChooser.fadeIn());
}
use of com.kotcrab.vis.ui.widget.file.FileChooserAdapter in project talos by rockbite.
the class UIStage method exportAsAction.
public void exportAsAction() {
IProject projectType = TalosMain.Instance().ProjectController().getProject();
String defaultLocation = TalosMain.Instance().ProjectController().getLastDir("Export", projectType);
fileChooser.setDirectory(defaultLocation);
final String ext = projectType.getExportExtension();
fileChooser.setMode(FileChooser.Mode.SAVE);
fileChooser.setMultiSelectionEnabled(false);
fileChooser.setFileFilter(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.isDirectory() || pathname.getAbsolutePath().endsWith(ext);
}
});
fileChooser.setSelectionMode(FileChooser.SelectionMode.FILES);
fileChooser.setListener(new FileChooserAdapter() {
@Override
public void selected(Array<FileHandle> file) {
String path = file.first().file().getAbsolutePath();
if (!path.endsWith(ext)) {
if (path.indexOf(".") > 0) {
path = path.substring(0, path.indexOf("."));
}
path += ext;
}
FileHandle handle = Gdx.files.absolute(path);
TalosMain.Instance().ProjectController().exportProject(handle);
}
});
fileChooser.setDefaultFileName(TalosMain.Instance().ProjectController().getCurrentExportNameSuggestion());
stage.addActor(fileChooser.fadeIn());
}
use of com.kotcrab.vis.ui.widget.file.FileChooserAdapter 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);
}
}
}
Aggregations