From 47174b0e2fc6e8efa5ae6e7e468f0db054955617 Mon Sep 17 00:00:00 2001 From: Nikita Krapivin <33228822+nkrapivin@users.noreply.github.com> Date: Mon, 13 Jan 2020 22:22:38 +0500 Subject: [PATCH 01/10] Implement Physics, makerSettings, and got rid of all TODOs hooray! --- ExportToGMS1Project.csx | 80 ++++++++++++++++++++++++++++++++++------- 1 file changed, 68 insertions(+), 12 deletions(-) diff --git a/ExportToGMS1Project.csx b/ExportToGMS1Project.csx index cd9269c..a0d46f7 100644 --- a/ExportToGMS1Project.csx +++ b/ExportToGMS1Project.csx @@ -11,8 +11,9 @@ using UndertaleModLib.Models; using UndertaleModLib.Util; using UndertaleModLib.Decompiler; +string GameName = Data.GeneralInfo.Name.ToString().Replace(@"""",""); //Name == "Project" -> Project int progress = 0; -string projFolder = GetFolder(FilePath) + "Export_Project" + Path.DirectorySeparatorChar; +string projFolder = GetFolder(FilePath) + GameName + ".gmx" + Path.DirectorySeparatorChar; TextureWorker worker = new TextureWorker(); ThreadLocal DECOMPILE_CONTEXT = new ThreadLocal(() => new DecompileContext(Data, false)); string gmxDeclaration = "This Document is generated by GameMaker, if you edit it by hand then you do so at your own risk!"; @@ -213,10 +214,36 @@ void ExportGameObject(UndertaleGameObject gameObject) new XElement("persistent", BoolToString(gameObject.Persistent)), new XElement("parentName", gameObject.ParentId is null ? "" : gameObject.ParentId.Name.Content), new XElement("maskName", gameObject.TextureMaskId is null ? "" : gameObject.TextureMaskId.Name.Content), - new XElement("events") + new XElement("events"), + + //Physics + new XElement("PhysicsObject", BoolToString(gameObject.UsesPhysics)), + new XElement("PhysicsObjectSensor", BoolToString(gameObject.IsSensor)), + new XElement("PhysicsObjectShape", (uint)gameObject.CollisionShape), + new XElement("PhysicsObjectDensity", gameObject.Density), + new XElement("PhysicsObjectRestitution", gameObject.Restitution), + new XElement("PhysicsObjectGroup", gameObject.Group), + new XElement("PhysicsObjectLinearDamping", gameObject.LinearDamping), + new XElement("PhysicsObjectAngularDamping", gameObject.AngularDamping), + new XElement("PhysicsObjectFriction", gameObject.Friction), + new XElement("PhysicsObjectAwake", BoolToString(gameObject.Awake)), + new XElement("PhysicsObjectKinematic", BoolToString(gameObject.Kinematic)), + new XElement("PhysicsShapePoints") ) ); + + + // Loop through PhysicsShapePoints List + for (int _point = 0; _point < gameObject.PhysicsVertices.Count; _point++) + { + var _x = gameObject.PhysicsVertices[_point].X; + var _y = gameObject.PhysicsVertices[_point].Y; + + var physicsPointsNode = gmx.Element("object").Element("PhysicsShapePoints"); + physicsPointsNode.Add(new XElement("points",_x.ToString() + "," + _y.ToString())); + } + // Traversing the event type list for (int i = 0; i < gameObject.Events.Count; i++) { @@ -273,12 +300,11 @@ void ExportGameObject(UndertaleGameObject gameObject) eventNode.Add(actionNode); eventsNode.Add(eventNode); - // TODO:Physics } } } - File.WriteAllText(projFolder + "/objects/" + gameObject.Name.Content + ".object.gmx", gmx.ToString()); + File.WriteAllText(projFolder + "/objects/" + gameObject.Name.Content + ".object.gmx", gmx.ToString() + "\n"); } // --------------- Export Room --------------- @@ -307,10 +333,25 @@ void ExportRoom(UndertaleRoom room) new XElement("code", room.CreationCodeId != null ? Decompiler.Decompile(room.CreationCodeId, DECOMPILE_CONTEXT.Value) : ""), new XElement("enableViews", BoolToString(room.Flags.HasFlag(UndertaleRoom.RoomEntryFlags.EnableViews))), new XElement("clearViewBackground", BoolToString(room.Flags.HasFlag(UndertaleRoom.RoomEntryFlags.ShowColor))), - new XElement("clearDisplayBuffer", BoolToString(room.Flags.HasFlag(UndertaleRoom.RoomEntryFlags.ClearDisplayBuffer))) + new XElement("clearDisplayBuffer", BoolToString(room.Flags.HasFlag(UndertaleRoom.RoomEntryFlags.ClearDisplayBuffer))), + new XElement("makerSettings", + new XElement("isSet", 0), + new XElement("w", 0), + new XElement("h", 0), + new XElement("showGrid", 0), + new XElement("showObjects", 0), + new XElement("showTiles", 0), + new XElement("showBackgrounds", 0), + new XElement("showForegrounds", 0), + new XElement("showViews", 0), + new XElement("deleteUnderlyingObj", 0), + new XElement("deleteUnderlyingTiles", 0), + new XElement("page", 0), + new XElement("xoffset", 0), + new XElement("yoffset", 0) + ) ) ); - // TODO:MakerSettings // Room backgrounds var backgroundsNode = new XElement("backgrounds"); @@ -399,9 +440,20 @@ void ExportRoom(UndertaleRoom room) } gmx.Element("room").Add(tilesNode); - // TODO:Room physics + //Room Physics + + gmx.Element("room").Add( + new XElement("PhysicsWorld", room.World), + new XElement("PhysicsWorldTop", room.Top), + new XElement("PhysicsWorldLeft", room.Left), + new XElement("PhysicsWorldRight", room.Right), + new XElement("PhysicsWorldBottom", room.Bottom), + new XElement("PhysicsWorldGravityX", room.GravityX), + new XElement("PhysicsWorldGravityY", room.GravityY), + new XElement("PhysicsWorldPixToMeters", room.MetersPerPixel) + ); - File.WriteAllText(projFolder + "/rooms/" + room.Name.Content + ".room.gmx", gmx.ToString()); + File.WriteAllText(projFolder + "/rooms/" + room.Name.Content + ".room.gmx", gmx.ToString() + "\n"); } // --------------- Export Sound --------------- @@ -422,9 +474,13 @@ void ExportSound(UndertaleSound sound) new XElement("extension", Path.GetExtension(sound.File.Content)), new XElement("origname", "sound\\audio\\" + sound.File.Content), new XElement("effects", sound.Effects.ToString()), - new XElement("volume", sound.Volume.ToString()), + new XElement("volume", + new XElement("volume", sound.Volume.ToString()) + ), new XElement("pan", "0"), - new XElement("bitRates", "192"), + new XElement("bitRates", + new XElement("bitRate", "192") + ), new XElement("sampleRates", new XElement("sampleRate", "44100") ), @@ -443,7 +499,7 @@ void ExportSound(UndertaleSound sound) ) ); - File.WriteAllText(projFolder + "/sound/" + sound.Name.Content + ".sound.gmx", gmx.ToString()); + File.WriteAllText(projFolder + "/sound/" + sound.Name.Content + ".sound.gmx", gmx.ToString() + "\n"); // Save sound files if (sound.AudioFile != null) @@ -626,7 +682,7 @@ void GenerateProjectFile() WriteIndexes(gmx.Element("assets"), "paths", "paths", Data.Paths, "path", "paths\\"); WriteIndexes(gmx.Element("assets"), "timelines", "timelines", Data.Timelines, "timeline", "timelines\\"); - File.WriteAllText(projFolder + "Export_Project.project.gmx", gmx.ToString()); + File.WriteAllText(projFolder + GameName + ".project.gmx", gmx.ToString()); } void WriteIndexes(XElement rootNode, string elementName, string attributeName, IList dataList, string oneName, string resourcePath, string fileExtension = "") From e3c753b6647483ce8ed09fda00e5f55adab92099 Mon Sep 17 00:00:00 2001 From: Cube <35161393+cubeww@users.noreply.github.com> Date: Tue, 28 Jan 2020 19:45:54 +0800 Subject: [PATCH 02/10] fix sprite border --- ExportToGMS1Project.csx | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/ExportToGMS1Project.csx b/ExportToGMS1Project.csx index a0d46f7..16bc478 100644 --- a/ExportToGMS1Project.csx +++ b/ExportToGMS1Project.csx @@ -142,15 +142,7 @@ void ExportSprite(UndertaleSprite sprite) { if (sprite.Textures[i]?.Texture != null) { - // Fix sprite size - var bitmapNew = new Bitmap((int)sprite.Width, (int)sprite.Height); - var bitmapOrigin = worker.GetTextureFor(sprite.Textures[i].Texture, Path.GetFileNameWithoutExtension(projFolder + "/sprites/images/" + sprite.Name.Content + "_" + i + ".png")); - //worker.ExportAsPNG(sprite.Textures[i].Texture, projFolder + "/sprites/images/" + sprite.Name.Content + "_" + i + ".png"); - var g = Graphics.FromImage(bitmapNew); - g.DrawImage(bitmapOrigin, (int)sprite.Textures[i].Texture.TargetX, (int)sprite.Textures[i].Texture.TargetY); - bitmapNew.Save(projFolder + "/sprites/images/" + sprite.Name.Content + "_" + i + ".png"); - bitmapNew.Dispose(); - bitmapOrigin.Dispose(); + worker.ExportAsPNG(sprite.Textures[i].Texture, projFolder + "/sprites/images/" + sprite.Name.Content + "_" + i + ".png", null, true); } } } From c0ca4e1adcdc50c90fbb57b682ec80d05eb5501f Mon Sep 17 00:00:00 2001 From: Cube <35161393+cubeww@users.noreply.github.com> Date: Tue, 24 Mar 2020 21:58:55 +0800 Subject: [PATCH 03/10] Fix background export --- ExportToGMS1Project.csx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ExportToGMS1Project.csx b/ExportToGMS1Project.csx index 16bc478..bc1075e 100644 --- a/ExportToGMS1Project.csx +++ b/ExportToGMS1Project.csx @@ -162,8 +162,8 @@ void ExportBackground(UndertaleBackground background) new XComment(gmxDeclaration), new XElement("background", new XElement("istileset", "-1"), - new XElement("tilewidth", background.Texture.BoundingWidth.ToString()), - new XElement("tileheight", background.Texture.BoundingHeight.ToString()), + new XElement("tilewidth", background.Texture == null ? "0" : background.Texture.BoundingWidth.ToString()), + new XElement("tileheight", background.Texture == null ? "0" : background.Texture.BoundingHeight.ToString()), new XElement("tilexoff", "0"), new XElement("tileyoff", "0"), new XElement("tilehsep", "0"), @@ -174,8 +174,8 @@ void ExportBackground(UndertaleBackground background) new XElement("TextureGroup0", "0") ), new XElement("For3D", "0"), - new XElement("width", background.Texture.BoundingWidth.ToString()), - new XElement("height", background.Texture.BoundingHeight.ToString()), + new XElement("width", background.Texture == null ? "0" : background.Texture.BoundingWidth.ToString()), + new XElement("height",background.Texture == null ? "0" : background.Texture.BoundingHeight.ToString()), new XElement("data", "images\\" + background.Name.Content + ".png") ) ); @@ -183,7 +183,8 @@ void ExportBackground(UndertaleBackground background) File.WriteAllText(projFolder + "/background/" + background.Name.Content + ".background.gmx", gmx.ToString()); // Save background images - worker.ExportAsPNG(background.Texture, projFolder + "/background/images/" + background.Name.Content + ".png"); + if (background.Texture != null) + worker.ExportAsPNG(background.Texture, projFolder + "/background/images/" + background.Name.Content + ".png"); } // --------------- Export Object --------------- async Task ExportGameObjects() @@ -688,4 +689,4 @@ void WriteIndexes(XElement rootNode, string elementName, string attributeName resourcesNode.Add(resourceNode); } rootNode.Add(resourcesNode); -} +} \ No newline at end of file From 39b8958d9c9eda123bc2dea45b8d83ce0e090646 Mon Sep 17 00:00:00 2001 From: ithinkandicode Date: Sun, 17 May 2020 10:51:23 +0100 Subject: [PATCH 04/10] fix: Remove repeated `bbox_right` in sprite export (minor) --- ExportToGMS1Project.csx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ExportToGMS1Project.csx b/ExportToGMS1Project.csx index bc1075e..ce0328d 100644 --- a/ExportToGMS1Project.csx +++ b/ExportToGMS1Project.csx @@ -116,8 +116,7 @@ void ExportSprite(UndertaleSprite sprite) new XElement("For3D", "0"), new XElement("width", sprite.Width.ToString()), new XElement("height", sprite.Height.ToString()), - new XElement("frames"), - new XElement("bbox_right", sprite.MarginRight.ToString()) + new XElement("frames") ) ); From f26c349ed98abe6e60153fa6745102272cbc820c Mon Sep 17 00:00:00 2001 From: ithinkandicode Date: Wed, 29 Apr 2020 20:45:47 +0100 Subject: [PATCH 05/10] feat: Add variable to set EOL character (LF or CRLF) --- ExportToGMS1Project.csx | 1 + 1 file changed, 1 insertion(+) diff --git a/ExportToGMS1Project.csx b/ExportToGMS1Project.csx index ce0328d..57efe1e 100644 --- a/ExportToGMS1Project.csx +++ b/ExportToGMS1Project.csx @@ -17,6 +17,7 @@ string projFolder = GetFolder(FilePath) + GameName + ".gmx" + Path.DirectorySepa TextureWorker worker = new TextureWorker(); ThreadLocal DECOMPILE_CONTEXT = new ThreadLocal(() => new DecompileContext(Data, false)); string gmxDeclaration = "This Document is generated by GameMaker, if you edit it by hand then you do so at your own risk!"; +string eol = "\n"; // Linux: "\n", Windows: "\r\n" if (Directory.Exists(projFolder)) { From 90bf7f24f3554519760b869c4fea32f2e522c57b Mon Sep 17 00:00:00 2001 From: ithinkandicode Date: Wed, 29 Apr 2020 20:48:17 +0100 Subject: [PATCH 06/10] feat: Add variable to set EOL character (LF or CRLF) - use `eol` variable --- ExportToGMS1Project.csx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ExportToGMS1Project.csx b/ExportToGMS1Project.csx index 57efe1e..df45eae 100644 --- a/ExportToGMS1Project.csx +++ b/ExportToGMS1Project.csx @@ -135,7 +135,7 @@ void ExportSprite(UndertaleSprite sprite) } } - File.WriteAllText(projFolder + "/sprites/" + sprite.Name.Content + ".sprite.gmx", gmx.ToString()); + File.WriteAllText(projFolder + "/sprites/" + sprite.Name.Content + ".sprite.gmx", gmx.ToString() + eol); // Save sprite images for (int i = 0; i < sprite.Textures.Count; i++) @@ -180,7 +180,7 @@ void ExportBackground(UndertaleBackground background) ) ); - File.WriteAllText(projFolder + "/background/" + background.Name.Content + ".background.gmx", gmx.ToString()); + File.WriteAllText(projFolder + "/background/" + background.Name.Content + ".background.gmx", gmx.ToString() + eol); // Save background images if (background.Texture != null) @@ -297,7 +297,7 @@ void ExportGameObject(UndertaleGameObject gameObject) } } - File.WriteAllText(projFolder + "/objects/" + gameObject.Name.Content + ".object.gmx", gmx.ToString() + "\n"); + File.WriteAllText(projFolder + "/objects/" + gameObject.Name.Content + ".object.gmx", gmx.ToString() + eol); } // --------------- Export Room --------------- @@ -446,7 +446,7 @@ void ExportRoom(UndertaleRoom room) new XElement("PhysicsWorldPixToMeters", room.MetersPerPixel) ); - File.WriteAllText(projFolder + "/rooms/" + room.Name.Content + ".room.gmx", gmx.ToString() + "\n"); + File.WriteAllText(projFolder + "/rooms/" + room.Name.Content + ".room.gmx", gmx.ToString() + eol); } // --------------- Export Sound --------------- @@ -492,7 +492,7 @@ void ExportSound(UndertaleSound sound) ) ); - File.WriteAllText(projFolder + "/sound/" + sound.Name.Content + ".sound.gmx", gmx.ToString() + "\n"); + File.WriteAllText(projFolder + "/sound/" + sound.Name.Content + ".sound.gmx", gmx.ToString() + eol); // Save sound files if (sound.AudioFile != null) @@ -562,7 +562,7 @@ void ExportFont(UndertaleFont font) glyphsNode.Add(glyphNode); } - File.WriteAllText(projFolder + "/fonts/" + font.Name.Content + ".font.gmx", gmx.ToString()); + File.WriteAllText(projFolder + "/fonts/" + font.Name.Content + ".font.gmx", gmx.ToString() + eol); // Save font textures worker.ExportAsPNG(font.Texture, projFolder + "/fonts/" + font.Name.Content + ".png"); @@ -599,7 +599,7 @@ void ExportPath(UndertalePath path) ); } - File.WriteAllText(projFolder + "/paths/" + path.Name.Content + ".path.gmx", gmx.ToString()); + File.WriteAllText(projFolder + "/paths/" + path.Name.Content + ".path.gmx", gmx.ToString() + eol); } // --------------- Export Timelines --------------- @@ -650,7 +650,7 @@ void ExportTimeline(UndertaleTimeline timeline) gmx.Element("timeline").Add(entryNode); } - File.WriteAllText(projFolder + "/timelines/" + timeline.Name.Content + ".timeline.gmx", gmx.ToString()); + File.WriteAllText(projFolder + "/timelines/" + timeline.Name.Content + ".timeline.gmx", gmx.ToString() + eol); } @@ -675,7 +675,7 @@ void GenerateProjectFile() WriteIndexes(gmx.Element("assets"), "paths", "paths", Data.Paths, "path", "paths\\"); WriteIndexes(gmx.Element("assets"), "timelines", "timelines", Data.Timelines, "timeline", "timelines\\"); - File.WriteAllText(projFolder + GameName + ".project.gmx", gmx.ToString()); + File.WriteAllText(projFolder + GameName + ".project.gmx", gmx.ToString() + eol); } void WriteIndexes(XElement rootNode, string elementName, string attributeName, IList dataList, string oneName, string resourcePath, string fileExtension = "") From 74e8f74385c7ccd449255a01ac648a4789f2fb8e Mon Sep 17 00:00:00 2001 From: ithinkandicode Date: Wed, 29 Apr 2020 20:49:28 +0100 Subject: [PATCH 07/10] fix: Write room setting for "Draw background color" (`showColour`) --- ExportToGMS1Project.csx | 1 + 1 file changed, 1 insertion(+) diff --git a/ExportToGMS1Project.csx b/ExportToGMS1Project.csx index df45eae..87d8b54 100644 --- a/ExportToGMS1Project.csx +++ b/ExportToGMS1Project.csx @@ -323,6 +323,7 @@ void ExportRoom(UndertaleRoom room) new XElement("speed", room.Speed.ToString()), new XElement("persistent", BoolToString(room.Persistent)), new XElement("colour", room.BackgroundColor.ToString()), + new XElement("showcolour", BoolToString(room.DrawBackgroundColor)), new XElement("code", room.CreationCodeId != null ? Decompiler.Decompile(room.CreationCodeId, DECOMPILE_CONTEXT.Value) : ""), new XElement("enableViews", BoolToString(room.Flags.HasFlag(UndertaleRoom.RoomEntryFlags.EnableViews))), new XElement("clearViewBackground", BoolToString(room.Flags.HasFlag(UndertaleRoom.RoomEntryFlags.ShowColor))), From 349983498b65c9c3814c8c093ebe546efc48551f Mon Sep 17 00:00:00 2001 From: ithinkandicode Date: Wed, 29 Apr 2020 20:50:07 +0100 Subject: [PATCH 08/10] fix: Write room view setting for height (hview) --- ExportToGMS1Project.csx | 1 + 1 file changed, 1 insertion(+) diff --git a/ExportToGMS1Project.csx b/ExportToGMS1Project.csx index 87d8b54..9e92e44 100644 --- a/ExportToGMS1Project.csx +++ b/ExportToGMS1Project.csx @@ -377,6 +377,7 @@ void ExportRoom(UndertaleRoom room) new XAttribute("xview", i.ViewX.ToString()), new XAttribute("yview", i.ViewY.ToString()), new XAttribute("wview", i.ViewHeight.ToString()), + new XAttribute("hview", i.ViewHeight.ToString()), new XAttribute("xport", i.PortX.ToString()), new XAttribute("yport", i.PortY.ToString()), new XAttribute("wport", i.PortWidth.ToString()), From 6ec4691448da1cbd47b209b870e589d5a13120c7 Mon Sep 17 00:00:00 2001 From: ithinkandicode Date: Wed, 29 Apr 2020 20:50:41 +0100 Subject: [PATCH 09/10] fix: Fix room view setting for width (was set to ViewHeight) --- ExportToGMS1Project.csx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ExportToGMS1Project.csx b/ExportToGMS1Project.csx index 9e92e44..edf2066 100644 --- a/ExportToGMS1Project.csx +++ b/ExportToGMS1Project.csx @@ -376,7 +376,7 @@ void ExportRoom(UndertaleRoom room) new XAttribute("objName", i.ObjectId is null ? "" : i.ObjectId.Name.Content), new XAttribute("xview", i.ViewX.ToString()), new XAttribute("yview", i.ViewY.ToString()), - new XAttribute("wview", i.ViewHeight.ToString()), + new XAttribute("wview", i.ViewWidth.ToString()), new XAttribute("hview", i.ViewHeight.ToString()), new XAttribute("xport", i.PortX.ToString()), new XAttribute("yport", i.PortY.ToString()), From 81e89b84fcea51f52d5d1b9799a7c920a79cf947 Mon Sep 17 00:00:00 2001 From: OleSTEEP Date: Wed, 14 May 2025 02:53:05 +0300 Subject: [PATCH 10/10] Update to work with UTMT 0.8.x --- ExportToGMS1Project.csx | 36 ++++++++++++++++++++++-------------- README.md | 4 +++- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/ExportToGMS1Project.csx b/ExportToGMS1Project.csx index edf2066..aa25435 100644 --- a/ExportToGMS1Project.csx +++ b/ExportToGMS1Project.csx @@ -10,12 +10,13 @@ using System.Reflection; using UndertaleModLib.Models; using UndertaleModLib.Util; using UndertaleModLib.Decompiler; +using Underanalyzer.Decompiler; string GameName = Data.GeneralInfo.Name.ToString().Replace(@"""",""); //Name == "Project" -> Project int progress = 0; string projFolder = GetFolder(FilePath) + GameName + ".gmx" + Path.DirectorySeparatorChar; -TextureWorker worker = new TextureWorker(); -ThreadLocal DECOMPILE_CONTEXT = new ThreadLocal(() => new DecompileContext(Data, false)); +TextureWorker worker = new(); +GlobalDecompileContext decompileContext = new(Data); string gmxDeclaration = "This Document is generated by GameMaker, if you edit it by hand then you do so at your own risk!"; string eol = "\n"; // Linux: "\n", Windows: "\r\n" @@ -70,7 +71,7 @@ await ExportTimelines(); GenerateProjectFile(); // --------------- Export completed --------------- -worker.Cleanup(); +worker.Dispose(); // worker.Cleanup()? HideProgressBar(); ScriptMessage("Export Complete.\n\nLocation: " + projFolder); @@ -269,6 +270,13 @@ void ExportGameObject(UndertaleGameObject gameObject) // Traversing the action list foreach (var k in j.Actions) { + DecompileContext dec_context = new(decompileContext, k.CodeId, Data.ToolInfo.DecompilerSettings); + XElement act_string = null; + try { + act_string = new XElement("string", (k.CodeId != null && dec_context != null) ? dec_context.DecompileToString() : ""); + } catch (DecompilerException) { + act_string = new XElement("string", ""); + } actionNode.Add( new XElement("libid", k.LibID.ToString()), new XElement("id", k.ID.ToString()), @@ -277,7 +285,7 @@ void ExportGameObject(UndertaleGameObject gameObject) new XElement("isquestion", BoolToString(k.IsQuestion)), new XElement("useapplyto", BoolToString(k.UseApplyTo)), new XElement("exetype", k.ExeType.ToString()), - new XElement("functionname", k.ActionName.Content), + new XElement("functionname", k.ActionName != null ? k.ActionName.Content : ""), new XElement("codestring", ""), new XElement("whoName", "self"), new XElement("relative", BoolToString(k.Relative)), @@ -285,7 +293,7 @@ void ExportGameObject(UndertaleGameObject gameObject) new XElement("arguments", new XElement("argument", new XElement("kind", "1"), - new XElement("string", k.CodeId != null ? Decompiler.Decompile(k.CodeId, DECOMPILE_CONTEXT.Value) : "") + act_string ) ) ); @@ -324,10 +332,10 @@ void ExportRoom(UndertaleRoom room) new XElement("persistent", BoolToString(room.Persistent)), new XElement("colour", room.BackgroundColor.ToString()), new XElement("showcolour", BoolToString(room.DrawBackgroundColor)), - new XElement("code", room.CreationCodeId != null ? Decompiler.Decompile(room.CreationCodeId, DECOMPILE_CONTEXT.Value) : ""), + new XElement("code", room.CreationCodeId != null ? new DecompileContext(decompileContext, room.CreationCodeId).DecompileToString() : ""), new XElement("enableViews", BoolToString(room.Flags.HasFlag(UndertaleRoom.RoomEntryFlags.EnableViews))), new XElement("clearViewBackground", BoolToString(room.Flags.HasFlag(UndertaleRoom.RoomEntryFlags.ShowColor))), - new XElement("clearDisplayBuffer", BoolToString(room.Flags.HasFlag(UndertaleRoom.RoomEntryFlags.ClearDisplayBuffer))), + //new XElement("clearDisplayBuffer", BoolToString(room.Flags.HasFlag(UndertaleRoom.RoomEntryFlags.ClearDisplayBuffer))), new XElement("makerSettings", new XElement("isSet", 0), new XElement("w", 0), @@ -357,8 +365,8 @@ void ExportRoom(UndertaleRoom room) new XAttribute("name", i.BackgroundDefinition is null ? "" : i.BackgroundDefinition.Name.Content), new XAttribute("x", i.X.ToString()), new XAttribute("y", i.Y.ToString()), - new XAttribute("htiled", i.TileX.ToString()), - new XAttribute("vtiled", i.TileY.ToString()), + new XAttribute("htiled", i.X.ToString()), + new XAttribute("vtiled", i.Y.ToString()), new XAttribute("hspeed", i.SpeedX.ToString()), new XAttribute("vspeed", i.SpeedY.ToString()), new XAttribute("stretch", "0") @@ -401,7 +409,7 @@ void ExportRoom(UndertaleRoom room) new XAttribute("y", i.Y.ToString()), new XAttribute("name", "inst_" + i.InstanceID.ToString("X")), new XAttribute("locked", "0"), - new XAttribute("code", i.CreationCode != null ? Decompiler.Decompile(i.CreationCode, DECOMPILE_CONTEXT.Value) : ""), + new XAttribute("code", i.CreationCode != null ? new DecompileContext(decompileContext, i.CreationCode).DecompileToString() : ""), new XAttribute("scaleX", i.ScaleX.ToString()), new XAttribute("scaleY", i.ScaleY.ToString()), new XAttribute("colour", i.Color.ToString()), @@ -512,7 +520,7 @@ void ExportScript(UndertaleScript script) UpdateProgressBar(null, $"Exporting script: {script.Name.Content}", progress++, resourceNum); // Save GML files - File.WriteAllText(projFolder + "/scripts/" + script.Name.Content + ".gml", (script.Code != null ? Decompiler.Decompile(script.Code, DECOMPILE_CONTEXT.Value) : "")); + File.WriteAllText(projFolder + "/scripts/" + script.Name.Content + ".gml", script.Code != null ? new DecompileContext(decompileContext, script.Code).DecompileToString() : ""); } // --------------- Export Font --------------- @@ -622,9 +630,9 @@ void ExportTimeline(UndertaleTimeline timeline) foreach (var i in timeline.Moments) { var entryNode = new XElement("entry"); - entryNode.Add(new XElement("step", i.Item1)); + entryNode.Add(new XElement("step", i.Step)); entryNode.Add(new XElement("event")); - foreach (var j in i.Item2) + foreach (var j in i.Event) { entryNode.Element("event").Add( new XElement("action", @@ -643,7 +651,7 @@ void ExportTimeline(UndertaleTimeline timeline) new XElement("arguments", new XElement("argument", new XElement("kind", "1"), - new XElement("string", j.CodeId != null ? Decompiler.Decompile(j.CodeId, DECOMPILE_CONTEXT.Value) : "") + new XElement("string", j.CodeId != null ? new DecompileContext(decompileContext, j.CodeId).DecompileToString() : "") ) ) ) diff --git a/README.md b/README.md index 14d20dc..f4506b2 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,6 @@ This is a script for UndertaleModTool, which can export game files as project files of GameMaker Studio. -Currently compatible with gms1.4, will support gms2 in the future. \ No newline at end of file +Currently compatible with gms1.4, will support gms2 in the future. + +Original repo: https://github.com/cubeww/UndertaleModTool-ExportToProjectScript \ No newline at end of file