示例#1
0
        public static GameLocationInfo GetGameLocation(FFXIIIGamePart gamePart)
        {
            try
            {
                using (RegistryKey localMachine = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
                using (RegistryKey registryKey = localMachine.OpenSubKey(GetSteamRegistyPath(gamePart)))
                {
                    if (registryKey == null)
                        throw Exceptions.CreateException("Запись в реестре не обнаружена.");

                    GameLocationInfo result = new GameLocationInfo((string)registryKey.GetValue(GameLocationSteamRegistryProvider.SteamGamePathTag));
                    result.Validate();

                    return result;
                }
            }
            catch
            {
                return Application.Current.Dispatcher.Invoke(() =>
                {
                    using (CommonOpenFileDialog dlg = new CommonOpenFileDialog(String.Format("Укажите каталог Final Fantasy XIII-{0}...", (int)gamePart)))
                    {
                        dlg.IsFolderPicker = true;
                        if (dlg.ShowDialog() != CommonFileDialogResult.Ok)
                            throw new OperationCanceledException();

                        GameLocationInfo result = new GameLocationInfo(dlg.FileName);
                        result.Validate();

                        return result;
                    }
                });
            }
        }
示例#2
0
 public static Task<UiArchives> BuildAsync(GameLocationInfo gameLocation)
 {
     return Task.Run(() =>
     {
         UiArchiveTreeBuilder builder = new UiArchiveTreeBuilder(gameLocation);
         return builder.Build();
     });
 }
示例#3
0
        private async Task RefreshContent(GameLocationInfo obj)
        {
            try
            {
                if (CheckAccess())
                {
                    _treeNodes            = await obj.ArchivesTree;
                    _treeView.ItemsSource = _treeNodes;

                    SelectNode();

                    IsEnabled = true;
                }
                else
                {
                    await Dispatcher.Invoke(async() => await RefreshContent(obj));
                }
            }
            catch (Exception ex)
            {
                ClearContent();
                UiHelper.ShowError(this, ex);
            }
        }
        private async Task RefreshContent(GameLocationInfo obj)
        {
            try
            {
                if (CheckAccess())
                {
                    _treeNodes = await InteractionService.GameLocation.Provide().ArchivesTree;
                    _treeView.ItemsSource = _treeNodes;

                    SelectNode();

                    IsEnabled = true;
                }
                else
                {
                    await Dispatcher.Invoke(async () => await RefreshContent(obj));
                }
            }
            catch (Exception ex)
            {
                ClearContent();
                UiHelper.ShowError(this, ex);
            }
        }
示例#5
0
 public UiArchiveTreeBuilder(GameLocationInfo gameLocation)
 {
     _gameLocation = gameLocation;
 }
示例#6
0
 public UiArchiveTreeBuilder(GameLocationInfo gameLocation)
 {
     _gameLocation = gameLocation;
 }
        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();
        }
示例#8
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();
            }
        }