コード例 #1
0
        public static Dictionary <ModDefEx, bool> ConflictsWithMe(this ModDefEx moddef)
        {
            Dictionary <ModDefEx, bool> result = new Dictionary <ModDefEx, bool>();

            foreach (var mod in moddef.AffectingOnline)
            {
                if (mod.Key.PendingEnable != mod.Value)
                {
                    result.Add(mod.Key, mod.Value);
                }
            }
            return(result);
        }
コード例 #2
0
        public static ModStatusItem ToVanilla(this ModDefEx mod)
        {
            ModStatusItem result = new ModStatusItem();

            result.name         = mod.Name;
            result.enabled      = mod.Enabled;
            result.version      = mod.Version;
            result.website      = mod.Website;
            result.failedToLoad = mod.LoadFail;
            result.dependsOn    = mod.DependsOn.ToList();
            result.directory    = mod.Directory;
            //result.Author = mod.Author;
            //result.Contact = mod.Contact;
            //result.Description = mod.Description;
            return(result);
        }
コード例 #3
0
 public static void Postfix(BattleTech.UI.ModManagerListViewItem __instance, ModStatusItem modStatusItem, LocalizableText ___modNameText, BattleTech.UI.HBSDOTweenToggle ___toggleBox)
 {
     if (ModTek.allModDefs.ContainsKey(modStatusItem.name))
     {
         ModDefEx mod = ModTek.allModDefs[modStatusItem.name];
         ___toggleBox.SetToggled(mod.PendingEnable);
         if (mod.LoadFail)
         {
             ___modNameText.color = Color.red;
             ___modNameText.SetText("!" + mod.Name);
         }
         else
         {
             ___modNameText.color = Color.white;
             ___modNameText.SetText(mod.Name);
         }
     }
 }
コード例 #4
0
 public static bool Prefix(BattleTech.UI.ModManagerListViewItem __instance, BattleTech.UI.HBSDOTweenToggle ___toggleBox, ModManagerScreen ____screen)
 {
     if (ModTek.allModDefs.ContainsKey(__instance.ModStatusItem.name) == false)
     {
         //if (ModTek.allModDefs[modDef.Name].Enabled == false) { ___modNameText.color = Color.red; };
         ___toggleBox.SetToggled(false);
     }
     else
     {
         ModDefEx mod = ModTek.allModDefs[__instance.ModStatusItem.name];
         if (mod.Locked)
         {
             ___toggleBox.SetToggled(mod.PendingEnable);
             return(false);
         }
         if (mod.PendingEnable == true)
         {
             Dictionary <ModDefEx, bool> deps = mod.GatherDependsOnMe();
             if (deps.Count > 0)
             {
                 StringBuilder text = new StringBuilder();
                 text.AppendLine("Some mods relay on this:");
                 List <KeyValuePair <ModDefEx, bool> > listdeps = deps.ToList();
                 for (int t = 0; t < Mathf.Min(7, deps.Count); ++t)
                 {
                     text.AppendLine(listdeps[t].Key.Name + "->" + (listdeps[t].Value ? "Enable" : "Disable"));
                 }
                 if (deps.Count > 7)
                 {
                     text.AppendLine("...........");
                 }
                 text.AppendLine("They will fail to load, but it will be only your damn problem.");
                 GenericPopupBuilder.Create("Dependency conflict", text.ToString()).AddButton("Return", (Action)(() => { mod.PendingEnable = true; ___toggleBox.SetToggled(mod.PendingEnable); })).AddButton("Resolve", (Action)(() =>
                 {
                     mod.PendingEnable = false;
                     ___toggleBox.SetToggled(mod.PendingEnable);
                     foreach (var dmod in deps)
                     {
                         dmod.Key.PendingEnable = dmod.Value;
                     }
                     ____screen.installedModsPanel.RefreshListViewItems();
                 })).AddButton("Shoot own leg", (Action)(() => { mod.PendingEnable = false; ___toggleBox.SetToggled(mod.PendingEnable); })).IsNestedPopupWithBuiltInFader().SetAlwaysOnTop().Render();
             }
             else
             {
                 mod.PendingEnable = false;
                 ___toggleBox.SetToggled(mod.PendingEnable);
             }
         }
         else
         {
             Dictionary <ModDefEx, bool> conflicts = mod.ConflictsWithMe();
             if (conflicts.Count > 0)
             {
                 StringBuilder text = new StringBuilder();
                 text.AppendLine("Some mods conflics with this or this mod have unresolved dependency:");
                 List <KeyValuePair <ModDefEx, bool> > listconflicts = conflicts.ToList();
                 for (int t = 0; t < Mathf.Min(7, listconflicts.Count); ++t)
                 {
                     text.AppendLine(listconflicts[t].Key.Name + "->" + (listconflicts[t].Value ? "Enable":"Disable"));
                 }
                 if (conflicts.Count > 7)
                 {
                     text.AppendLine("...........");
                 }
                 text.AppendLine("They will fail to load, but it will be only your damn problem.");
                 GenericPopupBuilder.Create("Dependency conflict", text.ToString()).AddButton("Return", (Action)(() => { mod.PendingEnable = false; ___toggleBox.SetToggled(mod.PendingEnable); })).AddButton("Resolve", (Action)(() =>
                 {
                     mod.PendingEnable = true;
                     ___toggleBox.SetToggled(mod.PendingEnable);
                     foreach (var dmod in listconflicts)
                     {
                         dmod.Key.PendingEnable = dmod.Value;
                     }
                     ____screen.installedModsPanel.RefreshListViewItems();
                 })).AddButton("Shoot own leg", (Action)(() => { mod.PendingEnable = true; ___toggleBox.SetToggled(mod.PendingEnable); })).IsNestedPopupWithBuiltInFader().SetAlwaysOnTop().Render();
             }
             else
             {
                 mod.PendingEnable = true;
                 ___toggleBox.SetToggled(mod.PendingEnable);
             }
         }
     }
     return(false);
 }