InstallTexture() публичный Метод

public InstallTexture ( string texname, List pccs, List IDs, byte imgdata ) : bool
texname string
pccs List
IDs List
imgdata byte
Результат bool
Пример #1
0
        private bool InstallTextures(List<TPFTexInfo> textures, bool result)
        {
            // KFreon: Cancel if analysis failed
            if (!result)
            {
                this.Invoke(new Action(() =>
                {
                    EnableSecondProgressBar(false);
                    OverallStatusLabel.Text = "Ready.";
                    OverallProgressBar.Value = 0;
                }));
                return false;
            }

            // KFreon: Get valids only
            List<TPFTexInfo> validtexes = new List<TPFTexInfo>();
            validtexes = new List<TPFTexInfo>(textures.Where(tex => tex.Valid));

            int valids = validtexes.Count;
            if (valids == 0)
                return true;

            // KFreon: Setup modified DLC list
            List<string> modifiedDLC = new List<string>();

            // Heff: Cancellation check
            if (cts.IsCancellationRequested)
                return false;
            OverallProg.ChangeProgressBar(0, validtexes.Count + 1);
            int count = 0;
            DebugOutput.PrintLn("Textures loaded = " + validtexes.Count);
            DebugOutput.PrintLn("Num valid: " + valids);

            // KFreon: Install textures
            Texplorer2 texplorer = new Texplorer2(true, WhichGame);
            var numInstalled = 0;
            foreach (TPFTexInfo tex in validtexes)
            {
                // Heff: Cancellation check
                if (cts.IsCancellationRequested)
                    return false;
                
                // Heff: match against known problematic hashes, prompt the user.
                // (particularly textures animateed by distortion)
                if (DistortionHashList.Contains(tex.Hash))
                {
                    bool install = false;
                    this.Invoke(new Action(() =>
                    {
                        var dialogResult = MessageBox.Show("This texture is known to cause problems when resolution is higher than normal. \nDo you still want to try to install it? (Not recommended for normal users)", "Warning!", 
                            MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                        install = dialogResult == System.Windows.Forms.DialogResult.Yes ? true : false;
                    }));
                    if (!install)
                    {
                        this.Invoke(new Action(() =>
                        {
                            Overall.UpdateText("Skipping mod:  " + tex.TexName + " | " + count + "/" + valids + " mods completed.");
                            DebugOutput.PrintLn("Skipping mod:  " + tex.TexName + " | " + count++ + "/" + valids + " mods completed.");
                            OverallProg.IncrementBar();
                        }));
                        continue;
                    }
                }

                this.Invoke(new Action(() =>
                {
                    Overall.UpdateText("Installing mod:  " + tex.TexName + " | " + count + "/" + valids + " mods completed.");
                    DebugOutput.PrintLn("Installing mod:  " + tex.TexName + " | " + count++ + "/" + valids + " mods completed.");
                    OverallProg.IncrementBar();
                }));

                try
                {
                    if (texplorer.InstallTexture(tex.TexName, tex.Files, tex.ExpIDs, tex.Extract(null, true)))
                        numInstalled++;
                } catch (Exception e)
                {
                    if (e is System.UnauthorizedAccessException)
                    {
                        this.Invoke(new Action(() =>
                        {
                            MessageBox.Show("Could not install " + tex.TexName + " due to problems with the pcc file, \nplease check that the relevant .pcc files are not set as read-only, \nand try running me3explorer as admin.", "Warning!",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }));
                    }
                    else
                    {
                        DebugOutput.PrintLn("Unknown error with mod:  " + tex.TexName + ", skipping.");
                        DebugOutput.PrintLn("(Error:  " + e.Message + ")");
                    }
                    continue;
                }

                // KFreon: Add modified DLC to list
                if (WhichGame == 3)
                {
                    foreach (string file in tex.Files)
                    {
                        string dlcname = KFreonLib.Misc.Methods.GetDLCNameFromPath(file);
                        if (dlcname != "" && dlcname != null && !modifiedDLC.Contains(dlcname))
                            modifiedDLC.Add(dlcname);
                    }
                }
            }

            // Heff: Cancellation check
            if (cts.IsCancellationRequested)
                return false;

            if (numInstalled > 0)
            {
                // KFreon: Update TOC's
                this.Invoke(new Action(() =>
                {
                    OverallProgressBar.Value = OverallProgressBar.Maximum - 1;
                    OverallStatusLabel.Text = "Checking TOC.bin...";
                }));
                Texplorer2.UpdateTOCs(WhichGame);

                // Heff: Cancellation check
                if (cts.IsCancellationRequested)
                    return false;
                this.Invoke(new Action(() =>
                {
                    OverallStatusLabel.Text = "Installed " + numInstalled + "/" + valids + " valid mods.";
                    OverallProgressBar.Value = OverallProgressBar.Maximum;
                }));
            }
            else
            {
                DebugOutput.PrintLn("All mods were skipped.");
                this.Invoke(new Action(() =>
                {
                    OverallStatusLabel.Text = "No mods installed!";
                    OverallProgressBar.Value = OverallProgressBar.Maximum;
                }));
            }

            return true;
        }
        private bool InstallTextures(List<TPFTexInfo> textures, bool result)
        {
            // KFreon: Cancel if analysis failed
            if (!result)
            {
                this.Invoke(new Action(() =>
                {
                    EnableSecondProgressBar(false);
                    OverallStatusLabel.Text = "Ready.";
                    OverallProgressBar.Value = 0;
                }));
                return false;
            }

            // KFreon: Get valids only
            List<TPFTexInfo> validtexes = new List<TPFTexInfo>();
            validtexes = new List<TPFTexInfo>(textures.Where(tex => tex.Valid));

            int valids = validtexes.Count;
            if (valids == 0)
                return true;

            // KFreon: Setup modified DLC list
            List<string> modifiedDLC = new List<string>();

            OverallProg.ChangeProgressBar(0, validtexes.Count + 1);
            int count = 1;
            DebugOutput.PrintLn("Textures loaded = " + validtexes.Count);
            DebugOutput.PrintLn("Num valid: " + valids);

            // KFreon: Install textures
            Texplorer2 texplorer = new Texplorer2(true, WhichGame);
            foreach (TPFTexInfo tex in validtexes)
            {
                Overall.UpdateText("Installing mod:  " + tex.TexName + " | " + count + "/" + valids + " mods completed.");
                DebugOutput.PrintLn("Installing mod:  " + tex.TexName + " | " + count++ + "/" + valids + " mods completed.");
                OverallProg.IncrementBar();

                texplorer.InstallTexture(tex.TexName, tex.Files, tex.ExpIDs, tex.Extract(null, true));

                // KFreon: Add modified DLC to list
                if (WhichGame == 3)
                {
                    foreach (string file in tex.Files)
                    {
                        string dlcname = KFreonLib.Misc.Methods.GetDLCNameFromPath(file);
                        if (dlcname != "" && dlcname != null && !modifiedDLC.Contains(dlcname))
                            modifiedDLC.Add(dlcname);
                    }
                }

                // KFreon: Check cancellation
                if (cts.IsCancellationRequested)
                    return false;
            }

            // KFreon: Update TOC's
            this.Invoke(new Action(() =>
            {
                OverallProgressBar.Value = OverallProgressBar.Maximum - 1;
                OverallStatusLabel.Text = "Checking TOC.bin...";
            }));
            DebugOutput.PrintLn("Updating Basegame...");
            Texplorer2.UpdateTOCs(pathBIOGame, WhichGame, DLCPath, modifiedDLC);
            this.Invoke(new Action(() =>
            {
                OverallStatusLabel.Text = "All mods installed!";
                OverallProgressBar.Value = OverallProgressBar.Maximum;
            }));

            return true;
        }