package de.frajul.particlelab.entities.particles.attributes;

import de.frajul.particlelab.entities.particles.attributes.attributeValues.ParticleAttributeValueType;

public enum ParticleAttributeType {
    NONE(""),
    DELAY("Delay", ParticleAttributeValueType.RANGE),
    DURATION("Duration", ParticleAttributeValueType.RANGE),
    COUNT("Count", ParticleAttributeValueType.RANGE),
    EMISSION("Emission", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
    LIFE("Life", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
    LIFE_OFFSET("Life Offset", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
    X_OFFSET("X Offset", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
    Y_OFFSET("Y Offset", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
    SPAWN_SHAPE("Spawn Shape", ParticleAttributeValueType.SPAWN_SHAPE),
    SPAWN_WIDTH("Spawn Width", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
    SPAWN_HEIGHT("Spawn Height", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
    SCALE("Scale", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
    VELOCITY("Velocity", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
    ANGLE("Angle", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
    ROTATION("Rotation", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
    WIND("Wind", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
    GRAVITY("Gravity", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
    TINT("Tint", ParticleAttributeValueType.TINT_TIMELINE),
    TRANSPARENCY("Transparency", ParticleAttributeValueType.RANGE, ParticleAttributeValueType.TIMELINE),
    OPTIONS("Options", ParticleAttributeValueType.OPTIONS),
    IMAGE_PATH("Image Path", ParticleAttributeValueType.IMAGE_PATH);

    private String name;
    private ParticleAttributeValueType[] valueTypes;

    ParticleAttributeType(String name, ParticleAttributeValueType... valueTypes) {
        this.name = name;
        this.valueTypes = valueTypes;
    }

    private String getInFileTitle() {
        return "- " + name + " -";
    }

    public static ParticleAttributeType getByInFileTitle(String title) throws Exception {
        for (ParticleAttributeType setting : values()) {
            if (setting != NONE && setting.getInFileTitle().equals(title))
                return setting;
        }
        throw new Exception("Could not find ParticleAttributeType by title: " + title);
    }

    public Attribute createInstance() throws Exception {
        if (this == NONE)
            throw new Exception("Cannot create Instance from Attribute NONE");
        return new Attribute(this, valueTypes);
    }

}