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);
    }
  }
}

@@ -146,16 +146,73 @@
 butes;%0D%0A
+import de.lessvoid.nifty.loader.xpp3.SubstitutionGroup;%0D%0A
 import d
@@ -1352,16 +1352,66 @@
 oOrMore(
+%0D%0A        new SubstitutionGroup().%0D%0A          add(
 %22onStart
@@ -1489,35 +1489,24 @@
 en))
-;
+.
 %0D%0A    
-xmlParser.zeroOrMore
+      add
 (%22on
@@ -1585,35 +1585,24 @@
 en))
-;
+.
 %0D%0A    
-xmlParser.zeroOrMore
+      add
 (%22on
@@ -1673,35 +1673,24 @@
 er))
-;
+.
 %0D%0A    
-xmlParser.zeroOrMore
+      add
 (%22on
@@ -1761,35 +1761,24 @@
 ck))
-;
+.
 %0D%0A    
-xmlParser.zeroOrMore
+      add
 (%22on
@@ -1849,35 +1849,24 @@
 us))
-;
+.
 %0D%0A    
-xmlParser.zeroOrMore
+      add
 (%22on
@@ -1939,35 +1939,24 @@
 ve))
-;
+.
 %0D%0A    
-xmlParser.zeroOrMore
+      add
 (%22on
@@ -2025,16 +2025,29 @@
 Custom))
+%0D%0A          )
 ;%0D%0A%0D%0A   

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