Exemple #1
0
        public static void Save(GMAssets _assets, string _name)
        {
            ms_code.Clear();
            if (Program.RemoveDND)
            {
                _assets.RemoveDND();
                foreach (KeyValuePair <string, GMScript> script in _assets.Scripts)
                {
                    if (script.Value != null && !string.IsNullOrEmpty(script.Value.Script))
                    {
                        GMLCode code   = new GMLCode(_assets, script.Key, script.Value.Script, eGMLCodeType.eScript);
                        GML2VM  gML2VM = new GML2VM();
                        gML2VM.Compile(_assets, code);
                        ms_code.Add(gML2VM);
                    }
                }
                foreach (KeyValuePair <string, GMObject> @object in _assets.Objects)
                {
                    if (@object.Value != null)
                    {
                        foreach (IList <KeyValuePair <int, GMEvent> > @event in @object.Value.Events)
                        {
                            foreach (KeyValuePair <int, GMEvent> item in @event)
                            {
                                if (item.Value != null && item.Value.Actions != null && item.Value.Actions.Count > 0 && item.Value.Actions[0].Kind == eAction.ACT_CODE)
                                {
                                    GMLCode code2   = new GMLCode(_assets, @object.Key, item.Value.Actions[0].Args[0], eGMLCodeType.eEvent);
                                    GML2VM  gML2VM2 = new GML2VM();
                                    gML2VM2.Compile(_assets, code2);
                                    ms_code.Add(gML2VM2);
                                }
                            }
                        }
                    }
                }
                foreach (KeyValuePair <string, GMTimeLine> timeLine in _assets.TimeLines)
                {
                    if (timeLine.Value != null)
                    {
                        foreach (KeyValuePair <int, GMEvent> entry in timeLine.Value.Entries)
                        {
                            if (entry.Value != null && entry.Value.Actions != null && entry.Value.Actions.Count > 0 && entry.Value.Actions[0].Kind == eAction.ACT_CODE)
                            {
                                GMLCode code3   = new GMLCode(_assets, timeLine.Key, entry.Value.Actions[0].Args[0], eGMLCodeType.eEvent);
                                GML2VM  gML2VM3 = new GML2VM();
                                gML2VM3.Compile(_assets, code3);
                                ms_code.Add(gML2VM3);
                            }
                        }
                    }
                }
                foreach (GMTrigger trigger in _assets.Triggers)
                {
                    if (trigger != null)
                    {
                        GMLCode code4   = new GMLCode(_assets, trigger.Name, trigger.Condition, eGMLCodeType.eTrigger);
                        GML2VM  gML2VM4 = new GML2VM();
                        gML2VM4.Compile(_assets, code4);
                        ms_code.Add(gML2VM4);
                    }
                }
                foreach (KeyValuePair <string, GMRoom> room in _assets.Rooms)
                {
                    if (room.Value != null)
                    {
                        if (!string.IsNullOrEmpty(room.Value.Code))
                        {
                            GMLCode code5   = new GMLCode(_assets, room.Key, room.Value.Code, eGMLCodeType.eRoomCreate);
                            GML2VM  gML2VM5 = new GML2VM();
                            gML2VM5.Compile(_assets, code5);
                            ms_code.Add(gML2VM5);
                        }
                        foreach (GMInstance instance in room.Value.Instances)
                        {
                            if (!string.IsNullOrEmpty(instance.Code))
                            {
                                GMLCode code6   = new GMLCode(_assets, room.Key, instance.Code, eGMLCodeType.eRoomInstanceCreate);
                                GML2VM  gML2VM6 = new GML2VM();
                                gML2VM6.Compile(_assets, code6);
                                ms_code.Add(gML2VM6);
                            }
                        }
                    }
                }
            }
            ms_tpageSprites = new TexturePage(2, 2, 0, 0, Program.MachineType.TPageWidth, Program.MachineType.TPageHeight);
            ms_Waves.Clear();
            Program.Out.WriteLine("Saving IFF file... {0}", _name);
            List <string> list = new List <string>();

            if (Path.GetExtension(_name) == ".zip")
            {
                using (FileStream stream = File.Create(_name))
                {
                    ZipOutputStream zipOutputStream = new ZipOutputStream(stream);
                    zipOutputStream.PutNextEntry(string.Format("assets\\game{0}", Program.MachineType.Extension));
                    Save(_assets, zipOutputStream, list);
                    foreach (string item2 in list)
                    {
                        if (File.Exists(item2))
                        {
                            string entryName = Path.Combine("assets", Path.GetFileName(item2));
                            zipOutputStream.PutNextEntry(entryName);
                            byte[] array = File.ReadAllBytes(item2);
                            zipOutputStream.Write(array, 0, array.Length);
                        }
                    }
                    zipOutputStream.Close();
                }
            }
            else
            {
                using (FileStream stream2 = File.Create(_name))
                {
                    Save(_assets, stream2, list);
                }
            }
        }
Exemple #2
0
        public static void Save(GMAssets _assets, string _name)
        {
            String InputFolder = Path.Combine(Program.OutputDir, "_iso_temp");

            _name = Path.Combine(Program.OutputDir, "_iso_temp", "PSP_GAME", "USRDIR", "games", "game.psp"); // Allways "game.psp"

            ms_code.Clear();
            if (Program.RemoveDND)
            {
                _assets.RemoveDND();
                foreach (KeyValuePair <string, GMScript> script in _assets.Scripts)
                {
                    if (script.Value != null && !string.IsNullOrEmpty(script.Value.Script))
                    {
                        GMLCode code   = new GMLCode(_assets, script.Key, script.Value.Script, eGMLCodeType.eScript);
                        GML2VM  gML2VM = new GML2VM();
                        gML2VM.Compile(_assets, code);
                        ms_code.Add(gML2VM);
                    }
                }
                foreach (KeyValuePair <string, GMObject> @object in _assets.Objects)
                {
                    if (@object.Value != null)
                    {
                        foreach (IList <KeyValuePair <int, GMEvent> > @event in @object.Value.Events)
                        {
                            foreach (KeyValuePair <int, GMEvent> item in @event)
                            {
                                if (item.Value != null && item.Value.Actions != null && item.Value.Actions.Count > 0 && item.Value.Actions[0].Kind == eAction.ACT_CODE)
                                {
                                    GMLCode code2   = new GMLCode(_assets, @object.Key, item.Value.Actions[0].Args[0], eGMLCodeType.eEvent);
                                    GML2VM  gML2VM2 = new GML2VM();
                                    gML2VM2.Compile(_assets, code2);
                                    ms_code.Add(gML2VM2);
                                }
                            }
                        }
                    }
                }
                foreach (KeyValuePair <string, GMTimeLine> timeLine in _assets.TimeLines)
                {
                    if (timeLine.Value != null)
                    {
                        foreach (KeyValuePair <int, GMEvent> entry in timeLine.Value.Entries)
                        {
                            if (entry.Value != null && entry.Value.Actions != null && entry.Value.Actions.Count > 0 && entry.Value.Actions[0].Kind == eAction.ACT_CODE)
                            {
                                GMLCode code3   = new GMLCode(_assets, timeLine.Key, entry.Value.Actions[0].Args[0], eGMLCodeType.eEvent);
                                GML2VM  gML2VM3 = new GML2VM();
                                gML2VM3.Compile(_assets, code3);
                                ms_code.Add(gML2VM3);
                            }
                        }
                    }
                }
                foreach (GMTrigger trigger in _assets.Triggers)
                {
                    if (trigger != null)
                    {
                        GMLCode code4   = new GMLCode(_assets, trigger.Name, trigger.Condition, eGMLCodeType.eTrigger);
                        GML2VM  gML2VM4 = new GML2VM();
                        gML2VM4.Compile(_assets, code4);
                        ms_code.Add(gML2VM4);
                    }
                }
                foreach (KeyValuePair <string, GMRoom> room in _assets.Rooms)
                {
                    if (room.Value != null)
                    {
                        if (!string.IsNullOrEmpty(room.Value.Code))
                        {
                            GMLCode code5   = new GMLCode(_assets, room.Key, room.Value.Code, eGMLCodeType.eRoomCreate);
                            GML2VM  gML2VM5 = new GML2VM();
                            gML2VM5.Compile(_assets, code5);
                            ms_code.Add(gML2VM5);
                        }
                        foreach (GMInstance instance in room.Value.Instances)
                        {
                            if (!string.IsNullOrEmpty(instance.Code))
                            {
                                GMLCode code6   = new GMLCode(_assets, room.Key, instance.Code, eGMLCodeType.eRoomInstanceCreate);
                                GML2VM  gML2VM6 = new GML2VM();
                                gML2VM6.Compile(_assets, code6);
                                ms_code.Add(gML2VM6);
                            }
                        }
                    }
                }
            }
            ms_tpageSprites = new TexturePage(2, 2, 0, 0, Program.MachineType.TPageWidth, Program.MachineType.TPageHeight);
            ms_Waves.Clear();
            Program.Out.WriteLine("Saving IFF file... {0}", _name);
            List <string> list = new List <string>();

            if (Path.GetExtension(_name) == ".zip")
            {
                using (FileStream stream = File.Create(_name))
                {
                    ZipOutputStream zipOutputStream = new ZipOutputStream(stream);
                    zipOutputStream.PutNextEntry(string.Format("assets\\game{0}", Program.MachineType.Extension));
                    Save(_assets, zipOutputStream, list);
                    foreach (string item2 in list)
                    {
                        if (File.Exists(item2))
                        {
                            string entryName = Path.Combine("assets", Path.GetFileName(item2));
                            zipOutputStream.PutNextEntry(entryName);
                            byte[] array = File.ReadAllBytes(item2);
                            zipOutputStream.Write(array, 0, array.Length);
                        }
                    }
                    zipOutputStream.Close();
                }
            }
            else
            {
                using (FileStream stream2 = File.Create(_name))
                {
                    Save(_assets, stream2, list);
                }
            }
            String ISOPath = Path.Combine(Program.OutputDir, Path.ChangeExtension(Program.Assets.FileName, "ISO"));

            Console.WriteLine("Building ISO");

            String UmiFile = Path.Combine(Program.OutputDir, "UmiFile.umi");
            String UflFile = Path.ChangeExtension(UmiFile, "ufl");

            UMDGEN.CreateUmi(UmiFile);
            UMDGEN.CreateUfl(UflFile, InputFolder);
            UMDGEN.CreateISO(UmiFile, Program.OutputDir);

            File.Delete(Path.Combine(Program.OutputDir, "UMD_AUTH.DAT"));
            File.Delete(Path.Combine(Program.OutputDir, "CONT_L0.IMG"));
            File.Delete(Path.Combine(Program.OutputDir, "MDI.IMG"));
            File.Delete(Path.Combine(Program.OutputDir, "UmiFile.ufl"));
            File.Delete(Path.Combine(Program.OutputDir, "UmiFile.umi"));
            if (File.Exists(ISOPath))
            {
                File.Delete(ISOPath);
            }

            File.Move(Path.Combine(Program.OutputDir, "USER_L0.IMG"), ISOPath);
            if (Directory.Exists(InputFolder))
            {
                Directory.Delete(InputFolder, true);
            }
            Console.WriteLine("Done!");

            MessageBox.Show("ISO Built @ " + ISOPath, "Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }