Search in sources :

Example 1 with ButtonPropertyWidget

use of com.talosvfx.talos.editor.widgets.propertyWidgets.ButtonPropertyWidget in project talos by rockbite.

the class ParticleComponent method getListOfProperties.

@Override
public Array<PropertyWidget> getListOfProperties() {
    Array<PropertyWidget> properties = new Array<>();
    AssetSelectWidget descriptorWidget = new AssetSelectWidget("Effect", "p", new Supplier<String>() {

        @Override
        public String get() {
            FileHandle fileHandle = Gdx.files.absolute(path);
            return fileHandle.path();
        }
    }, new PropertyWidget.ValueChanged<String>() {

        @Override
        public void report(String value) {
            path = value;
            reloadDescriptor();
        }
    });
    ButtonPropertyWidget<String> linkedToWidget = new ButtonPropertyWidget<String>("Effect Project", "Edit", new ButtonPropertyWidget.ButtonListener<String>() {

        @Override
        public void clicked(ButtonPropertyWidget<String> widget) {
            String link = widget.getValue();
            if (link.isEmpty()) {
                FileHandle sample = Gdx.files.internal("addons/scene/missing/sample.tls");
                FileHandle thisEffect = AssetImporter.get(path);
                FileHandle destination;
                if (!path.isEmpty() && thisEffect.exists()) {
                // idk which scenario is this
                } else {
                    String projectPath = SceneEditorAddon.get().workspace.getProjectPath();
                    destination = AssetImporter.attemptToImport(sample);
                    FileHandle pHandle = AssetImporter.makeSimilar(destination, "p");
                    FileHandle texture = Gdx.files.internal("addons/scene/missing/white.png");
                    FileHandle textureDst = Gdx.files.absolute(projectPath + File.separator + "assets/white.png");
                    texture.copyTo(textureDst);
                    path = pHandle.path();
                    linkedTo = destination.path();
                    Notifications.fireEvent(Notifications.obtainEvent(ComponentUpdated.class).set(ParticleComponent.this, false));
                    TalosMain.Instance().ProjectController().setProject(ProjectController.TLS);
                    TalosMain.Instance().ProjectController().loadProject(destination);
                }
            } else {
                FileHandle fileHandle = AssetImporter.get(link);
                TalosMain.Instance().ProjectController().setProject(ProjectController.TLS);
                TalosMain.Instance().ProjectController().loadProject(fileHandle);
            }
        }
    }, new Supplier<String>() {

        @Override
        public String get() {
            return linkedTo;
        }
    }, new PropertyWidget.ValueChanged<String>() {

        @Override
        public void report(String value) {
            linkedTo = value;
        }
    });
    properties.add(descriptorWidget);
    properties.add(linkedToWidget);
    properties.addAll(super.getListOfProperties());
    return properties;
}
Also used : ButtonPropertyWidget(com.talosvfx.talos.editor.widgets.propertyWidgets.ButtonPropertyWidget) FileHandle(com.badlogic.gdx.files.FileHandle) AssetSelectWidget(com.talosvfx.talos.editor.addons.scene.widgets.property.AssetSelectWidget) PropertyWidget(com.talosvfx.talos.editor.widgets.propertyWidgets.PropertyWidget) ButtonPropertyWidget(com.talosvfx.talos.editor.widgets.propertyWidgets.ButtonPropertyWidget) Array(com.badlogic.gdx.utils.Array) ComponentUpdated(com.talosvfx.talos.editor.addons.scene.events.ComponentUpdated)

Example 2 with ButtonPropertyWidget

use of com.talosvfx.talos.editor.widgets.propertyWidgets.ButtonPropertyWidget in project talos by rockbite.

the class FilePropertyProvider method getListOfProperties.

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

        @Override
        public String get() {
            return fileHandle.name();
        }
    });
    ButtonPropertyWidget<String> actionWidget = new ButtonPropertyWidget<String>("action", "Open", new ButtonPropertyWidget.ButtonListener<String>() {

        @Override
        public void clicked(ButtonPropertyWidget<String> widget) {
            AssetImporter.fileOpen(fileHandle);
        }
    });
    properties.add(nameWidget);
    properties.add(actionWidget);
    return properties;
}
Also used : Array(com.badlogic.gdx.utils.Array) ButtonPropertyWidget(com.talosvfx.talos.editor.widgets.propertyWidgets.ButtonPropertyWidget) LabelWidget(com.talosvfx.talos.editor.widgets.propertyWidgets.LabelWidget) PropertyWidget(com.talosvfx.talos.editor.widgets.propertyWidgets.PropertyWidget) ButtonPropertyWidget(com.talosvfx.talos.editor.widgets.propertyWidgets.ButtonPropertyWidget)

Aggregations

Array (com.badlogic.gdx.utils.Array)2 ButtonPropertyWidget (com.talosvfx.talos.editor.widgets.propertyWidgets.ButtonPropertyWidget)2 PropertyWidget (com.talosvfx.talos.editor.widgets.propertyWidgets.PropertyWidget)2 FileHandle (com.badlogic.gdx.files.FileHandle)1 ComponentUpdated (com.talosvfx.talos.editor.addons.scene.events.ComponentUpdated)1 AssetSelectWidget (com.talosvfx.talos.editor.addons.scene.widgets.property.AssetSelectWidget)1 LabelWidget (com.talosvfx.talos.editor.widgets.propertyWidgets.LabelWidget)1