Пример #1
0
        private async Task <bool> InitializePlugins()
        {
            if (!Settings.ValidateAll())
            {
                return(false);
            }

            await Async.Run(() =>
            {
                IoC.Notif.ShowStatus("Removing old version...");
                //remove failed / old patches
                Compatibility.CleanupOldVersions();
                FileBackup.CleanupBackups(Configs.PatchPath);
            });

            IoC.Notif.ShowStatus("Initializing Plugins...");
            foreach (var module in Plugins)
            {
                await module.Initialize();
            }

            _initialized = true;

            if (File.Exists(Configs.PatchPath))
            {
                await LoadExistingPack(Configs.PatchPath, true);
            }

            return(true);
        }
Пример #2
0
        public static void CleanupOldVersions()
        {
            foreach (var fileName in IoC.Config.OldVersionsToDelete)
            {
                var path = Path.Combine(Configs.GamePackDir, fileName);

                FileBackup.CleanupBackups(path);
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
            }
        }
Пример #3
0
        private bool CreatePatch()
        {
            //remove failed patches
            FileBackup.CleanupBackups(Configs.PatchPath);

            using (var oldPatch = new FileBackup(Configs.PatchPath))
            {
                var patcher = new Patcher();

                var patch = patcher.StartPatch();
                foreach (var module in Plugins)
                {
                    IoC.Notif.ShowStatus($"Generating patch ({module.PluginName})...");
                    module.ApplyChanges(patch);
                }

                IoC.Notif.ShowStatus("Generating plugin patches...");
                patcher.ApplyCustomPatches(patch, PluginManager);

                IoC.Notif.ShowStatus("Generating patch (rebuild prefetch)...");

                var p = Prefetch.Load(patch);
                if (p.Rebuild(patch))
                {
                    p.Save();
                }

                if (!Directory.Exists(patch.WorkingDir))
                {
                    IoC.Notif.ShowStatus("No changes found, aborting pack creation.");

                    return(false);
                }

                IoC.Notif.ShowStatus("Generating patch (packing)...");
                patcher.PackPatch(patch);

                IoC.Notif.ShowStatus("Copying patch...");
                patcher.InstallPatch(patch);

                oldPatch.Delete();

#if !DEBUG
                Paths.Cleanup(IoC.Config.TempPath);
#endif
            }

            return(true);
        }