Ejemplo n.º 1
0
        private void extractFile_Click(object sender, EventArgs e)
        {
            // Get the selected tree node
            TreeNode selectedNode = packageView.SelectedNode;

            if (selectedNode == null)
            {
                return;
            }

            // Get the file entry from its tag
            StfsFileEntry entry = selectedNode.Tag as StfsFileEntry;

            if (entry == null || entry.IsFolder)
            {
                return;
            }

            // Ask where to save the file
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Title    = "Extract File";
            sfd.Filter   = "All Files|*.*";
            sfd.FileName = entry.Name;
            if (sfd.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            // Extract it
            package.ExtractFile(entry, sfd.FileName);
            MessageBox.Show("File extracted!", Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Ejemplo n.º 2
0
        private void btnCreateAndDeploy_Click(object sender, EventArgs e)
        {
            var tempStfsFile = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\gfaiutzayvy545555iuug2vmslaqbaaaaaaaaaaaa";

            File.Copy(_inputStfsPackage, tempStfsFile, true);

            // Get Base Shit
            Stream templateStfs = new FileStream(tempStfsFile, FileMode.OpenOrCreate, FileAccess.ReadWrite);
            var    stfs         = new StfsPackage(templateStfs)
            {
                Name = string.Format("{0}/{1} - Yrs2013", _cityA, _cityB)
            };

            stfs.SaveMetadata();

            // Extract shit
            var tempFile = Path.GetTempFileName();

            stfs.ExtractFile("variant", tempFile);

            // Load Shit
            var gametype = GameType.Load(tempFile);

            gametype = CreateMegaloGametype(gametype, Convert.ToUInt32(txtGametypeLength.Text));

            // Save Shit
            gametype.Save(tempFile);
            if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\variant"))
            {
                File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\variant");
            }
            File.Copy(tempFile, Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\variant");

            // Inject Shit
            stfs.ReplaceFile(tempFile, "variant");

            // Fix Shit
            stfs.Rehash();
            stfs.SaveChanges(@"Stfs/KV_D.bin");
            templateStfs.Close();

            // Transfer Stuff
            XboxCommunication.XboxCopy(tempStfsFile, @"hdd:\Content\E00006B45A52FF20\4D530919\00000001");

            // Tell Shit
            MessageBox.Show("Gametype deployed to console");
        }
Ejemplo n.º 3
0
        private void btnCreateAndDeploy_Click(object sender, EventArgs e)
        {
            var tempStfsFile = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\gfaiutzayvy545555iuug2vmslaqbaaaaaaaaaaaa";
            File.Copy(_inputStfsPackage, tempStfsFile, true);

            // Get Base Shit
            Stream templateStfs = new FileStream(tempStfsFile, FileMode.OpenOrCreate, FileAccess.ReadWrite);
            var stfs = new StfsPackage(templateStfs)
            {
                Name = string.Format("{0}/{1} - Yrs2013", _cityA, _cityB)
            };
            stfs.SaveMetadata();

            // Extract shit
            var tempFile = Path.GetTempFileName();
            stfs.ExtractFile("variant", tempFile);

            // Load Shit
            var gametype = GameType.Load(tempFile);
            gametype = CreateMegaloGametype(gametype, Convert.ToUInt32(txtGametypeLength.Text));

            // Save Shit
            gametype.Save(tempFile);
            if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\variant"))
                File.Delete(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\variant");
            File.Copy(tempFile, Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\variant");

            // Inject Shit
            stfs.ReplaceFile(tempFile, "variant");

            // Fix Shit
            stfs.Rehash();
            stfs.SaveChanges(@"Stfs/KV_D.bin");
            templateStfs.Close();

            // Transfer Stuff
            XboxCommunication.XboxCopy(tempStfsFile, @"hdd:\Content\E00006B45A52FF20\4D530919\00000001");

            // Tell Shit
            MessageBox.Show("Gametype deployed to console");
        }
Ejemplo n.º 4
0
        public ActionResult Index(CreateProject createProject, HttpPostedFileBase stfsUpload)
        {
            if (!ModelState.IsValid)
                return View();

            // Get the User
            var user = Helpers.GetAuthenticatedUser();
            if (user == null)
                return View();

            // Check Name is Unique
            if (_dbContext.Projects.Count(p =>
                !p.IsDeleted && p.Name.ToLower().Equals(createProject.ProjectName.ToLower())) > 0)
            {
                ModelState.AddModelError("ProjectName", "You can't have 2 Projects with the same name.");
                return View();
            }

            // Do file validation stuff
            if (stfsUpload == null)
            {
                ModelState.AddModelError("File", "You must select a Halo 4 Gametype to create a project.");
                return View();
            }
            else
            {
                var outputPath = Path.GetTempFileName();
                var variantExtrated = Path.GetTempFileName();
                System.IO.File.WriteAllBytes(outputPath, VariousFunctions.StreamToByteArray(stfsUpload.InputStream));
                try
                {
                    var stfsParsed = new StfsPackage(outputPath);

                    // Validate contains variant
                    if (!stfsParsed.FileExists("variant"))
                        throw new Exception();

                    // Extract variant
                    stfsParsed.ExtractFile("variant", variantExtrated);

                    var gametype = GameType.Load(variantExtrated);

                    // TODO: seralize gametype data
                    var seralizedData = "";

                    // Write data to Database
                    var project = new Project
                    {
                        Name = createProject.ProjectName,
                        Description = createProject.ProjectDescription,
                        UserId = user.Id
                    };

                    // Write data to the S3 Bucket
                    try
                    {
                        var s3 = new S3Storage();
                        s3.WriteObject(VariousFunctions.StreamToByteArray(stfsUpload.InputStream),
                            S3Storage.StorageLocations.Stfs, project.StfsId);
                        s3.WriteObject(seralizedData,
                            S3Storage.StorageLocations.Solution, project.SolutionId);
                    }
                    catch
                    {
                        return RedirectToAction("Index").Error("There was an unknown error trying to create the project.");
                    }

                    // Save project to database
                    _dbContext.Projects.Add(project);
                    _dbContext.SaveChanges();

                    // Delete files now we done, yo
                    System.IO.File.Delete(outputPath);
                    System.IO.File.Delete(variantExtrated);

                    // Redirect outa here
                    return RedirectToAction("Edit", new { id = project.Id });
                }
                catch
                {
                    // Uh Oh, NSA - get the f**k out of here, and delete all the evidence.
                    System.IO.File.Delete(outputPath);
                    System.IO.File.Delete(variantExtrated);

                    ModelState.AddModelError("File", "Invalid Halo 4 Gametype.");
                    return View();
                }
            }
        }
Ejemplo n.º 5
0
        public ActionResult Index(CreateProject createProject, HttpPostedFileBase stfsUpload)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            // Get the User
            var user = Helpers.GetAuthenticatedUser();

            if (user == null)
            {
                return(View());
            }

            // Check Name is Unique
            if (_dbContext.Projects.Count(p =>
                                          !p.IsDeleted && p.Name.ToLower().Equals(createProject.ProjectName.ToLower())) > 0)
            {
                ModelState.AddModelError("ProjectName", "You can't have 2 Projects with the same name.");
                return(View());
            }

            // Do file validation stuff
            if (stfsUpload == null)
            {
                ModelState.AddModelError("File", "You must select a Halo 4 Gametype to create a project.");
                return(View());
            }
            else
            {
                var outputPath      = Path.GetTempFileName();
                var variantExtrated = Path.GetTempFileName();
                System.IO.File.WriteAllBytes(outputPath, VariousFunctions.StreamToByteArray(stfsUpload.InputStream));
                try
                {
                    var stfsParsed = new StfsPackage(outputPath);

                    // Validate contains variant
                    if (!stfsParsed.FileExists("variant"))
                    {
                        throw new Exception();
                    }

                    // Extract variant
                    stfsParsed.ExtractFile("variant", variantExtrated);

                    var gametype = GameType.Load(variantExtrated);

                    // TODO: seralize gametype data
                    var seralizedData = "";

                    // Write data to Database
                    var project = new Project
                    {
                        Name        = createProject.ProjectName,
                        Description = createProject.ProjectDescription,
                        UserId      = user.Id
                    };

                    // Write data to the S3 Bucket
                    try
                    {
                        var s3 = new S3Storage();
                        s3.WriteObject(VariousFunctions.StreamToByteArray(stfsUpload.InputStream),
                                       S3Storage.StorageLocations.Stfs, project.StfsId);
                        s3.WriteObject(seralizedData,
                                       S3Storage.StorageLocations.Solution, project.SolutionId);
                    }
                    catch
                    {
                        return(RedirectToAction("Index").Error("There was an unknown error trying to create the project."));
                    }

                    // Save project to database
                    _dbContext.Projects.Add(project);
                    _dbContext.SaveChanges();

                    // Delete files now we done, yo
                    System.IO.File.Delete(outputPath);
                    System.IO.File.Delete(variantExtrated);

                    // Redirect outa here
                    return(RedirectToAction("Edit", new { id = project.Id }));
                }
                catch
                {
                    // Uh Oh, NSA - get the f**k out of here, and delete all the evidence.
                    System.IO.File.Delete(outputPath);
                    System.IO.File.Delete(variantExtrated);

                    ModelState.AddModelError("File", "Invalid Halo 4 Gametype.");
                    return(View());
                }
            }
        }