Beispiel #1
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);
         }
     }
 }
Beispiel #2
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);
 }