コード例 #1
0
        private void SetME3KeyWithThread(GameTarget target, string consoleKeyStr = null, string typeKeyStr = null)
        {
            OperationInProgress   = true;
            ME3FullConsoleKeyText = M3L.GetString(M3L.string_updatingKeybindsPleaseWait);
            ME3MiniConsoleKeyText = "";
            NamedBackgroundWorker nbw = new NamedBackgroundWorker(@"ME3-ConsoleKeySetterThread");

            nbw.DoWork += (a, b) =>
            {
                SetME3ConsoleKeybinds(SelectedME3Target, consoleKeyStr, typeKeyStr);
                LoadME3Keys(SelectedME3Target);
                Analytics.TrackEvent(@"Set ME3 Console Keys", new Dictionary <string, string>()
                {
                    { @"Full Console Key", consoleKeyStr },
                    { @"Mini Console Key", typeKeyStr }
                });
            };
            nbw.RunWorkerCompleted += (a, b) =>
            {
                if (b.Error != null)
                {
                    Log.Error($@"Exception occurred in {nbw.Name} thread: {b.Error.Message}");
                }
                OperationInProgress = false;
                CommandManager.InvalidateRequerySuggested();
            };
            nbw.RunWorkerAsync();
        }
コード例 #2
0
 private void ResetME3Keybinds()
 {
     KeybindsInstallingME3 = true;
     NamedBackgroundWorker nbw = new NamedBackgroundWorker(@"ME3KeybindsInstaller");
     nbw.DoWork += (await, b) =>
     {
         var coalPath = Path.Combine(BackupService.GetGameBackupPath(Mod.MEGame.ME3), @"BioGame", @"CookedPCConsole", @"Coalesced.bin");
         if (File.Exists(coalPath))
         {
             using FileStream fs = new FileStream(coalPath, FileMode.Open);
             var coalescedFilemapping = MassEffect3.Coalesce.Converter.DecompileToMemory(fs);
             InstallME3Keybinds(coalescedFilemapping[@"BioInput.xml"], SelectedME3Target);
         }
     };
     nbw.RunWorkerCompleted += (a, b) =>
     {
         if (b.Error != null)
         {
             Log.Error(@"Error resetting ME3 keybinds: " + b.Error.Message);
         }
         KeybindsInstallingME3 = false;
         CommandManager.InvalidateRequerySuggested();
     };
     nbw.RunWorkerAsync();
 }
コード例 #3
0
        private void btnExecute_Click(object sender, System.EventArgs e)
        {
            // Reset all vars
            Reset();

            beginTime = DateTime.Now;

            watch.Start();
            watch.Interval = 200;
            watch.Elapsed += new ElapsedEventHandler(OnTimedEvent);
            watch.Enabled  = true;

            int iterations = Convert.ToInt32(txtIterations.Text);
            int users      = Convert.ToInt32(txtUsers.Text);

            for (int i = 0; i < users; i++)
            {
                var worker = new NamedBackgroundWorker();
                worker.Id                  = i;
                worker.DoWork             += new DoWorkEventHandler(Run);
                worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(RunCompleted);
                worker.RunWorkerAsync(iterations);
                worker.WorkerSupportsCancellation = true;

                backgroundWorkers.Add(worker);
            }
        }
コード例 #4
0
        private void StartUpdate()
        {
            NamedBackgroundWorker bw = new NamedBackgroundWorker(@"ProgramUpdater");

            bw.DoWork += DownloadAndApplyUpdate;
            bw.RunWorkerAsync();
            UpdateInProgress = true;
        }
コード例 #5
0
        public override void OnPanelVisible()
        {
            SaveFileDialog d = new SaveFileDialog
            {
                Filter   = $@"{M3L.GetString(M3L.string_7zipArchiveFile)}|*.7z",
                FileName = Utilities.SanitizePath($@"{ModForArchive.ModName}_{ModForArchive.ModVersionString}".Replace(@" ", ""), true)
            };
            var outputarchive = d.ShowDialog();

            if (outputarchive.HasValue && outputarchive.Value)
            {
                var bw = new NamedBackgroundWorker(@"TestArchiveGenerator");
                bw.DoWork += (a, b) =>
                {
                    var stagingPath     = Directory.CreateDirectory(Path.Combine(Utilities.GetTempPath(), @"TestGenerator")).FullName;
                    var referencedFiles = ModForArchive.GetAllRelativeReferences();
                    int numdone         = 0;
                    ActionText = M3L.GetString(M3L.string_hashingFiles);

                    Parallel.ForEach(referencedFiles, new ParallelOptions()
                    {
                        MaxDegreeOfParallelism = 3
                    }, (x) =>
                    {
                        var sourcefile = Path.Combine(ModForArchive.ModPath, x);
                        var destfile   = Path.Combine(stagingPath, x);

                        Log.Information(@"Hashing " + sourcefile);
                        var md5 = Utilities.CalculateMD5(sourcefile);
                        Directory.CreateDirectory(Directory.GetParent(destfile).FullName);
                        Log.Information(@"Writing blank hash file " + destfile);
                        File.WriteAllText(destfile, md5);


                        var done = Interlocked.Increment(ref numdone);
                        Percent  = (int)(done * 100.0 / referencedFiles.Count);
                    });
                    Log.Information(@"Copying moddesc.ini");
                    File.Copy(ModForArchive.ModDescPath, Path.Combine(stagingPath, @"moddesc.ini"), true);
                    Mod testmod = new Mod(Path.Combine(stagingPath, @"moddesc.ini"), Mod.MEGame.Unknown);
                    if (testmod.ValidMod)
                    {
                        ActionText = M3L.GetString(M3L.string_creatingArchive);

                        SevenZipCompressor svc = new SevenZipCompressor();
                        svc.Progressing += (o, details) => { Percent = (int)(details.AmountCompleted * 100.0 / details.TotalAmount); };
                        svc.CompressDirectory(stagingPath, d.FileName);
                        Utilities.HighlightInExplorer(d.FileName);
                    }
                };
                bw.RunWorkerCompleted += (a, b) => { OnClosing(DataEventArgs.Empty); };
                bw.RunWorkerAsync();
            }
            else
            {
                OnClosing(DataEventArgs.Empty);
            }
        }
コード例 #6
0
            public void RestoreSFAR(bool batchRestore, Action signalRestoreCompleted = null)
            {
                bool?restore = batchRestore;

                if (!restore.Value)
                {
                    restore = RestoreConfirmationCallback?.Invoke(FilePath);
                }
                if (restore.HasValue && restore.Value)
                {
                    NamedBackgroundWorker nbw = new NamedBackgroundWorker(@"RestoreSFARThread");
                    nbw.DoWork += (a, b) =>
                    {
                        var backupFile = Path.Combine(BackupService.GetGameBackupPath(target.Game), FilePath);
                        var targetFile = Path.Combine(target.TargetPath, FilePath);
                        Restoring = true;
                        Log.Information($@"Restoring SFAR from backup: {backupFile} {targetFile}");
                        XCopy.Copy(backupFile, targetFile, true, true,
                                   (o, pce) =>
                        {
                            RestoreButtonContent = M3L.GetString(M3L.string_interp_restoringXpercent,
                                                                 pce.ProgressPercentage.ToString());
                        });
                        var unpackedFiles = Directory.GetFiles(DLCDirectory, @"*", SearchOption.AllDirectories);
                        RestoreButtonContent = M3L.GetString(M3L.string_cleaningUp);
                        foreach (var file in unpackedFiles)
                        {
                            if (!file.EndsWith(@".sfar"))
                            {
                                Log.Information(@"Deleting unpacked file: " + file);
                                File.Delete(file);
                            }
                        }

                        Utilities.DeleteEmptySubdirectories(DLCDirectory);
                        RestoreButtonContent = M3L.GetString(M3L.string_restored);
                    };
                    nbw.RunWorkerCompleted += (a, b) =>
                    {
                        if (b.Error != null)
                        {
                            Log.Error($@"Exception occured in {nbw.Name} thread: {b.Error.Message}");
                        }
                        //File.Copy(backupFile, targetFile, true);
                        //if (!batchRestore)
                        //{
                        RevalidateIsModified();
                        //restoreCompletedCallback?.Invoke();
                        //}
                        Restoring = false;
                        signalRestoreCompleted?.Invoke();
                    };
                    startingRestoreCallback?.Invoke();
                    nbw.RunWorkerAsync();
                }
            }
コード例 #7
0
        /// <summary>
        /// Attempts to endorse/unendorse this mod on NexusMods.
        /// </summary>
        /// <param name="newEndorsementStatus"></param>
        /// <param name="endorse"></param>
        /// <param name="currentuserid"></param>
        public void EndorseMod(Action <Mod, bool> newEndorsementStatus, bool endorse, int currentuserid)
        {
            if (!NexusModsUtilities.HasAPIKey || !CanEndorse)
            {
                return;
            }
            NamedBackgroundWorker nbw = new NamedBackgroundWorker(@"ModSpecificEndorsement");

            nbw.DoWork += (a, b) =>
            {
                var    client   = NexusModsUtilities.GetClient();
                string gamename = @"masseffect";
                if (Game == MEGame.ME2)
                {
                    gamename += @"2";
                }
                if (Game == MEGame.ME3)
                {
                    gamename += @"3";
                }
                string telemetryOverride = null;
                try
                {
                    if (endorse)
                    {
                        client.Mods.Endorse(gamename, NexusModID, @"1.0").Wait();
                    }
                    else
                    {
                        client.Mods.Unendorse(gamename, NexusModID, @"1.0").Wait();
                    }
                }
                catch (Exception e)
                {
                    Log.Error(@"Error endorsing/unendorsing: " + e.ToString());
                    telemetryOverride = e.ToString();
                }

                checkedEndorsementStatus = false;
                IsEndorsed = GetEndorsementStatus(currentuserid).Result ?? false;
                Analytics.TrackEvent(@"Set endorsement for mod", new Dictionary <string, string>
                {
                    { @"Endorsed", endorse.ToString() },
                    { @"Succeeded", telemetryOverride ?? (endorse == IsEndorsed).ToString() }
                });
            };
            nbw.RunWorkerCompleted += (a, b) => {
                if (b.Error != null)
                {
                    Log.Error($@"Exception occured in {nbw.Name} thread: {b.Error.Message}");
                }
                newEndorsementStatus.Invoke(this, IsEndorsed);
            };
            nbw.RunWorkerAsync();
        }
コード例 #8
0
        private void RestoreAllBasegame()
        {
            bool restore = false;

            if (SelectedTarget.TextureModded)
            {
                if (!Settings.DeveloperMode)
                {
                    M3L.ShowDialog(Window.GetWindow(this), M3L.GetString(M3L.string_dialogRestoringFilesWhileAlotIsInstalledNotAllowed), M3L.GetString(M3L.string_cannotRestoreSfarFiles), MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                else
                {
                    var res = M3L.ShowDialog(Window.GetWindow(this), M3L.GetString(M3L.string_dialogRestoringFilesWhileAlotIsInstalledNotAllowedDevMode), M3L.GetString(M3L.string_invalidTexturePointersWarning), MessageBoxButton.YesNo, MessageBoxImage.Warning);
                    restore = res == MessageBoxResult.Yes;
                }
            }
            else
            {
                restore = M3L.ShowDialog(Window.GetWindow(this), M3L.GetString(M3L.string_restoreAllModifiedFilesQuestion), M3L.GetString(M3L.string_confirmRestoration), MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes;
            }
            if (restore)
            {
                NamedBackgroundWorker nbw = new NamedBackgroundWorker(@"RestoreAllBasegameFilesThread");
                nbw.DoWork += (a, b) =>
                {
                    RestoreAllBasegameInProgress = true;
                    var restorableFiles = SelectedTarget.ModifiedBasegameFiles.Where(x => x.CanRestoreFile()).ToList();
                    //Set UI states
                    foreach (var v in restorableFiles)
                    {
                        v.Restoring = true;
                    }
                    //Restore files
                    foreach (var v in restorableFiles) //to list will make sure this doesn't throw concurrent modification
                    {
                        v.RestoreFile(true);
                    }
                };
                nbw.RunWorkerCompleted += (a, b) =>
                {
                    if (b.Error != null)
                    {
                        Log.Error($@"Exception occurred in {nbw.Name} thread: {b.Error.Message}");
                    }
                    RestoreAllBasegameInProgress = false;
                    if (SelectedTarget.Game == MEGame.ME3)
                    {
                        AutoTOC.RunTOCOnGameTarget(SelectedTarget);
                    }
                    CommandManager.InvalidateRequerySuggested();
                };
                nbw.RunWorkerAsync();
            }
        }
コード例 #9
0
        /// <summary>
        /// Begins inspection of archive file. This method will spawn a background thread that will
        /// run asynchronously.
        /// </summary>
        /// <param name="filepath">Path to the archive file</param>
        private void InspectArchiveFile(string filepath)
        {
            ScanningFile = Path.GetFileName(filepath);
            NamedBackgroundWorker nbw = new NamedBackgroundWorker(@"ModArchiveInspector");

            nbw.DoWork           += InspectArchiveBackgroundThread;
            ProgressValue         = 0;
            ProgressMaximum       = 100;
            ProgressIndeterminate = true;

            nbw.RunWorkerCompleted += (a, b) =>
            {
                if (b.Error != null)
                {
                    Log.Error($@"Exception occurred in {nbw.Name} thread: {b.Error.Message}");
                }
                if (CompressedMods.Count > 0)
                {
                    ActionText = M3L.GetString(M3L.string_selectModsToImportIntoModManagerLibrary);
                    if (CompressedMods.Count == 1)
                    {
                        CompressedMods_ListBox.SelectedIndex = 0; //Select the only item
                    }
                    ArchiveScanned = true;
                    TriggerPropertyChangedFor(nameof(CanCompressPackages));
                }
                else if (TextureFilesImported)
                {
                    CancelButtonText  = M3L.GetString(M3L.string_close);
                    NoModSelectedText = M3L.GetString(M3L.string_interp_dialogImportedALOTMainToTextureLibrary, ScanningFile, Utilities.GetALOTInstallerTextureLibraryDirectory());
                    ActionText        = M3L.GetString(M3L.string_importCompleted);
                }
                else
                {
                    ActionText = M3L.GetString(M3L.string_noCompatibleModsFoundInArchive);
                    if (filepath.EndsWith(@".exe"))
                    {
                        NoModSelectedText = M3L.GetString(M3L.string_executableModsMustBeValidatedByME3Tweaks);
                    }
                    else
                    {
                        NoModSelectedText = M3L.GetString(M3L.string_noCompatibleModsFoundInArchiveExtended);
                    }
                }

                ProgressValue         = 0;
                ProgressIndeterminate = false;
                TaskRunning           = false;
                CommandManager.InvalidateRequerySuggested();
            };
            ActionText = M3L.GetString(M3L.string_interp_scanningX, Path.GetFileName(filepath));

            nbw.RunWorkerAsync(filepath);
        }
コード例 #10
0
        public override void OnPanelVisible()
        {
            NamedBackgroundWorker bw = new NamedBackgroundWorker("telemetrydatagathering");

            bw.DoWork             += GatherTelemetryDataBGThread;
            bw.RunWorkerCompleted += (a, b) =>
            {
                List <TelemetryPackage> list = (List <TelemetryPackage>)b.Result;
                TelemetryPackages.ReplaceAll(list);
            };
            bw.RunWorkerAsync();
        }
コード例 #11
0
        private void BeginInstallingMod()
        {
            ModIsInstalling = true;
            Log.Information($@"BeginInstallingMod(): {ModBeingInstalled.ModName}");
            NamedBackgroundWorker bw = new NamedBackgroundWorker($@"ModInstaller-{ModBeingInstalled.ModName}");

            bw.WorkerReportsProgress = true;
            bw.DoWork             += InstallModBackgroundThread;
            bw.RunWorkerCompleted += ModInstallationCompleted;
            //bw.ProgressChanged += ModProgressChanged;
            bw.RunWorkerAsync();
        }
コード例 #12
0
        /// <summary>
        /// Begins inspection of archive file. This method will spawn a background thread that will
        /// run asynchronously.
        /// </summary>
        /// <param name="filepath">Path to the archive file</param>
        private void InspectArchiveFile(string filepath)
        {
            ScanningFile = Path.GetFileName(filepath);
            NamedBackgroundWorker bw = new NamedBackgroundWorker(@"ModArchiveInspector");

            bw.DoWork            += InspectArchiveBackgroundThread;
            ProgressValue         = 0;
            ProgressMaximum       = 100;
            ProgressIndeterminate = true;

            bw.RunWorkerCompleted += (a, b) =>
            {
                if (CompressedMods.Count > 0)
                {
                    ActionText = M3L.GetString(M3L.string_selectModsToImportIntoModManagerLibrary);
                    if (CompressedMods.Count == 1)
                    {
                        CompressedMods_ListBox.SelectedIndex = 0; //Select the only item
                    }
                    ArchiveScanned = true;

                    //Initial release disables this.
                    //TODO: RE-ENABLE THIS
                    CanCompressPackages = false && CompressedMods.Any() && CompressedMods.Any(x => x.Game == Mod.MEGame.ME3); //Change to include ME2 when support for LZO is improved
                }
                else if (TextureFilesImported)
                {
                    CancelButtonText  = M3L.GetString(M3L.string_close);
                    NoModSelectedText = $"{ScanningFile} has been imported to the ALOT Installer texture library, located at {Utilities.GetALOTInstallerTextureLibraryDirectory()}. Launch ALOT Installer to install the file. Once you install files with ALOT Installer, you will be unable to use Mod Manager to install further files into this installation without restoring the game. Ensure you install all non-texture mods BEFORE you use ALOT Installer.";
                    ActionText        = "Import completed";
                }
                else
                {
                    ActionText = M3L.GetString(M3L.string_noCompatibleModsFoundInArchive);
                    if (filepath.EndsWith(@".exe"))
                    {
                        NoModSelectedText = M3L.GetString(M3L.string_executableModsMustBeValidatedByME3Tweaks);
                    }
                    else
                    {
                        NoModSelectedText = M3L.GetString(M3L.string_noCompatibleModsFoundInArchiveExtended);
                    }
                }

                ProgressValue         = 0;
                ProgressIndeterminate = false;
                TaskRunning           = false;
                CommandManager.InvalidateRequerySuggested();
            };
            ActionText = M3L.GetString(M3L.string_interp_scanningX, Path.GetFileName(filepath));

            bw.RunWorkerAsync(filepath);
        }
コード例 #13
0
        /// <summary>
        /// Asynchronously endorses a file. This call does not wait for a result of the operation.
        /// </summary>
        /// <param name="gamedomain"></param>
        /// <param name="endorse"></param>
        /// <param name="fileid"></param>
        /// <param name="currentuserid"></param>
        public static void EndorseFile(string gamedomain, bool endorse, int fileid,
                                       Action <bool> newEndorsementStatusCallback = null)
        {
            if (NexusModsUtilities.UserInfo == null)
            {
                return;
            }
            NamedBackgroundWorker nbw = new NamedBackgroundWorker(@"EndorseMod");

            nbw.DoWork += (a, b) =>
            {
                var    client            = NexusModsUtilities.GetClient();
                string telemetryOverride = null;
                try
                {
                    if (endorse)
                    {
                        client.Mods.Endorse(gamedomain, fileid, @"1.0").Wait();
                    }
                    else
                    {
                        client.Mods.Unendorse(gamedomain, fileid, @"1.0").Wait();
                    }
                }
                catch (Exception e)
                {
                    Log.Error(@"Error endorsing/unendorsing: " + e.ToString());
                    telemetryOverride = e.ToString();
                }

                var newStatus = GetEndorsementStatusForFile(gamedomain, fileid).Result;

                Analytics.TrackEvent(@"Set endorsement for mod", new Dictionary <string, string>
                {
                    { @"Endorsed", endorse.ToString() },
                    { @"Succeeded", telemetryOverride ?? (endorse == newStatus).ToString() }
                });
                b.Result = newStatus;
            };
            nbw.RunWorkerCompleted += (a, b) =>
            {
                if (b.Error != null)
                {
                    Log.Error($@"Exception occurred in {nbw.Name} thread: {b.Error.Message}");
                }

                if (b.Result is bool val)
                {
                    newEndorsementStatusCallback?.Invoke(val);
                }
            };
            nbw.RunWorkerAsync();
        }
        public override void OnPanelVisible()
        {
            NamedBackgroundWorker nbw = new NamedBackgroundWorker(@"telemetrydatagathering");

            nbw.DoWork             += GatherTelemetryDataBGThread;
            nbw.RunWorkerCompleted += (a, b) =>
            {
                if (b.Error != null)
                {
                    Log.Error($@"Exception occurred in {nbw.Name} thread: {b.Error.Message}");
                }
                List <TelemetryPackage> list = (List <TelemetryPackage>)b.Result;
                TelemetryPackages.ReplaceAll(list);
            };
            nbw.RunWorkerAsync();
        }
コード例 #15
0
        private void CheckAuth(string pwOverride = null, Action <object> authCompletedCallback = null)
        {
            NamedBackgroundWorker nbw = new NamedBackgroundWorker(@"UpdaterServiceAuthCheck");

            nbw.DoWork += (a, b) =>
            {
                b.Result = false;
                string host     = @"ftp.me3tweaks.com";
                string username = Username;
                string password = pwOverride ?? Password_TextBox.Password;
                if (string.IsNullOrWhiteSpace(password))
                {
                    return;
                }

                using (SftpClient sftp = new SftpClient(host, username, password))
                {
                    string currentOp = @"Connecting";
                    try
                    {
                        sftp.Connect();
                        currentOp = M3L.GetString(M3L.string_checkingLZMAStorageDirectory);
                        sftp.ChangeDirectory(LZMAStoragePath.Trim());
                        currentOp = M3L.GetString(M3L.string_checkingManifestsStorageDirectory);
                        sftp.ChangeDirectory(ManifestStoragePath.Trim());
                        b.Result = true;
                    }
                    catch (Exception e)
                    {
                        Log.Information($@"Error logging in during operation '{currentOp}': " + e.Message);
                        b.Result = M3L.GetString(M3L.string_interp_errorValidatingSettingsXY, currentOp, e.Message);
                    }
                }
            };
            nbw.RunWorkerCompleted += (a, b) =>
            {
                if (b.Error != null)
                {
                    Log.Error($@"Exception occurred in {nbw.Name} thread: {b.Error.Message}");
                }
                Log.Information(@"Auth checked");
                OperationInProgress = false;
                authCompletedCallback?.Invoke(b.Result);
            };
            OperationInProgress = true;
            nbw.RunWorkerAsync();
        }
コード例 #16
0
            public void RestoreSFAR(bool batchRestore)
            {
                bool?restore = batchRestore;

                if (!restore.Value)
                {
                    restore = RestoreConfirmationCallback?.Invoke(FilePath);
                }
                if (restore.HasValue && restore.Value)
                {
                    //Todo: Background thread this maybe?
                    NamedBackgroundWorker bw = new NamedBackgroundWorker("RestoreSFARThread");
                    bw.DoWork += (a, b) =>
                    {
                        var backupFile = Path.Combine(Utilities.GetGameBackupPath(target.Game), FilePath);
                        var targetFile = Path.Combine(target.TargetPath, FilePath);
                        Restoring = true;
                        Log.Information("Restoring SFAR from backup: " + backupFile + " => " + targetFile);
                        XCopy.Copy(backupFile, targetFile, true, true, (o, pce) => { RestoreButtonContent = $"Restoring {pce.ProgressPercentage}%"; });
                        var unpackedFiles = Directory.GetFiles(DLCDirectory, "*", SearchOption.AllDirectories);
                        RestoreButtonContent = $"Cleaning up";
                        foreach (var file in unpackedFiles)
                        {
                            if (!file.EndsWith(".sfar"))
                            {
                                Log.Information("Deleting unpacked file: " + file);
                                File.Delete(file);
                            }
                        }
                        Utilities.DeleteEmptySubdirectories(DLCDirectory);
                        RestoreButtonContent = "Restored";
                    };
                    bw.RunWorkerCompleted += (a, b) =>
                    {
                        //File.Copy(backupFile, targetFile, true);
                        //if (!batchRestore)
                        //{
                        RevalidateIsModified();
                        //restoreCompletedCallback?.Invoke();
                        //}
                        Restoring = false;
                    };
                    startingRestoreCallback?.Invoke();
                    bw.RunWorkerAsync();
                }
            }
コード例 #17
0
        private void GetTopMods()
        {
            NamedBackgroundWorker nbw = new NamedBackgroundWorker(@"ModMaker-TopModsFetch");

            nbw.DoWork += (a, b) =>
            {
                b.Result = OnlineContent.FetchTopModMakerMods();
            };
            nbw.RunWorkerCompleted += (a, b) =>
            {
                if (b.Error == null && b.Result is List <OnlineContent.ServerModMakerModInfo> topMods)
                {
                    TopMods.ReplaceAll(topMods);
                }
            };
            nbw.RunWorkerAsync();
        }
コード例 #18
0
        /// <summary>
        /// Begins inspection of archive file. This method will spawn a background thread that will
        /// run asynchronously.
        /// </summary>
        /// <param name="filepath">Path to the archive file</param>
        private void InspectArchiveFile(string filepath)
        {
            ScanningFile = Path.GetFileName(filepath);
            NamedBackgroundWorker bw = new NamedBackgroundWorker(@"ModArchiveInspector");

            bw.DoWork            += InspectArchiveBackgroundThread;
            ProgressValue         = 0;
            ProgressMaximum       = 100;
            ProgressIndeterminate = true;

            bw.RunWorkerCompleted += (a, b) =>
            {
                if (CompressedMods.Count > 0)
                {
                    ActionText = M3L.GetString(M3L.string_selectModsToImportIntoModManagerLibrary);
                    if (CompressedMods.Count == 1)
                    {
                        CompressedMods_ListBox.SelectedIndex = 0; //Select the only item
                    }
                    ArchiveScanned = true;

                    //Initial release disables this.
                    CanCompressPackages = false && CompressedMods.Any() && CompressedMods.Any(x => x.Game == Mod.MEGame.ME3); //Change to include ME2 when support for LZO is improved
                }
                else
                {
                    ActionText = M3L.GetString(M3L.string_noCompatibleModsFoundInArchive);
                    if (filepath.EndsWith(@".exe"))
                    {
                        NoModSelectedText = M3L.GetString(M3L.string_executableModsMustBeValidatedByME3Tweaks);
                    }
                    else
                    {
                        NoModSelectedText = M3L.GetString(M3L.string_noCompatibleModsFoundInArchiveExtended);
                    }
                }

                ProgressValue         = 0;
                ProgressIndeterminate = false;
                TaskRunning           = false;
                CommandManager.InvalidateRequerySuggested();
            };
            ActionText = M3L.GetString(M3L.string_interp_scanningX, Path.GetFileName(filepath));

            bw.RunWorkerAsync(filepath);
        }
コード例 #19
0
        public override void OnPanelVisible()
        {
            NamedBackgroundWorker bw = new NamedBackgroundWorker(@"AutoTOC");

            bw.DoWork += (a, b) =>
            {
                if (mode == AutoTOCMode.MODE_GAMEWIDE)
                {
                    RunTOCOnGameTarget(gameWideModeTarget, x => Percent = x);
                }
            };
            bw.RunWorkerCompleted += (a, b) =>
            {
                OnClosing(DataEventArgs.Empty);
            };
            bw.RunWorkerAsync();
        }
コード例 #20
0
        private void RestoreAllBasegame()
        {
            bool restore = false;


            if (SelectedTarget.ALOTInstalled)
            {
                if (!Settings.DeveloperMode)
                {
                    M3L.ShowDialog(Window.GetWindow(this), M3L.GetString(M3L.string_dialogRestoringFilesWhileAlotIsInstalledNotAllowed), M3L.GetString(M3L.string_cannotRestoreSfarFiles), MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                else
                {
                    var res = M3L.ShowDialog(Window.GetWindow(this), M3L.GetString(M3L.string_dialogRestoringFilesWhileAlotIsInstalledNotAllowedDevMode), M3L.GetString(M3L.string_invalidTexturePointersWarning), MessageBoxButton.YesNo, MessageBoxImage.Warning);
                    restore = res == MessageBoxResult.Yes;
                }
            }
            else
            {
                restore = M3L.ShowDialog(Window.GetWindow(this), M3L.GetString(M3L.string_restoreAllModifiedFilesQuestion), M3L.GetString(M3L.string_confirmRestoration), MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes;
            }
            if (restore)
            {
                NamedBackgroundWorker bw = new NamedBackgroundWorker(@"RestoreAllBasegameFilesThread");
                bw.DoWork += (a, b) =>
                {
                    RestoreAllBasegameInProgress = true;
                    foreach (var v in SelectedTarget.ModifiedBasegameFiles)
                    {
                        v.Restoring = true;
                    }
                    foreach (var v in SelectedTarget.ModifiedBasegameFiles.ToList()) //to list will make sure this doesn't throw concurrent modification
                    {
                        v.RestoreFile(true);
                    }
                };
                bw.RunWorkerCompleted += (a, b) =>
                {
                    RestoreAllBasegameInProgress = false;
                    CommandManager.InvalidateRequerySuggested();
                };
                bw.RunWorkerAsync();
            }
        }
コード例 #21
0
        private void RestoreAllBasegame()
        {
            bool restore = false;


            if (SelectedTarget.ALOTInstalled)
            {
                if (!Settings.DeveloperMode)
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show(Window.GetWindow(this), $"Restoring files while ALOT is installed is not allowed, as it will introduce invalid texture pointers into the installation.", $"Cannot restore SFAR files", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                else
                {
                    var res = Xceed.Wpf.Toolkit.MessageBox.Show(Window.GetWindow(this), $"Restoring files while ALOT is installed will introduce invalid texture pointers into the installation, which will cause black textures and possibly cause the game to crash. Please ensure you know what you are doing before continuing.", $"Invalid texture pointers warning", MessageBoxButton.YesNo, MessageBoxImage.Warning);
                    restore = res == MessageBoxResult.Yes;
                }
            }
            else
            {
                restore = Xceed.Wpf.Toolkit.MessageBox.Show(Window.GetWindow(this), $"Restore all modified files?", $"Confirm restoration", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes;
            }
            if (restore)
            {
                NamedBackgroundWorker bw = new NamedBackgroundWorker("RestoreAllBasegameFilesThread");
                bw.DoWork += (a, b) =>
                {
                    RestoreAllBasegameInProgress = true;
                    foreach (var v in SelectedTarget.ModifiedBasegameFiles)
                    {
                        v.Restoring = true;
                    }
                    foreach (var v in SelectedTarget.ModifiedBasegameFiles.ToList()) //to list will make sure this doesn't throw concurrent modification
                    {
                        v.RestoreFile(true);
                    }
                };
                bw.RunWorkerCompleted += (a, b) =>
                {
                    RestoreAllBasegameInProgress = false;
                    CommandManager.InvalidateRequerySuggested();
                };
                bw.RunWorkerAsync();
            }
        }
コード例 #22
0
        /// <summary>
        /// Begins inspection of archive file. This method will spawn a background thread that will
        /// run asynchronously.
        /// </summary>
        /// <param name="filepath">Path to the archive file</param>
        private void InspectArchiveFile(string filepath)
        {
            ScanningFile = Path.GetFileName(filepath);
            NamedBackgroundWorker bw = new NamedBackgroundWorker("ModArchiveInspector");

            bw.DoWork            += InspectArchiveBackgroundThread;
            ProgressValue         = 0;
            ProgressMaximum       = 100;
            ProgressIndeterminate = true;

            bw.RunWorkerCompleted += (a, b) =>
            {
                if (CompressedMods.Count > 0)
                {
                    ActionText = $"Select mods to import into Mod Manager library";
                    if (CompressedMods.Count == 1)
                    {
                        CompressedMods_ListBox.SelectedIndex = 0; //Select the only item
                    }
                    ArchiveScanned = true;
                    //Initial release disables this.
                    CanCompressPackages = false && CompressedMods.Any() && CompressedMods.Any(x => x.Game == Mod.MEGame.ME3); //Change to include ME2 when support for LZO is improved
                }
                else
                {
                    ActionText = "No compatible mods found in archive";
                    if (filepath.EndsWith(".exe"))
                    {
                        NoModSelectedText = "Executable installer based mods must be validated by ME3Tweaks before they can be imported into M3. This is to prevent breaking third party mods.\n\nThis executable has not been validated. Check for a ME3Tweaks Mod Manager compatible version from the download page, or ask the developer to make a ME3Tweaks Mod Manager compatible version.";
                    }
                    else
                    {
                        NoModSelectedText = "No compatible mods found in archive. If this is a texture mod, you must install it with ALOT Installer. If this is a known Mod Manager mod, please come to the ME3Tweaks Discord from the Help menu.";
                    }
                }

                ProgressValue         = 0;
                ProgressIndeterminate = false;
                TaskRunning           = false;
                CommandManager.InvalidateRequerySuggested();
            };
            ActionText = $"Scanning {Path.GetFileName(filepath)}";

            bw.RunWorkerAsync(filepath);
        }
コード例 #23
0
        public override void OnPanelVisible()
        {
            NamedBackgroundWorker nbw = new NamedBackgroundWorker(@"PlotManagerUpdate");

            nbw.DoWork += (a, b) =>
            {
                RunPlotManagerUpdate(PlotManagerUpdateTarget);
            };
            nbw.RunWorkerCompleted += (a, b) =>
            {
                if (b.Error != null)
                {
                    Log.Error($@"Exception occurred in {nbw.Name} thread: {b.Error.Message}");
                }
                OnClosing(DataEventArgs.Empty);
            };
            nbw.RunWorkerAsync();
        }
コード例 #24
0
        public override void OnPanelVisible()
        {
            NamedBackgroundWorker nbw = new NamedBackgroundWorker(@"BackupFileFetcher-Load");

            nbw.DoWork += (a, b) =>
            {
                LoadME1FilesList();
                LoadME2FilesList();
                LoadME3FilesList();
            };
            nbw.RunWorkerCompleted += (a, b) =>
            {
                LoadingInProgress   = false;
                ME1FilesView.Filter = FilterBackupFilesME1;
                ME2FilesView.Filter = FilterBackupFilesME2;
                ME3FilesView.Filter = FilterBackupFilesME3;
            };
            nbw.RunWorkerAsync();
        }
コード例 #25
0
        public override void OnPanelVisible()
        {
            lastPercentUpdateTime = DateTime.Now;
            NamedBackgroundWorker bw = new NamedBackgroundWorker(@"DeploymentValidation");

            bw.DoWork += (a, b) =>
            {
                foreach (var checkItem in DeploymentChecklistItems)
                {
                    checkItem.ExecuteValidationFunction();
                }
            };
            bw.RunWorkerCompleted += (a, b) =>
            {
                PrecheckCompleted = true;
                CommandManager.InvalidateRequerySuggested();
            };
            bw.RunWorkerAsync();
        }
コード例 #26
0
        public override void OnPanelVisible()
        {
            NamedBackgroundWorker nbw = new NamedBackgroundWorker(@"RunAndDoneThread");

            nbw.DoWork += (a, b) =>
            {
                runAndDoneDelegate?.Invoke();
            };
            nbw.RunWorkerCompleted += (a, b) =>
            {
                if (b.Error != null)
                {
                    Log.Error($@"Exception occurred in {nbw.Name} thread: {b.Error.Message}");
                    Result.Error = b.Error;
                }
                OnClosing(DataEventArgs.Empty);
            };
            nbw.RunWorkerAsync();
        }
コード例 #27
0
        /// <summary>
        /// Starts preparing a mod by launching a background thread. This should be called from a UI thread
        /// </summary>
        private void StartPreparingModWrapper()
        {
            NamedBackgroundWorker nbw = new NamedBackgroundWorker(@"UpdaterServiceUpload");

            nbw.DoWork += (a, b) =>
            {
                OperationInProgress = true;
                b.Result            = UploadMod();
            };
            nbw.RunWorkerCompleted += (a, b) =>
            {
                Analytics.TrackEvent("Uploaded mod to updater service", new Dictionary <string, string>()
                {
                    { @"Result", b.Result?.ToString() },
                    { @"Mod", mod.ModName + @" " + mod.ModVersionString }
                });
                OperationInProgress = false;
            };
            nbw.RunWorkerAsync();
        }
コード例 #28
0
 private void InternalInstallME3Keybinds()
 {
     KeybindsInstallingME3 = true;
     NamedBackgroundWorker nbw = new NamedBackgroundWorker(@"ME3KeybindsInstaller");
     nbw.DoWork += (await, b) =>
     {
         var xmlText = File.ReadAllText(SelectedME3Keybinds.filepath);
         InstallME3Keybinds(xmlText, SelectedME3Target);
     };
     nbw.RunWorkerCompleted += (a, b) =>
     {
         if (b.Error != null)
         {
             Log.Error(@"Error setting ME3 keybinds: " + b.Error.Message);
         }
         KeybindsInstallingME3 = false;
         CommandManager.InvalidateRequerySuggested();
     };
     nbw.RunWorkerAsync();
 }
コード例 #29
0
        public override void OnPanelVisible()
        {
            NamedBackgroundWorker bw = new NamedBackgroundWorker("AutoTOC");

            bw.DoWork += (a, b) =>
            {
                if (mode == AutoTOCMode.MODE_GAMEWIDE)
                {
                    RunGameWideAutoTOC();
                }
                else if (mode == AutoTOCMode.MODE_MOD)
                {
                    RunModAutoTOC();
                }
            };
            bw.RunWorkerCompleted += (a, b) =>
            {
                OnClosing(DataEventArgs.Empty);
            };
            bw.RunWorkerAsync();
        }
コード例 #30
0
        public override void OnPanelVisible()
        {
            NamedBackgroundWorker nbw = new NamedBackgroundWorker(@"AutoTOC");

            nbw.DoWork += (a, b) =>
            {
                if (mode == AutoTOCMode.MODE_GAMEWIDE)
                {
                    RunTOCOnGameTarget(gameWideModeTarget, x => Percent = x);
                }
            };
            nbw.RunWorkerCompleted += (a, b) =>
            {
                if (b.Error != null)
                {
                    Log.Error($@"Exception occurred in {nbw.Name} thread: {b.Error.Message}");
                }
                OnClosing(DataEventArgs.Empty);
            };
            nbw.RunWorkerAsync();
        }