// Path: core/src/com/odysseedesmaths/util/XMLSequencialReader.java
// public abstract class XMLSequencialReader {
// 
//     protected Document document;
//     protected Node currentNode;
// 
//     public XMLSequencialReader(String xmlFilePath) {
//         try {
//             DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
//             DocumentBuilder builder = factory.newDocumentBuilder();
//             document = builder.parse(Gdx.files.internal(xmlFilePath).read());
//             currentNode = initCurrentNode();
//         } catch (Exception e) {
//             e.printStackTrace();
//         }
//     }
// 
//     public Node goToFirstChild(Node node, String targetNodeName, boolean processing) {
//         Node result = node.getFirstChild();
//         if (result == null) return null;
//         String nodeName = processing ? process(result) : result.getNodeName();
//         return nodeName.equals(targetNodeName) ? result : goToNextSibling(result, targetNodeName, processing);
//     }
// 
//     public Node goToNextSibling(Node node, String targetNodeName, boolean processing) {
//         Node result = node;
//         String nodeName = "";
//         do {
//             result = result.getNextSibling();
//             if (result != null) nodeName = processing ? process(result) : result.getNodeName();
//         } while (result != null && !nodeName.equals(targetNodeName));
//         return result;
//     }
// 
//     public abstract Node initCurrentNode();
//     public abstract String process(Node node);
// }


import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.utils.Align;
import com.odysseedesmaths.*;
import com.odysseedesmaths.util.XMLSequencialReader;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
            public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
                return true;
            }

            @Override
            public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
                if (!displayAction.isFinished()) {
                    displayAction.finish();
                } else if (reader.hasNext()) {
                    reader.next();
                } else {
                    for (TextButton endButton : endButtonsList) {
                        buttonsGroup.addActor(endButton);
                    }
                }
            }
        });
        dialogTable.add(dialogChar).fill().padBottom(10).row();
        dialogTable.add(dialogText).fill().expand();

        reader = this.new SimpleDialogReader(dialogPath);
    }

    public void setText(final String text) {
        displayAction.reset();
        displayAction.setText(text);
        displayAction.setDuration(text.length()/DISPLAY_SPEED);
        dialogText.addAction(displayAction);
    }

// Path: core/src/com/odysseedesmaths/util/XMLSequencialReader.java
// public abstract class XMLSequencialReader {
// 
//     protected Document document;
//     protected Node currentNode;
// 
//     public XMLSequencialReader(String xmlFilePath) {
//         try {
//             DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
//             DocumentBuilder builder = factory.newDocumentBuilder();
//             document = builder.parse(Gdx.files.internal(xmlFilePath).read());
//             currentNode = initCurrentNode();
//         } catch (Exception e) {
//             e.printStackTrace();
//         }
//     }
// 
//     public Node goToFirstChild(Node node, String targetNodeName, boolean processing) {
//         Node result = node.getFirstChild();
//         if (result == null) return null;
//         String nodeName = processing ? process(result) : result.getNodeName();
//         return nodeName.equals(targetNodeName) ? result : goToNextSibling(result, targetNodeName, processing);
//     }
// 
//     public Node goToNextSibling(Node node, String targetNodeName, boolean processing) {
//         Node result = node;
//         String nodeName = "";
//         do {
//             result = result.getNextSibling();
//             if (result != null) nodeName = processing ? process(result) : result.getNodeName();
//         } while (result != null && !nodeName.equals(targetNodeName));
//         return result;
//     }
// 
//     public abstract Node initCurrentNode();
//     public abstract String process(Node node);
// }


// Path: core/src/com/odysseedesmaths/dialogs/SimpleDialog.java
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.utils.Align;
import com.odysseedesmaths.*;
import com.odysseedesmaths.util.XMLSequencialReader;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

            public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
                return true;
            }

            @Override
            public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
                if (!displayAction.isFinished()) {
                    displayAction.finish();
                } else if (reader.hasNext()) {
                    reader.next();
                } else {
                    for (TextButton endButton : endButtonsList) {
                        buttonsGroup.addActor(endButton);
                    }
                }
            }
        });
        dialogTable.add(dialogChar).fill().padBottom(10).row();
        dialogTable.add(dialogText).fill().expand();

        reader = this.new SimpleDialogReader(dialogPath);
    }

    public void setText(final String text) {
        displayAction.reset();
        displayAction.setText(text);
        displayAction.setDuration(text.length()/DISPLAY_SPEED);
        dialogText.addAction(displayAction);
    }

    private class SimpleDialogReader extends XMLSequencialReader {