use of com.talosvfx.talos.editor.assets.TalosAssetProvider in project talos by rockbite.
the class TextureDropModuleWrapper method read.
@Override
public void read(Json json, JsonValue jsonData) {
super.read(json, jsonData);
filePath = jsonData.getString("filePath", null);
regionName = jsonData.getString("regionName", null);
// hack for older version to patch broken files (we should do version transition logic and move it there later)
if (jsonData.has("fileName")) {
filePath = jsonData.getString("fileName");
regionName = filePath;
if (filePath.contains(".")) {
regionName = regionName.substring(0, regionName.lastIndexOf("."));
} else {
filePath = filePath + ".png";
}
}
final TalosAssetProvider assetProvider = TalosMain.Instance().TalosProject().getProjectAssetProvider();
final Sprite textureRegion = assetProvider.findAsset(regionName, Sprite.class);
if (textureRegion != null) {
setModuleRegion(regionName, textureRegion);
dropWidget.setDrawable(new TextureRegionDrawable(textureRegion));
} else {
// TalosMain.Instance().errorReporting.reportException(new GdxRuntimeException("Texture is missing on loading in all paths: " + regionName));
}
}
use of com.talosvfx.talos.editor.assets.TalosAssetProvider 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.assets.TalosAssetProvider 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.assets.TalosAssetProvider in project talos by rockbite.
the class ProjectSerializer method prereadhack.
/**
* Very naughty
* @param data
*/
public void prereadhack(String data) {
JsonReader jsonReader = new JsonReader();
final JsonValue parse = jsonReader.parse(data);
final JsonValue metaData = parse.get("metaData");
if (metaData != null) {
final JsonValue resourcePaths = metaData.get("resourcePaths");
if (resourcePaths != null) {
final TalosAssetProvider projectAssetProvider = TalosMain.Instance().TalosProject().getProjectAssetProvider();
for (JsonValue resourcePath : resourcePaths) {
projectAssetProvider.addUnknownResource(resourcePath.asString());
}
}
}
}
use of com.talosvfx.talos.editor.assets.TalosAssetProvider in project talos by rockbite.
the class TextureDropModuleWrapper method configureSlots.
@Override
protected void configureSlots() {
final TalosAssetProvider projectAssetProvider = TalosMain.Instance().TalosProject().getProjectAssetProvider();
defaultRegion = projectAssetProvider.findAsset("fire", TextureRegion.class);
dropWidget = new TextureDropWidget<AbstractModule>(defaultRegion, getSkin());
}
Aggregations