Esempio n. 1
0
        private void AddFile(Gp4Project proj, string targetPath, string origPath)
        {
            var f         = origPath;
            var fileEntry = new Gp4File
            {
                OrigPath   = f,
                TargetPath = targetPath + Path.GetFileName(origPath)
            };

            proj.files.Items.Add(fileEntry);
        }
Esempio n. 2
0
        private void AddFileTree(Gp4Project proj, Dir parent, string path)
        {
            var newDir = proj.AddDir(parent, Path.GetFileName(path));

            foreach (var d in Directory.EnumerateDirectories(path))
            {
                AddFileTree(proj, newDir, d);
            }
            var targetPath = newDir.Path;

            foreach (var f in Directory.EnumerateFiles(path))
            {
                AddFile(proj, targetPath, f);
            }
        }
Esempio n. 3
0
        public void TestCreateGP4()
        {
            using (var extractDir = new TempDir())
            {
                Gp4Creator.CreateProjectFromPKG(extractDir.Path, pkgFile.Path);
                using (var f = File.OpenRead(Path.Combine(extractDir.Path, "Project.gp4")))
                {
                    var project = Gp4Project.ReadFrom(f);
                    Assert.AreEqual(props.EntitlementKey, project.volume.Package.EntitlementKey);
                    Assert.AreEqual(props.VolumeType, project.volume.Type);
                    // TODO: Figure out timezone problems
                    //Assert.AreEqual(props.TimeStamp, project.volume.TimeStamp);


                    var file = File.ReadAllBytes(Path.Combine(extractDir.Path, "test.file"));
                    CollectionAssert.AreEqual(TestFile, file);
                }
            }
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            switch (args[0])
            {
            case "makepfs":
            {
                var proj    = args[1];
                var output  = args[2];
                var outFile = File.OpenWrite(output);
                var props   = new LibOrbisPkg.PFS.PfsProperties
                {
                    BlockSize = 65536,
                    output    = outFile,
                    proj      = Gp4Project.ReadFrom(File.OpenRead(proj)),
                    projDir   = Path.GetDirectoryName(proj)
                };
                new PfsBuilder().BuildPfs(props);
                break;
            }

            case "makepkg":
            {
                var proj       = args[1];
                var project    = Gp4Project.ReadFrom(File.OpenRead(proj));
                var outputPath = args[2];

                using (var outFile = File.Open(
                           Path.Combine(
                               outputPath,
                               $"{project.volume.Package.ContentId}.pkg"),
                           FileMode.Create))
                {
                    new PkgBuilder(project, Path.GetDirectoryName(proj)).Write(outFile);
                }
                break;
            }
            }
        }
Esempio n. 5
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);
        }