Esempio n. 1
0
  /**
   * Merge two fonts. If two font have the same style, merge will fail.
   *
   * @param styleSet Style must be assigned to this.
   * @author Yonghoon
   */
  public void merge(BitmapFont newFont) {
    charSet.merge(newFont.charSet);
    final int size1 = this.pages.length;
    final int size2 = newFont.pages.length;

    Material[] tmp = new Material[size1 + size2];
    System.arraycopy(this.pages, 0, tmp, 0, size1);
    System.arraycopy(newFont.pages, 0, tmp, size1, size2);

    this.pages = tmp;

    //        this.pages = Arrays.copyOf(this.pages, size1+size2);
    //        System.arraycopy(newFont.pages, 0, this.pages, size1, size2);
  }
Esempio n. 2
0
 @Override
 public void read(JmeImporter im) throws IOException {
   InputCapsule ic = im.getCapsule(this);
   charSet = (BitmapCharacterSet) ic.readSavable("charSet", null);
   Savable[] pagesSavable = ic.readSavableArray("pages", null);
   pages = new Material[pagesSavable.length];
   System.arraycopy(pagesSavable, 0, pages, 0, pages.length);
 }
Esempio n. 3
0
 @Override
 public void read(JmeImporter im) throws IOException {
   super.read(im);
   InputCapsule in = im.getCapsule(this);
   Savable[] sav = in.readSavableArray("targets", null);
   if (sav != null) {
     targets = new Mesh[sav.length];
     System.arraycopy(sav, 0, targets, 0, sav.length);
   }
   skeleton = (Skeleton) in.readSavable("skeleton", null);
 }
Esempio n. 4
0
 public static TypeList load(String gamePath, String dataName) {
   System.out.println("load:" + dataName);
   InputStream is = null;
   Savable sav = null;
   try {
     File file =
         new File(
             System.getProperty("user.dir")
                 + File.separator
                 + gamePath
                 + File.separator
                 + dataName);
     if (!file.exists()) {
       return null;
     }
     is = new BufferedInputStream(new FileInputStream(file));
     // is = new GZIPInputStream(new BufferedInputStream(new FileInputStream(file)));
     XMLImporter imp = XMLImporter.getInstance();
     // if (manager != null) {
     //     imp.setAssetManager(manager);
     // }
     sav = imp.load(is);
   } catch (IOException ex) {
     Logger.getLogger(Type.class.getName()).log(Level.SEVERE, "Error loading data: {0}", ex);
     ex.printStackTrace();
   } finally {
     if (is != null) {
       try {
         is.close();
       } catch (IOException ex) {
         Logger.getLogger(Type.class.getName()).log(Level.SEVERE, "Error loading data: {0}", ex);
         ex.printStackTrace();
       }
     }
   }
   return (TypeList) sav;
 }
Esempio n. 5
0
  public void save(String gamePath, String dataName) {
    XMLExporter ex = XMLExporter.getInstance();
    OutputStream os = null;
    try {

      File daveFolder = new File(System.getProperty("user.dir") + File.separator + gamePath);
      if (!daveFolder.exists() && !daveFolder.mkdirs()) {
        Logger.getLogger(Type.class.getName()).log(Level.SEVERE, "Error creating save file!");
        throw new IllegalStateException("SaveGame dataset cannot be created");
      }
      File saveFile = new File(daveFolder.getAbsolutePath() + File.separator + dataName);
      if (!saveFile.exists()) {
        if (!saveFile.createNewFile()) {
          Logger.getLogger(Type.class.getName()).log(Level.SEVERE, "Error creating save file!");
          throw new IllegalStateException("SaveGame dataset cannot be created");
        }
      }
      os = new BufferedOutputStream(new FileOutputStream(saveFile));
      // os = new GZIPOutputStream(new BufferedOutputStream(new FileOutputStream(saveFile)));
      ex.save(this, os);
    } catch (IOException ex1) {
      Logger.getLogger(Type.class.getName()).log(Level.SEVERE, "Error saving data: {0}", ex1);
      ex1.printStackTrace();
      throw new IllegalStateException("SaveGame dataset cannot be saved");
    } finally {
      try {
        if (os != null) {
          os.close();
        }
      } catch (IOException ex1) {
        Logger.getLogger(Type.class.getName()).log(Level.SEVERE, "Error saving data: {0}", ex1);
        ex1.printStackTrace();
        throw new IllegalStateException("SaveGame dataset cannot be saved");
      }
    }
  }