Skip to content

Commit 0985450

Browse files
authored
Merge pull request #9 from ithinkandicode/fix/room-showbg-viewsize
Fix/room showbg viewsize
2 parents c0ca4e1 + 0b87285 commit 0985450

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

ExportToGMS1Project.csx

+13-10
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ string projFolder = GetFolder(FilePath) + GameName + ".gmx" + Path.DirectorySepa
1717
TextureWorker worker = new TextureWorker();
1818
ThreadLocal<DecompileContext> DECOMPILE_CONTEXT = new ThreadLocal<DecompileContext>(() => new DecompileContext(Data, false));
1919
string gmxDeclaration = "This Document is generated by GameMaker, if you edit it by hand then you do so at your own risk!";
20+
string eol = "\n"; // Linux: "\n", Windows: "\r\n"
2021

2122
if (Directory.Exists(projFolder))
2223
{
@@ -135,7 +136,7 @@ void ExportSprite(UndertaleSprite sprite)
135136
}
136137
}
137138

138-
File.WriteAllText(projFolder + "/sprites/" + sprite.Name.Content + ".sprite.gmx", gmx.ToString());
139+
File.WriteAllText(projFolder + "/sprites/" + sprite.Name.Content + ".sprite.gmx", gmx.ToString() + eol);
139140

140141
// Save sprite images
141142
for (int i = 0; i < sprite.Textures.Count; i++)
@@ -180,7 +181,7 @@ void ExportBackground(UndertaleBackground background)
180181
)
181182
);
182183

183-
File.WriteAllText(projFolder + "/background/" + background.Name.Content + ".background.gmx", gmx.ToString());
184+
File.WriteAllText(projFolder + "/background/" + background.Name.Content + ".background.gmx", gmx.ToString() + eol);
184185

185186
// Save background images
186187
if (background.Texture != null)
@@ -297,7 +298,7 @@ void ExportGameObject(UndertaleGameObject gameObject)
297298
}
298299
}
299300

300-
File.WriteAllText(projFolder + "/objects/" + gameObject.Name.Content + ".object.gmx", gmx.ToString() + "\n");
301+
File.WriteAllText(projFolder + "/objects/" + gameObject.Name.Content + ".object.gmx", gmx.ToString() + eol);
301302
}
302303

303304
// --------------- Export Room ---------------
@@ -323,6 +324,7 @@ void ExportRoom(UndertaleRoom room)
323324
new XElement("speed", room.Speed.ToString()),
324325
new XElement("persistent", BoolToString(room.Persistent)),
325326
new XElement("colour", room.BackgroundColor.ToString()),
327+
new XElement("showcolour", BoolToString(room.DrawBackgroundColor)),
326328
new XElement("code", room.CreationCodeId != null ? Decompiler.Decompile(room.CreationCodeId, DECOMPILE_CONTEXT.Value) : ""),
327329
new XElement("enableViews", BoolToString(room.Flags.HasFlag(UndertaleRoom.RoomEntryFlags.EnableViews))),
328330
new XElement("clearViewBackground", BoolToString(room.Flags.HasFlag(UndertaleRoom.RoomEntryFlags.ShowColor))),
@@ -375,7 +377,8 @@ void ExportRoom(UndertaleRoom room)
375377
new XAttribute("objName", i.ObjectId is null ? "<undefined>" : i.ObjectId.Name.Content),
376378
new XAttribute("xview", i.ViewX.ToString()),
377379
new XAttribute("yview", i.ViewY.ToString()),
378-
new XAttribute("wview", i.ViewHeight.ToString()),
380+
new XAttribute("wview", i.ViewWidth.ToString()),
381+
new XAttribute("hview", i.ViewHeight.ToString()),
379382
new XAttribute("xport", i.PortX.ToString()),
380383
new XAttribute("yport", i.PortY.ToString()),
381384
new XAttribute("wport", i.PortWidth.ToString()),
@@ -446,7 +449,7 @@ void ExportRoom(UndertaleRoom room)
446449
new XElement("PhysicsWorldPixToMeters", room.MetersPerPixel)
447450
);
448451

449-
File.WriteAllText(projFolder + "/rooms/" + room.Name.Content + ".room.gmx", gmx.ToString() + "\n");
452+
File.WriteAllText(projFolder + "/rooms/" + room.Name.Content + ".room.gmx", gmx.ToString() + eol);
450453
}
451454

452455
// --------------- Export Sound ---------------
@@ -492,7 +495,7 @@ void ExportSound(UndertaleSound sound)
492495
)
493496
);
494497

495-
File.WriteAllText(projFolder + "/sound/" + sound.Name.Content + ".sound.gmx", gmx.ToString() + "\n");
498+
File.WriteAllText(projFolder + "/sound/" + sound.Name.Content + ".sound.gmx", gmx.ToString() + eol);
496499

497500
// Save sound files
498501
if (sound.AudioFile != null)
@@ -562,7 +565,7 @@ void ExportFont(UndertaleFont font)
562565
glyphsNode.Add(glyphNode);
563566
}
564567

565-
File.WriteAllText(projFolder + "/fonts/" + font.Name.Content + ".font.gmx", gmx.ToString());
568+
File.WriteAllText(projFolder + "/fonts/" + font.Name.Content + ".font.gmx", gmx.ToString() + eol);
566569

567570
// Save font textures
568571
worker.ExportAsPNG(font.Texture, projFolder + "/fonts/" + font.Name.Content + ".png");
@@ -599,7 +602,7 @@ void ExportPath(UndertalePath path)
599602
);
600603
}
601604

602-
File.WriteAllText(projFolder + "/paths/" + path.Name.Content + ".path.gmx", gmx.ToString());
605+
File.WriteAllText(projFolder + "/paths/" + path.Name.Content + ".path.gmx", gmx.ToString() + eol);
603606
}
604607

605608
// --------------- Export Timelines ---------------
@@ -650,7 +653,7 @@ void ExportTimeline(UndertaleTimeline timeline)
650653
gmx.Element("timeline").Add(entryNode);
651654
}
652655

653-
File.WriteAllText(projFolder + "/timelines/" + timeline.Name.Content + ".timeline.gmx", gmx.ToString());
656+
File.WriteAllText(projFolder + "/timelines/" + timeline.Name.Content + ".timeline.gmx", gmx.ToString() + eol);
654657
}
655658

656659

@@ -675,7 +678,7 @@ void GenerateProjectFile()
675678
WriteIndexes<UndertalePath>(gmx.Element("assets"), "paths", "paths", Data.Paths, "path", "paths\\");
676679
WriteIndexes<UndertaleTimeline>(gmx.Element("assets"), "timelines", "timelines", Data.Timelines, "timeline", "timelines\\");
677680

678-
File.WriteAllText(projFolder + GameName + ".project.gmx", gmx.ToString());
681+
File.WriteAllText(projFolder + GameName + ".project.gmx", gmx.ToString() + eol);
679682
}
680683

681684
void WriteIndexes<T>(XElement rootNode, string elementName, string attributeName, IList<T> dataList, string oneName, string resourcePath, string fileExtension = "")

0 commit comments

Comments
 (0)