Example #1
0
        public OptionsWindow(InstallConfiguration installConfiguration)
        {
            InitializeComponent();

            _ViewModel  = new OptionsWindowViewModel(installConfiguration);
            DataContext = _ViewModel;
        }
Example #2
0
        public ArksLayerInstallConfiguration(InstallConfiguration configuration)
        {
            App.Logger.Info(nameof(ArksLayerInstallConfiguration), "Creating ArksLayer install configuration");

            PluginsDirectory         = Path.Combine(configuration.PSO2BinDirectory, "plugins/");
            PluginsDisabledDirectory = Path.Combine(PluginsDirectory, "disabled/");

            PatchesDirectory = Path.Combine(configuration.PSO2BinDirectory, "patches/");

            TweakerBin  = Path.Combine(configuration.PSO2BinDirectory, "tweaker.bin");
            VersionFile = Path.Combine(configuration.PSO2BinDirectory, "version.ver");

            DDrawDll = Path.Combine(configuration.PSO2BinDirectory, "ddraw.dll");
            PSO2hDll = Path.Combine(configuration.PSO2BinDirectory, "pso2h.dll");

            PluginPSO2BlockRenameDll     = Path.Combine(PluginsDirectory, "PSO2BlockRename.dll");
            PluginPSO2ItemTranslatorDll  = Path.Combine(PluginsDirectory, "PSO2ItemTranslator.dll");
            PluginPSO2TitleTranslatorDll = Path.Combine(PluginsDirectory, "PSO2TitleTranslator.dll");
            PluginPSO2RAISERSystemDll    = Path.Combine(PluginsDirectory, "PSO2RAISERSystem.dll");
            PluginTelepipeProxyDll       = Path.Combine(PluginsDirectory, "TelepipeProxy.dll");

            EnglishBlockPatch = Path.Combine(PatchesDirectory, "translation_blocks.bin");
            EnglishItemPatch  = Path.Combine(PatchesDirectory, "translation_items.bin");
            EnglishTextPatch  = Path.Combine(PatchesDirectory, "patch.tar");
            EnglishTitlePatch = Path.Combine(PatchesDirectory, "translation_titles.bin");

            TelepipeProxyConfig    = Path.Combine(configuration.PSO2BinDirectory, "proxy.txt");
            TelepipeProxyPublicKey = Path.Combine(configuration.PSO2BinDirectory, "publickey.blob");
        }
Example #3
0
 public VerifyFilesPhase(InstallConfiguration installConfiguration)
 {
     _InstallConfiguration = installConfiguration;
 }
Example #4
0
 public TelepipeProxyPhase(InstallConfiguration installConfiguration, bool enabled)
 {
     _InstallConfiguration = installConfiguration;
     _Enabled = enabled;
 }
Example #5
0
 public ComparePhase(InstallConfiguration installConfiguration)
 {
     _InstallConfiguration = installConfiguration;
 }
 public PSO2DirectoriesPhase(InstallConfiguration installConfiguration)
 {
     _InstallConfiguration = installConfiguration;
 }
        //

        public MainWindowViewModel(string pso2BinDirectory)
        {
            InstallConfiguration = new InstallConfiguration(pso2BinDirectory);
        }
Example #8
0
 public EnglishPatchPhase(InstallConfiguration installConfiguration, bool enabled)
 {
     _InstallConfiguration = installConfiguration;
     _Enabled = enabled;
 }
Example #9
0
        //

        public MainWindowViewModel(string pso2BinDirectory, UpdateChecker.UpdateInformation updateInformation)
        {
            InstallConfiguration      = new InstallConfiguration(pso2BinDirectory);
            UpdatedVersionInformation = updateInformation;
        }
Example #10
0
 public LargeAddressAwarePhase(InstallConfiguration installConfiguration)
 {
     _InstallConfiguration = installConfiguration;
 }
Example #11
0
 public ModFilesPhase(InstallConfiguration installConfiguration)
 {
     _InstallConfiguration = installConfiguration;
 }
Example #12
0
 public PSO2hPhase(InstallConfiguration installConfiguration, bool enabled)
 {
     _InstallConfiguration = installConfiguration;
     _Enabled = enabled;
 }
 public DeleteCensorFilePhase(InstallConfiguration installConfiguration)
 {
     _InstallConfiguration = installConfiguration;
 }
Example #14
0
        public OptionsWindowViewModel(InstallConfiguration installConfiguration)
        {
            _InstallConfiguration = installConfiguration;

            PatchCacheExists = File.Exists(_InstallConfiguration.PatchCacheDatabase);
        }
Example #15
0
            public async Task ValidateAsync(InstallConfiguration installConfiguration, CancellationToken ct = default)
            {
                async Task ValidateFileAsync(string relativePath, string hash, string url)
                {
                    var path = Path.Combine(installConfiguration.PSO2BinDirectory, relativePath);

                    if (File.Exists(path))
                    {
                        using (var md5 = MD5.Create())
                            using (var fs = File.OpenRead(path))
                            {
                                var hashBytes  = md5.ComputeHash(fs);
                                var hashString = string.Concat(hashBytes.Select(b => b.ToString("X2", CultureInfo.InvariantCulture)));
                                if (hashString == Hash)
                                {
                                    return;
                                }
                            }
                    }

                    App.Logger.Info(nameof(PluginInfo), $"Downloading plugin file english data: \"{relativePath}\"");
                    using (var client = new ArksLayerHttpClient())
                        using (var response = await client.GetAsync(url, ct))
                        {
                            App.Logger.Info(nameof(PluginInfo), $"Download plugin file english data status code: {response.StatusCode}");
                            response.EnsureSuccessStatusCode();

                            App.Logger.Info(nameof(PluginInfo), $"Reading plugin data: \"{relativePath}\"");
                            using (var ns = await response.Content.ReadAsStreamAsync())
                            {
                                if (Path.GetExtension(new Uri(url).LocalPath).ToLowerInvariant() != ".rar")
                                {
                                    App.Logger.Info(nameof(PluginInfo), $"Writing file: \"{relativePath}\"");
                                    using (var fs = File.Create(path, 4096, FileOptions.Asynchronous))
                                        await ns.CopyToAsync(fs);
                                    return;
                                }

                                App.Logger.Info(nameof(PluginInfo), $"Extracting archive file: \"{relativePath}\"");
                                // when the file is an archive we hash against the file named the same
                                using (var archive = RarArchive.Open(ns))
                                {
                                    var fileEntries = archive.Entries.Where(e => !e.IsDirectory).ToArray();

                                    if (fileEntries.Length == 0)
                                    {
                                        var entryNames = fileEntries.Select(e => e.Key).ToArray();
                                        throw new Exception($"Expected more than one file in archive");
                                    }

                                    if (fileEntries.Length == 1)
                                    {
                                        using (var fs = File.Create(path, 4096, FileOptions.Asynchronous))
                                            using (var es = fileEntries.First().OpenEntryStream())
                                                await es.CopyToAsync(fs);
                                        return;
                                    }

                                    App.Logger.Info(nameof(PluginInfo), "Multiple entries present in archive");

                                    var primaryEntry = fileEntries.First(e => e.Key.ToLowerInvariant() == Path.GetFileName(path).ToLowerInvariant());
                                    var otherEntries = fileEntries.Where(e => e != primaryEntry).ToArray();

                                    using (var fs = File.Create(path, 4096, FileOptions.Asynchronous))
                                        using (var es = primaryEntry.OpenEntryStream())
                                            await es.CopyToAsync(fs);

                                    foreach (var entry in otherEntries)
                                    {
                                        var directory = Path.GetDirectoryName(path);
                                        var otherPath = Path.Combine(directory, entry.Key);

                                        using (var fs = File.Create(otherPath, 4096, FileOptions.Asynchronous))
                                            using (var es = entry.OpenEntryStream())
                                                await es.CopyToAsync(fs);
                                    }
                                }
                            }
                        }
                }

                App.Logger.Info(nameof(PluginInfo), $"Validating plugin file: \"{FilePath}\"");
                await Task.Run(async() => await ValidateFileAsync(FilePath, Hash, Url));

                if (EnglishData != null)
                {
                    App.Logger.Info(nameof(PluginInfo), $"Validating plugin file english data: \"{EnglishData.FilePath}\"");
                    await Task.Run(async() => await ValidateFileAsync(EnglishData.FilePath, EnglishData.Hash, EnglishData.Url));
                }
            }