Search in sources :

Example 6 with FileChooser

use of com.kotcrab.vis.ui.widget.file.FileChooser in project bladecoder-adventure-engine by bladecoder.

the class ToolsWindow method exportTSV.

private void exportTSV() {
    FileChooser fileChooser = new FileChooser(Mode.SAVE);
    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 {
                // fileChooser.setTitle("Select the file to export the
                // project texts");
                I18NUtils.exportTSV(Ctx.project.getAssetPath() + Project.MODEL_PATH, files.get(0).file().getAbsolutePath(), Ctx.project.getChapter().getId(), "default");
                Message.showMsg(getStage(), files.get(0).file().getName() + " exported sucessfully.", 4);
            } catch (IOException e) {
                Message.showMsg(getStage(), "There was a problem generating the .tsv file.", 4);
                EditorLogger.printStackTrace(e);
            }
        }

        @Override
        public void canceled() {
        }
    });
}
Also used : FileChooserListener(com.kotcrab.vis.ui.widget.file.FileChooserListener) FileHandle(com.badlogic.gdx.files.FileHandle) FileChooser(com.kotcrab.vis.ui.widget.file.FileChooser) IOException(java.io.IOException)

Example 7 with FileChooser

use of com.kotcrab.vis.ui.widget.file.FileChooser in project bladecoder-adventure-engine by bladecoder.

the class ToolsWindow method createUIAtlas.

protected void createUIAtlas() {
    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) {
            List<String> res = Ctx.project.getResolutions();
            for (String r : res) {
                float scale = Float.parseFloat(r);
                try {
                    int maxWH = (int) (ImageUtils.getRecommendedAtlasSize() * scale);
                    ImageUtils.createAtlas(files.get(0).file().getAbsolutePath(), Ctx.project.getAssetPath() + Project.UI_PATH + "/" + r, "ui" + ".atlas", scale, maxWH, maxWH, TextureFilter.Linear, TextureFilter.Nearest, "png", false);
                } catch (IOException e) {
                    EditorLogger.error(e.getMessage());
                    Message.showMsgDialog(getStage(), "Error creating atlas", e.getMessage());
                    return;
                }
            }
            Message.showMsg(getStage(), "UI Atlas created sucessfully.", 4);
        }

        @Override
        public void canceled() {
        }
    });
}
Also used : FileChooserListener(com.kotcrab.vis.ui.widget.file.FileChooserListener) FileHandle(com.badlogic.gdx.files.FileHandle) FileChooser(com.kotcrab.vis.ui.widget.file.FileChooser) ArrayList(java.util.ArrayList) List(java.util.List) IOException(java.io.IOException)

Example 8 with FileChooser

use of com.kotcrab.vis.ui.widget.file.FileChooser in project talos by rockbite.

the class UIStage method initFileChoosers.

private void initFileChoosers() {
    fileChooser = new FileChooser(FileChooser.Mode.SAVE);
    fileChooser.setBackground(skin.getDrawable("window-noborder"));
}
Also used : FileChooser(com.kotcrab.vis.ui.widget.file.FileChooser)

Example 9 with FileChooser

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

Example 10 with FileChooser

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

Aggregations

FileChooser (com.kotcrab.vis.ui.widget.file.FileChooser)16 FileHandle (com.badlogic.gdx.files.FileHandle)14 FileChooserAdapter (com.kotcrab.vis.ui.widget.file.FileChooserAdapter)9 IOException (java.io.IOException)6 FileChooserListener (com.kotcrab.vis.ui.widget.file.FileChooserListener)5 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)3 Array (com.badlogic.gdx.utils.Array)3 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)2 FileTypeFilter (com.kotcrab.vis.ui.widget.file.FileTypeFilter)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)1 JsonReader (com.badlogic.gdx.utils.JsonReader)1 JsonValue (com.badlogic.gdx.utils.JsonValue)1 CustomList (com.bladecoder.engineeditor.ui.panels.CustomList)1 SingleFileChooserListener (com.kotcrab.vis.ui.widget.file.SingleFileChooserListener)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1