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());
}
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;
}
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();
}
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;
}
Aggregations