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