today I'm gonna release a small part of my (actually unfinished) .tif Editor.
It's compatible with the 4Story 3.5 .tif files. Well, actually the .tif file isn't only representing frames but I think I'm good with it throughout the other parts are not that complex like a frame.
Here's how to use it (Pseudo) :
Code:
var reader = new BinaryReader(TifFilePath, FileEncoding); var frame = new Frame(); frame.Read(ref reader);
Code:
public sealed class Frame { public Frame() { ChildFrame = null; NextFrame = null; Comp = new Components(); } public Frame ChildFrame { get; set; } public Frame NextFrame { get; set; } public Components Comp { get; set; } public bool Read(ref BinaryReader reader) { Comp.Id = reader.ReadUInt32(); Comp.Type = reader.ReadByte(); for (var i = 0; i < Components.MenuCount; i++) Comp.Menu[i] = reader.ReadUInt32(); for (var i = 0; i < Components.ImageCount; i++) Comp.ImageId[i] = reader.ReadUInt32(); Comp.TooltipId = reader.ReadUInt32(); Comp.FontId = reader.ReadUInt32(); Comp.Style = reader.ReadUInt32(); Comp.Color = reader.ReadUInt32(); Comp.Snd = reader.ReadUInt32(); Comp.MargineH = reader.ReadInt32(); Comp.MargineV = reader.ReadInt32(); Comp.PosX = reader.ReadInt32(); Comp.PosY = reader.ReadInt32(); Comp.Width = reader.ReadInt32(); Comp.Height = reader.ReadInt32(); Comp.Display = reader.ReadByte(); Comp.Align = reader.ReadByte(); //Placeholder for union Components until there'll be no solution for (var i = 0; i < TypeSpecification.ListDescription.MaxListColumn; i++) Comp.Ex.List.Item[i] = reader.ReadUInt32(); Comp.Ex.List.Column = reader.ReadUInt32(); Comp.Ex.List.Vs = reader.ReadUInt32(); //reads string → Comp.Tooltip var count = reader.ReadInt32(); if (count > 0) { var cstring = new byte[count + 1]; for (var i = 0; i < count; i++) cstring[i] = reader.ReadByte(); cstring[count] = 0x0; Comp.Tooltip = Encoding.ASCII.GetString(cstring); } //reads string → Comp.Text count = reader.ReadInt32(); if (count > 0) { var cstring = new byte[count + 1]; for (var i = 0; i < count; i++) cstring[i] = reader.ReadByte(); cstring[count] = 0x0; Comp.Text = Encoding.ASCII.GetString(cstring); } //read next frames count = reader.ReadInt32(); if (count == 0) return true; var next = this; for (var i = 0; i < count; i++) { if (i == 0) { next.ChildFrame = new Frame(); next.ChildFrame.Read(ref reader); next = next.ChildFrame; continue; } next.NextFrame = new Frame(); next.NextFrame.Read(ref reader); next = next.NextFrame; } return true; } ~Frame() { ChildFrame = null; NextFrame = null; Comp = null; } public sealed class TypeSpecification { public TypeSpecification() { Button = new ButtonDescription(); Scroll = new ScrollDescription(); Combo = new ComboDescription(); Meter = new MeterDescription(); Edit = new EditDescription(); List = new ListDescription(); Gauge = new GaugeDescription(); } public ButtonDescription Button { get; set; } public ScrollDescription Scroll { get; set; } public ComboDescription Combo { get; set; } public MeterDescription Meter { get; set; } public EditDescription Edit { get; set; } public ListDescription List { get; set; } public GaugeDescription Gauge { get; set; } public sealed class ButtonDescription { public uint Up { get; set; } public uint Down { get; set; } public uint Hover { get; set; } } public sealed class ScrollDescription { public uint Bar { get; set; } public uint Ul { get; set; } public uint Dr { get; set; } } public sealed class ComboDescription { public uint Drop { get; set; } public uint Downlist { get; set; } } public sealed class MeterDescription { public const byte MaxMeterSublevel = 7; public MeterDescription() { Sub = new uint[MaxMeterSublevel]; } public uint[] Sub { get; set; } public uint Sublevel { get; set; } public uint Super { get; set; } public uint Superlevel { get; set; } } public sealed class EditDescription { public uint Caret { get; set; } } public sealed class ListDescription { public const byte MaxListColumn = 15; public ListDescription() { Item = new uint[MaxListColumn]; } public uint[] Item { get; set; } public uint Column { get; set; } public uint Vs { get; set; } } public sealed class GaugeDescription { public const byte MaxGaugeBar = 10; public GaugeDescription() { Bar = new uint[MaxGaugeBar]; } public uint[] Bar { get; set; } public uint Count { get; set; } } } public sealed class Components { public static readonly byte MenuCount; public static readonly byte ImageCount; static Components() { MenuCount = 12; ImageCount = 2; } public Components() { Menu = new uint[MenuCount]; ImageId = new uint[ImageCount]; Ex = new TypeSpecification(); } public string Tooltip { get; set; } public string Text { get; set; } public uint Id { get; set; } public byte Type { get; set; } public uint[] Menu { get; set; } public uint[] ImageId { get; set; } public uint TooltipId { get; set; } public uint FontId { get; set; } public uint Style { get; set; } public uint Color { get; set; } public uint Snd { get; set; } public int MargineH { get; set; } public int MargineV { get; set; } public int PosX { get; set; } public int PosY { get; set; } public int Width { get; set; } public int Height { get; set; } public byte Display { get; set; } public byte Align { get; set; } public TypeSpecification Ex { get; set; } } }