Search in sources :

Example 1 with SceneEditorWorkspace

use of com.talosvfx.talos.editor.addons.scene.SceneEditorWorkspace in project talos by rockbite.

the class Scene method getListOfProperties.

@Override
public Array<PropertyWidget> getListOfProperties() {
    Array<PropertyWidget> properties = new Array<>();
    LabelWidget labelWidget = new LabelWidget("Name", new Supplier<String>() {

        @Override
        public String get() {
            FileHandle file = Gdx.files.absolute(path);
            String name = file.nameWithoutExtension();
            return name;
        }
    });
    final SceneEditorWorkspace workspace = SceneEditorAddon.get().workspace;
    DynamicItemListWidget itemListWidget = new DynamicItemListWidget("Layers", new Supplier<Array<DynamicItemListWidget.ItemData>>() {

        @Override
        public Array<DynamicItemListWidget.ItemData> get() {
            Array<DynamicItemListWidget.ItemData> list = new Array<>();
            for (String layerName : workspace.layers) {
                DynamicItemListWidget.ItemData itemData = new DynamicItemListWidget.ItemData(layerName);
                if (layerName.equals("Default")) {
                    itemData.canDelete = false;
                }
                list.add(itemData);
            }
            return list;
        }
    }, new PropertyWidget.ValueChanged<Array<DynamicItemListWidget.ItemData>>() {

        @Override
        public void report(Array<DynamicItemListWidget.ItemData> value) {
            workspace.layers.clear();
            for (DynamicItemListWidget.ItemData item : value) {
                workspace.layers.add(item.text);
            }
            Notifications.fireEvent(Notifications.obtainEvent(LayerListUpdated.class));
        }
    });
    itemListWidget.defaultItemName = "New Layer";
    properties.add(labelWidget);
    properties.add(itemListWidget);
    return properties;
}
Also used : SceneEditorWorkspace(com.talosvfx.talos.editor.addons.scene.SceneEditorWorkspace) FileHandle(com.badlogic.gdx.files.FileHandle)

Example 2 with SceneEditorWorkspace

use of com.talosvfx.talos.editor.addons.scene.SceneEditorWorkspace in project talos by rockbite.

the class AssetImporter method createAssetInstance.

public static void createAssetInstance(FileHandle fileHandle, GameObject parent) {
    if (fileHandle.extension().equals("png")) {
        // check if non imported nine patch
        if (fileHandle.name().endsWith(".9.png")) {
            // import it
            attemptToImport(fileHandle);
        } else {
            importerMap.get(AssetType.SPRITE).makeInstance(fileHandle, parent);
        }
    }
    if (fileHandle.extension().equals("tls")) {
        importerMap.get(AssetType.TLS).makeInstance(fileHandle, parent);
    }
    if (fileHandle.extension().equals("p")) {
        importerMap.get(AssetType.TLS).makeInstance(fileHandle, parent);
    }
    if (fileHandle.extension().equals("skel")) {
        importerMap.get(AssetType.SPINE).makeInstance(fileHandle, parent);
    }
    if (fileHandle.extension().equals("prefab")) {
        SceneEditorWorkspace workspace = SceneEditorAddon.get().workspace;
        Vector2 sceneCords = workspace.getMouseCordsOnScene();
        Prefab prefab = Prefab.from(fileHandle);
        GameObject gameObject = workspace.createFromPrefab(prefab, sceneCords, parent);
    }
}
Also used : SceneEditorWorkspace(com.talosvfx.talos.editor.addons.scene.SceneEditorWorkspace) Vector2(com.badlogic.gdx.math.Vector2) GameObject(com.talosvfx.talos.editor.addons.scene.logic.GameObject) Prefab(com.talosvfx.talos.editor.addons.scene.logic.Prefab)

Example 3 with SceneEditorWorkspace

use of com.talosvfx.talos.editor.addons.scene.SceneEditorWorkspace in project talos by rockbite.

the class AssetImporter method saveMetadata.

public static void saveMetadata(AMetadata aMetadata) {
    FileHandle assetHandle = aMetadata.currentFile;
    if (assetHandle != null && assetHandle.exists()) {
        FileHandle metadataHandle = getMetadataHandleFor(assetHandle);
        saveMetadata(metadataHandle, aMetadata);
        SceneEditorWorkspace workspace = SceneEditorAddon.get().workspace;
        workspace.clearMetadata(AssetImporter.relative(assetHandle.path()));
    }
}
Also used : SceneEditorWorkspace(com.talosvfx.talos.editor.addons.scene.SceneEditorWorkspace) FileHandle(com.badlogic.gdx.files.FileHandle)

Example 4 with SceneEditorWorkspace

use of com.talosvfx.talos.editor.addons.scene.SceneEditorWorkspace in project talos by rockbite.

the class SpineImporter method makeInstance.

@Override
public void makeInstance(FileHandle asset, GameObject parent) {
    SceneEditorWorkspace workspace = SceneEditorAddon.get().workspace;
    Vector2 sceneCords = workspace.getMouseCordsOnScene();
    GameObject gameObject = workspace.createObjectByTypeName("spine", sceneCords, parent);
    // now do some fancy component configuring from this guy
    SpineRendererComponent spineRendererComponent = gameObject.getComponent(SpineRendererComponent.class);
    SkeletonComponent skeletonComponent = gameObject.getComponent(SkeletonComponent.class);
    SpineMetadata spineMetadata = AssetImporter.readMetadataFor(asset, SpineMetadata.class);
    // read this from meta instead later
    spineRendererComponent.path = spineMetadata.atlasPath;
    skeletonComponent.path = AssetImporter.relative(asset.path());
    spineRendererComponent.reloadAtlas();
    skeletonComponent.setAtlas(spineRendererComponent.textureAtlas);
    skeletonComponent.reloadData(spineMetadata.scale);
}
Also used : SceneEditorWorkspace(com.talosvfx.talos.editor.addons.scene.SceneEditorWorkspace) Vector2(com.badlogic.gdx.math.Vector2) SpineMetadata(com.talosvfx.talos.editor.addons.scene.utils.metadata.SpineMetadata) GameObject(com.talosvfx.talos.editor.addons.scene.logic.GameObject) SkeletonComponent(com.talosvfx.talos.editor.addons.scene.logic.components.SkeletonComponent) SpineRendererComponent(com.talosvfx.talos.editor.addons.scene.logic.components.SpineRendererComponent)

Example 5 with SceneEditorWorkspace

use of com.talosvfx.talos.editor.addons.scene.SceneEditorWorkspace 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)

Aggregations

SceneEditorWorkspace (com.talosvfx.talos.editor.addons.scene.SceneEditorWorkspace)7 GameObject (com.talosvfx.talos.editor.addons.scene.logic.GameObject)5 Vector2 (com.badlogic.gdx.math.Vector2)4 FileHandle (com.badlogic.gdx.files.FileHandle)3 Texture (com.badlogic.gdx.graphics.Texture)1 MainRenderer (com.talosvfx.talos.editor.addons.scene.MainRenderer)1 Prefab (com.talosvfx.talos.editor.addons.scene.logic.Prefab)1 ParticleComponent (com.talosvfx.talos.editor.addons.scene.logic.components.ParticleComponent)1 SkeletonComponent (com.talosvfx.talos.editor.addons.scene.logic.components.SkeletonComponent)1 SpineRendererComponent (com.talosvfx.talos.editor.addons.scene.logic.components.SpineRendererComponent)1 SpriteRendererComponent (com.talosvfx.talos.editor.addons.scene.logic.components.SpriteRendererComponent)1 TransformComponent (com.talosvfx.talos.editor.addons.scene.logic.components.TransformComponent)1 SpineMetadata (com.talosvfx.talos.editor.addons.scene.utils.metadata.SpineMetadata)1 SpriteMetadata (com.talosvfx.talos.editor.addons.scene.utils.metadata.SpriteMetadata)1 TlsMetadata (com.talosvfx.talos.editor.addons.scene.utils.metadata.TlsMetadata)1