コード例 #1
0
 internal void ReloadButton()
 {
     if (gadgetIndex >= 0)
     {
         GadgetCoreAPI.DisplayYesNoDialog("Are you sure you want to perform a Gadget reload?\nThe following Gadgets will be reloaded:\n\n" + modEntries[modIndex].Gadgets[gadgetIndex].Dependents.Union(Gadgets.LoadOrderTree.Find(modEntries[modIndex].Gadgets[gadgetIndex]).FlattenUniqueByBreadth()).Select(x => x.Attribute.Name).Concat("\n"), () => {
             Gadgets.ReloadGadget(modEntries[modIndex].Gadgets[gadgetIndex]);
         });
     }
     else
     {
         if (modEntries[modIndex].Type == ModMenuEntryType.GADGET)
         {
             GadgetCoreAPI.DisplayYesNoDialog("<color=red>WARNING: This feature does not work! Unexpected consequences may occur from attempting to use it!</color>\n\nAre you sure you want to perform a mod reload?\nThe following mods will be reloaded:\n\n" + modEntries[modIndex].Gadgets.SelectMany(x => Gadgets.LoadOrderTree.Find(x).FlattenUniqueByBreadth()).Where(x => x != null).Select(x => x.Mod).Distinct().Select(x => x.Name).Concat("\n"), () => {
                 GadgetLoader.ReloadMod(modEntries[modIndex].Gadgets[0].Mod);
             });
         }
         else
         {
             GadgetCoreAPI.DisplayYesNoDialog("UMF mods can only have their configs reloaded at runtime.\nWould you like to reload " + modEntries[modIndex].Name + "'s config?", () => {
                 GadgetCore.UMFAPI.SendCommand("cfgReload " + modEntries[modIndex].Name);
             });
         }
     }
     Rebuild();
     UpdateRestartNeeded();
 }
コード例 #2
0
 /// <summary>
 /// Soft-reloads the given GadgetMod. (Does not load it freshly from the disk).
 /// Also refreshes all Gadgets that are dependent on these Gadgets.
 /// Be warned that this only reloads the mod's <see cref="Gadget"/> instances, so some mods may not function as expected after a refresh.
 /// </summary>
 public static GadgetMod RefreshMod(GadgetMod mod)
 {
     foreach (GadgetInfo gadget in mod.LoadedGadgets)
     {
         Gadgets.ReloadGadget(gadget);
     }
     return(mod);
 }