Ejemplo n.º 1
0
  private String writeCode(CodeGenVisitor generator)
      throws IOException, MoPaQException, MapFormatException {
    String outputName = options.outDir.getPath() + "/Andromeda.galaxy";
    StringBufferWriter w = new StringBufferWriter();
    generator.flushOutCode(w);
    String code = w.toString();

    // Create out directory
    options.outDir.mkdirs();

    // Write to external file
    BufferedWriter bw =
        new BufferedWriter(new FileWriter(new File(options.outDir, "Andromeda.galaxy")));
    bw.write(code);
    bw.close();

    // If we have an input map, manipulate its mapScript
    if (map != null || options.mapScriptIn != null) {

      // Write map script to output folder
      String mapScript;
      if (map != null) {
        mapScript = ScriptInjector.getManipulatedMapScript(map);
      } else {
        mapScript = ScriptInjector.getManipulatedMapScript(options.mapScriptIn);
      }
      BufferedWriter bw2 =
          new BufferedWriter(new FileWriter(new File(options.outDir, "MapScript.galaxy")));
      bw2.write(mapScript);
      bw2.close();

      // Write to map file if specified
      if (options.mapOut != null) {
        ScriptInjector.injectAndromeda(map, mapScript, code);
        map.save(options.mapOut);
        outputName = options.mapOut.getName();
      }
    }

    return outputName;
  }
Ejemplo n.º 2
0
 public static void injectAndromeda(MoPaQ m, String mapScriptCode, String andromedaCode) {
   m.writeFile("Andromeda.galaxy", andromedaCode.getBytes());
   m.writeFile("MapScript.galaxy", mapScriptCode.getBytes());
 }
Ejemplo n.º 3
0
 public static String getManipulatedMapScript(MoPaQ m) throws MapFormatException {
   String mapScript = ScriptInjector.inject(new String(m.returnFileByName("MapScript.galaxy")));
   return mapScript;
 }