package de.lessvoid.nifty.loader.xpp3.processor;


import de.lessvoid.nifty.effects.EffectEventId;
import de.lessvoid.nifty.loader.xpp3.Attributes;
import de.lessvoid.nifty.loader.xpp3.XmlParser;
import de.lessvoid.nifty.loader.xpp3.elements.EffectsType;
import de.lessvoid.nifty.loader.xpp3.elements.ElementType;
import de.lessvoid.nifty.loader.xpp3.elements.StyleType;

/**
 * EffectsType.
 * @author void
 */
public class EffectsTypeProcessor implements XmlElementProcessor {

  /**
   * the element this belongs to.
   */
  private ElementType element;

  /**
   * StyleType.
   */
  private StyleType style;

  /**
   * init with StyleType.
   * @param styleParam StyleType
   */
  public EffectsTypeProcessor(final StyleType styleParam) {
    style = styleParam;
  }

  /**
   * init it.
   * @param elementParam element
   */
  public EffectsTypeProcessor(final ElementType elementParam) {
    element = elementParam;
  }

  /**
   * process.
   * @param xmlParser xmlParser
   * @param attributes attributes
   * @throws Exception exception
   */
  public void process(final XmlParser xmlParser, final Attributes attributes) throws Exception {
    EffectsType effectsType = new EffectsType();
    xmlParser.nextTag();
    xmlParser.zeroOrMore("onStartScreen", new EffectTypeProcessor(effectsType, EffectEventId.onStartScreen));
    xmlParser.zeroOrMore("onEndScreen", new EffectTypeProcessor(effectsType, EffectEventId.onEndScreen));
    xmlParser.zeroOrMore("onHover", new EffectTypeProcessor(effectsType, EffectEventId.onHover));
    xmlParser.zeroOrMore("onClick", new EffectTypeProcessor(effectsType, EffectEventId.onClick));
    xmlParser.zeroOrMore("onFocus", new EffectTypeProcessor(effectsType, EffectEventId.onFocus));
    xmlParser.zeroOrMore("onActive", new EffectTypeProcessor(effectsType, EffectEventId.onActive));
    xmlParser.zeroOrMore("onCustom", new EffectTypeProcessor(effectsType, EffectEventId.onCustom));

    if (element != null) {
      element.setEffects(effectsType);
    }

    if (style != null) {
      style.setEffects(effectsType);
    }
  }
}

package de.lessvoid.nifty.loader.xpp3.processor;


import de.lessvoid.nifty.effects.EffectEventId;
import de.lessvoid.nifty.loader.xpp3.Attributes;
import de.lessvoid.nifty.loader.xpp3.SubstitutionGroup;
import de.lessvoid.nifty.loader.xpp3.XmlParser;
import de.lessvoid.nifty.loader.xpp3.elements.EffectsType;
import de.lessvoid.nifty.loader.xpp3.elements.ElementType;
import de.lessvoid.nifty.loader.xpp3.elements.StyleType;

/**
 * EffectsType.
 * @author void
 */
public class EffectsTypeProcessor implements XmlElementProcessor {

  /**
   * the element this belongs to.
   */
  private ElementType element;

  /**
   * StyleType.
   */
  private StyleType style;

  /**
   * init with StyleType.
   * @param styleParam StyleType
   */
  public EffectsTypeProcessor(final StyleType styleParam) {
    style = styleParam;
  }

  /**
   * init it.
   * @param elementParam element
   */
  public EffectsTypeProcessor(final ElementType elementParam) {
    element = elementParam;
  }

  /**
   * process.
   * @param xmlParser xmlParser
   * @param attributes attributes
   * @throws Exception exception
   */
  public void process(final XmlParser xmlParser, final Attributes attributes) throws Exception {
    EffectsType effectsType = new EffectsType();
    xmlParser.nextTag();
    xmlParser.zeroOrMore(
        new SubstitutionGroup().
          add("onStartScreen", new EffectTypeProcessor(effectsType, EffectEventId.onStartScreen)).
          add("onEndScreen", new EffectTypeProcessor(effectsType, EffectEventId.onEndScreen)).
          add("onHover", new EffectTypeProcessor(effectsType, EffectEventId.onHover)).
          add("onClick", new EffectTypeProcessor(effectsType, EffectEventId.onClick)).
          add("onFocus", new EffectTypeProcessor(effectsType, EffectEventId.onFocus)).
          add("onActive", new EffectTypeProcessor(effectsType, EffectEventId.onActive)).
          add("onCustom", new EffectTypeProcessor(effectsType, EffectEventId.onCustom))
          );

    if (element != null) {
      element.setEffects(effectsType);
    }

    if (style != null) {
      style.setEffects(effectsType);
    }
  }
}

order of effects is not important anymore, you can mix them now