Exemple #1
0
        public void Import(string path, bool copyMods, IProgress <int> progress)
        {
            if (CanImport(path) != ImportStatus.CAN_IMPORT)
            {
                return;
            }

            int            basePercent     = 0;
            Progress <int> partialProgress = new Progress <int>(percent =>
            {
                progress.Report(basePercent + percent / 3);
            });

            string gameVersion = Helpers.GetGameVersion(path);
            string xmlFilename = gameVersion.Replace(".", "_") + ".xml";
            string xml         = Path.Combine(Settings.Default.VersionDataDirectory, xmlFilename);
            string output      = Path.Combine(Settings.Default.GameOutputDirectory, "World of Tanks " + gameVersion);

            CreateVersionXML(path, xml, partialProgress);
            basePercent = 33;
            _gds.ExtractToContainer(xml, path, partialProgress);
            basePercent = 66;
            _gds.CreateGameDirectory(xml, output, partialProgress);

            if (copyMods)
            {
                CopyDirectory("mods", path, output);
                CopyDirectory("res_mods", path, output);
            }
            progress.Report(100);

            System.Windows.Application.Current.Dispatcher.BeginInvoke((Action) delegate()
            {
                _mvs.Add(xml, output);
            });
        }
Exemple #2
0
        public void Import(string path, bool copyMods, IProgress <int> progress)
        {
            ImportStatus status = CanImport(path);

            if (status == ImportStatus.INVALID_PATH)
            {
                return;
            }

            if (status == ImportStatus.ALREADY_EXISTS)
            {
                // Check if user attempted to import from managed directory
                bool isTargetDirectoryManaged = _mvs.GetManagedVersions().Select(v => Path.GetFullPath(v.Path)).Contains(Path.GetFullPath(path));
                if (isTargetDirectoryManaged)
                {
                    return;
                }
            }

            int            basePercent     = 0;
            Progress <int> partialProgress = new Progress <int>(percent =>
            {
                progress.Report(basePercent + percent / 3);
            });

            string gameVersion = Helpers.GetGameVersion(path);
            string xmlFilename = gameVersion.Replace(".", "_") + ".xml";
            string xml         = Path.Combine(Settings.Default.VersionDataDirectory, xmlFilename);
            string output      = Path.Combine(Settings.Default.GameOutputDirectory, "World of Tanks " + gameVersion);

            if (status == ImportStatus.CAN_IMPORT)
            {
                // Import new version
                CreateVersionXML(path, xml, partialProgress);
                basePercent = 33;
                _gds.ExtractToContainer(xml, path, partialProgress);
                basePercent = 66;
                _gds.CreateGameDirectory(xml, output, partialProgress);
            }
            else if (status == ImportStatus.ALREADY_EXISTS)
            {
                // Update version
                RootDirectoryEntity newBuild = Helpers.CreateRootEntityFromDirectory(path, true, partialProgress);
                basePercent = 33;
                _gds.ExtractToContainer(newBuild, path, partialProgress);
                basePercent = 66;
                _gds.UpdateGameDirectory(newBuild, output, partialProgress);
                new RootDirectoryEntityIO().Serialize(newBuild, xml);
            }


            if (copyMods)
            {
                CopyDirectory("mods", path, output);
                CopyDirectory("res_mods", path, output);
            }
            progress.Report(100);

            if (status == ImportStatus.CAN_IMPORT)
            {
                System.Windows.Application.Current.Dispatcher.BeginInvoke((Action) delegate()
                {
                    _mvs.Add(xml, output);
                });
            }
        }