Search in sources :

Example 6 with FileChooserAdapter

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());
}
Also used : FileHandle(com.badlogic.gdx.files.FileHandle) FileChooserAdapter(com.kotcrab.vis.ui.widget.file.FileChooserAdapter)

Example 7 with FileChooserAdapter

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);
}
Also used : Array(com.badlogic.gdx.utils.Array) ShaderNodeStage(com.talosvfx.talos.editor.addons.shader.workspace.ShaderNodeStage) FileHandle(com.badlogic.gdx.files.FileHandle) FileChooserAdapter(com.kotcrab.vis.ui.widget.file.FileChooserAdapter) MenuItem(com.kotcrab.vis.ui.widget.MenuItem) Menu(com.kotcrab.vis.ui.widget.Menu) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) Pixmap(com.badlogic.gdx.graphics.Pixmap)

Example 8 with FileChooserAdapter

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());
}
Also used : FileHandle(com.badlogic.gdx.files.FileHandle) FileChooserAdapter(com.kotcrab.vis.ui.widget.file.FileChooserAdapter) FileFilter(java.io.FileFilter) File(java.io.File) IProject(com.talosvfx.talos.editor.project.IProject)

Example 9 with FileChooserAdapter

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);
                }
            });
        }
    });
}
Also used : Array(com.badlogic.gdx.utils.Array) FileHandle(com.badlogic.gdx.files.FileHandle) FileChooserAdapter(com.kotcrab.vis.ui.widget.file.FileChooserAdapter) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 10 with FileChooserAdapter

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();
        }
    });
}
Also used : Array(com.badlogic.gdx.utils.Array) FileChooserAdapter(com.kotcrab.vis.ui.widget.file.FileChooserAdapter) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Aggregations

FileChooserAdapter (com.kotcrab.vis.ui.widget.file.FileChooserAdapter)18 FileHandle (com.badlogic.gdx.files.FileHandle)16 FileChooser (com.kotcrab.vis.ui.widget.file.FileChooser)9 Array (com.badlogic.gdx.utils.Array)5 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)4 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)4 File (java.io.File)3 FileFilter (java.io.FileFilter)3 IProject (com.talosvfx.talos.editor.project.IProject)2 Pixmap (com.badlogic.gdx.graphics.Pixmap)1 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)1 JsonReader (com.badlogic.gdx.utils.JsonReader)1 JsonValue (com.badlogic.gdx.utils.JsonValue)1 Menu (com.kotcrab.vis.ui.widget.Menu)1 MenuItem (com.kotcrab.vis.ui.widget.MenuItem)1 FileTypeFilter (com.kotcrab.vis.ui.widget.file.FileTypeFilter)1 ShaderNodeStage (com.talosvfx.talos.editor.addons.shader.workspace.ShaderNodeStage)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1