private static void WriteTexturePages(GMAssets _data, Stream _s, IFF _iff) { if (ms_tpageSprites.Entries.Count > 0) { ms_tpageSprites.Compile(); } IOrderedEnumerable <TexturePageEntry> source = ms_tpageSprites.Entries.OrderBy((TexturePageEntry e) => e.Entry); WriteDataList(source.ToList(), _s, _iff, delegate(TexturePageEntry _tpe, Stream __s, IFF __iff, long __index) { __s.PatchOffset(__index); __iff.SetOffset(__s, _tpe, __s.Position); __s.WriteShort((short)_tpe.X); __s.WriteShort((short)_tpe.Y); __s.WriteShort((short)_tpe.W); __s.WriteShort((short)_tpe.H); __s.WriteShort((short)_tpe.XOffset); __s.WriteShort((short)_tpe.YOffset); __s.WriteShort((short)_tpe.CropWidth); __s.WriteShort((short)_tpe.CropHeight); __s.WriteShort((short)_tpe.OW); __s.WriteShort((short)_tpe.OH); __s.WriteShort((short)_tpe.TP.TP); }); }
public GMAction(GMAssets _a, Stream _stream) { _stream.ReadInteger(); LibID = _stream.ReadInteger(); ID = _stream.ReadInteger(); Kind = (eAction)_stream.ReadInteger(); UseRelative = _stream.ReadBoolean(); IsQuestion = _stream.ReadBoolean(); UseApplyTo = _stream.ReadBoolean(); ExeType = (eExecuteTypes)_stream.ReadInteger(); Name = _stream.ReadString(); Code = _stream.ReadString(); ArgumentCount = _stream.ReadInteger(); int num = _stream.ReadInteger(); ArgTypes = new List <eArgTypes>(num); for (int i = 0; i < num; i++) { ArgTypes.Add((eArgTypes)_stream.ReadInteger()); } Who = _stream.ReadInteger(); Relative = _stream.ReadBoolean(); num = _stream.ReadInteger(); Args = new List <string>(num); for (int j = 0; j < num; j++) { Args.Add(_stream.ReadString()); } IsNot = _stream.ReadBoolean(); }
public GMBackground(GMAssets _a, Stream _s) { switch (_s.ReadInteger()) { case 543: Width = _s.ReadInteger(); Height = _s.ReadInteger(); Transparent = _s.ReadBoolean(); Smooth = _s.ReadBoolean(); Preload = _s.ReadBoolean(); Tileset = false; if (_s.ReadBoolean()) { Bitmap = new GMBitmap32(_s); } break; case 710: Bitmap = new GMBitmap32(_s); Width = _s.ReadInteger(); Height = _s.ReadInteger(); Width = Bitmap.Width; Height = Bitmap.Height; break; } }
public GMSound(GMAssets _a, Stream _s) { int num = _s.ReadInteger(); Kind = _s.ReadInteger(); Extension = _s.ReadString(); OrigName = _s.ReadString(); if (OrigName == "") { OrigName = "Dummy" + Extension; } bool flag = _s.ReadBoolean(); Data = null; if (flag) { switch (num) { case 600: Data = _s.ReadCompressedStream(); break; case 800: Data = _s.ReadStream(); break; } } Effects = _s.ReadInteger(); Volume = _s.ReadDouble(); Pan = _s.ReadDouble(); Preload = _s.ReadBoolean(); }
public GMDataFile(GMAssets _a, Stream _stream) { int num = _stream.ReadInteger(); FileName = _stream.ReadString(); OrigName = _stream.ReadString(); Exists = _stream.ReadBoolean(); Size = _stream.ReadInteger(); Store = _stream.ReadBoolean(); if (Exists && Store) { switch (num) { case 620: Data = _stream.ReadCompressedStream(); break; case 800: Data = _stream.ReadStream(); break; } } ExportAction = _stream.ReadInteger(); ExportDir = _stream.ReadString(); Overwrite = _stream.ReadBoolean(); FreeData = _stream.ReadBoolean(); RemoveEnd = _stream.ReadBoolean(); }
public GMExtension(GMAssets _a, Stream _s) { _s.ReadInteger(); Name = _s.ReadString(); Folder = _s.ReadString(); Includes = new List <GMExtensionInclude>(); int num = _s.ReadInteger(); for (int i = 0; i < num; i++) { Includes.Add(new GMExtensionInclude(_s)); } byte[] array = _s.ReadStream(); if (array == null) { return; } MemoryStream memoryStream = new MemoryStream(array); int key = memoryStream.ReadInteger(); GMAssets.Decrypt(key, array, memoryStream.Position + 1); ExtensionDLL = new List <byte[]>(); for (int j = 0; j < Includes.Count; j++) { if (Includes[j].Kind != 3) { ExtensionDLL.Add(memoryStream.ReadCompressedStream()); } } }
public GMLCode(GMAssets _assets, string _name, string _code, eGMLCodeType _type) { Name = _name.Replace(' ', '_').Replace('\t', '_'); Code = _code; Type = _type; List <GMLError> _errors = null; Token = GMLCompile.Compile(_assets, Name, Code, out _errors); Errors = _errors; }
public void Compile(GMAssets _assets, GMLCode _code) { Code = _code; if (Program.CompileVerbose) { RewriteTree(_code.Token); CompileProgram(_code.Token); Disasm(Program.Out); } }
public GMFont(GMAssets _a, Stream _s) { int num = _s.ReadInteger(); Name = _s.ReadString(); Size = _s.ReadInteger(); Bold = _s.ReadBoolean(); Italic = _s.ReadBoolean(); First = _s.ReadInteger(); Last = _s.ReadInteger(); CharSet = ((First >> 16) & 0xFF); AntiAlias = ((First >> 24) & 0xFF); First &= 65535; Glyphs = new List <GMGlyph>(); for (int i = 0; i < 256; i++) { int x = _s.ReadInteger(); int y = _s.ReadInteger(); int w = _s.ReadInteger(); int h = _s.ReadInteger(); int shift = _s.ReadInteger(); int offset = _s.ReadInteger(); Glyphs.Add(new GMGlyph(x, y, w, h, shift, offset)); } int num2 = _s.ReadInteger(); int num3 = _s.ReadInteger(); byte[] array = null; array = ((num != 540) ? _s.ReadStream() : _s.ReadCompressedStream()); Bitmap = new Bitmap(num2, num3, PixelFormat.Format32bppArgb); Rectangle rect = new Rectangle(0, 0, Bitmap.Width, Bitmap.Height); BitmapData bitmapData = Bitmap.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); IntPtr intPtr = new IntPtr(bitmapData.Scan0.ToInt64()); int num4 = 0; int num5 = 0; while (num5 < num3) { int num6 = num4; IntPtr ptr = intPtr; int num7 = 0; while (num7 < num2) { int val = 16777215 + (array[num6] << 24); Marshal.WriteInt32(ptr, val); num7++; num6++; ptr = new IntPtr(ptr.ToInt64() + 4); } num5++; intPtr = new IntPtr(intPtr.ToInt64() + bitmapData.Stride); num4 += num2; } Bitmap.UnlockBits(bitmapData); }
public GMEvent(GMAssets _a, Stream _stream) { _stream.ReadInteger(); int num = _stream.ReadInteger(); Actions = new List <GMAction>(num); for (int i = 0; i < num; i++) { Actions.Add(new GMAction(_a, _stream)); } }
public GMTrigger(GMAssets _a, Stream _s) { int num = _s.ReadInteger(); if (num == 800) { Name = _s.ReadString(); Condition = _s.ReadString(); Moment = _s.ReadInteger(); ConstName = _s.ReadString(); } }
public void Compile(GMAssets _assets) { switch (Kind) { case eAction.ACT_VARIABLE: if (Relative) { Code = Code + Args[0] + " += " + Args[1]; } else { Code = Code + Args[0] + " = " + Args[1]; } Kind = eAction.ACT_NORMAL; Args.Clear(); break; case eAction.ACT_CODE: Code = Args[0]; Kind = eAction.ACT_NORMAL; Args.Clear(); if (Program.RemoveDND) { List <GMLError> _errors = null; bool inhibitErrorOutput = Program.InhibitErrorOutput; Program.InhibitErrorOutput = true; GMLCompile.Compile(_assets, "test_compile", Code, out _errors); Program.InhibitErrorOutput = inhibitErrorOutput; if (_errors.Count > 0) { foreach (GMLError item2 in _errors) { eErrorKind kind = item2.Kind; if (kind == eErrorKind.Warning_Unclosed_Comment) { Code += "*/"; } } } } break; } if (IsQuestion && ExeType == eExecuteTypes.EXE_CODE) { Name = string.Format("__script{0}__", countScript); GMScript value = new GMScript(Code); KeyValuePair <string, GMScript> item = new KeyValuePair <string, GMScript>(Name, value); _assets.Scripts.Add(item); countScript++; ExeType = eExecuteTypes.EXE_FUNCTION; } }
public GMTimeLine(GMAssets _a, Stream _stream) { _stream.ReadInteger(); int num = _stream.ReadInteger(); Entries = new List <KeyValuePair <int, GMEvent> >(num); for (int i = 0; i < num; i++) { int key = _stream.ReadInteger(); GMEvent value = new GMEvent(_a, _stream); Entries.Add(new KeyValuePair <int, GMEvent>(key, value)); } }
public static void TagBackgroundTilesets(GMAssets _assets) { foreach (KeyValuePair <string, GMRoom> room in _assets.Rooms) { GMRoom value = room.Value; if (value != null) { foreach (GMTile tile in value.Tiles) { _assets.Backgrounds[tile.Index].Value.Tileset = true; } } } }
private static void WriteHeader(GMAssets _data, Stream _s, IFF _iff) { _s.WriteInteger(((!_data.Debug) ? 1 : 0) | 0x201); _iff.AddString(_s, Path.GetFileNameWithoutExtension(_data.FileName)); _s.WriteInteger(_data.RoomMaxId); _s.WriteInteger(_data.RoomMaxTileId); _s.WriteInteger(_data.GameID); _s.WriteInteger(0); _s.WriteInteger(0); _s.WriteInteger(0); _s.WriteInteger(0); _s.WriteInteger(_data.RoomOrder.Count); foreach (int item in _data.RoomOrder) { _s.WriteInteger(item); } }
public GMRoom(GMAssets _a, Stream _stream) { int num = _stream.ReadInteger(); Caption = _stream.ReadString(); Width = _stream.ReadInteger(); Height = _stream.ReadInteger(); Speed = _stream.ReadInteger(); Persistent = _stream.ReadBoolean(); Colour = _stream.ReadInteger(); int num2 = _stream.ReadInteger(); ShowColour = ((num2 & 1) != 0); ViewClearScreen = ((num2 & 2) == 0); Code = _stream.ReadString(); int num3 = _stream.ReadInteger(); Backgrounds = new List <GMBack>(num3); for (int i = 0; i < num3; i++) { GMBack item = new GMBack(_stream); Backgrounds.Add(item); } EnableViews = _stream.ReadBoolean(); num3 = _stream.ReadInteger(); Views = new List <GMView>(num3); for (int j = 0; j < num3; j++) { GMView item2 = new GMView(_stream); Views.Add(item2); } num3 = _stream.ReadInteger(); Instances = new List <GMInstance>(num3); for (int k = 0; k < num3; k++) { GMInstance item3 = new GMInstance(_stream, num); Instances.Add(item3); } num3 = _stream.ReadInteger(); Tiles = new List <GMTile>(num3); for (int l = 0; l < num3; l++) { GMTile item4 = new GMTile(_stream, num); Tiles.Add(item4); } }
public GMPath(GMAssets _a, Stream _s) { _s.ReadInteger(); Kind = _s.ReadInteger(); Closed = _s.ReadBoolean(); Precision = _s.ReadInteger(); Points = new List <GMPathPoint>(); int num = _s.ReadInteger(); for (int i = 0; i < num; i++) { double x = _s.ReadDouble(); double y = _s.ReadDouble(); double speed = _s.ReadDouble(); Points.Add(new GMPathPoint(x, y, speed)); } }
public GMScript(GMAssets _a, Stream _s) { switch (_s.ReadInteger()) { case 400: { byte[] array = _s.ReadCompressedStream(); GMAssets.Decrypt(12345, array, 0L); MemoryStream s = new MemoryStream(array); Script = s.ReadString(); break; } case 800: Script = _s.ReadString(); break; } }
private static void WriteTextures(GMAssets _data, Stream _s, IFF _iff) { List <byte[]> list = new List <byte[]>(); if (ms_tpageSprites.Textures != null) { int num = 0; foreach (Texture texture in ms_tpageSprites.Textures) { Program.Out.Write("{0} Compressing texture... ", num); Image _dest = null; Bitmap bitmap = texture.Bitmap; byte[] array = Form1.createOutTexture(bitmap, eSquishFlags.kDxt5 | eSquishFlags.kColourMetricPerceptual | eSquishFlags.kClusterFitMaxIteration8, out _dest, Program.TextureType[texture.Group]); string path = Path.Combine(Program.OutputDir, string.Format("texture_{0}{1}", num, Program.TextureTypeExtension(Program.TextureType[texture.Group]))); Program.Out.WriteLine("writing texture {0}... ", Path.GetFileName(path)); if (Program.WriteTextures) { if (string.Compare(Path.GetExtension(path), ".png", true) != 0) { texture.Bitmap.Save(Path.ChangeExtension(path, ".original.png"), ImageFormat.Png); } if (_dest != null) { _dest.Save(Path.ChangeExtension(path, ".png"), ImageFormat.Png); } File.WriteAllBytes(path, array); } list.Add(array); Application.DoEvents(); num++; } } WriteDataList(list, _s, _iff, delegate(byte[] __tex, Stream __s, IFF __iff, long __index) { int num2 = 128; int num3 = num2 - 1; while ((__s.Position & num3) != 0) { __s.WriteByte(0); } __s.PatchOffset(__index); __s.Write(__tex, 0, __tex.Length); }); }
public static GMAssets LoadGMK(Stream _stream, string _name) { GMAssets gMAssets = null; if (string.Compare(Path.GetExtension(_name), ".gmk", true) != 0) { if (!CheckFor8_1(_stream)) { bool flag = CheckForOldVersions(_stream); } gMAssets = new GMAssets(_stream); } else { gMAssets = new GMAssets(_stream, true); } TagBackgroundTilesets(gMAssets); return(gMAssets); }
public GMHelp(GMAssets _a, Stream _stream) { int num = _stream.ReadInteger(); if (num == 800) { _stream = _stream.ReadStreamC(); } BackgroundColour = _stream.ReadInteger(); Mimic = _stream.ReadBoolean(); Caption = _stream.ReadString(); Left = _stream.ReadInteger(); Top = _stream.ReadInteger(); Width = _stream.ReadInteger(); Height = _stream.ReadInteger(); Border = _stream.ReadBoolean(); Sizable = _stream.ReadBoolean(); OnTop = _stream.ReadBoolean(); Modal = _stream.ReadBoolean(); byte[] array = null; switch (num) { case 600: array = _stream.ReadCompressedStream(); break; case 800: array = _stream.ReadStream(); break; } if (array != null) { MemoryStream memoryStream = new MemoryStream(array); StringBuilder stringBuilder = new StringBuilder(); while (memoryStream.Position != memoryStream.Length) { char value = (char)memoryStream.ReadByte(); stringBuilder.Append(value); } Text = stringBuilder.ToString(); } }
public GMObject(GMAssets _a, Stream _stream) { int num = _stream.ReadInteger(); if (num != 400 && num != 430 && num != 820) { return; } SpriteIndex = _stream.ReadInteger(); Solid = _stream.ReadBoolean(); Visible = _stream.ReadBoolean(); Depth = _stream.ReadInteger(); Persistent = _stream.ReadBoolean(); Parent = _stream.ReadInteger(); Mask = _stream.ReadInteger(); int num2 = 8; if (num == 430 || num >= 820) { num2 = _stream.ReadInteger(); } Events = new List <IList <KeyValuePair <int, GMEvent> > >(num2); for (int i = 0; i <= num2; i++) { List <KeyValuePair <int, GMEvent> > list = new List <KeyValuePair <int, GMEvent> >(); int num3; do { num3 = _stream.ReadInteger(); if (num3 >= 0) { GMEvent value = new GMEvent(_a, _stream); KeyValuePair <int, GMEvent> item = new KeyValuePair <int, GMEvent>(num3, value); list.Add(item); } }while (num3 >= 0); Events.Add(list); } Console.WriteLine("DEBUG: num var: " + num.ToString() + " !"); }
public static void Save(GMAssets _assets, Stream _stream, List <string> _extraFilenames) { IFF iFF = new IFF(); iFF.ExternalFiles = _extraFilenames; string name = "GENL"; switch (_assets.Version) { case 700: case 701: name = "GEN7"; break; case 800: case 810: name = "GEN8"; break; } iFF.RegisterChunk(name, WriteHeader, _assets, IFFChunkType.CPU); iFF.RegisterChunk("TXTR", WriteTextures, _assets, IFFChunkType.GPU | IFFChunkType.Align, 128); iFF.RegisterChunk("AUDO", WriteWaveforms, _assets, IFFChunkType.Audio); iFF.RegisterChunk("HELP", WriteHelp, _assets.Help, IFFChunkType.CPU); iFF.RegisterChunk("OPTN", WriteOptions, _assets.Options, IFFChunkType.CPU); iFF.RegisterChunk("EXTN", WriteExtensions, _assets.Extensions, IFFChunkType.CPU); iFF.RegisterChunk("SOND", WriteSounds, _assets.Sounds, IFFChunkType.CPU); iFF.RegisterChunk("SPRT", WriteSprites, _assets.Sprites, IFFChunkType.CPU); iFF.RegisterChunk("BGND", WriteBackgrounds, _assets.Backgrounds, IFFChunkType.CPU); iFF.RegisterChunk("PATH", WritePaths, _assets.Paths, IFFChunkType.CPU); iFF.RegisterChunk("SCPT", WriteScripts, _assets.Scripts, IFFChunkType.CPU); iFF.RegisterChunk("FONT", WriteFonts, _assets.Fonts, IFFChunkType.CPU); iFF.RegisterChunk("TMLN", WriteTimelines, _assets.TimeLines, IFFChunkType.CPU); iFF.RegisterChunk("OBJT", WriteObjects, _assets.Objects, IFFChunkType.CPU); iFF.RegisterChunk("ROOM", WriteRooms, _assets.Rooms, IFFChunkType.CPU); iFF.RegisterChunk("DAFL", WriteDataFiles, _assets.DataFiles, IFFChunkType.CPU); iFF.RegisterChunk("TPAGE", WriteTexturePages, _assets, IFFChunkType.CPU); iFF.RegisterChunk("STRG", (IFFChunkSaver <IList <IFFString> >)WriteStrings, (IList <IFFString>)iFF.Strings, IFFChunkType.CPU); iFF.WriteChunks(_stream); }
public static GMAssets Load(string _name) { GMAssets gMAssets = null; if (string.Compare(Path.GetExtension(_name), ".psp", true) == 0) { FileStream fileStream = File.Open(_name, FileMode.Open, FileAccess.Read, FileShare.Read); gMAssets = LoadPSP(fileStream); fileStream.Close(); } else { g_FileBuffer = File.ReadAllBytes(_name); MemoryStream memoryStream = new MemoryStream(g_FileBuffer, true); gMAssets = LoadGMK(memoryStream, _name); memoryStream.Close(); } if (gMAssets != null) { gMAssets.FileName = Path.GetFullPath(_name); } return(gMAssets); }
private static int Main(string[] _args) { Trace.Write("------------ {1} {0} --------------", Assembly.GetExecutingAssembly().GetName().Version.ToString(), Assembly.GetExecutingAssembly().GetName().Name); /*if (!Debugger.IsAttached) * { * AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; * }*/ //Unlike yoyogames. i see NO issue with running a debugger here :D Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); GMLCompile.Test(); GMLCompile.Code_Init(); HTMLRunner = "C:\\source\\GameMaker\\Runner\\HTML5\\scripts"; Verbose = false; CompileVerbose = false; Out = Console.Out; SplashOmit = true; TextureType = new eTexType[2]; SeparateOpaqueAndAlpha = false; DisplaySortedTextures = false; RemoveDND = true; CenterHTML5Game = false; NoCache = false; HTMLRunner = string.Empty; NoIndexHTML = false; TextureGroups = new Dictionary <string, List <string> >(); DoObfuscate = false; ObfuscateObfuscate = true; ObfuscatePrettyPrint = false; ObfuscateRemoveUnused = true; ObfuscateEncodeStrings = true; LoadingBarName = null; CustomLoadingScreen = false; ExitCode = 0; InhibitErrorOutput = false; string PreObfuscateLib = string.Empty; TextureScale = 1; Studio = false; m_options = new OptionSet().Add("?|help", "display help usage", (Action <string>) delegate { ShowHelp(); }).Add("m=|machine=", "set machine type (ios, psp, win, droid)", delegate(string m) { SetMachineType(m); }).Add("t=|tex=", "override opaque texture type (dxt,raw,pvr,png)", delegate(string s) { TextureType[0] = SetTextureType(s); }) .Add("at=|alphatex=", "override alpha texture type (dxt,raw,pvr,png)", delegate(string s) { TextureType[1] = SetTextureType(s); }) .Add("o=|outputDir=", "set output directory", delegate(string d) { OutputDir = d; }) .Add("w=|tpageWidth=", "set texture page width", delegate(int w) { TexturePageWidth = w; }) .Add("h=|tpageHeight=", "set texture page height", delegate(int h) { TexturePageHeight = h; }) .Add("wt|writeTextures", "optionally write textures generated to output directory", (Action <string>) delegate { WriteTextures = true; }) .Add("ww|writeWaves", "optionally write audio waves generated to output directory", (Action <string>) delegate { WriteTextures = true; }) .Add("so|splashOmit", "optionally disable writing of the Spash screen to output file", (Action <string>) delegate { SplashOmit = true; }) .Add("dst|DisplaySortedTextures", "optionally display sorted texture information", (Action <string>) delegate { DisplaySortedTextures = true; }) .Add("c|compile", "do not display gui compile only", (Action <string>) delegate { CompileOnly = true; }) .Add("s|separate", "separate the alpha and opaque textures (false by default)", (Action <string>) delegate { SeparateOpaqueAndAlpha = true; }) .Add("v|verbose", "output verbose debug info", (Action <string>) delegate { Verbose = true; }) .Add("nohtml", "do not output index.html", (Action <string>) delegate { NoIndexHTML = true; }) .Add("HTMLRunner=", "directory with HTML Runner (will be copied as scripts)", delegate(string d) { HTMLRunner = d; }) .Add("tg=|TextureGroup=", "Group resources onto texture pages comma param is a filename, file has format <groupname> : <comma delim list of resourcenames>, use # for comment (NOTE: entries MUST all be on the same line", delegate(string f) { string[] array4 = File.ReadAllLines(f); string[] array5 = array4; foreach (string text3 in array5) { string text4 = text3.Trim().Replace(" ", "").Replace("\t", ""); if (!string.IsNullOrEmpty(text4) && !text4.StartsWith("#")) { string[] array6 = text4.Split(':'); if (array6.Length == 2) { string[] collection2 = array6[1].Split(','); string key = array6[0]; List <string> value = new List <string>(collection2); TextureGroups.Add(key, value); } } } }) .Add("to=|TextureOption=", "Set an option for a set of textures via <option> : <comma delimited list of resourcenames>. Valid options are: " + TextureOptions.ValidTextureOptions() + ")", delegate(string f) { string[] array = File.ReadAllLines(f); string[] array2 = array; foreach (string text in array2) { string text2 = text.Trim().Replace(" ", "").Replace("\t", ""); if (!string.IsNullOrEmpty(text2) && !text2.StartsWith("#")) { string[] array3 = text2.Split(':'); if (array3.Length == 2) { string[] collection = array3[1].Split(','); string optionName = array3[0]; List <string> resources = new List <string>(collection); TextureOptions.AddResourceOptions(optionName, resources); } } } }) .Add("nodnd", "remove any Drag and Drop (dnd)", (Action <string>) delegate { RemoveDND = true; }) .Add("obfuscate|ob", "obfuscate the Javascript output", (Action <string>) delegate { DoObfuscate = true; }) .Add("obfuscateDo=|obob=", "Really do the obfuscation (default true)", delegate(bool v) { ObfuscateObfuscate = v; }) .Add("obfuscatePrettyPrint=|obpp=", "when obfuscating Pretty Print the output (default false)", delegate(bool v) { ObfuscatePrettyPrint = v; }) .Add("obfuscateRemoveUnused=|obru=", "when obfuscating Remove Unused functions from the output (default true)", delegate(bool v) { ObfuscateRemoveUnused = v; }) .Add("obfuscateEncodeStrings=|obes=", "when obfuscating Encode strings in the output (default true)", delegate(bool v) { ObfuscateEncodeStrings = v; }) .Add("compileVerbose|cv", "switch on verbose mode when compiling the GML (default false)", (Action <string>) delegate { CompileVerbose = true; }) .Add("c_html5", "Center the HTML5 game in the browser", (Action <string>) delegate { CenterHTML5Game = true; }) .Add("nocache_html5", "Add the \"no cache\" option to the default index.html page", (Action <string>) delegate { NoCache = true; }) .Add("preObfuscateLib=|pob=", "Pre-Obfuscate a directory of JS files into a single file - keep GM public interface", delegate(string v) { PreObfuscateLib = v; }) .Add("textureScale=|ts=", "scale textures by an integer amount (default 1)", delegate(int v) { TextureScale = v; }) .Add("loadingbarcallback=", "Name of the loading bar callback function", delegate(string v) { LoadingBarName = v; }) .Add("customloadingimage", "Use the custom screen provided?", (Action <string>) delegate { CustomLoadingScreen = true; }) .Add("studio", "Enable Studio use...", (Action <string>) delegate { Studio = true; }); List <string> list = m_options.Parse(_args); if (!string.IsNullOrEmpty(PreObfuscateLib)) { DoPreObfuscateLib(PreObfuscateLib, OutputDir); return(ExitCode); } GMAssets gMAssets = null; foreach (string item in list) { if (File.Exists(item)) { gMAssets = Loader.Load(item); } } if (MachineType == null) { SetMachineType("ios"); } if (gMAssets == null) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Exe files (*.exe, *.ios, *.psp, *.win, *.droid)|*.exe;*.ios;*.psp;*.win;*.droid|All files (*.*)|*.*"; openFileDialog.FilterIndex = 1; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() != DialogResult.OK) { return(-1); } gMAssets = Loader.Load(openFileDialog.FileName); } if (OutputDir == null) { if (gMAssets != null) { OutputDir = Path.GetDirectoryName(gMAssets.FileName); } } Assets = gMAssets; if (!CompileOnly) { Application.Run(new Form1(gMAssets)); } else { string extension = MachineType.Extension; if (Studio) { extension = ".zip"; } string name = Path.Combine(OutputDir, Path.ChangeExtension(Path.GetFileName(gMAssets.FileName), extension)); switch (MachineType.OutputType) { case eOutputType.eWAD: IFFSaver.Save(gMAssets, name); break; case eOutputType.eHTML5: HTML5Saver.Save(gMAssets, name); break; } } return(ExitCode); }
public GMRoom(GMAssets _a, Stream _stream, bool _gmk) { int num = _stream.ReadInteger(); Caption = _stream.ReadString(); Width = _stream.ReadInteger(); Height = _stream.ReadInteger(); _stream.ReadInteger(); _stream.ReadInteger(); if (num >= 520) { _stream.ReadBoolean(); } Speed = _stream.ReadInteger(); Persistent = _stream.ReadBoolean(); Colour = _stream.ReadInteger(); ShowColour = _stream.ReadBoolean(); Code = _stream.ReadString(); int num2 = _stream.ReadInteger(); Backgrounds = new List <GMBack>(num2); for (int i = 0; i < num2; i++) { GMBack item = new GMBack(_stream); Backgrounds.Add(item); } EnableViews = _stream.ReadBoolean(); num2 = _stream.ReadInteger(); Views = new List <GMView>(num2); for (int j = 0; j < num2; j++) { GMView item2 = new GMView(_stream); Views.Add(item2); } num2 = _stream.ReadInteger(); Instances = new List <GMInstance>(num2); for (int k = 0; k < num2; k++) { GMInstance item3 = new GMInstance(_stream, true); Instances.Add(item3); } num2 = _stream.ReadInteger(); Tiles = new List <GMTile>(num2); for (int l = 0; l < num2; l++) { GMTile item4 = new GMTile(_stream, num); if (num >= 520) { _stream.ReadBoolean(); } Tiles.Add(item4); } _stream.ReadBoolean(); _stream.ReadInteger(); _stream.ReadInteger(); _stream.ReadBoolean(); _stream.ReadBoolean(); _stream.ReadBoolean(); if (num < 520) { _stream.ReadBoolean(); } _stream.ReadBoolean(); _stream.ReadBoolean(); _stream.ReadBoolean(); _stream.ReadBoolean(); _stream.ReadBoolean(); if (num < 520) { _stream.ReadBoolean(); } if (num < 541) { _stream.ReadInteger(); } if (num < 541) { _stream.ReadInteger(); } if (num < 541) { _stream.ReadInteger(); } if (num < 541) { _stream.ReadInteger(); } if (num >= 520 && num < 541) { _stream.ReadInteger(); } if (num >= 520 && num < 541) { _stream.ReadInteger(); } _stream.ReadInteger(); _stream.ReadInteger(); _stream.ReadInteger(); }
internal GMOptions(GMAssets _a, Stream _s) { int num = _s.ReadInteger(); if (num >= 800) { _s = _s.ReadStreamC(); } FullScreen = _s.ReadBoolean(); InterpolatePixels = _s.ReadBoolean(); NoBorder = _s.ReadBoolean(); ShowCursor = _s.ReadBoolean(); Scale = _s.ReadInteger(); Sizeable = _s.ReadBoolean(); StayOnTop = _s.ReadBoolean(); WindowColour = _s.ReadInteger(); ChangeResolution = _s.ReadBoolean(); ColorDepth = _s.ReadInteger(); Resolution = _s.ReadInteger(); Frequency = _s.ReadInteger(); NoButtons = _s.ReadBoolean(); Sync_Vertex = _s.ReadInteger(); if (num >= 800) { NoScreenSaver = _s.ReadBoolean(); } ScreenKey = _s.ReadBoolean(); HelpKey = _s.ReadBoolean(); QuitKey = _s.ReadBoolean(); SaveKey = _s.ReadBoolean(); ScreenShotKey = _s.ReadBoolean(); CloseSec = _s.ReadBoolean(); Priority = _s.ReadInteger(); Freeze = _s.ReadBoolean(); ShowProgress = _s.ReadBoolean(); if (ShowProgress) { BackImage = null; FrontImage = null; Image image = _s.ReadBitmap(); if (image != null) { BackImage = new Bitmap(image); } image = _s.ReadBitmap(); if (image != null) { FrontImage = new Bitmap(image); } } Image image2 = _s.ReadBitmap(); LoadImage = ((image2 != null) ? new Bitmap(image2) : null); LoadTransparent = _s.ReadBoolean(); LoadAlpha = _s.ReadInteger(); ScaleProgress = _s.ReadBoolean(); DisplayErrors = _s.ReadBoolean(); WriteErrors = _s.ReadBoolean(); AbortErrors = _s.ReadBoolean(); VariableErrors = _s.ReadBoolean(); if (num >= 820) { WebGL = _s.ReadInteger(); CreationEventOrder = _s.ReadBoolean(); } Constants = new Dictionary <string, string>(); if (num != 800) { for (int num2 = _s.ReadInteger(); num2 > 0; num2--) { string key = _s.ReadString(); string value = _s.ReadString(); Constants.Add(key, value); } } }
internal GMOptions(GMAssets _a, Stream _s, bool _gmk) { int num = _s.ReadInteger(); FullScreen = _s.ReadBoolean(); if (num >= 600) { InterpolatePixels = _s.ReadBoolean(); } NoBorder = _s.ReadBoolean(); ShowCursor = _s.ReadBoolean(); Scale = _s.ReadInteger(); if (num >= 540) { Sizeable = _s.ReadBoolean(); } if (num >= 540) { StayOnTop = _s.ReadBoolean(); } if (num >= 540) { WindowColour = _s.ReadInteger(); } if (num < 540) { _s.ReadInteger(); } if (num < 540) { _s.ReadBoolean(); } ChangeResolution = _s.ReadBoolean(); if (num < 540) { _s.ReadInteger(); } ColorDepth = _s.ReadInteger(); if (num < 540) { ColorDepth = 0; } Resolution = _s.ReadInteger(); if (num < 540) { Resolution = 0; } Frequency = _s.ReadInteger(); if (num < 540) { Frequency = 0; } if (num < 540) { _s.ReadBoolean(); } if (num < 540) { _s.ReadBoolean(); } NoButtons = _s.ReadBoolean(); if (num >= 542) { Sync_Vertex = _s.ReadInteger(); } ScreenKey = _s.ReadBoolean(); HelpKey = _s.ReadBoolean(); QuitKey = _s.ReadBoolean(); SaveKey = _s.ReadBoolean(); if (num >= 701) { ScreenShotKey = _s.ReadBoolean(); } if (num >= 620) { CloseSec = _s.ReadBoolean(); } if (num >= 520) { Priority = _s.ReadInteger(); } if (num < 540) { _s.ReadBoolean(); } if (num < 540) { _s.ReadBoolean(); } Freeze = _s.ReadBoolean(); ShowProgress = (_s.ReadInteger() == 2); if (ShowProgress) { BackImage = null; FrontImage = null; Image image = _s.ReadBitmap(); if (image != null) { BackImage = new Bitmap(image); } image = _s.ReadBitmap(); if (image != null) { FrontImage = new Bitmap(image); } } if (_s.ReadBoolean()) { int num2 = _s.ReadInteger(); if (num2 != -1) { byte[] buffer = _s.ReadCompressedStream(); MemoryStream stream = new MemoryStream(buffer); LoadImage = (Bitmap)Image.FromStream(stream); } } if (num >= 510) { LoadTransparent = _s.ReadBoolean(); LoadAlpha = _s.ReadInteger(); ScaleProgress = _s.ReadBoolean(); } _s.ReadStream(); DisplayErrors = _s.ReadBoolean(); WriteErrors = _s.ReadBoolean(); AbortErrors = _s.ReadBoolean(); VariableErrors = _s.ReadBoolean(); _s.ReadString(); string empty = string.Empty; if (num < 700) { _s.ReadInteger().ToString(); } else { _s.ReadString(); } _s.ReadDouble(); _s.ReadString(); Constants = new Dictionary <string, string>(); if (num >= 530) { for (int num3 = _s.ReadInteger(); num3 > 0; num3--) { string key = _s.ReadString(); string value = _s.ReadString(); Constants.Add(key, value); } } if (num >= 702) { _s.ReadInteger(); _s.ReadInteger(); _s.ReadInteger(); _s.ReadInteger(); _s.ReadString(); _s.ReadString(); _s.ReadString(); _s.ReadString(); } WebGL = _s.ReadInteger(); CreationEventOrder = _s.ReadBoolean(); }
public GMSprite(GMAssets _a, Stream _s) { int num = _s.ReadInteger(); switch (num) { case 542: { Width = _s.ReadInteger(); Height = _s.ReadInteger(); BBoxLeft = _s.ReadInteger(); BBoxRight = _s.ReadInteger(); BBoxBottom = _s.ReadInteger(); BBoxTop = _s.ReadInteger(); Transparent = _s.ReadBoolean(); Smooth = _s.ReadBoolean(); Preload = _s.ReadBoolean(); BBoxMode = _s.ReadInteger(); ColCheck = _s.ReadBoolean(); XOrig = _s.ReadInteger(); YOrig = _s.ReadInteger(); Images = new List <GMBitmap32>(); int num3 = _s.ReadInteger(); for (int k = 0; k < num3; k++) { Images.Add(new GMBitmap32(_s)); } Masks = CreateMask(); break; } case 800: case 810: { BBoxLeft = 99999999; BBoxTop = 9999999; BBoxRight = -9999999; BBoxBottom = -9999999; Transparent = true; Preload = true; ColCheck = true; XOrig = _s.ReadInteger(); YOrig = _s.ReadInteger(); Images = new List <GMBitmap32>(); int num2 = _s.ReadInteger(); for (int i = 0; i < num2; i++) { GMBitmap32 gMBitmap = new GMBitmap32(_s); Images.Add(gMBitmap); Width = gMBitmap.Width; Height = gMBitmap.Height; } if (num == 810) { switch (_s.ReadInteger()) { case 0: case 2: case 3: ColCheck = true; break; case 1: ColCheck = false; break; } } Masks = new List <byte[]>(); SepMasks = _s.ReadBoolean(); if (num2 <= 0) { break; } if (SepMasks) { for (int j = 0; j < num2; j++) { Masks.Add(LoadMaskFromStream(_s)); } } else { Masks.Add(LoadMaskFromStream(_s)); } break; } } }
private static void WriteWaveforms(GMAssets _data, Stream _s, IFF _iff) { WriteDataList(ms_Waves, _s, _iff, delegate(Wave _wave, Stream __s, IFF __iff, long __index) { int num = 4; int num2 = num - 1; while ((__s.Position & num2) != 0) { __s.WriteByte(0); } __s.PatchOffset(__index); __s.WriteInteger(_wave.RawWavFile.Length); __s.Write(_wave.RawWavFile, 0, _wave.RawWavFile.Length); if (Program.WriteWaves && _wave.FileName.ToLower().EndsWith("wav")) { File.WriteAllBytes(Path.Combine(Program.OutputDir, Path.GetFileName(_wave.FileName)), _wave.RawWavFile); } }); Console.WriteLine("SILICA PATCH!"); int NumSounds = _data.Sounds.Count; for (int i = 0; i < NumSounds; i++) { // Console.WriteLine("Reading Sound: " + i.ToString()); if (_data.Sounds[i].ToString() == "[, ]") { continue; } KeyValuePair <string, GMSound> SoundPair = _data.Sounds[i]; GMSound Sound = SoundPair.Value; String OriginalName = Sound.OrigName; Console.WriteLine("Writing: " + OriginalName); String AudioFile = Path.Combine(Program.OutputDir, OriginalName); Console.WriteLine("Converting " + OriginalName + " To .WAV"); if (Path.GetExtension(OriginalName).ToLower() == ".mid" || Path.GetExtension(OriginalName).ToLower() == ".midi") { // File.WriteAllBytes(AudioFile, Sound.Data); MessageBox.Show("MIDI NOT SUPPORTED!\nPlease convert " + OriginalName + " to an MP3 File!", "MIDI", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (Path.GetExtension(OriginalName).ToLower() == ".mp3" || Path.GetExtension(OriginalName).ToLower() == ".wav") { if (Path.GetExtension(OriginalName).ToLower() == ".mp3") { MemoryStream Mp3Stream = new MemoryStream(Sound.Data); Mp3FileReader mp3 = new Mp3FileReader(Mp3Stream); WaveStream pcm = WaveFormatConversionStream.CreatePcmStream(mp3); WaveFileWriter.CreateWaveFile(Path.ChangeExtension(AudioFile, "wav"), pcm); pcm.Close(); mp3.Close(); pcm.Dispose(); mp3.Dispose(); //Convert to AT3 Process At3Tool = new Process(); At3Tool.StartInfo.FileName = Path.Combine(Application.StartupPath, "at3tool.exe"); At3Tool.StartInfo.CreateNoWindow = true; At3Tool.StartInfo.UseShellExecute = false; At3Tool.StartInfo.RedirectStandardOutput = true; At3Tool.StartInfo.RedirectStandardError = true; At3Tool.StartInfo.Arguments = "-e \"" + Path.ChangeExtension(AudioFile, "wav") + "\" \"" + Path.ChangeExtension(AudioFile, "at3") + "\""; Console.WriteLine(At3Tool.StartInfo.FileName + " " + At3Tool.StartInfo.Arguments); At3Tool.Start(); At3Tool.WaitForExit(); if (At3Tool.ExitCode != 0) { Console.WriteLine(At3Tool.StandardOutput.ReadToEnd() + At3Tool.StandardError.ReadToEnd()); return; } At3Tool.Dispose(); File.Delete(Path.ChangeExtension(AudioFile, "wav")); } /*else if(Path.GetExtension(OriginalName) == ".wav") * { * MemoryStream WavStream = new MemoryStream(Sound.Data); * WaveFileReader WavReader = new WaveFileReader(WavStream); * WaveFormat WavFormat = new WaveFormat(44100, 16, 2); * WaveFormatConversionStream conversionStream = new WaveFormatConversionStream(WavFormat, WavReader); * WaveFileWriter.CreateWaveFile(AudioFile, conversionStream); * * WavStream.Close(); * WavStream.Dispose(); * WavReader.Close(); * WavReader.Dispose(); * conversionStream.Close(); * conversionStream.Dispose(); * }*/ } } Console.WriteLine("Done"); }