Search in sources :

Example 1 with TlsMetadata

use of com.talosvfx.talos.editor.addons.scene.utils.metadata.TlsMetadata in project talos by rockbite.

the class ProjectExplorerWidget method showContextMenu.

public void showContextMenu(Array<FileHandle> files) {
    contextualMenu.clearItems();
    contextualMenu.addItem("Cut", new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            invokeCut(files);
        }
    });
    contextualMenu.addItem("Copy", new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            invokeCopy(files);
        }
    });
    contextualMenu.addItem("Paste", new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            FileHandle destination = files.first();
            invokePaste(destination);
        }
    });
    contextualMenu.addSeparator();
    contextualMenu.addItem("Rename", new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            String path = files.first().path();
            if (path != null) {
                FileHandle handle = Gdx.files.absolute(path);
                if (handle.isDirectory()) {
                    if (nodes.get(path) != null) {
                        RowWidget widget = (RowWidget) nodes.get(path).getActor();
                        widget.label.setEditMode();
                    }
                } else {
                    // check if its in the other guy
                    directoryViewWidget.startRenameFor(handle);
                }
            }
        }
    });
    contextualMenu.addItem("Delete", new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            String path = files.first().path();
            Array<String> paths = new Array<>();
            for (FileHandle file : files) {
                paths.add(file.path());
            }
            deletePath(paths);
        }
    });
    if (files.size == 1 && files.first().isDirectory()) {
        contextualMenu.addSeparator();
        PopupMenu popupMenu = new PopupMenu();
        createSubMenuItem(popupMenu, "New Directory", new ClickListener() {

            @Override
            public void clicked(InputEvent event, float x, float y) {
                String path = files.first().path();
                if (path != null) {
                    FileHandle handle = Gdx.files.absolute(path);
                    if (handle.isDirectory()) {
                        FileHandle newHandle = findAvailableHandleIn(handle, "New Directory");
                        newHandle.mkdirs();
                        loadDirectoryTree((String) rootNode.getObject());
                        FilteredTree.Node newNode = nodes.get(newHandle.path());
                        expand(newHandle.path());
                        select(newNode.getParent());
                        RowWidget widget = (RowWidget) newNode.getActor();
                        directoryViewWidget.reload();
                        directoryViewWidget.startRenameFor(newHandle);
                    }
                }
            }
        });
        createSubMenuItem(popupMenu, "New Scene", new ClickListener() {

            @Override
            public void clicked(InputEvent event, float x, float y) {
                String path = files.first().path();
                FileHandle sceneDestination = AssetImporter.suggestNewName(path, "New Scene", "scn");
                Scene mainScene = new Scene(sceneDestination.path());
                mainScene.save();
                directoryViewWidget.reload();
            }
        });
        createSubMenuItem(popupMenu, "Particle Effect", new ClickListener() {

            @Override
            public void clicked(InputEvent event, float x, float y) {
                String path = files.first().path();
                FileHandle tlsDestination = AssetImporter.suggestNewName(path, "New Effect", "tls");
                FileHandle metadataHandle = AssetImporter.makeSimilar(tlsDestination, "meta");
                FileHandle originalTls = Gdx.files.internal("addons/scene/missing/sample.tls");
                originalTls.copyTo(tlsDestination);
                TlsMetadata metadata = new TlsMetadata();
                metadata.tlsChecksum = AssetImporter.checkSum(tlsDestination);
                AssetImporter.saveMetadata(metadataHandle, metadata);
                directoryViewWidget.reload();
            }
        });
        MenuItem createMenu = contextualMenu.addItem("Create", new ClickListener() {

            @Override
            public void clicked(InputEvent event, float x, float y) {
                super.clicked(event, x, y);
            }
        });
        createMenu.setSubMenu(popupMenu);
    }
    contextualMenu.show(getStage());
}
Also used : FileHandle(com.badlogic.gdx.files.FileHandle) TlsMetadata(com.talosvfx.talos.editor.addons.scene.utils.metadata.TlsMetadata) MenuItem(com.kotcrab.vis.ui.widget.MenuItem) Scene(com.talosvfx.talos.editor.addons.scene.logic.Scene) Array(com.badlogic.gdx.utils.Array) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) PopupMenu(com.kotcrab.vis.ui.widget.PopupMenu)

Example 2 with TlsMetadata

use of com.talosvfx.talos.editor.addons.scene.utils.metadata.TlsMetadata in project talos by rockbite.

the class TlsImporter method importAsset.

@Override
public FileHandle importAsset(FileHandle fileHandle, FileHandle destinationDir) {
    FileHandle importedAsset = importAssetFile(fileHandle, destinationDir);
    FileHandle metadataHandle = AssetImporter.getMetadataHandleFor(importedAsset);
    TlsMetadata metadata = AssetImporter.readMetadata(metadataHandle, TlsMetadata.class);
    metadata.tlsChecksum = AssetImporter.checkSum(importedAsset);
    AssetImporter.saveMetadata(metadataHandle, metadata);
    exportTlsFile(importedAsset);
    return importedAsset;
}
Also used : FileHandle(com.badlogic.gdx.files.FileHandle) TlsMetadata(com.talosvfx.talos.editor.addons.scene.utils.metadata.TlsMetadata)

Example 3 with TlsMetadata

use of com.talosvfx.talos.editor.addons.scene.utils.metadata.TlsMetadata in project talos by rockbite.

the class TlsImporter method makeInstance.

@Override
public void makeInstance(FileHandle asset, GameObject parent) {
    if (!AssetImporter.getMetadataHandleFor(asset).exists()) {
        createMetadataFor(asset);
    }
    TlsMetadata metadata = AssetImporter.readMetadataFor(asset, TlsMetadata.class);
    if (asset.extension().equals("tls")) {
        // if p doesnot exist, create it
        FileHandle pHandle = AssetImporter.makeSimilar(asset, "p");
        if (!pHandle.exists()) {
            // create
            exportTlsFile(asset);
        }
        asset = pHandle;
    }
    SceneEditorWorkspace workspace = SceneEditorAddon.get().workspace;
    Vector2 sceneCords = workspace.getMouseCordsOnScene();
    GameObject gameObject = workspace.createObjectByTypeName("particle", sceneCords, parent);
    ParticleComponent component = gameObject.getComponent(ParticleComponent.class);
    component.path = AssetImporter.relative(AssetImporter.makeSimilar(asset, "p").path());
    component.linkedTo = AssetImporter.relative(AssetImporter.makeSimilar(asset, "tls").path());
    component.reloadDescriptor();
}
Also used : ParticleComponent(com.talosvfx.talos.editor.addons.scene.logic.components.ParticleComponent) SceneEditorWorkspace(com.talosvfx.talos.editor.addons.scene.SceneEditorWorkspace) Vector2(com.badlogic.gdx.math.Vector2) TlsMetadata(com.talosvfx.talos.editor.addons.scene.utils.metadata.TlsMetadata) FileHandle(com.badlogic.gdx.files.FileHandle) GameObject(com.talosvfx.talos.editor.addons.scene.logic.GameObject)

Example 4 with TlsMetadata

use of com.talosvfx.talos.editor.addons.scene.utils.metadata.TlsMetadata in project talos by rockbite.

the class TlsImporter method createMetadataFor.

@Override
public FileHandle createMetadataFor(FileHandle handle) {
    FileHandle metadataHandle = AssetImporter.getMetadataHandleFor(handle);
    TlsMetadata metadata = new TlsMetadata();
    AssetImporter.saveMetadata(metadataHandle, metadata);
    return metadataHandle;
}
Also used : FileHandle(com.badlogic.gdx.files.FileHandle) TlsMetadata(com.talosvfx.talos.editor.addons.scene.utils.metadata.TlsMetadata)

Aggregations

FileHandle (com.badlogic.gdx.files.FileHandle)4 TlsMetadata (com.talosvfx.talos.editor.addons.scene.utils.metadata.TlsMetadata)4 Vector2 (com.badlogic.gdx.math.Vector2)1 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)1 Array (com.badlogic.gdx.utils.Array)1 MenuItem (com.kotcrab.vis.ui.widget.MenuItem)1 PopupMenu (com.kotcrab.vis.ui.widget.PopupMenu)1 SceneEditorWorkspace (com.talosvfx.talos.editor.addons.scene.SceneEditorWorkspace)1 GameObject (com.talosvfx.talos.editor.addons.scene.logic.GameObject)1 Scene (com.talosvfx.talos.editor.addons.scene.logic.Scene)1 ParticleComponent (com.talosvfx.talos.editor.addons.scene.logic.components.ParticleComponent)1