public override void Unserialize(GMDataReader reader) { base.Unserialize(reader); List = new GMUniquePointerList <GMObject>(); List.Unserialize(reader); }
public void Unserialize(GMDataReader reader) { Name = reader.ReadStringPointerObject(); DisplayName = reader.ReadStringPointerObject(); Size = reader.ReadInt32(); if (Size < 0) { reader.Offset -= 4; SizeFloat = -reader.ReadSingle(); } Bold = reader.ReadWideBoolean(); Italic = reader.ReadWideBoolean(); RangeStart = reader.ReadUInt16(); Charset = reader.ReadByte(); AntiAlias = reader.ReadByte(); RangeEnd = reader.ReadInt32(); TextureItem = reader.ReadPointer <GMTextureItem>(); ScaleX = reader.ReadSingle(); ScaleY = reader.ReadSingle(); if (reader.VersionInfo.FormatID >= 17) { AscenderOffset = reader.ReadInt32(); } Glyphs = new GMUniquePointerList <GMGlyph>(); Glyphs.Unserialize(reader); }
public void Unserialize(GMDataReader reader) { Name = reader.ReadStringPointerObject(); SpriteID = reader.ReadInt32(); Visible = reader.ReadWideBoolean(); Solid = reader.ReadWideBoolean(); Depth = reader.ReadInt32(); Persistent = reader.ReadWideBoolean(); ParentObjectID = reader.ReadInt32(); MaskSpriteID = reader.ReadInt32(); Physics = reader.ReadWideBoolean(); PhysicsSensor = reader.ReadWideBoolean(); PhysicsShape = (CollisionShape)reader.ReadInt32(); PhysicsDensity = reader.ReadSingle(); PhysicsRestitution = reader.ReadSingle(); PhysicsGroup = reader.ReadInt32(); PhysicsLinearDamping = reader.ReadSingle(); PhysicsAngularDamping = reader.ReadSingle(); int vertexCount = reader.ReadInt32(); PhysicsFriction = reader.ReadSingle(); PhysicsAwake = reader.ReadWideBoolean(); PhysicsKinematic = reader.ReadWideBoolean(); PhysicsVertices = new List <PhysicsVertex>(vertexCount); for (int i = vertexCount; i > 0; i--) { PhysicsVertex v = new PhysicsVertex(); v.Unserialize(reader); PhysicsVertices.Add(v); } Events = new GMUniquePointerList <GMUniquePointerList <Event> >(); Events.Unserialize(reader); }
public override void Unserialize(GMDataReader reader) { base.Unserialize(reader); List = new GMUniquePointerList <GMAudioGroup>(); List.Unserialize(reader); // Now load the audio groups if possible string dir = reader.Data.Directory; if (dir != null) { AudioData = new Dictionary <int, GMData>(); for (int i = 1; i < List.Count; i++) { string fname = $"audiogroup{i}.dat"; string path = Path.Combine(dir, fname); if (File.Exists(path)) { reader.Data.Logger?.Invoke($"Reading audio group \"{fname}\"..."); using (FileStream fs = new FileStream(path, FileMode.Open)) { GMDataReader groupReader = new GMDataReader(fs, fs.Name); AudioData[i] = groupReader.Data; foreach (GMWarning w in groupReader.Warnings) { w.File = fname; reader.Warnings.Add(w); } } } } } }
public override void Unserialize(GMDataReader reader) { base.Unserialize(reader); List = new GMUniquePointerList <GMFont>(); List.Unserialize(reader); Padding = reader.ReadBytes(512); }
public override void Unserialize(GMDataReader reader) { base.Unserialize(reader); if (Length == 0) { return; // In YYC, before bytecode 17, CODE is empty } List = new GMUniquePointerList <GMCode>(); List.Unserialize(reader); }
public override void Unserialize(GMDataReader reader) { base.Unserialize(reader); int chunkVersion = reader.ReadInt32(); if (chunkVersion != 1) { reader.Warnings.Add(new GMWarning($"ACRV version is {chunkVersion}, expected 1")); } List = new GMUniquePointerList <GMAnimCurve>(); List.Unserialize(reader); }
public void Unserialize(GMDataReader reader) { LegacyTiles = reader.ReadPointerObjectUnique <GMUniquePointerList <Tile> >(); Sprites = reader.ReadPointerObjectUnique <GMUniquePointerList <AssetInstance> >(); if (reader.VersionInfo.IsNumberAtLeast(2, 3)) { Sequences = reader.ReadPointerObjectUnique <GMUniquePointerList <AssetInstance> >(); if (!reader.VersionInfo.IsNumberAtLeast(2, 3, 2)) { NineSlices = reader.ReadPointerObjectUnique <GMUniquePointerList <AssetInstance> >(); } } }
public override void Unserialize(GMDataReader reader) { base.Unserialize(reader); reader.Pad(4); int chunkVersion = reader.ReadInt32(); if (chunkVersion != 1) { reader.Warnings.Add(new GMWarning($"FEDS version is {chunkVersion}, expected 1")); } List = new GMUniquePointerList <GMFilterEffect>(); List.Unserialize(reader); }
public override void Unserialize(GMDataReader reader) { base.Unserialize(reader); List = new GMUniquePointerList <GMExtension>(); List.Unserialize(reader); // Product ID information for each extension if (reader.VersionInfo.IsNumberAtLeast(1, 0, 0, 9999)) { for (int i = 0; i < List.Count; i++) { List[i].ProductID = new Guid(reader.ReadBytes(16).Memory.ToArray()); } } }
public override void Unserialize(GMDataReader reader) { base.Unserialize(reader); List = new GMUniquePointerList <GMBackground>(); reader.VersionInfo.AlignBackgroundsTo8 = reader.VersionInfo.IsNumberAtLeast(2, 3); // only occurs on newer 2.3.1 versions List.Unserialize(reader, null, null, (GMDataReader reader, bool notLast) => { int ptr = reader.ReadInt32(); // Check if backgrounds are aligned to 8 byte offsets reader.VersionInfo.AlignBackgroundsTo8 &= (ptr % 8 == 0); return(reader.ReadPointerObject <GMBackground>(ptr, notLast)); }); }
public override void Unserialize(GMDataReader reader) { base.Unserialize(reader); // This chunk can just be empty sometimes if (Length == 0) { return; } int chunkVersion = reader.ReadInt32(); if (chunkVersion != 1) { reader.Warnings.Add(new GMWarning($"SEQN version is {chunkVersion}, expected 1")); } List = new GMUniquePointerList <GMSequence>(); List.Unserialize(reader); }
public override void Unserialize(GMDataReader reader) { base.Unserialize(reader); reader.Pad(4); int chunkVersion = reader.ReadInt32(); if (chunkVersion != 1) { reader.Warnings.Add(new GMWarning($"TAGS version is {chunkVersion}, expected 1")); } int count = reader.ReadInt32(); AllTags = new List <GMString>(count); for (int i = count; i > 0; i--) { AllTags.Add(reader.ReadStringPointerObject()); } AssetTagsList = new GMUniquePointerList <AssetTags>(); AssetTagsList.Unserialize(reader); }
public override void ConvertProject(ProjectFile pf) { var dataAssets = pf.DataHandle.GetChunk <GMChunkOBJT>().List; // TODO: use asset refs whenever code is implemented GMList <GMCode> dataCode = ((GMChunkCODE)pf.DataHandle.Chunks["CODE"]).List; int getCode(string name) { try { return(dataCode.Select((elem, index) => new { elem, index }).First(p => p.elem.Name.Content == name).index); } catch (InvalidOperationException) { return(-1); } } int getObject(string name) { if (name == null) { return(-1); } if (name == "<undefined>") { return(-100); } return(pf.Objects.FindIndex(name)); } List <GMObject> newList = new List <GMObject>(); for (int i = 0; i < pf.Objects.Count; i++) { AssetObject projectAsset = pf.Objects[i].Asset; if (projectAsset == null) { // This asset was never converted // No need to update IDs since they won't change newList.Add((GMObject)pf.Objects[i].DataAsset); continue; } GMObject dataAsset = new GMObject() { Name = pf.DataHandle.DefineString(projectAsset.Name), SpriteID = pf.Sprites.FindIndex(projectAsset.Sprite), Visible = projectAsset.Visible, Solid = projectAsset.Solid, Depth = projectAsset.Depth, Persistent = projectAsset.Persistent, ParentObjectID = getObject(projectAsset.ParentObject), MaskSpriteID = pf.Sprites.FindIndex(projectAsset.MaskSprite), Physics = projectAsset.Physics, PhysicsSensor = projectAsset.PhysicsSensor, PhysicsShape = projectAsset.PhysicsShape, PhysicsDensity = projectAsset.PhysicsDensity, PhysicsRestitution = projectAsset.PhysicsRestitution, PhysicsGroup = projectAsset.PhysicsGroup, PhysicsLinearDamping = projectAsset.PhysicsLinearDamping, PhysicsAngularDamping = projectAsset.PhysicsAngularDamping, PhysicsVertices = new List <GMObject.PhysicsVertex>(), PhysicsFriction = projectAsset.PhysicsFriction, PhysicsAwake = projectAsset.PhysicsAwake, PhysicsKinematic = projectAsset.PhysicsKinematic, Events = new GMUniquePointerList <GMUniquePointerList <GMObject.Event> >() }; foreach (AssetObject.PhysicsVertex v in projectAsset.PhysicsVertices) { dataAsset.PhysicsVertices.Add(new GMObject.PhysicsVertex() { X = v.X, Y = v.Y }); } foreach (var events in projectAsset.Events.Values) { var newEvents = new GMUniquePointerList <GMObject.Event>(); foreach (var ev in events) { GMObject.Event newEv = new GMObject.Event() { Subtype = 0, Actions = new GMUniquePointerList <GMObject.Event.Action>() { new GMObject.Event.Action() { LibID = 1, ID = ev.Actions[0].ID, Kind = 7, UseRelative = false, IsQuestion = false, UseApplyTo = ev.Actions[0].UseApplyTo, ExeType = 2, ActionName = ev.Actions[0].ActionName != null?pf.DataHandle.DefineString(ev.Actions[0].ActionName) : null, CodeID = getCode(ev.Actions[0].Code), ArgumentCount = ev.Actions[0].ArgumentCount, Who = -1, Relative = false, IsNot = false } } }; // Handle subtype switch (ev) { case AssetObject.EventAlarm e: newEv.Subtype = e.AlarmNumber; break; case AssetObject.EventStep e: newEv.Subtype = (int)e.SubtypeStep; break; case AssetObject.EventCollision e: newEv.Subtype = getObject(e.ObjectName); break; case AssetObject.EventKeyboard e: newEv.Subtype = (int)e.SubtypeKey; break; case AssetObject.EventMouse e: newEv.Subtype = (int)e.SubtypeMouse; break; case AssetObject.EventOther e: newEv.Subtype = (int)e.SubtypeOther; break; case AssetObject.EventDraw e: newEv.Subtype = (int)e.SubtypeDraw; break; case AssetObject.EventGesture e: newEv.Subtype = (int)e.SubtypeGesture; break; } newEvents.Add(newEv); } dataAsset.Events.Add(newEvents); } newList.Add(dataAsset); } dataAssets.Clear(); foreach (var obj in newList) { dataAssets.Add(obj); } }
public void Unserialize(GMDataReader reader) { Name = reader.ReadStringPointerObject(); Caption = reader.ReadStringPointerObject(); Width = reader.ReadInt32(); Height = reader.ReadInt32(); Speed = reader.ReadInt32(); Persistent = reader.ReadWideBoolean(); BackgroundColor = reader.ReadInt32(); DrawBackgroundColor = reader.ReadWideBoolean(); CreationCodeID = reader.ReadInt32(); int flags = reader.ReadInt32(); if (reader.VersionInfo.IsNumberAtLeast(2, 3)) { flags &= ~0x30000; } else if (reader.VersionInfo.IsNumberAtLeast(2)) { flags &= ~0x20000; } Flags = (RoomFlags)flags; Backgrounds = reader.ReadPointerObjectUnique <GMUniquePointerList <Background> >(); Views = reader.ReadPointerObjectUnique <GMUniquePointerList <View> >(); int gameObjectListPtr = reader.ReadInt32(); // read this later int tilePtr = reader.ReadInt32(); Tiles = reader.ReadPointerObjectUnique <GMUniquePointerList <Tile> >(tilePtr); Physics = reader.ReadWideBoolean(); Top = reader.ReadInt32(); Left = reader.ReadInt32(); Right = reader.ReadInt32(); Bottom = reader.ReadInt32(); GravityX = reader.ReadSingle(); GravityY = reader.ReadSingle(); PixelsToMeters = reader.ReadSingle(); if (reader.VersionInfo.IsNumberAtLeast(2)) { Layers = reader.ReadPointerObjectUnique <GMUniquePointerList <Layer> >(); if (reader.VersionInfo.IsNumberAtLeast(2, 3)) { // Read sequence ID list reader.Offset = reader.ReadInt32(); int seqIdCount = reader.ReadInt32(); SequenceIDs = new List <int>(seqIdCount); for (int i = seqIdCount; i > 0; i--) { SequenceIDs.Add(reader.ReadInt32()); } } } // Handle reading game objects, which change lengths in 2.2.2.302 roughly, so calculate the size of them reader.Offset = gameObjectListPtr; int count = reader.ReadInt32(); int eachSize; if (count > 1) { int first = reader.ReadInt32(); eachSize = reader.ReadInt32() - first; } else { eachSize = tilePtr - (reader.Offset + 4); } if (eachSize >= 40) { reader.VersionInfo.RoomObjectPreCreate = true; if (eachSize == 48) { reader.VersionInfo.SetNumber(2, 2, 2, 302); } } reader.Offset = gameObjectListPtr; GameObjects = new GMUniquePointerList <GameObject>(); GameObjects.Unserialize(reader); }
public void Unserialize(GMDataReader reader) { Subtype = reader.ReadInt32(); Actions = new GMUniquePointerList <Action>(); Actions.Unserialize(reader); }