/// <summary> /// Saves the windowstyle to the Sphere .rws format. /// </summary> /// <param name="filename">The path in which to save to.</param> public void Save(string filename) { using (BinaryWriter writer = new BinaryWriter(File.Open(filename, FileMode.Create))) { writer.Write(_sig.ToCharArray()); writer.Write(_version); writer.Write(_edgeWidth); writer.Write(_backgroundMode); foreach (RGBA color in _edgeColors) { color.SaveData(writer); } foreach (byte edge in _edgeOffset) { writer.Write(edge); } writer.Write(new byte[36]); switch (_version) { case 2: foreach (Bitmap b in _images) { writer.Write((short)b.Width); writer.Write((short)b.Height); BitmapSaver saver = new BitmapSaver(b.Width, b.Height); saver.SaveToStream(b, writer); } break; } writer.Flush(); } }
/// <summary> /// Savbes the tileset to a separate file. /// </summary> /// <param name="filename">The filename to save to.</param> public void Save(string filename) { using (BinaryWriter writer = new BinaryWriter(File.OpenWrite(filename))) { // save header data: writer.Write(".rts".ToCharArray()); writer.Write(_version); writer.Write((short)Tiles.Count); writer.Write(TileWidth); writer.Write(TileHeight); writer.Write((short)32); writer.Write(_compression); foreach (Tile t in Tiles) { if (t.Obstructions.Count > 0) { _hasObstruct = 1; } } writer.Write(_hasObstruct); writer.Write(new byte[240]); // save tile pixels: BitmapSaver saver = new BitmapSaver(TileWidth, TileHeight); foreach (Tile tile in Tiles) { saver.SaveToStream(tile.Graphic, writer); } // save tile info: foreach (Tile t in Tiles) { writer.Write(new byte()); writer.Write(t.Animated); writer.Write(t.NextAnim); writer.Write(t.Delay); writer.Write(new byte()); writer.Write((byte)2); writer.Write((short)t.Obstructions.Count); writer.Write((short)t.Name.Length); writer.Write(new byte[20]); writer.Write(t.Name.ToCharArray()); foreach (Line l in t.Obstructions) { writer.Write(l.X1); writer.Write(l.Y1); writer.Write(l.X2); writer.Write(l.Y2); } } writer.Flush(); } }
public void Save(BinaryWriter writer, short version) { writer.Write(_width); writer.Write(_height); writer.Write(new byte[28]); BitmapSaver saver = new BitmapSaver(_width, _height); if (version >= 1) { saver.SaveToStream(_image, writer); } }
public void Save(string filename) { if (File.Exists(filename)) { File.Delete(filename); } BinaryWriter binwrite = new BinaryWriter(File.OpenWrite(filename)); // Save Header Data // binwrite.Write(".rts".ToCharArray()); binwrite.Write(version); binwrite.Write((short)tiles.Count); binwrite.Write(tile_width); binwrite.Write(tile_height); binwrite.Write(tile_bpp); binwrite.Write(compression); binwrite.Write(has_obstructions); binwrite.Write(new byte[240]); // Save Tiles // BitmapSaver saver = new BitmapSaver(tile_width, tile_height); foreach (Tile t in tiles) { saver.SaveToStream(t.Graphic, binwrite); } // Save Tile Info Block: // foreach (Tile t in tiles) { binwrite.Write(new byte()); binwrite.Write(t.Animated); binwrite.Write(t.NextAnim); binwrite.Write(t.Delay); binwrite.Write(new byte()); binwrite.Write(t.Blocked); binwrite.Write((short)t.Obstructions.Count); binwrite.Write((short)t.Name.Length); binwrite.Write(new byte[20]); binwrite.Write(t.Name.ToCharArray()); foreach (Line l in t.Obstructions) { binwrite.Write(l.X1); binwrite.Write(l.Y1); binwrite.Write(l.X2); binwrite.Write(l.Y2); } } binwrite.Flush(); binwrite.Close(); }
/// <summary> /// Saves the Spriteset to the filename. /// </summary> /// <param name="filename">The filename to store the spriteset.</param> public void Save(string filename) { using (BinaryWriter writer = new BinaryWriter(File.OpenWrite(filename))) { // save header data: writer.Write(".rss".ToCharArray()); writer.Write(_version); writer.Write((short)_images.Count); writer.Write(_frameWidth); writer.Write(_frameHeight); writer.Write((short)_directions.Count); // save the sprite base: writer.Write(_spriteBase.X1); writer.Write(_spriteBase.Y1); writer.Write(_spriteBase.X2); writer.Write(_spriteBase.Y2); //reserved: writer.Write(new byte[106]); switch (_version) { case 3: BitmapSaver saver = new BitmapSaver(_frameWidth, _frameHeight); for (short i = 0; i < _images.Count; ++i) { saver.SaveToStream(Images[i], writer); } foreach (Direction d in _directions) { writer.Write((short)d.Frames.Count); writer.Write(new byte[6]); writer.Write((short)(d.Name.Length + 1)); writer.Write((d.Name + "\0").ToCharArray()); foreach (Frame f in d.Frames) { writer.Write(f.Index); writer.Write(f.Delay); writer.Write(new byte[4]); } } break; } writer.Flush(); } }
public void Save(string filename) { if (File.Exists(filename)) File.Delete(filename); BinaryWriter binwrite = new BinaryWriter(File.OpenWrite(filename)); // Save Header Data // binwrite.Write(".rts".ToCharArray()); binwrite.Write(version); binwrite.Write((short)tiles.Count); binwrite.Write(tile_width); binwrite.Write(tile_height); binwrite.Write(tile_bpp); binwrite.Write(compression); binwrite.Write(has_obstructions); binwrite.Write(new byte[240]); // Save Tiles // BitmapSaver saver = new BitmapSaver(tile_width, tile_height); foreach (Tile t in tiles) saver.SaveToStream(t.Graphic, binwrite); // Save Tile Info Block: // foreach (Tile t in tiles) { binwrite.Write(new byte()); binwrite.Write(t.Animated); binwrite.Write(t.NextAnim); binwrite.Write(t.Delay); binwrite.Write(new byte()); binwrite.Write(t.Blocked); binwrite.Write((short)t.Obstructions.Count); binwrite.Write((short)t.Name.Length); binwrite.Write(new byte[20]); binwrite.Write(t.Name.ToCharArray()); foreach (Line l in t.Obstructions) { binwrite.Write(l.X1); binwrite.Write(l.Y1); binwrite.Write(l.X2); binwrite.Write(l.Y2); } } binwrite.Flush(); binwrite.Close(); }