public GR.Memory.ByteBuffer SaveToBuffer() { GR.Memory.ByteBuffer projectFile = new GR.Memory.ByteBuffer(); // version projectFile.AppendU32(1); // Name projectFile.AppendString(Name); // Value table // number of entries projectFile.AppendI32(ValueTable.Values.Count); foreach (var entry in ValueTable.Values) { projectFile.AppendString(entry); } projectFile.AppendString(ValueTable.Formula); projectFile.AppendString(ValueTable.StartValue); projectFile.AppendString(ValueTable.EndValue); projectFile.AppendString(ValueTable.StepValue); return(projectFile); }
public GR.Memory.ByteBuffer SaveToBuffer() { GR.Memory.ByteBuffer projectFile = new GR.Memory.ByteBuffer(); // version projectFile.AppendU32(1); // Name projectFile.AppendString(System.IO.Path.GetFileNameWithoutExtension(Name)); // charset Filename projectFile.AppendString(System.IO.Path.GetFileNameWithoutExtension(Name)); for (int i = 0; i < 256; ++i) { projectFile.AppendI32(Characters[i].Color); } for (int i = 0; i < 256; ++i) { projectFile.AppendU8(Characters[i].Multicolor ? (byte)1 : (byte)0); } projectFile.AppendI32(BackgroundColor); projectFile.AppendI32(MultiColor1); projectFile.AppendI32(MultiColor2); for (int i = 0; i < 256; ++i) { // Tile colors projectFile.AppendI32(0); projectFile.AppendI32(0); projectFile.AppendI32(0); projectFile.AppendI32(0); // Tile chars projectFile.AppendI32(0); projectFile.AppendI32(0); projectFile.AppendI32(0); projectFile.AppendI32(0); } // generic multi color projectFile.AppendI32(0); // test bed projectFile.Append(new GR.Memory.ByteBuffer(64)); // charset data for (int i = 0; i < 256; ++i) { projectFile.Append(Characters[i].Data); } // used tiles projectFile.AppendU32(UsedTiles); // export name projectFile.AppendString(ExportFilename); // export path block table projectFile.AppendString(""); // export path charset projectFile.AppendString(""); // export path editor tiles projectFile.AppendString(""); // categories projectFile.AppendI32(Categories.Count); foreach (System.Collections.Generic.KeyValuePair <int, string> category in Categories) { projectFile.AppendI32(category.Key); projectFile.AppendString(category.Value); } for (int i = 0; i < 256; ++i) { projectFile.AppendI32(Characters[i].Category); } return(projectFile); }
public GR.Memory.ByteBuffer SaveToBuffer() { GR.Memory.ByteBuffer projectFile = new GR.Memory.ByteBuffer(); // version projectFile.AppendU32(1); projectFile.AppendI32(Sprites.Count); // Name projectFile.AppendString(Name); for (int i = 0; i < Sprites.Count; ++i) { projectFile.AppendI32(Sprites[i].Color); } for (int i = 0; i < Sprites.Count; ++i) { projectFile.AppendU8(Sprites[i].Multicolor ? (byte)1 : (byte)0); } projectFile.AppendI32(BackgroundColor); projectFile.AppendI32(MultiColor1); projectFile.AppendI32(MultiColor2); // generic MC projectFile.AppendU32(0); for (int i = 0; i < Sprites.Count; ++i) { projectFile.Append(Sprites[i].Data); projectFile.AppendU8((byte)Sprites[i].Color); } projectFile.AppendU32(UsedSprites); // export name projectFile.AppendString(ExportFilename); // exportpath projectFile.AppendString(""); // desc for (int i = 0; i < Sprites.Count; ++i) { projectFile.AppendString(""); } // testbed (not used anymore, write 0 as number of sprites) projectFile.AppendI32(0); foreach (var layer in SpriteLayers) { GR.IO.FileChunk chunkLayer = new GR.IO.FileChunk(Types.FileChunk.SPRITESET_LAYER); GR.IO.FileChunk chunkLayerInfo = new GR.IO.FileChunk(Types.FileChunk.SPRITESET_LAYER_INFO); chunkLayerInfo.AppendString(layer.Name); chunkLayerInfo.AppendU8((byte)layer.BackgroundColor); chunkLayer.Append(chunkLayerInfo.ToBuffer()); foreach (var sprite in layer.Sprites) { GR.IO.FileChunk chunkLayerSprite = new GR.IO.FileChunk(Types.FileChunk.SPRITESET_LAYER_ENTRY); chunkLayerSprite.AppendI32(sprite.Index); chunkLayerSprite.AppendU8((byte)sprite.Color); chunkLayerSprite.AppendI32(sprite.X); chunkLayerSprite.AppendI32(sprite.Y); chunkLayerSprite.AppendU8((byte)(sprite.ExpandX ? 1 : 0)); chunkLayerSprite.AppendU8((byte)(sprite.ExpandY ? 1 : 0)); chunkLayer.Append(chunkLayerSprite.ToBuffer()); } projectFile.Append(chunkLayer.ToBuffer()); } /* * int spriteTestCount = memIn.ReadInt32(); * for ( int i = 0; i < spriteTestCount; ++i ) * { * int spriteIndex = memIn.ReadInt32(); * byte spriteColor = memIn.ReadUInt8(); * bool spriteMultiColor = ( memIn.ReadUInt8() != 0 ); * int spriteX = memIn.ReadInt32(); * int spriteY = memIn.ReadInt32(); * }*/ return(projectFile); }
public GR.Memory.ByteBuffer SaveToBuffer() { GR.Memory.ByteBuffer projectFile = new GR.Memory.ByteBuffer(); // version projectFile.AppendU32(1); // Name projectFile.AppendString(System.IO.Path.GetFileNameWithoutExtension(Name)); // charset Filename projectFile.AppendString(System.IO.Path.GetFileNameWithoutExtension(Name)); for (int i = 0; i < 256; ++i) { projectFile.AppendI32(Characters[i].Color); } for (int i = 0; i < 256; ++i) { projectFile.AppendU8((byte)Characters[i].Mode); } projectFile.AppendI32(BackgroundColor); projectFile.AppendI32(MultiColor1); projectFile.AppendI32(MultiColor2); for (int i = 0; i < 256; ++i) { // Tile colors projectFile.AppendI32(0); projectFile.AppendI32(0); projectFile.AppendI32(0); projectFile.AppendI32(0); // Tile chars projectFile.AppendI32(0); projectFile.AppendI32(0); projectFile.AppendI32(0); projectFile.AppendI32(0); } // generic multi color projectFile.AppendI32(0); // test bed projectFile.Append(new GR.Memory.ByteBuffer(64)); // charset data for (int i = 0; i < 256; ++i) { projectFile.Append(Characters[i].Data); } // used tiles projectFile.AppendU32(UsedTiles); // export name projectFile.AppendString(ExportFilename); // export path block table projectFile.AppendString(""); // export path charset projectFile.AppendString(""); // export path editor tiles projectFile.AppendString(""); // categories projectFile.AppendI32(Categories.Count); for (int i = 0; i < Categories.Count; ++i) { projectFile.AppendI32(i); projectFile.AppendString(Categories[i]); } for (int i = 0; i < 256; ++i) { projectFile.AppendI32(Characters[i].Category); } projectFile.AppendI32(NumCharacters); projectFile.AppendI32(ShowGrid ? 1 : 0); projectFile.AppendI32(StartCharacter); projectFile.AppendI32(BGColor4); // playground projectFile.AppendI32(16); // w projectFile.AppendI32(16); // h for (int i = 0; i < PlaygroundChars.Count; ++i) { projectFile.AppendU16(PlaygroundChars[i]); } return(projectFile); }
public virtual void SaveToChunk(GR.Memory.ByteBuffer OutBuffer) { OutBuffer.AppendString(DocumentInfo.DocumentFilename); }