Ejemplo n.º 1
0
        public void Inject(UiInjectionManager manager)
        {
            if (_leafs.Length == 0)
                return;

            String root = _source.ProvideRootDirectory();

            foreach (ArchiveEntry entry in _leafs)
            {
                String sourcePath = Path.Combine(root, PathEx.ChangeMultiDotExtension(entry.Name, null));
                String directoryPath = Path.GetDirectoryName(sourcePath);

                if (entry.Name.EndsWith(".ztr"))
                {
                    if (_source.TryProvideStrings() == null && !_source.DirectoryIsExists(directoryPath))
                        continue;
                }
                else if (!_source.DirectoryIsExists(directoryPath))
                    continue;

                Inject(entry, sourcePath);
            }

            if (_injected)
                manager.Enqueue(_listing);
        }
        public void Execute(object parameter)
        {
            try
            {
                UiArchives archives = _archivesProvider();
                if (archives == null)
                    return;

                UiGameFileCommanderSettingsWindow settingsDlg = new UiGameFileCommanderSettingsWindow(false);
                if (settingsDlg.ShowDialog() != true)
                    return;

                Stopwatch sw = new Stopwatch();
                sw.Start();

                Wildcard wildcard = new Wildcard(settingsDlg.Wildcard, false);
                bool? compression = settingsDlg.Compression;
                bool? conversion = settingsDlg.Convert;

                UiInjectionManager manager = new UiInjectionManager();
                FileSystemInjectionSource source = new FileSystemInjectionSource();
                foreach (IUiLeafsAccessor accessor in archives.AccessToCheckedLeafs(wildcard, conversion, compression))
                    accessor.Inject(source, manager);
                manager.WriteListings();

                if (sw.ElapsedMilliseconds / 1000 > 2)
                    MessageBox.Show(String.Format("Упаковка завершена за {0}.", sw.Elapsed.ToString(@"d\.hh\:mm\:ss")), "Готово!", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 3
0
        private void Inject(WpdArchiveListing listing, WpdEntry[] fontEntries, WflContent[] fontContent)
        {
            UiInjectionManager manager = new UiInjectionManager();

            using (MemoryInjectionSource source = new MemoryInjectionSource())
            {
                String injectionRoot = Path.Combine(source.ProvideRootDirectory(), listing.ExtractionSubpath);
                for (int i = 0; i < fontEntries.Length; i++)
                {
                    WpdEntry   entry         = fontEntries[i];
                    WflContent content       = fontContent[i];
                    String     injectionPath = Path.Combine(injectionRoot, entry.Name);

                    MemoryStream stream = new MemoryStream(1024);
                    source.RegisterStream(injectionPath, stream);

                    WflFileWriter writer = new WflFileWriter(stream);
                    writer.Write(content);
                    stream.SetPosition(0);
                }

                UiWpdInjector injector = new UiWpdInjector(listing, fontEntries, false, source);
                injector.Inject(manager);
            }
            manager.WriteListings();
        }
Ejemplo n.º 4
0
        public void Inject(UiInjectionManager manager)
        {
            if (_leafs.Length == 0)
            {
                return;
            }

            String root = _source.ProvideRootDirectory();

            foreach (ArchiveEntry entry in _leafs)
            {
                String sourcePath    = Path.Combine(root, PathEx.ChangeMultiDotExtension(entry.Name, null));
                String directoryPath = Path.GetDirectoryName(sourcePath);

                if (entry.Name.EndsWith(".ztr"))
                {
                    if (_source.TryProvideStrings() == null && !_source.DirectoryIsExists(directoryPath))
                    {
                        continue;
                    }
                }
                else if (!_source.DirectoryIsExists(directoryPath))
                {
                    continue;
                }

                Inject(entry, sourcePath);
            }

            if (_injected)
            {
                manager.Enqueue(_listing);
            }
        }
Ejemplo n.º 5
0
        public static void InjectSingle(WpdArchiveListing listing, WpdEntry entry, MemoryStream output)
        {
            using (MemoryInjectionSource source = new MemoryInjectionSource())
            {
                source.RegisterStream(String.Empty, output);
                UiWpdInjector injector = new UiWpdInjector(listing, new[] {entry}, false, source);

                UiInjectionManager manager = new UiInjectionManager();
                injector.Inject(manager);
                manager.WriteListings();
            }
        }
Ejemplo n.º 6
0
        public static void InjectSingle(WpdArchiveListing listing, WpdEntry entry, MemoryStream output)
        {
            using (MemoryInjectionSource source = new MemoryInjectionSource())
            {
                source.RegisterStream(String.Empty, output);
                UiWpdInjector injector = new UiWpdInjector(listing, new[] { entry }, false, source);

                UiInjectionManager manager = new UiInjectionManager();
                injector.Inject(manager);
                manager.WriteListings();
            }
        }
Ejemplo n.º 7
0
        public void Inject(UiInjectionManager manager)
        {
            if (_leafs.Length == 0)
            {
                return;
            }

            String root            = _source.ProvideRootDirectory();
            String targetDirectory = Path.Combine(root, _listing.ExtractionSubpath);

            if (!_source.DirectoryIsExists(targetDirectory))
            {
                return;
            }

            foreach (WpdEntry entry  in _leafs)
            {
                String targetPath = Path.Combine(targetDirectory, entry.NameWithoutExtension);
                Inject(entry, targetPath);
            }

            if (_injected)
            {
                List <ArchiveEntry>   entries      = new List <ArchiveEntry>(2);
                MemoryInjectionSource memorySource = new MemoryInjectionSource();
                if (_headers.IsValueCreated)
                {
                    ArchiveEntry entry = _listing.Accessor.HeadersEntry;
                    entries.Add(entry);
                    memorySource.RegisterStream(entry.Name, _headers.Value);
                }
                if (_content.IsValueCreated)
                {
                    ArchiveEntry entry = _listing.Accessor.ContentEntry;
                    entries.Add(entry);
                    memorySource.RegisterStream(entry.Name, _content.Value);
                }

                using (UiArchiveInjector injector = new UiArchiveInjector(_listing.Accessor.Parent, entries.ToArray(), _conversion, false, memorySource))
                    injector.Inject(manager);

                manager.Enqueue(_listing.Accessor.Parent);
            }
        }
        public void Execute(object parameter)
        {
            try
            {
                UiArchives archives = _archivesProvider();
                if (archives == null)
                {
                    return;
                }

                UiGameFileCommanderSettingsWindow settingsDlg = new UiGameFileCommanderSettingsWindow(false);
                if (settingsDlg.ShowDialog() != true)
                {
                    return;
                }

                Stopwatch sw = new Stopwatch();
                sw.Start();

                Wildcard wildcard    = new Wildcard(settingsDlg.Wildcard, false);
                bool?    compression = settingsDlg.Compression;
                bool?    conversion  = settingsDlg.Convert;

                UiInjectionManager        manager = new UiInjectionManager();
                FileSystemInjectionSource source  = new FileSystemInjectionSource();
                foreach (IUiLeafsAccessor accessor in archives.AccessToCheckedLeafs(wildcard, conversion, compression))
                {
                    accessor.Inject(source, manager);
                }
                manager.WriteListings();

                if (sw.ElapsedMilliseconds / 1000 > 2)
                {
                    MessageBox.Show(String.Format(Lang.Message.Done.InjectionCompleteFormat, sw.Elapsed), Lang.Message.Done.Title, MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), Lang.Message.Error.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 9
0
        public void Inject(UiInjectionManager manager)
        {
            if (_leafs.Length == 0)
                return;

            String root = _source.ProvideRootDirectory();
            String targetDirectory = Path.Combine(root, _listing.ExtractionSubpath);
            if (!_source.DirectoryIsExists(targetDirectory))
                return;

            foreach (WpdEntry entry  in _leafs)
            {
                String targetPath = Path.Combine(targetDirectory, entry.NameWithoutExtension);
                Inject(entry, targetPath);
            }

            if (_injected)
            {
                List<ArchiveEntry> entries = new List<ArchiveEntry>(2);
                MemoryInjectionSource memorySource = new MemoryInjectionSource();
                if (_headers.IsValueCreated)
                {
                    ArchiveEntry entry = _listing.Accessor.HeadersEntry;
                    entries.Add(entry);
                    memorySource.RegisterStream(entry.Name, _headers.Value);
                }
                if (_content.IsValueCreated)
                {
                    ArchiveEntry entry = _listing.Accessor.ContentEntry;
                    entries.Add(entry);
                    memorySource.RegisterStream(entry.Name, _content.Value);
                }

                using (UiArchiveInjector injector = new UiArchiveInjector(_listing.Accessor.Parent, entries.ToArray(), _conversion, false, memorySource))
                    injector.Inject(manager);

                manager.Enqueue(_listing.Accessor.Parent);
            }
        }
Ejemplo n.º 10
0
 public void Inject(IUiInjectionSource source, UiInjectionManager manager)
 {
     using (UiWpdInjector injector = new UiWpdInjector(_listing, _leafs, _conversion, source))
         injector.Inject(manager);
 }
Ejemplo n.º 11
0
 public void Inject(IUiInjectionSource source, UiInjectionManager manager)
 {
     using (UiArchiveInjector injector = new UiArchiveInjector(_listing, _leafs, _conversion, _compression, source))
         injector.Inject(manager);
 }
Ejemplo n.º 12
0
        private void Patch(DirectoryInfo translationDir, GameLocationInfo gameLocation)
        {
            if (CancelEvent.IsSet())
                return;

            Dictionary<string, string> dic = ReadStrings(translationDir);
            if (CancelEvent.IsSet())
                return;

            FileSystemInjectionSource source = new FileSystemInjectionSource();
            source.RegisterStrings(dic);

            UiArchiveTreeBuilder builder = new UiArchiveTreeBuilder(gameLocation);
            UiArchives archives = builder.Build();
            Position = 0;
            Maximum = archives.Count;
            foreach (UiContainerNode archive in archives)
            {
                Check(archive);
                OnProgress(1);
            }

            if (CancelEvent.IsSet())
                return;

            IUiLeafsAccessor[] accessors = archives.AccessToCheckedLeafs(new Wildcard("*"), null, false).ToArray();
            Position = 0;
            Maximum = accessors.Length;

            UiInjectionManager manager = new UiInjectionManager();
            foreach (IUiLeafsAccessor accessor in accessors)
            {
                accessor.Inject(source, manager);
                OnProgress(1);
            }

            manager.WriteListings();
        }
Ejemplo n.º 13
0
        private void Patch(BinaryReader br, GameLocationInfo gameLocation)
        {
            if (CancelEvent.IsSet())
                return;

            FFXIIITextEncoding encoding = ReadEncoding(br);
            TextEncodingInfo encodingInfo = new TextEncodingInfo(encoding);
            InteractionService.TextEncoding.SetValue(encodingInfo);
            if (CancelEvent.IsSet())
                return;

            Dictionary<string, string> dic = ReadStrings(br);
            dic["$title_newgame"] = _userName;
            if (CancelEvent.IsSet())
                return;

            using (DisposableStack disposables = new DisposableStack())
            {
                MemoryInjectionSource source = disposables.Add(new MemoryInjectionSource());
                source.RegisterStrings(dic);
                if (CancelEvent.IsSet())
                    return;

                int count = br.ReadInt32();
                OnProgress(4);

                for (int i = 0; i < count; i++)
                {
                    long position = br.BaseStream.Position;
                    ImgbPatchData imgb = disposables.Add(ImgbPatchData.ReadFrom(br));
                    foreach (KeyValuePair<string, SafeUnmanagedArray> data in imgb)
                        source.RegisterStream(Path.Combine(imgb.XgrArchiveUnpackName, data.Key), data.Value.OpenStream(FileAccess.Read));
                    OnProgress(br.BaseStream.Position - position);
                    if (CancelEvent.IsSet())
                        return;
                }

                UiArchiveTreeBuilder builder = new UiArchiveTreeBuilder(gameLocation);
                UiArchives archives = builder.Build();
                Position = 0;
                Maximum = archives.Count;
                foreach (UiContainerNode archive in archives)
                {
                    Check(archive);
                    OnProgress(1);
                }

                if (CancelEvent.IsSet())
                    return;

                IUiLeafsAccessor[] accessors = archives.AccessToCheckedLeafs(new Wildcard("*"), null, false).ToArray();
                Position = 0;
                Maximum = accessors.Length;

                UiInjectionManager manager = new UiInjectionManager();
                foreach (IUiLeafsAccessor accessor in accessors)
                {
                    accessor.Inject(source, manager);
                    OnProgress(1);
                }
                manager.WriteListings();
            }
        }
Ejemplo n.º 14
0
 public void Inject(IUiInjectionSource source, UiInjectionManager manager)
 {
     throw new NotImplementedException();
     //using (UiWpdInjector injector = new UiWpdInjector(_listing, _leafs, _conversion, source))
     //    injector.Inject(manager);
 }
Ejemplo n.º 15
0
 public void Inject(IUiInjectionSource source, UiInjectionManager manager)
 {
     throw new NotImplementedException();
     //using (UiWpdInjector injector = new UiWpdInjector(_listing, _leafs, _conversion, source))
     //    injector.Inject(manager);
 }