Exemplo n.º 1
0
 private void Update(object Sender, RoutedEventArgs Args)
 {
     if ((string)UpdateButton.Content == LocString(LocCode.Pause))
     {
         SteamDownloader.Pause();
     }
     else
     {
         Update(false);
     }
 }
Exemplo n.º 2
0
 private void ClosingHandler(object Sender, CancelEventArgs Args)
 {
     if (Shutdown)
     {
         Downloader.Pause();
     }
     else if (Finished)
     {
         if (Mod is null)
         {
             DLC.SetStatus(Succeeded ? ARK.Status.Installed : LastStatus);
         }
         else
         {
             Mod.UpdateAvailable = false;
             Mod.Status          = ARK.Status.Installed;
             Dispatcher.Invoke(() =>
             {
                 if (Instance.CurrentPage is ModsPage Page)
                 {
                     ModItem Item = Page.FindItem(Mod);
                     if (!(Item is null))
                     {
                         Item.ValidateButton.Visibility = Visibility.Visible;
                     }
                 }
             });
         }
     }
     else if (ShowOptions("Warning", LocString(LocCode.ValidatorClosePrompt)))
     {
         CloseCancelling = true;
         Downloader.Pause();
         Args.Cancel = true;
         Message.Show("Info", LocString(LocCode.ValidatorWaitingForCancel));
     }
     else
     {
         Args.Cancel = true;
     }
 }
Exemplo n.º 3
0
 private void ClosingHandler(object Sender, CancelEventArgs Args)
 {
     if (Shutdown)
     {
         Downloader.Pause();
     }
     else if (Finished)
     {
         return;
     }
     else if (ShowOptions("Warning", LocString(LocCode.ValidatorClosePrompt)))
     {
         CloseCancelling = true;
         Downloader.Pause();
         Args.Cancel = true;
         Message.Show("Info", LocString(LocCode.ValidatorWaitingForCancel));
     }
     else
     {
         Args.Cancel = true;
     }
 }
Exemplo n.º 4
0
        private async void InstallCancel(object Sender, RoutedEventArgs Args)
        {
            if (IsInstalling)
            {
                InstallCancelButton.IsEnabled = false;
                Downloader.Pause();
                SetStatus(LocString(LocCode.Cancelling), YellowBrush);
            }
            else if (ARKID.Text.Length == 0)
            {
                SetStatus(LocString(LocCode.MIEnterARKID), DarkRed);
            }
            else
            {
                ulong ID = ulong.Parse(ARKID.Text);
                if (Workshop.ContainsKey(ID))
                {
                    if (!(Mods.Find(Mod => Mod.ID == Workshop[ID])?.IsInstalled ?? false) && ShowOptions("Info", LocString(LocCode.MIARKdictedPrompt)))
                    {
                        ulong ARKDictedID = Workshop[ID];
                        SetStatus(LocString(LocCode.MIRequestingDetails), YellowBrush);
                        ModDetails[] Response = await GetModsDetailsAsync(ARKDictedID);

                        ModDetails Details = (Response?.Length ?? 0) == 0 ? default : Response[0];
                                             string Name = Details.Status == 1 ? Details.Name : LocString(LocCode.MIDefaultModName);
                                             SetStatus(string.Format(LocString(LocCode.MISubscribing), Name), YellowBrush);
                                             bool Subscribed = false;
                                             if (await TryDeployAsync())
                                             {
                                                 if (await SteamAPI.SubscribeModAsync(ARKDictedID))
                                                 {
                                                     Subscribed = true;
                                                 }
                                             }
                                             if (Subscribed)
                                             {
                                                 SetStatus(LocString(LocCode.MIWaitingForSteam), YellowBrush);
                                                 if (await SteamAPI.TrackDownloadProgressAsync(ARKDictedID, ProgressBar, SetStatus))
                                                 {
                                                     string ModFolder = $@"{WorkshopPath}\{ARKDictedID}";
                                                     SetStatus(LocString(LocCode.MIWaitingModCopy), YellowBrush);
                                                     int TimeoutCounter = 60;
                                                     while (!Exists($@"{ModFolder}\mod.info") && --TimeoutCounter != 0)
                                                     {
                                                         await Delay(1000);
                                                     }
                                                     if (TimeoutCounter == 0)
                                                     {
                                                         SetStatus(LocString(LocCode.MIModCopyTimeout), DarkRed);
                                                     }
                                                     else
                                                     {
                                                         SetStatus(LocString(LocCode.CInstallingMod), YellowBrush);
                                                         Mod Mod = Mods.Find(ListMod => ListMod.ID == ARKDictedID);
                                                         if (!(Mod is null))
                                                         {
                                                             Mods.Remove(Mod);
                                                         }
                                                         Mod = new Mod(ModFolder, null)
                                                         {
                                                             IsSubscribed = true, Details = Details
                                                         };
                                                         await Run(() => Mod.Install(ProgressBar.Progress, ProgressBar));

                                                         Mods.Add(Mod);
                                                         SetStatus(string.Format(LocString(LocCode.MISuccess), Name), DarkGreen);
                                                     }
                                                 }
                                             }
                                             else
                                             {
                                                 Show("Info", LocString(LocCode.FailedToSub));
                                                 Execute($"{SteamWorkshop}{ARKDictedID}");
                                                 SetStatus(string.Format(LocString(LocCode.MISubSuccess), Name), DarkGreen);
                                             }
                                             FinishHandler();
                                             return;
                    }
                }
                if (SpacewarID.Text.Length == 0)
                {
                    SetStatus(LocString(LocCode.MIEnterSpacewarID), DarkRed);
                }
                else if (Mods.Find(Mod => Mod.ID == ulong.Parse(SpacewarID.Text))?.IsInstalled ?? false)
                {
                    SetStatus(LocString(LocCode.MIIDInUse), DarkRed);
                }
                else
                {
                    IsInstalling             = true;
                    SpacewarID.IsReadOnly    = ARKID.IsReadOnly = true;
                    SelectIDButton.IsEnabled = BackButton.IsEnabled = false;
                    ((VectorImage)InstallCancelButton.Template.FindName("Icon", InstallCancelButton)).Source = "Pause";
                    ARKModID      = ID;
                    SpacewarModID = ulong.Parse(SpacewarID.Text);
                    SetStatus(LocString(LocCode.MIRequestingDetails), YellowBrush);
                    string       Message = null;
                    ModDetails[] Details = await GetModsDetailsAsync(ARKModID, SpacewarModID);

                    if ((Details?.Length ?? 0) < 2)
                    {
                        Message = LocString(LocCode.MIRequestFailed);
                    }
                    else if (Details[0].Status == 2)
                    {
                        Message = LocString(LocCode.MINoARKMod);
                    }
                    else if (Details[0].AppID != 346110U)
                    {
                        Message = LocString(LocCode.MINotAnARKMod);
                    }
                    else if (Details[1].Status == 2)
                    {
                        Message = LocString(LocCode.MINoSpacewarMod);
                    }
                    else if (Details[1].AppID != 480U)
                    {
                        Message = LocString(LocCode.MINotASpacewarMod);
                    }
                    if (Message is null)
                    {
                        ARKModDetails      = Details[0];
                        SpacewarModDetails = Details[1];
                        new Thread(DownloadJob).Start();
                    }
                    else
                    {
                        SetStatus(Message, DarkRed);
                        Downloader.FilesUpToDate = 0;
                        FinishHandler();
                    }
                }
            }
        }