コード例 #1
0
        private async Task <Unit> OpenRedFileAsync(FileEntry file)
        {
            if (file != null)
            {
                _progressService.IsIndeterminate = true;
                try
                {
                    var fileViewModel = new RedDocumentViewModel(file.FileName);
                    await using (var stream = new MemoryStream())
                    {
                        file.Extract(stream);
                        fileViewModel.OpenStream(stream, null);
                    }

                    if (!DockedViews.Contains(fileViewModel))
                    {
                        DockedViews.Add(fileViewModel);
                    }

                    ActiveDocument = fileViewModel;
                    UpdateTitle();
                }
                catch (Exception e)
                {
                    _loggerService.Error(e.Message);
                }
                finally
                {
                    _progressService.IsIndeterminate = false;
                }
            }

            return(Unit.Default);
        }
コード例 #2
0
ファイル: PackageExplorer.cs プロジェクト: randprint/X360
        private void extractFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedIndices.Count == 0)
            {
                return;
            }
            FileEntry xent = (FileEntry)listView1.SelectedItems[0].Tag;
            string    File = xent.Name;
            string    xOut = VariousFunctions.GetUserFileLocale("Open a save location", "", false);

            if (xOut == null)
            {
                return;
            }
            this.Enabled = false;
            Log("Extracting " + File + "...");
            if (!xent.Extract(xOut))
            {
                Log("Extraction error");
                this.Enabled = true;
                return;
            }
            Log(File + " extracted");
            this.Enabled = true;
        }
コード例 #3
0
ファイル: PackageExplorer.cs プロジェクト: randprint/X360
        private void loadInViewerToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            this.Enabled = false;
            FileEntry xent = xprof.GetFile(xprof.UserGPD.TitlesPlayed[listBox3.SelectedIndex].ID.ToString("X") + ".gpd");

            if (xent == null)
            {
                Log("Could not find specified file");
                this.Enabled = true;
                return;
            }
            Log("Extracting " + xent.Name + "...");
            string xOut = VariousFunctions.GetTempFileLocale();

            if (!xent.Extract(xOut))
            {
                Log("Extraction error");
                VariousFunctions.DeleteFile(xOut);
                this.Enabled = true;
                return;
            }
            GameGPD xload = new GameGPD(xOut, ProfileTools.GPDNameToID(xent.Name));

            if (!xload.IsValid)
            {
                Log("Error when parsing GPD");
                xload.Close();
                try { VariousFunctions.DeleteFile(xOut); }
                catch { }
                this.Enabled = true;
                return;
            }
            GPDViewer x = new GPDViewer(xload);

            x.MdiParent = xMForm;
            x.Show();
            Log("GPD Loaded");
            this.Enabled = true;
        }
コード例 #4
0
ファイル: PackageExplorer.cs プロジェクト: randprint/X360
        private void loadInViewerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedIndices.Count == 0)
            {
                return;
            }
            FileEntry xent = (FileEntry)listView1.SelectedItems[0].Tag;

            this.Enabled = false;
            Log("Extracting " + xent.Name + "...");
            string xOut = VariousFunctions.GetTempFileLocale();

            if (!xent.Extract(xOut))
            {
                Log("Extraction error");
                this.Enabled = true;
                return;
            }
            GameGPD xload = new GameGPD(xOut, ProfileTools.GPDNameToID(xent.Name));

            if (!xload.IsValid)
            {
                Log("Error when parsing GPD");
                xload.Close();
                try { VariousFunctions.DeleteFile(xOut); }
                catch { }
                this.Enabled = true;
                return;
            }
            GPDViewer x = new GPDViewer(xload);

            x.MdiParent = xMForm;
            x.Show();
            Log("GPD Loaded");
            this.Enabled = true;
        }
コード例 #5
0
ファイル: PboFSNode.cs プロジェクト: Dahlgren/DokanPbo
 public System.IO.Stream GetFileStream()
 {
     return(File.Extract()); //#TODO cache with Open/Close functions
 }
コード例 #6
0
ファイル: PackageExplorer.cs プロジェクト: randprint/X360
        private void listBox3_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBox3.SelectedIndex < 0)
            {
                return;
            }
            tabControl1.Enabled = false;
            buttonX12.Enabled   = true;
            TitlePlayedEntry x = xprof.UserGPD.TitlesPlayed[listBox3.SelectedIndex];

            try { dateTimePicker3.Value = dateTimePicker4.Value = x.LastLoadedDT; }
            catch { dateTimePicker3.Value = dateTimePicker4.Value = DateTime.Now; }
            textBoxX14.Text  = "Unlocked " + x.EarnedCount.ToString() + " of " + x.PossibleCount.ToString();
            textBoxX14.Text += Environment.NewLine + "Total of " + x.EarnedWorth.ToString() + " of " + x.PossibleWorth.ToString();
            string    path = x.TitleID.ToString("X").ToUpper() + ".gpd";
            FileEntry xent = xPackage.GetFile(path);

            if (xent == null)
            {
                Log("Error: could not find GPD");
                killachievetab();
                tabControl1.Enabled = true;
                return;
            }
            string xOut = VariousFunctions.GetTempFileLocale();

            if (!xent.Extract(xOut))
            {
                Log("Extraction error");
                killachievetab();
                tabControl1.Enabled = true;
                return;
            }
            GameGPD xload = new GameGPD(xOut, x.TitleID);

            if (!xload.IsValid)
            {
                Log("Error when parsing GPD");
                xload.Close();
                try { VariousFunctions.DeleteFile(xOut); }
                catch { }
                xload = null;
                killachievetab();
                tabControl1.Enabled = true;
                return;
            }
            listBox2.Items.Clear();
            for (int i = 0; i < xload.Achievements.Length; i++)
            {
                listBox2.Items.Add(xload.Achievements[i].Title);
            }
            Image xTitleIMGS = xload.GetImageByID(0x8000);

            if (xTitleIMGS != null)
            {
                pictureBox4.Image = xTitleIMGS;
            }
            else
            {
                pictureBox4.Image = PublicResources.NoImage;
            }
            string xTitleStrings = xload.GetStringByID(0x8000);

            if (xTitleStrings != null)
            {
                textBoxX4.Text = xTitleStrings;
            }
            else
            {
                textBoxX4.Text = "Unknown";
            }
            xLoadedGPD   = xload;
            xLoadedEntry = xent;
            if (listBox2.Items.Count > 0)
            {
                listBox2.SelectedIndex = 0;
            }
            listBox2_SelectedIndexChanged(null, null);
            buttonX11.Enabled                =
                buttonX3.Enabled             =
                    buttonX10.Enabled        =
                        tabControl1.Enabled  =
                            buttonX6.Enabled =
                                tabControlPanel10.Enabled = true;
            Log("GPD Loaded");
        }
コード例 #7
0
ファイル: StartPage.xaml.cs プロジェクト: XboxChaos/Liberty
        public void LoadSavesFromDevices()
        {
            // Do Save Selector Code
            BackgroundWorker bw = new BackgroundWorker();

            bw.DoWork += (o2, args2) =>
            {
                Dispatcher.Invoke(new Action(delegate
                {
                    // Setup Pending UI stuff
                    progressPendingRefresh.Visibility = System.Windows.Visibility.Visible;

                    // Close Existing Streams
                    foreach (StartPageViewModel.FATXGameSave save in PageViewModel.FATXGameSaves)
                    {
                        save.Stream.Close();
                    }

                    // Clear ObservableCollection
                    PageViewModel.FATXGameSaves.Clear();
                }));

                if (_physDrives != null)
                {
                    foreach (Drive drive in _physDrives)
                    {
                        drive.Close();
                    }
                    _physDrives = null;
                }

                // Get Drives
                _physDrives = StartHere.GetFATXDrives().ToList();

                // Get Saves from said drives
                foreach (Drive drive in _physDrives)
                {
                    Folder xboxContent = drive.FolderFromPath("Data\\Content");

                    foreach (Folder content in xboxContent.Folders())
                    {
                        if (content.Name.StartsWith("E"))
                        {
                            // We're in a profile, lets go right into a game file
                            foreach (Manager.SupportedGames.SupportedGame supportedGame in Manager.SupportedGame.Games)
                            {
                                string filePath = string.Format("{0}\\Content\\{1}\\{2}\\00000001", "Data", content.Name, supportedGame.TitleID.ToString("X"));
                                if (drive.DirectoryExists(filePath))
                                {
                                    Folder profileGamesaveContent = drive.FolderFromPath(filePath);

                                    // Look though the profile folder for a campaign save
                                    foreach (CLKsFATXLib.File gamesaveContent in profileGamesaveContent.Files())
                                    {
                                        if (gamesaveContent.Name.StartsWith(supportedGame.STFSStartsWith))
                                        {
                                            try
                                            {
                                                // Is a campaign save, woop!
                                                // Add to the ObservableCollection and move out!
                                                StartPageViewModel.FATXGameSave fatxGamesave = new StartPageViewModel.FATXGameSave();

                                                fatxGamesave.FATXPath      = gamesaveContent.FullPath;
                                                fatxGamesave.PackageName   = gamesaveContent.Name;
                                                fatxGamesave.GameName      = supportedGame.Name;
                                                fatxGamesave.SafeGameName  = supportedGame.SafeName;
                                                fatxGamesave.SupportedGame = supportedGame;
                                                fatxGamesave.FATXDrive     = drive;

                                                // Check the save isn't already open
                                                string USID = Utilities.CreateUniqueSaveIdentification(gamesaveContent.Name, gamesaveContent.FullPath, true);
                                                if (!Backend.Settings.OpenedSaves.Contains(USID))
                                                {
                                                    // Extract gamestate to get data about the save
                                                    STFSPackage package         = new STFSPackage(new X360.IO.DJsIO(gamesaveContent.GetStream(), true), null);
                                                    FileEntry   gamestateHeader = package.GetFile("gamestate.hdr");
                                                    string      extractionPath  = Backend.VariousFunctions.CreateTemporaryFile(Backend.VariousFunctions.GetTemporaryExtractionLocation());
                                                    gamestateHeader.Extract(extractionPath);

                                                    // Create Stream, lol
                                                    EndianStream endianStream = new EndianStream(new MemoryStream(System.IO.File.ReadAllBytes(extractionPath)), Endian.BigEndian);

                                                    // Get Header Layout
                                                    StructureValueCollection saveHeader = StructureReader.ReadStructure(endianStream, supportedGame.GetLayout("header"));

                                                    fatxGamesave.Stream      = endianStream;
                                                    fatxGamesave.USID        = USID;
                                                    fatxGamesave.MapName     = SaveManager.Utilities.GetFriendlyMissionName(saveHeader.GetString("scenario"), (Utilities.HaloGames)Enum.Parse(typeof(Utilities.HaloGames), supportedGame.SafeName));
                                                    fatxGamesave.MapScenario = saveHeader.GetString("scenario");
                                                    string libertyImagePath = string.Format(@"/Liberty;component/Metro/Images/Games/MapImages/{0}/{1}.jpg", supportedGame.SafeName, saveHeader.GetString("scenario").Substring(saveHeader.GetString("scenario").LastIndexOf('\\') + 1).ToLower());
                                                    fatxGamesave.MapImage   = libertyImagePath;
                                                    fatxGamesave.GamerTag   = saveHeader.GetString("gamer tag");
                                                    fatxGamesave.ServiceTag = saveHeader.GetString("service tag");

                                                    Dispatcher.Invoke(new Action(delegate
                                                    {
                                                        // Add to ObservableCollection, has to be invoked to do this
                                                        PageViewModel.FATXGameSaves.Add(fatxGamesave);
                                                    }));
                                                }
                                            }
                                            catch { }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };
            bw.RunWorkerCompleted += (o, args) =>
            {
                // Setup Pending UI stuff
                Dispatcher.Invoke(new Action(delegate { progressPendingRefresh.Visibility = System.Windows.Visibility.Collapsed; }));
            };
            bw.RunWorkerAsync();
        }
コード例 #8
0
ファイル: ShellViewModel.cs プロジェクト: shagged/nucleuscoop
        public IEnumerable <IResult> ReadSave()
        {
            string fileName = null;

            MyOpenFileResult ofr;

            ofr = new MyOpenFileResult()
                  .FilterFiles(
                ffc => ffc.AddFilter("sav", true)
                .WithDescription("Borderlands 2 Save Files")
                .AddAllFilesFilter())
                  .WithFileDo(s => fileName = s);

            if (string.IsNullOrEmpty(this._SavePath) == false &&
                Directory.Exists(this._SavePath) == true)
            {
                ofr = ofr.In(this._SavePath);
            }

            yield return(ofr);

            if (fileName == null)
            {
                yield break;
            }

            ///////////////////////////////////////////
            //SPITFIRE1337 MODS
            ///////////////////////////////////////////

            string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            //using (FileStream fs = File.Create(path)) { }
            File.Delete(path + "/mytempsave.sav");
            File.Delete(path + "/savegame.sav");
            File.Copy(fileName, path + "/mytempsave.sav");
            string profileid = "";
            string deviceid  = "";
            string consoleid = "";


            Stream input1 = new FileStream(fileName, FileMode.Open);

            // Ensure that the target does not exist.



            //Stream input = new Stream(fs);
            var check = input1.ReadValueU32(Endian.Big);

            input1.Close();

            if (check == 0x434F4E20)
            {
                //MessageBox.Show("This is a xbox save");

                yield return(new DelegateResult(() =>
                {
                    DJsIO io = new DJsIO(fileName, DJFileMode.Open, true);

                    io.Position = 0x371;
                    profileid = io.ReadHexString(8); //Profile ID
                    io.Close();
                })
                             .Rescue().Execute(
                                 x =>
                                 new MyMessageBox("An exception was thrown (press Ctrl+C to copy):\n\n" + x.ToString(),
                                                  "Error")
                                 .WithIcon(MessageBoxImage.Error).AsCoroutine()));


                STFSPackage xPackage = new STFSPackage(fileName, null);
                FileEntry   xent     = (FileEntry)xPackage.GetFile("savegame.sav");

                if (!xent.Extract(path + "/savegame.sav"))
                {
                    //MessageBoxEx.Show("Extraction Failed!", "Failed!", MessageBoxButtons.OK, MessageBoxIcon.[Error])
                    //xboxextract.ReportProgress(200, "Extraction Failed");
                    //Thread.Sleep(2000);
                    //Return
                    MessageBox.Show("Could not extract savegame.sav. Please use a program like modio or horizon to extract your savegame.sav");
                }
                else
                {
                    fileName = path + "/savegame.sav";
                    //MessageBox.Show("File extracted");
                    //Thread.Sleep(2000);
                    //MessageBoxEx.Show("Extraction Complete!", "Complete!", MessageBoxButtons.OK, MessageBoxIcon.Information)
                }
            }
            else
            {
                profileid = "0";
                deviceid  = "0";
                consoleid = "0";
            }

            yield return(new DelegateResult(() =>
            {
                FileFormats.SaveFile saveFile;
                using (var input = File.OpenRead(fileName))
                {
                    saveFile = FileFormats.SaveFile.Deserialize(input, FileFormats.SaveFile.DeserializeSettings.None);
                }

                this.SaveFile = saveFile;
                this.General.ImportData(saveFile.SaveGame, saveFile.Endian, profileid, deviceid, consoleid);
                this.CurrencyOnHand.ImportData(saveFile.SaveGame);
                this.Backpack.ImportData(saveFile.SaveGame);
                this.Bank.ImportData(saveFile.SaveGame);
            })
                         .Rescue <DllNotFoundException>().Execute(
                             x => new MyMessageBox("Failed to load save: " + x.Message, "Error")
                             .WithIcon(MessageBoxImage.Error).AsCoroutine())
                         .Rescue <FileFormats.SaveFormatException>().Execute(
                             x => new MyMessageBox("Failed to load save: " + x.Message, "Error")
                             .WithIcon(MessageBoxImage.Error).AsCoroutine())
                         .Rescue <FileFormats.SaveCorruptionException>().Execute(
                             x => new MyMessageBox("Failed to load save: " + x.Message, "Error")
                             .WithIcon(MessageBoxImage.Error).AsCoroutine())
                         .Rescue().Execute(
                             x =>
                             new MyMessageBox("An exception was thrown (press Ctrl+C to copy):\n\n" + x.ToString(),
                                              "Error")
                             .WithIcon(MessageBoxImage.Error).AsCoroutine()));
            ///////////////////////////////////////////
            //END SPITFIRE1337 MODS
            ///////////////////////////////////////////
        }