Search in sources :

Example 1 with IProject

use of com.talosvfx.talos.editor.project.IProject 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 2 with IProject

use of com.talosvfx.talos.editor.project.IProject in project talos by rockbite.

the class BvBAddon method projectFileDrop.

@Override
public boolean projectFileDrop(FileHandle handle) {
    if (handle.extension().equals("bvb")) {
        TalosMain.Instance().ProjectController().setProject(getProjectType());
        TalosMain.Instance().ProjectController().loadProject(handle);
        return true;
    }
    IProject currProjectType = TalosMain.Instance().ProjectController().getProject();
    if (currProjectType == BVB) {
        if (handle.extension().equals("json")) {
            // cool let's load skeletal animation
            workspace.setSkeleton(handle);
            TalosMain.Instance().FileTracker().trackFile(handle, spineTracker);
            return true;
        }
        if (handle.extension().equals("p")) {
            // adding particle effect? I can do that
            workspace.addParticle(handle);
            TalosMain.Instance().FileTracker().trackFile(handle, particleTracker);
            return true;
        }
    }
    return false;
}
Also used : IProject(com.talosvfx.talos.editor.project.IProject)

Example 3 with IProject

use of com.talosvfx.talos.editor.project.IProject in project talos by rockbite.

the class CurveGizmo method draw.

@Override
public void draw(Batch batch, float parentAlpha) {
    if (gameObject.hasComponent(CurveComponent.class)) {
        CurveComponent curve = gameObject.getComponent(CurveComponent.class);
        Array<Vector2> points = curve.points;
        if (selected) {
            for (int i = 0; i < points.size; i++) {
                if (i % 3 == 0) {
                    drawCircle(toWorld(points.get(i)), batch);
                }
            }
        }
        for (int i = 0; i < curve.getNumSegments(); i++) {
            Vector2[] pointsInSegment = curve.getPointsInSegment(i);
            if (selected) {
                Color color = Color.GRAY;
                if (curve.automaticControl) {
                    color = darkerLine;
                }
                ctrlOne.set(pointsInSegment[1]);
                ctrlTwo.set(pointsInSegment[2]);
                if (animatingAnchor >= 0) {
                    if (i * 3 + 2 == animatingAnchor - 1) {
                        tmp.set(ctrlTwo).sub(curve.points.get(animatingAnchor)).scl(animateActor.getX()).add(curve.points.get(animatingAnchor));
                        ctrlTwo.set(tmp);
                    } else if (i * 3 + 1 == animatingAnchor + 1) {
                        tmp.set(ctrlOne).sub(curve.points.get(animatingAnchor)).scl(animateActor.getX()).add(curve.points.get(animatingAnchor));
                        ctrlOne.set(tmp);
                    }
                }
                drawLine(batch, toWorld(ctrlOne, tmp2), toWorld(pointsInSegment[0], tmp3), color);
                drawLine(batch, toWorld(ctrlTwo, tmp2), toWorld(pointsInSegment[3], tmp3), color);
                if (!curve.automaticControl) {
                    drawCircle(toWorld(ctrlOne), batch);
                    drawCircle(toWorld(ctrlTwo), batch);
                }
            }
            bezier.set(pointsInSegment);
            Vector2 prev = bezier.valueAt(tmp, 0);
            float step = 1f / 20f;
            for (float t = step; t <= 1f; t += step) {
                Vector2 curr = bezier.valueAt(tmp2, t);
                if (selectedSegmentIndex == i) {
                    drawLine(batch, toWorld(prev, tmp3), toWorld(curr, tmp4), Color.YELLOW);
                } else {
                    drawLine(batch, toWorld(prev, tmp3), toWorld(curr, tmp4), Color.RED);
                }
                prev.set(curr);
            }
            Vector2 curr = bezier.valueAt(tmp2, 1f);
            if (selectedSegmentIndex == i) {
                drawLine(batch, toWorld(prev, tmp3), toWorld(curr, tmp4), Color.YELLOW);
            } else {
                drawLine(batch, toWorld(prev, tmp3), toWorld(curr, tmp4), Color.RED);
            }
        }
    }
    if (Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE)) {
        IProject project = TalosMain.Instance().ProjectController().getProject();
        if (project instanceof SceneEditorProject) {
            SceneEditorProject sceneEditorProject = (SceneEditorProject) project;
            sceneEditorProject.sceneEditorAddon.workspace.requestSelectionClear();
        }
    }
}
Also used : CurveComponent(com.talosvfx.talos.editor.addons.scene.logic.components.CurveComponent) Vector2(com.badlogic.gdx.math.Vector2) SceneEditorProject(com.talosvfx.talos.editor.addons.scene.SceneEditorProject) Color(com.badlogic.gdx.graphics.Color) IProject(com.talosvfx.talos.editor.project.IProject)

Example 4 with IProject

use of com.talosvfx.talos.editor.project.IProject in project talos by rockbite.

the class ShaderAddon method projectFileDrop.

@Override
public boolean projectFileDrop(FileHandle handle) {
    // a shader project should be loaded, but any other files go straight to modules
    IProject currProjectType = TalosMain.Instance().ProjectController().getProject();
    if (currProjectType == SHADER_PROJECT) {
        AssetFileDroppedEvent event = Notifications.obtainEvent(AssetFileDroppedEvent.class);
        event.setFileHandle(handle);
        event.setScreenPos(Gdx.input.getX(), Gdx.input.getY());
        Notifications.fireEvent(event);
    }
    return false;
}
Also used : AssetFileDroppedEvent(com.talosvfx.talos.editor.notifications.events.AssetFileDroppedEvent) IProject(com.talosvfx.talos.editor.project.IProject)

Example 5 with IProject

use of com.talosvfx.talos.editor.project.IProject 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());
}
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)

Aggregations

IProject (com.talosvfx.talos.editor.project.IProject)5 FileHandle (com.badlogic.gdx.files.FileHandle)2 FileChooserAdapter (com.kotcrab.vis.ui.widget.file.FileChooserAdapter)2 File (java.io.File)2 FileFilter (java.io.FileFilter)2 Color (com.badlogic.gdx.graphics.Color)1 Vector2 (com.badlogic.gdx.math.Vector2)1 SceneEditorProject (com.talosvfx.talos.editor.addons.scene.SceneEditorProject)1 CurveComponent (com.talosvfx.talos.editor.addons.scene.logic.components.CurveComponent)1 AssetFileDroppedEvent (com.talosvfx.talos.editor.notifications.events.AssetFileDroppedEvent)1