示例#1
0
 public static Task<UiArchives> BuildAsync(GameLocationInfo gameLocation)
 {
     return Task.Run(() =>
     {
         UiArchiveTreeBuilder builder = new UiArchiveTreeBuilder(gameLocation);
         return builder.Build();
     });
 }
        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();
        }
示例#3
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();
            }
        }