Exemple #1
0
        internal async void ReloadAddons()
        {
            if (_addons == null)
            {
                _addons = new ObservableCollection <IAddon>();
            }

            _addons.Clear();

            var armaPath = Settings.Default.ArmaPath;

            await ReloadAddonsAsync(armaPath, true);
            await
            ReloadAddonsAsync(
                Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments,
                                          Environment.SpecialFolderOption.DoNotVerify) +
                Path.DirectorySeparatorChar + "Arma 3" + Path.DirectorySeparatorChar, true);

            await
            ReloadAddonsAsync(
                Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments,
                                          Environment.SpecialFolderOption.DoNotVerify) + Path.DirectorySeparatorChar + @"ArmaBrowser" +
                Path.DirectorySeparatorChar + "Arma 3" + Path.DirectorySeparatorChar + "Addons", false);

            AddonWebApi.PostInstalledAddonsKeysAsync(_addons.ToArray()).Wait(0);
        }
Exemple #2
0
        internal static async Task UploadAddonAsync(IAddon addon)
        {
            IEnumerable <RestAddonInfoResult> infos = await AddonWebApi.GetAddonInfosAsync(addon.KeyNames.Select(k => k.Hash).ToArray());

            if (infos.Count() == 0 || infos.Any(a => a.easyinstall))
            {
                return;
            }

            AddonWebApi.UploadAddon(addon);
        }
Exemple #3
0
        internal async void DownloadAddonAsync(IAddon addon)
        {
            if (addon.IsEasyInstallable.HasValue && addon.IsEasyInstallable.Value && addon.KeyNames.Any() &&
                addon.KeyNames.Any(k => !string.IsNullOrEmpty(k.Hash)))
            {
                var installedAddon = await Task.Run(() =>
                {
                    var targetFolder =
                        Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments,
                                                  Environment.SpecialFolderOption.DoNotVerify) +
                        Path.DirectorySeparatorChar + @"ArmaBrowser" + Path.DirectorySeparatorChar +
                        "Arma 3" +
                        Path.DirectorySeparatorChar + "Addons" + Path.DirectorySeparatorChar;
                    var hash = addon.KeyNames.First(k => !string.IsNullOrEmpty(k.Hash)).Hash;
                    AddonWebApi.DownloadAddon(addon, hash, targetFolder);

                    var addons = _defaultDataRepository.GetInstalledAddons(targetFolder);
                    var item   = addons.FirstOrDefault(a => a.KeyNames.Any(k => k.Hash == hash));
                    if (item != null)
                    {
                        return(new Addon
                        {
                            Name = item.Name,
                            DisplayText = string.Format("{0} ({1})", item.DisplayText, item.Name),
                            Path = item.Path,
                            ModName = item.ModName,
                            Version = item.Version,
                            KeyNames = item.KeyNames,
                            IsInstalled = true,
                            IsEasyInstallable = true,
                            CanActived = addon.CanActived,
                            IsActive = addon.CanActived
                        });
                    }
                    return(null);
                });

                if (installedAddon != null)
                {
                    var idx = _addons.IndexOf(addon);
                    _addons[idx] = installedAddon;
                }
            }
        }
Exemple #4
0
 public async Task <IEnumerable <RestAddonInfoResult> > GetAddonInfosAsync(params string[] addonKeynames)
 {
     return(await AddonWebApi.GetAddonInfosAsync(addonKeynames));
 }