public override void SetTranslate(string[] strings) { var oldStrings = GetStrings(true); if (strings.Length != oldStrings.Length) { throw new Exception("Line count mismatch"); } ByteBuilder bb = new ByteBuilder(); for (int r = 0; r < strings.Length; r++) { var tr = strings[r]; if (tr == null) { tr = oldStrings[r]; } var bytes = GameEncoding.GetBytes(tr); bb.AddBytes(bytes); bb.AddByte(0); } SaveTranslate(bb.GetArray()); }
public byte[] GetBytes() { ByteBuilder bb = new ByteBuilder(); WriteExt(bb); return(bb.GetArray()); }
public void SetFont(SCIFont spr) { ushort cnt = (ushort)(spr.Frames.Count & 0xFFFF); ByteBuilder bb = new ByteBuilder(); bb.AddByte(0); bb.AddShortLE(cnt); bb.AddShortLE(spr.FontHeight); bb.AddByte(0); for (int i = 0; i < cnt; i++) { bb.AddShortLE(0); } byte bit; byte bitMask; for (int i = 0; i < cnt; i++) { SpriteFrame frm = spr[i]; byte w = (byte)frm.Width; byte h = (byte)frm.Height; ushort offset = (ushort)bb.Position; bb.SetShortBE(6 + i * 2, offset); bb.AddByte(w); bb.AddByte(h); for (int y = 0; y < frm.Height; y++) { bit = 0; bitMask = 0; for (int x = 0; x < frm.Width; x++) { if (frm[x, y] == 1) { bitMask |= (byte)(1 << (7 - bit)); } bit++; if (bit == 8) { bit = 0; bb.AddByte(bitMask); bitMask = 0; } } if (bit != 0) { bb.AddByte(bitMask); } } } SaveTranslate(bb.GetArray()); }
public override byte[] GetPatch() { ushort cnt = (ushort)(_font.Frames.Count & 0xFFFF); ByteBuilder bb = new ByteBuilder(); bb.AddByte(0); bb.AddShortLE(cnt); bb.AddShortLE(_font.FontHeight); bb.AddByte(0); for (int i = 0; i < cnt; i++) { bb.AddShortLE(0); } byte bit; byte bitMask; for (int i = 0; i < cnt; i++) { SpriteFrame frm = _font[i]; byte w = (byte)frm.Width; byte h = (byte)frm.Height; ushort offset = (ushort)bb.Position; bb.SetShortBE(6 + i * 2, offset); bb.AddByte(w); bb.AddByte(h); for (int y = 0; y < frm.Height; y++) { bit = 0; bitMask = 0; for (int x = 0; x < frm.Width; x++) { if (frm[x, y] == 1) { bitMask |= (byte)(1 << (7 - bit)); } bit++; if (bit == 8) { bit = 0; bb.AddByte(bitMask); bitMask = 0; } } if (bit != 0) { bb.AddByte(bitMask); } } } return(bb.GetArray()); }
public override byte[] GetPatch() { var strings = GetStrings(); ByteBuilder bb = new ByteBuilder(); for (int i = 0; i < strings.Length; i++) { var bytes = GameEncoding.GetBytes(strings[i]); bb.AddBytes(bytes); bb.AddByte(0); } return(bb.GetArray()); }
public void SetMessages(List <MessageRecord> messages) { ByteBuilder bb = new ByteBuilder(); if (messages[0] is MessageRecordV3) { SaveV3(messages, bb); } else if (messages[0] is MessageRecordV4) { SaveV4(messages, bb); } else { throw new NotImplementedException(); } SaveTranslate(bb.GetArray()); }
public byte[] GetBytes() { PicOpCode prev = 0; ByteBuilder bb = new ByteBuilder(); foreach (var cmd in commands) { if (cmd.OpCode != prev || cmd.OpCode == PicOpCode.OPX) { bb.AddByte((byte)cmd.OpCode); } cmd.Write(bb); prev = cmd.OpCode; } return(bb.GetArray()); }
public override byte[] GetPatch() { var messages = GetMessages(); ByteBuilder bb = new ByteBuilder(); if (messages[0] is MessageRecordV3) { SaveV3(messages, bb); } else if (messages[0] is MessageRecordV4) { SaveV4(messages, bb); } else { throw new NotImplementedException(); } return(bb.GetArray()); }
public byte[] GetBytes() { ByteBuilder bb = new ByteBuilder(); foreach (Section sec in Sections) { bb.AddShortBE((ushort)sec.Type); int sizePos = bb.Position; bb.AddShortBE(0); sec.Write(bb); int endPos = bb.Position; bb.SetShortBE(sizePos, (ushort)(endPos - sizePos + 2)); } foreach (Section sec in Sections) { sec.WriteOffsets(bb); } bb.AddShortBE(0); return(bb.GetArray()); }