Exemple #1
0
 private static void WriteObjects(IList <KeyValuePair <string, GMObject> > _data, Stream _s, IFF _iff)
 {
     IFFSaver.WriteDataKVP <GMObject>(_data, _s, _iff, delegate(KeyValuePair <string, GMObject> _kvp, Stream __s, IFF __iff, long __index)
     {
         __s.PatchOffset(__index);
         __iff.AddString(__s, _kvp.Key);
         GMObject value = _kvp.Value;
         __s.WriteInteger(value.SpriteIndex);
         __s.WriteBoolean(value.Visible);
         __s.WriteBoolean(value.Solid);
         __s.WriteInteger(value.Depth);
         __s.WriteBoolean(value.Persistent);
         __s.WriteInteger(value.Parent);
         __s.WriteInteger(value.Mask);
         //   Console.WriteLine("DEBUG:\nOBJECT EVENTS: " + value.Events.ToString());
         IFFSaver.WriteDataList <IList <KeyValuePair <int, GMEvent> > >(value.Events, __s, __iff, delegate(IList <KeyValuePair <int, GMEvent> > _list, Stream ___s, IFF ___iff, long ___index)
         {
             ___s.PatchOffset(___index);
             IFFSaver.WriteDataList <KeyValuePair <int, GMEvent> >(_list, ___s, ___iff, delegate(KeyValuePair <int, GMEvent> _entry, Stream ____s, IFF ____iff, long ____index)
             {
                 ____s.PatchOffset(____index);
                 ____s.WriteInteger(_entry.Key);
                 IFFSaver.WriteGMEvent(_entry.Value, ____s, ____iff);
             });
         });
     });
 }
Exemple #2
0
        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);
        }
Exemple #3
0
        private static void WriteWaveforms(GMAssets _data, Stream _s, IFF _iff)
        {
            IFFSaver.WriteDataList <Wave>(IFFSaver.ms_Waves, _s, _iff, delegate(Wave _wave, Stream __s, IFF __iff, long __index)
            {
                int num  = 4;
                int num2 = num - 1;
                while ((__s.Position & (long)num2) != 0L)
                {
                    __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("Converting to at3..");
            int NumSounds = _data.Sounds.Count;

            for (int i = 0; i < NumSounds; i++)
            {
                if (!(_data.Sounds[i].ToString() == "[, ]"))
                {
                    GMSound Sound        = _data.Sounds[i].Value;
                    string  OriginalName = Sound.OrigName;
                    string  Extension    = Path.GetExtension(Sound.OrigName);
                    string  AudioFile    = Path.Combine(Program.OutputDir, OriginalName);
                    if (Extension.ToLower() == ".mid" || Extension.ToLower() == ".midi")
                    {
                        Console.WriteLine("Converting " + OriginalName + " To .WAV");
                        File.WriteAllBytes(AudioFile, Sound.Data);
                        Process FluidSynth = new Process();
                        FluidSynth.StartInfo.FileName               = Path.Combine(Application.StartupPath, "fluidsynth.exe");
                        FluidSynth.StartInfo.WorkingDirectory       = Application.StartupPath;
                        FluidSynth.StartInfo.CreateNoWindow         = true;
                        FluidSynth.StartInfo.UseShellExecute        = false;
                        FluidSynth.StartInfo.RedirectStandardOutput = true;
                        FluidSynth.StartInfo.RedirectStandardError  = true;
                        //Change "gm.sf2" to whatever soundfont you want.
                        FluidSynth.StartInfo.Arguments = "-F \"" + Path.ChangeExtension(AudioFile, "wav") + "\" \"gm.sf2\" \"" + AudioFile + "\"";
                        Console.WriteLine(FluidSynth.StartInfo.FileName + " " + FluidSynth.StartInfo.Arguments);
                        FluidSynth.Start();
                        FluidSynth.WaitForExit();
                        if (FluidSynth.ExitCode != 0)
                        {
                            Console.WriteLine(FluidSynth.StandardOutput.ReadToEnd() + FluidSynth.StandardError.ReadToEnd());
                            return;
                        }
                        FluidSynth.Dispose();
                    }
                    else if (Path.GetExtension(OriginalName).ToLower() == ".mp3")
                    {
                        Console.WriteLine("Converting " + OriginalName + " To .WAV");
                        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();
                    }
                    else
                    {
                        continue;
                    }

                    String OutputPath = Path.Combine(Program.OutputDir, "_iso_temp", "PSP_GAME", "USRDIR", Path.ChangeExtension(OriginalName, "at3"));
                    Console.WriteLine("Output: " + OutputPath);
                    Process At3Tool = new Process();
                    At3Tool.StartInfo.FileName               = Path.Combine(Application.StartupPath, "at3tool.exe");
                    At3Tool.StartInfo.WorkingDirectory       = Application.StartupPath;
                    At3Tool.StartInfo.CreateNoWindow         = true;
                    At3Tool.StartInfo.UseShellExecute        = false;
                    At3Tool.StartInfo.RedirectStandardOutput = true;
                    At3Tool.StartInfo.RedirectStandardError  = true;
                    At3Tool.StartInfo.Arguments              = "-e \"" + Path.ChangeExtension(AudioFile, "wav") + "\" \"" + OutputPath + "\"";
                    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();

                    if (File.Exists(AudioFile))
                    {
                        File.Delete(AudioFile);
                    }
                    File.Delete(Path.ChangeExtension(AudioFile, "wav"));
                }
            }

            Console.WriteLine("Done");
        }
Exemple #4
0
 private static void WriteRooms(IList <KeyValuePair <string, GMRoom> > _data, Stream _s, IFF _iff)
 {
     IFFSaver.WriteDataKVP <GMRoom>(_data, _s, _iff, delegate(KeyValuePair <string, GMRoom> _kvp, Stream __s, IFF __iff, long __index)
     {
         __s.PatchOffset(__index);
         __iff.AddString(__s, _kvp.Key);
         GMRoom value = _kvp.Value;
         __iff.AddString(__s, value.Caption);
         __s.WriteInteger(value.Width);
         __s.WriteInteger(value.Height);
         __s.WriteInteger(value.Speed);
         __s.WriteBoolean(value.Persistent);
         __s.WriteInteger(value.Colour);
         __s.WriteBoolean(value.ShowColour);
         __iff.AddString(__s, value.Code);
         __s.WriteBoolean(value.EnableViews);
         long position = __s.Position;
         __s.WriteInteger(0);
         long position2 = __s.Position;
         __s.WriteInteger(0);
         long position3 = __s.Position;
         __s.WriteInteger(0);
         long position4 = __s.Position;
         __s.WriteInteger(0);
         __s.PatchOffset(position);
         IFFSaver.WriteDataList <GMBack>(value.Backgrounds, __s, __iff, delegate(GMBack _back, Stream ___s, IFF ___iff, long ___index)
         {
             ___s.PatchOffset(___index);
             ___s.WriteBoolean(_back.Visible);
             ___s.WriteBoolean(_back.Foreground);
             ___s.WriteInteger(_back.Index);
             ___s.WriteInteger(_back.X);
             ___s.WriteInteger(_back.Y);
             ___s.WriteBoolean(_back.HTiled);
             ___s.WriteBoolean(_back.VTiled);
             ___s.WriteInteger(_back.HSpeed);
             ___s.WriteInteger(_back.VSpeed);
             ___s.WriteBoolean(_back.Stretch);
         });
         __s.PatchOffset(position2);
         IFFSaver.WriteDataList <GMView>(value.Views, __s, __iff, delegate(GMView _view, Stream ___s, IFF ___iff, long ___index)
         {
             ___s.PatchOffset(___index);
             ___s.WriteBoolean(_view.Visible);
             ___s.WriteInteger(_view.XView);
             ___s.WriteInteger(_view.YView);
             ___s.WriteInteger(_view.WView);
             ___s.WriteInteger(_view.HView);
             ___s.WriteInteger(_view.XPort);
             ___s.WriteInteger(_view.YPort);
             ___s.WriteInteger(_view.WPort);
             ___s.WriteInteger(_view.HPort);
             ___s.WriteInteger(_view.HBorder);
             ___s.WriteInteger(_view.VBorder);
             ___s.WriteInteger(_view.HSpeed);
             ___s.WriteInteger(_view.VSpeed);
             ___s.WriteInteger(_view.Index);
         });
         __s.PatchOffset(position3);
         IFFSaver.WriteDataList <GMInstance>(value.Instances, __s, __iff, delegate(GMInstance _inst, Stream ___s, IFF ___iff, long ___index)
         {
             ___s.PatchOffset(___index);
             ___s.WriteInteger(_inst.X);
             ___s.WriteInteger(_inst.Y);
             ___s.WriteInteger(_inst.Index);
             ___s.WriteInteger(_inst.Id);
             ___iff.AddString(___s, _inst.Code);
             ___s.WriteSingle((float)_inst.ScaleX);
             ___s.WriteSingle((float)_inst.ScaleY);
             ___s.WriteInteger((int)_inst.Colour);
             ___s.WriteSingle((float)_inst.Rotation);
         });
         __s.PatchOffset(position4);
         IFFSaver.WriteDataList <GMTile>(value.Tiles, __s, __iff, delegate(GMTile _tile, Stream ___s, IFF ___iff, long ___index)
         {
             ___s.PatchOffset(___index);
             ___s.WriteInteger(_tile.X);
             ___s.WriteInteger(_tile.Y);
             ___s.WriteInteger(_tile.Index);
             ___s.WriteInteger(_tile.XO);
             ___s.WriteInteger(_tile.YO);
             ___s.WriteInteger(_tile.W);
             ___s.WriteInteger(_tile.H);
             ___s.WriteInteger(_tile.Depth);
             ___s.WriteInteger(_tile.Id);
             ___s.WriteSingle((float)_tile.XScale);
             ___s.WriteSingle((float)_tile.YScale);
             ___s.WriteInteger(_tile.Blend + ((int)(_tile.Alpha * 255.0) << 24));
         });
     });
 }