Ejemplo n.º 1
0
  @Override
  public void load(Loader ff, Item item) {
    Section section = (Section) item;
    // Manditory section_id
    section.id = ff.getText("id");
    section.title = ff.getText("title");

    List<Loader> fragmentElements = ff.getChildren("text", "set", "choice", "chance", "if");

    boolean hasDesc = false;
    for (Loader fragmentElement : fragmentElements) {
      Fragment frag = null;
      if (fragmentElement.getName().equals("text")) {
        frag = new Text();
        Text.loadable.load(fragmentElement, frag);
        hasDesc = true;
      }
      if (fragmentElement.getName().equals("set")) {
        frag = new Set();
        Set.loadable.load(fragmentElement, frag);
      }
      if (fragmentElement.getName().equals("choice")) {
        frag = new Choice();
        Choice.loadable.load(fragmentElement, frag);
      }
      if (fragmentElement.getName().equals("chance")) {
        frag = new Chance();
        Chance.loadable.load(fragmentElement, frag);
      }
      if (fragmentElement.getName().equals("if")) {
        frag = new If();
        If.loadable.load(fragmentElement, frag);
      }

      if (frag != null) {
        section.fragments.add(frag);
      }
    }

    if (!hasDesc) {
      Text desc = new Text();
      desc.setup();
      section.fragments.add(desc);
    }

    Loader gotoElement = ff.getChild("goto");
    Goto secgoto = new Goto();
    if (gotoElement != null) {
      Goto.loadable.load(gotoElement, secgoto);
    } else {
      secgoto.setup();
    }
    section.gotoid = secgoto;
  }
Ejemplo n.º 2
0
  @Deprecated
  public void load(ArrayList<String> content, Item item) {
    Section section = new Section();
    section.id = content.get(0);
    boolean gotTitle = false;
    for (String line : content) {
      if (!gotTitle && line.contains("#")) {
        int pos = line.lastIndexOf('#');
        section.title = line.substring(pos + 1);
        gotTitle = true;
      } else {

      }
    }
  }