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>(); for (int i = vertexCount; i > 0; i--) { PhysicsVertex v = new PhysicsVertex(); v.Unserialize(reader); PhysicsVertices.Add(v); } Events = new GMPointerList <GMPointerList <Event> >(); Events.Unserialize(reader); }
public override void Unserialize(GMDataReader reader) { base.Unserialize(reader); List = new GMPointerList <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)) { 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 GMPointerList <GMPath>(); 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 GMPointerList <GMGlyph>(); Glyphs.Unserialize(reader); }
public void Unserialize(GMDataReader reader) { EmptyString = reader.ReadStringPointerObject(); Name = reader.ReadStringPointerObject(); ClassName = reader.ReadStringPointerObject(); Files = new GMPointerList <ExtensionFile>(); Files.Unserialize(reader); }
public void Unserialize(GMDataReader reader) { Filename = reader.ReadStringPointerObject(); FinalFunction = reader.ReadStringPointerObject(); InitFunction = reader.ReadStringPointerObject(); Kind = (ExtensionKind)reader.ReadUInt32(); Functions = new GMPointerList <ExtensionFunction>(); Functions.Unserialize(reader); }
public override void Unserialize(GMDataReader reader) { base.Unserialize(reader); if (Length == 0) { return; // In YYC, before bytecode 17, CODE is empty } List = new GMPointerList <GMCode>(); List.Unserialize(reader); }
public override void Unserialize(GMDataReader reader) { base.Unserialize(reader); if (reader.ReadUInt32() != 1) { reader.Warnings.Add(new GMWarning("Unknown SEQN version, expected 1.")); } List = new GMPointerList <GMSequence>(); List.Unserialize(reader); }
public override void Unserialize(GMDataReader reader) { base.Unserialize(reader); if (reader.ReadInt32() != 1) { reader.Warnings.Add(new GMWarning("Unexpected TGIN version, != 1", GMWarning.WarningLevel.Severe)); } List = new GMPointerList <GMTextureGroupInfo>(); List.Unserialize(reader); }
public override void Unserialize(GMDataReader reader) { base.Unserialize(reader); int chunkVersion = reader.ReadInt32(); if (chunkVersion != 1) { reader.Warnings.Add(new GMWarning(string.Format("ACRV version is {0}, expected 1", chunkVersion))); } List = new GMPointerList <GMAnimCurve>(); List.Unserialize(reader); }
public void Unserialize(GMDataReader reader) { LegacyTiles = reader.ReadPointerObject <GMPointerList <Tile> >(); Sprites = reader.ReadPointerObject <GMPointerList <AssetInstance> >(); if (reader.VersionInfo.IsNumberAtLeast(2, 3)) { Sequences = reader.ReadPointerObject <GMPointerList <AssetInstance> >(); if (!reader.VersionInfo.IsNumberAtLeast(2, 3, 2)) { NineSlices = reader.ReadPointerObject <GMPointerList <AssetInstance> >(); } } }
public override void Unserialize(GMDataReader reader) { base.Unserialize(reader); List = new GMPointerList <GMString>(); List.Unserialize(reader, null, null, (GMDataReader reader, bool notLast) => { int ptr = reader.ReadInt32(); // Check if strings are aligned to 4 byte offsets reader.VersionInfo.AlignStringsTo4 &= (ptr % 4 == 0); return(reader.ReadPointerObject <GMString>(ptr, notLast)); }); }
public override void Unserialize(GMDataReader reader) { base.Unserialize(reader); List = new GMPointerList <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); reader.Pad(4); int chunkVersion = reader.ReadInt32(); if (chunkVersion != 1) { reader.Warnings.Add(new GMWarning(string.Format("TAGS version is {0}, expected 1", chunkVersion))); } AllTags = new List <GMString>(); for (int i = reader.ReadInt32(); i > 0; i--) { AllTags.Add(reader.ReadStringPointerObject()); } AssetTagsList = new GMPointerList <AssetTags>(); AssetTagsList.Unserialize(reader); }
public override void Unserialize(GMDataReader reader) { base.Unserialize(reader); List = new GMPointerList <GMFont>(); List.Unserialize(reader); // Whatever this is for (short i = 0; i < 0x80; i++) { if (reader.ReadInt16() != i) { reader.Warnings.Add(new GMWarning("Incorrect weird values in FONT")); } } for (short i = 0; i < 0x80; i++) { if (reader.ReadInt16() != 0x3f) { reader.Warnings.Add(new GMWarning("Incorrect weird values in FONT (part 2)")); } } }
public void Unserialize(GMDataReader reader) { Subtype = reader.ReadInt32(); Actions = new GMPointerList <Action>(); Actions.Unserialize(reader); }
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.ReadPointerObject <GMPointerList <Background> >(); Views = reader.ReadPointerObject <GMPointerList <View> >(); int gameObjectListPtr = reader.ReadInt32(); // read this later int tilePtr = reader.ReadInt32(); Tiles = reader.ReadPointerObject <GMPointerList <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.ReadPointerObject <GMPointerList <Layer> >(); if (reader.VersionInfo.IsNumberAtLeast(2, 3)) { // Read sequence ID list reader.Offset = reader.ReadInt32(); SequenceIDs = new List <int>(); for (int i = reader.ReadInt32(); 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 GMPointerList <GameObject>(); GameObjects.Unserialize(reader); }
private static void ConvertObjects(ProjectFile pf) { GMList <GMObject> dataAssets = ((GMChunkOBJT)pf.DataHandle.Chunks["OBJT"]).List; GMList <GMSprite> dataSprites = ((GMChunkSPRT)pf.DataHandle.Chunks["SPRT"]).List; GMList <GMCode> dataCode = ((GMChunkCODE)pf.DataHandle.Chunks["CODE"]).List; int getSprite(string name) { if (name == null) { return(-1); } try { return(dataSprites.Select((elem, index) => new { elem, index }).First(p => p.elem.Name.Content == name).index); } catch (InvalidOperationException) { return(-1); } } 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); } try { return(dataAssets.Select((elem, index) => new { elem, index }).First(p => p.elem.Name.Content == name).index); } catch (InvalidOperationException) { return(-1); } } List <GMObject> newList = new List <GMObject>(); for (int i = 0; i < pf.Objects.Count; i++) { AssetObject projectAsset = pf.Objects[i]; GMObject dataAsset = new GMObject() { Name = pf.DataHandle.DefineString(projectAsset.Name), SpriteID = getSprite(projectAsset.Sprite), Visible = projectAsset.Visible, Solid = projectAsset.Solid, Depth = projectAsset.Depth, Persistent = projectAsset.Persistent, ParentObjectID = getObject(projectAsset.ParentObject), MaskSpriteID = getSprite(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 GMPointerList <GMPointerList <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 GMPointerList <GMObject.Event>(); foreach (var ev in events) { GMObject.Event newEv = new GMObject.Event() { Subtype = 0, Actions = new GMPointerList <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); } }