use of com.talosvfx.talos.editor.project.FileTracker in project talos by rockbite.
the class TextureDropModuleWrapper method fileDrop.
@Override
public void fileDrop(String[] paths, float x, float y) {
if (paths.length == 1) {
String resourcePath = paths[0];
FileHandle fileHandle = Gdx.files.absolute(resourcePath);
final String extension = fileHandle.extension();
if (extension.endsWith("png") || extension.endsWith("jpg")) {
final Texture texture = new Texture(fileHandle);
final Sprite region = new Sprite(texture);
TalosMain.Instance().TalosProject().getProjectAssetProvider().addToAtlas(fileHandle.nameWithoutExtension(), region);
setModuleRegion(fileHandle.nameWithoutExtension(), region);
dropWidget.setDrawable(new TextureRegionDrawable(region));
regionName = fileHandle.nameWithoutExtension();
filePath = fileHandle.path();
TalosMain.Instance().ProjectController().setDirty();
TalosMain.Instance().FileTracker().trackFile(fileHandle, new FileTracker.Tracker() {
@Override
public void updated(FileHandle handle) {
final TalosAssetProvider projectAssetProvider = TalosMain.Instance().TalosProject().getProjectAssetProvider();
Sprite region = projectAssetProvider.replaceRegion(handle);
setModuleRegion(handle.nameWithoutExtension(), region);
dropWidget.setDrawable(new TextureRegionDrawable(region));
}
});
}
}
}
use of com.talosvfx.talos.editor.project.FileTracker in project talos by rockbite.
the class VectorFieldModuleWrapper method fileDrop.
@Override
public void fileDrop(String[] paths, float x, float y) {
if (paths.length > 0) {
String path = paths[0];
FileHandle handle = Gdx.files.absolute(path);
VectorField vectorField = new VectorField();
vectorField.setBakedData(handle);
TalosAssetProvider assetProvider = TalosMain.Instance().TalosProject().getProjectAssetProvider();
assetProvider.addVectorField(handle.nameWithoutExtension(), vectorField);
setVectorField(vectorField, handle.nameWithoutExtension());
TalosMain.Instance().FileTracker().trackFile(handle, new FileTracker.Tracker() {
@Override
public void updated(FileHandle handle) {
VectorField vectorField = new VectorField();
vectorField.setBakedData(handle);
TalosAssetProvider assetProvider = TalosMain.Instance().TalosProject().getProjectAssetProvider();
assetProvider.addVectorField(handle.nameWithoutExtension(), vectorField);
setVectorField(vectorField, handle.nameWithoutExtension());
}
});
}
}
use of com.talosvfx.talos.editor.project.FileTracker in project talos by rockbite.
the class BvBWorkspace method registerTalosAssets.
public void registerTalosAssets(FileHandle handle) {
JsonReader jsonReader = new JsonReader();
final JsonValue parse = jsonReader.parse(handle);
final JsonValue metaData = parse.get("metadata");
final JsonValue resourcePaths = metaData.get("resources");
if (resourcePaths == null) {
return;
}
for (JsonValue path : resourcePaths) {
String name = path.asString();
// this is handling only PNG's which is bad
String possiblePath = handle.parent() + File.separator + name + ".png";
FileHandle fileHandle = TalosMain.Instance().ProjectController().findFile(possiblePath);
if (fileHandle == null) {
throw new GdxRuntimeException("Can't find: " + name + ".png in path: \n" + possiblePath);
}
TalosMain.Instance().FileTracker().trackFile(fileHandle, new FileTracker.Tracker() {
@Override
public void updated(FileHandle handle) {
// this is not good either... but whatever
}
});
}
}
Aggregations