Esempio n. 1
0
    protected void TryDownloadAllModUpdates(object sender, EventArgs e)
    {
        foreach (var localMod in ModInfoTools.LocalMods)
        {
            if (localMod.Value.CloudName != null)
            {
                ModInfoHolder cloudModInfo = null;
                if (localMod.Value.FoundOther == 0)
                {
                    bool flag = true;
                    try
                    {
                        var repoItem = GetRepos.GetOneRepo(localMod.Value.CloudName);
                        if (ModInfoTools.GetGithubMod(repoItem))
                        {
                            cloudModInfo = ModInfoTools.lastGithubMod;
                            flag         = false;
                        }
                    }
                    catch (Exception E)
                    {
                        Console.WriteLine(E);
                    }
                    if (flag)
                    {
                        localMod.Value.FoundOther = -1;
                    }
                }
                if (cloudModInfo != null || ModInfoTools.GithubMods.TryGetValue(localMod.Value.CloudName, out cloudModInfo))
                {
                    if (localMod.Value.CurrentVersion == cloudModInfo.CurrentVersion)
                    {
                        continue;
                    }

                    //if (localMod.Value.State == ModInfo.ModState.Disabled)
                    //{
                    //    Log("Can't update a disabled mod! (" + localMod.Value.Name + ")", Color.OrangeRed);
                    //    continue;
                    //}
                    if (ModDownloader.AddModDownload(cloudModInfo, ModListStoreGithub))
                    {
                        ModListStoreLocal.SetValue(localMod.Value.TreeIter, (int)TreeColumnInfo.Desc, "Updating...");
                    }
                    continue;
                }
            }
        }
    }
Esempio n. 2
0
 public void DownloadMod(ModInfoHolder ModRef, int TabPage)
 {
     if (TabPage != 0) // Is a server tab
     {
         if (ModRef.FoundOther == 1)
         {
             var localMod = ModInfoTools.LocalMods[ModRef.Name];
             //if (localMod.State == ModInfoHolder.ModState.Disabled)
             //{
             //    Log("Can't update a disabled mod!");
             //    return;
             //}
             if (ModDownloader.AddModDownload(ModRef, ModListStoreGithub))
             {
                 ModListStoreLocal.SetValue(localMod.TreeIter, (int)TreeColumnInfo.Desc, "Updating...");
             }
             return;
         }
         ModDownloader.AddModDownload(ModRef, ModListStoreGithub);
         return;
     }
     if (!string.IsNullOrEmpty(ModRef.CloudName))
     {
         ModInfoHolder cloudModInfo = null;
         if (ModRef.FoundOther == 0)
         {
             bool flag = true;
             try
             {
                 var repoItem = GetRepos.GetOneRepo(ModRef.CloudName);
                 if (ModInfoTools.GetGithubMod(repoItem))
                 {
                     cloudModInfo = ModInfoTools.lastGithubMod;
                     flag         = false;
                 }
             }
             catch (Exception E)
             {
                 Console.WriteLine(E);
             }
             if (flag)
             {
                 Log("Could not locate server mod!");
                 ModRef.FoundOther = -1;
                 return;
             }
         }
         if (cloudModInfo != null || ModInfoTools.GithubMods.TryGetValue(ModRef.CloudName, out cloudModInfo))
         {
             //if (modInfo.State == ModInfoHolder.ModState.Disabled)
             //{
             //    Log("Can't update a disabled mod!");
             //    return;
             //}
             if (ModDownloader.AddModDownload(cloudModInfo, ModListStoreGithub))
             {
                 ModListStoreLocal.SetValue(ModRef.TreeIter, (int)TreeColumnInfo.Desc, "Updating...");
                 return;
             }
         }
     }
     Log("Can't download mod!");
 }