Example #1
0
 public void Initialize()
 {
     pkgFile = new TempFile();
     props   = TestHelper.MakeProperties();
     props.EntitlementKey = "000102030405060708090A0B0C0D0E0F";
     props.RootDir.Files.Add(new FSFile(s => s.Write(TestFile, 0, 8), "test.file", 8)
     {
         Parent = props.RootDir
     });
     new PkgBuilder(props).Write(pkgFile.Path, s => { });
 }
Example #2
0
        private void CreatePKG_Click(object sender, EventArgs e)
        {
            string GMVer = VersionSelect.SelectedItem.ToString();

            if (Path.GetExtension(projectPath.Text).ToLower() == ".yyp" && GMVer.StartsWith("1."))
            {
                MessageBox.Show("Cannot build GMS2 Project using GMS1.4", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (Path.GetExtension(projectPath.Text).ToLower() == ".gmx" && GMVer.StartsWith("2."))
            {
                MessageBox.Show("Cannot build GMS1.4 Project using GMS2", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string tempdir = "";

            SaveFileDialog saveFileDialog1 = new SaveFileDialog();

            saveFileDialog1.Filter   = "PS4 Packages|*.PKG";
            saveFileDialog1.Title    = "Save PKG File";
            saveFileDialog1.FileName = contentID.Text;
            CreatePKG.Enabled        = false;

            if (GMVer.StartsWith("1."))
            {
                HasShaders = File.ReadAllText(projectPath.Text).Contains("</shaders>"); //Too lazy to parse XML properly.
            }
            else if (GMVer.StartsWith("2."))
            {
                HasShaders = File.ReadAllText(projectPath.Text).Contains("GMShader"); //Too lazy to parse XML properly.
            }
            if (HasShaders)
            {
                if (!Directory.Exists(@"ps4sdk"))
                {
                    DialogResult msgResult = MessageBox.Show("It's been detected that you are using Shaders in your GM Project\nHowever no copy of the PS4 Shader Compiler (orbis-wave-psslc.exe) was found.\nBrowse to orbis-wave-psslc.exe?", "Shader Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                    if (msgResult == DialogResult.Yes)
                    {
                        OpenFileDialog openFileDialog = new OpenFileDialog();
                        openFileDialog.Filter = "orbis-wave-psslc.exe|orbis-wave-psslc.exe";
                        openFileDialog.Title  = "Browse to PS4 Shader Compiler.";
                        if (openFileDialog.ShowDialog() == DialogResult.OK)
                        {
                            if (!Directory.Exists(@"ps4sdk"))
                            {
                                GmacOut.AppendText("Creating PS4SDK Directory Structure\n");
                                Directory.CreateDirectory("ps4sdk");
                                Directory.CreateDirectory("ps4sdk/host_tools");
                                Directory.CreateDirectory("ps4sdk/host_tools/bin");
                            }
                            File.Copy(openFileDialog.FileName, @"ps4sdk/host_tools/bin/orbis-wave-psslc.exe");
                        }
                        else
                        {
                            CreatePKG.Enabled = true;
                            return;
                        }
                    }
                    else
                    {
                        CreatePKG.Enabled = true;
                        return;
                    }
                }
            }


            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                tempdir = Path.GetDirectoryName(saveFileDialog1.FileName) + "\\_temp";

                if (Directory.Exists(tempdir))
                {
                    Directory.Delete(tempdir, true);
                }
                Directory.CreateDirectory(tempdir);

                if (GMVer == "1.4.9999")
                {
                    CopyDir(@"Runner", tempdir);
                }
                else
                {
                    CopyDir("versions\\" + GMVer + "\\Runner", tempdir);
                }


                Make24Bit(iconPath.Text, tempdir + "\\sce_sys\\icon0.png");
                Make24Bit(picPath.Text, tempdir + "\\sce_sys\\pic1.png");

                if (!CompileProject(projectPath.Text, tempdir + "\\games"))
                {
                    Directory.Delete(tempdir, true);
                    CreatePKG.Enabled = true;
                    return;
                }
            }
            else
            {
                CreatePKG.Enabled = true;
                return;
            }

            FileStream fd = File.Open(tempdir + "\\sce_sys\\param.sfo", FileMode.OpenOrCreate, FileAccess.ReadWrite);

            GmacOut.AppendText("Writing " + titleName.Text + " to TITLE of param.sfo\n");
            fd.Seek(0x350, SeekOrigin.Begin);
            foreach (Byte by in ASCIIEncoding.ASCII.GetBytes(titleName.Text))
            {
                fd.WriteByte(by);
            }


            GmacOut.AppendText("Writing " + titleID.Text + " to TITLE_ID of param.sfo\n");
            fd.Seek(0x3D0, SeekOrigin.Begin);
            foreach (Byte by in ASCIIEncoding.ASCII.GetBytes(titleID.Text))
            {
                fd.WriteByte(by);
            }

            GmacOut.AppendText("Writing " + contentID.Text + " to CONTENT_ID of param.sfo!\n");
            fd.Seek(0x284, SeekOrigin.Begin);
            foreach (Byte by in ASCIIEncoding.ASCII.GetBytes(contentID.Text))
            {
                fd.WriteByte(by);
            }
            fd.Close();


            GmacOut.AppendText("Creating GP4 ...");

            Gp4Project proj = Gp4Project.Create(VolumeType.pkg_ps4_app);
            Dir        root = null;

            foreach (var file in Directory.GetFileSystemEntries(tempdir))
            {
                if (File.Exists(file))
                {
                    AddFile(proj, "", file);
                }
                else if (Directory.Exists(file))
                {
                    AddFileTree(proj, root, file);
                }
            }

            proj.volume.Package.ContentId = contentID.Text;
            proj.volume.Package.Passcode  = "00000000000000000000000000000000";

            GmacOut.AppendText("OK!\n");


            if (File.Exists(saveFileDialog1.FileName))
            {
                File.Delete(saveFileDialog1.FileName);
            }

            GmacOut.AppendText("Building PKG ...");
            Thread thr = new Thread(() =>
            {
                PkgBuilder pkg = new PkgBuilder(PkgProperties.FromGp4(proj, ""));
                pkg.Write(saveFileDialog1.FileName);
            });

            thr.Start();

            while (thr.IsAlive)
            {
                Application.DoEvents();
            }

            GmacOut.AppendText("OK!\n");



            GmacOut.AppendText("Deleting " + tempdir + " ...");
            Directory.Delete(tempdir, true);
            GmacOut.AppendText("OK!\n");

            GmacOut.AppendText("Done!\n");
            CreatePKG.Enabled = true;
            MessageBox.Show("PKG Created!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }