use of com.kotcrab.vis.ui.widget.file.FileChooserAdapter in project talos by rockbite.
the class SettingsDialog method showFolderSelect.
private void showFolderSelect(final String id) {
fileChooser.setMode(FileChooser.Mode.OPEN);
fileChooser.setMultiSelectionEnabled(false);
fileChooser.setSelectionMode(FileChooser.SelectionMode.DIRECTORIES);
fileChooser.setListener(new FileChooserAdapter() {
@Override
public void selected(Array<FileHandle> file) {
textFieldMap.get(id).setText(file.get(0).path());
}
});
getStage().addActor(fileChooser.fadeIn());
}
use of com.kotcrab.vis.ui.widget.file.FileChooserAdapter in project talos by rockbite.
the class ShaderAddon method buildMenu.
@Override
public void buildMenu(MenuBar menuBar) {
Menu menu = new Menu("Shader Graph");
MenuItem newFile = new MenuItem("New Shader");
menu.addItem(newFile);
MenuItem openFile = new MenuItem("Open Shader");
menu.addItem(openFile);
MenuItem exportRaw = new MenuItem("Export RAW");
menu.addItem(exportRaw);
MenuItem exportPNG = new MenuItem("Export PNG");
menu.addItem(exportPNG);
MenuItem exportSequence = new MenuItem("Export Sequence");
menu.addItem(exportSequence);
newFile.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
TalosMain.Instance().ProjectController().newProject(SHADER_PROJECT);
}
});
openFile.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
TalosMain.Instance().UIStage().openProjectAction(SHADER_PROJECT);
}
});
exportRaw.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
// export RAW logic
TalosMain.Instance().UIStage().showSaveFileChooser(".frag", new FileChooserAdapter() {
@Override
public void selected(Array<FileHandle> files) {
String fragShader = ((ShaderNodeStage) (nodeStage)).getFragShader();
FileHandle file = files.get(0);
file.writeString(fragShader, false);
}
});
}
});
exportPNG.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
// export RAW logic
TalosMain.Instance().UIStage().showSaveFileChooser(".png", new FileChooserAdapter() {
@Override
public void selected(Array<FileHandle> files) {
FileHandle file = files.get(0);
Pixmap pixmap = ((ShaderNodeStage) (nodeStage)).exportPixmap();
if (pixmap != null) {
PixmapIO.writePNG(file, pixmap);
pixmap.dispose();
}
}
});
}
});
exportSequence.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
TalosMain.Instance().UIStage().getStage().addActor(exportSequenceDialog.fadeIn());
}
});
menuBar.addMenu(menu);
}
use of com.kotcrab.vis.ui.widget.file.FileChooserAdapter in project talos by rockbite.
the class UIStage method saveAsProjectAction.
public void saveAsProjectAction() {
IProject projectType = TalosMain.Instance().ProjectController().getProject();
String defaultLocation = TalosMain.Instance().ProjectController().getLastDir("Save", projectType);
fileChooser.setDirectory(defaultLocation);
final String ext = projectType.getExtension();
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().saveProject(handle);
}
});
fileChooser.setDefaultFileName(TalosMain.Instance().ProjectController().currentTab.fileName);
stage.addActor(fileChooser.fadeIn());
}
use of com.kotcrab.vis.ui.widget.file.FileChooserAdapter in project talos by rockbite.
the class FileActorBinder method registerInner.
private void registerInner(Actor actor, String extension) {
extensionMap.put(actor, extension);
actor.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
TalosMain.Instance().UIStage().showFileChooser(extension, new FileChooserAdapter() {
@Override
public void selected(Array<FileHandle> file) {
String path = file.first().file().getAbsolutePath();
FileHandle handle = Gdx.files.absolute(path);
FileEvent fileEvent = Pools.obtain(FileEvent.class);
fileEvent.setFileHandle(handle);
actor.fire(fileEvent);
}
});
}
});
}
use of com.kotcrab.vis.ui.widget.file.FileChooserAdapter in project talos by rockbite.
the class ExportSequenceDialog method initContent.
private void initContent() {
fileName = new TextField("sequence", getSkin());
Table fileNameRow = makeRow("Name prefix", fileName);
add(fileNameRow).pad(5).left().expandX().padTop(10);
row();
Table pathBrowseField = new Table();
inputPathField = new TextField("", getSkin());
pathBrowseField.add(inputPathField).width(200);
TextButton browseInputBtn = new TextButton("Browse", getSkin());
pathBrowseField.add(browseInputBtn).padLeft(3);
Table pathRow = makeRow("Output Directory", pathBrowseField);
add(pathRow).pad(5).left().expandX().padTop(10);
row();
widthField = new TextField("256", getSkin());
Table widthRow = makeRow("Width: ", widthField);
add(widthRow).pad(5).left().expandX().padTop(10);
row();
heightFIeld = new TextField("256", getSkin());
Table heightRow = makeRow("Height: ", heightFIeld);
add(heightRow).pad(5).left().expandX().padTop(10);
row();
durationField = new TextField("1", getSkin());
Table durationRow = makeRow("Duration: ", durationField);
add(durationRow).pad(5).left().expandX().padTop(10);
row();
fpsField = new TextField("40", getSkin());
Table fpsRow = makeRow("FPS: ", fpsField);
add(fpsRow).pad(5).left().expandX().padTop(10);
row();
browseInputBtn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
fileChooser.setMode(FileChooser.Mode.OPEN);
fileChooser.setMultiSelectionEnabled(false);
fileChooser.setSelectionMode(FileChooser.SelectionMode.DIRECTORIES);
fileChooser.setListener(new FileChooserAdapter() {
@Override
public void selected(Array<FileHandle> file) {
inputPathField.setText(file.get(0).path());
}
});
getStage().addActor(fileChooser.fadeIn());
}
});
TextButton saveButton = new TextButton("Save", getSkin());
add(saveButton).right().padRight(5);
row();
saveButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
save();
}
});
}
Aggregations