Пример #1
0
 private void Modlist_DragDrop(object sender, DragEventArgs e)
 {
     string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
     Debug.WriteLine($"Drag&Drop: {files.Length} files were dropped in the mod list.");
     Debug.Indent();
     foreach (string file in files)
     {
         // get the file info for easier operations
         FileInfo ModFileInfo = new FileInfo(file);
         // check if we are dealing with a dll file
         if (!String.Equals(ModFileInfo.Extension, ".dll", StringComparison.CurrentCultureIgnoreCase))
         {
             Debug.WriteLine($"Error: {ModFileInfo.Name} was ignored, as it is not a dll file.");
             continue;
         }
         // move the dll file to the Mods folder
         string ModFilePath = Path.Combine(RootPath, "Mods", ModFileInfo.Name);
         if (System.IO.File.Exists(ModFilePath))
         {
             Debug.WriteLine($"Error: {ModFileInfo.Name} was ignored, as it already exists.");
             continue;
         }
         // move the dll file to the Mods folder
         System.IO.File.Copy(ModFileInfo.FullName, ModFilePath);
         // get mod data
         var mr = new ModRelay(ModFilePath);
         // add the mod to the mod list
         Modlist.Items.Add(mr);
         Debug.WriteLine($"{ModFileInfo.Name} successfully added.");
         // since it's a new mod just added to the folder, it shouldn't be checked as active, nothing else to do here
     }
     Debug.Unindent();
     Debug.WriteLine("Drag&Drop operation ended.");
 }
Пример #2
0
 private void CompileModList()
 {
     string[] ModsFolderContents = Directory.GetFiles(ModFolder);
     foreach (string s in ModsFolderContents)
     {
         var fi = new FileInfo(s);
         if (fi.Extension == ".dll" && !fi.Attributes.HasFlag(FileAttributes.ReparsePoint))
         {
             targetFiles.Add(new ModRelay(s));
         }
         if (AintThisPS(s))
         {
             PubstuntFound = true;
         }
     }
     foreach (ModRelay mr in targetFiles)
     {
         Modlist.Items.Add(mr);
     }
     for (int i = 0; i < Modlist.Items.Count; i++)
     {
         if (Modlist.Items[i] is ModRelay)
         {
             ModRelay mr = Modlist.Items[i] as ModRelay;
             Modlist.SetItemCheckState(i, (mr.enabled) ? CheckState.Checked : CheckState.Unchecked);
         }
     }
 }
Пример #3
0
 //overload for manual checks/unchecks
 private void ApplyModlist(CheckState[] cst)
 {
     Debug.WriteLine("Applying modlist from manual check.");
     if (cst != null && cst.Length == Modlist.Items.Count)
     {
         for (int i = 0; i < cst.Length; i++)
         {
             if (Modlist.Items[i] is ModRelay)
             {
                 ModRelay mr = Modlist.Items[i] as ModRelay;
                 if (cst[i] == CheckState.Checked)
                 {
                     mr.Enable();
                 }
                 else
                 {
                     mr.Disable();
                 }
             }
         }
     }
 }
Пример #4
0
 private void ApplyModlist()
 {
     Debug.WriteLine("Applying modlist.");
     Debug.Indent();
     for (int i = 0; i < Modlist.Items.Count; i++)
     {
         if (Modlist.Items[i] is ModRelay)
         {
             ModRelay mr = Modlist.Items[i] as ModRelay;
             if (Modlist.GetItemChecked(i))
             {
                 mr.Enable();
             }
             else
             {
                 mr.Disable();
             }
             Debug.WriteLine(mr.AssociatedModData.DisplayedName + " : " + ((mr.enabled) ? "ON" : "OFF"));
         }
     }
     Debug.Unindent();
 }
Пример #5
0
        //deletes Pubstunt and mixmods
        private void Rootout()
        {
            string[] patchfoldercontents  = Directory.GetFiles(PatchesFolder);
            string[] pluginfoldercontents = Directory.GetFiles(PluginsFolder);
            foreach (string s in patchfoldercontents)
            {
                var fi = new FileInfo(s);
                if (fi.Extension == ".dll" && !fi.Attributes.HasFlag(FileAttributes.ReparsePoint))
                {
                    if (AintThisPS(s))
                    {
                        PubstuntFound = true;
                        Debug.WriteLine("Located PublicityStunt in active Plugins folder, removing.");
                        File.Delete(s);
                    }
                    else
                    {
                        ModRelay.ModType mt = ModRelay.GetModType(s);

                        if (mt != ModRelay.ModType.Patch && !patchBlacklist.Contains(s) && !fi.Attributes.HasFlag(FileAttributes.ReparsePoint))
                        {
                            Debug.WriteLine("Found a misplaced mod in Patches folder: " + fi.Name + "; Type: " + mt.ToString());
                            if (File.Exists(ModFolder + PtModData.GiveMeBackMyName(fi.Name)))
                            {
                                File.Delete(s);
                            }
                            else
                            {
                                File.Move(s, ModFolder + PtModData.GiveMeBackMyName(fi.Name));
                            }
                        }
                    }
                }
            }
            foreach (string s in pluginfoldercontents)
            {
                var fi = new FileInfo(s);
                if (fi.Extension == ".dll" && !pluginBlacklist.Contains(s) && !fi.Attributes.HasFlag(FileAttributes.ReparsePoint))
                {
                    if (AintThisPS(s))
                    {
                        File.Delete(s);
                        Debug.WriteLine("Located PublicityStunt in active Plugins folder, removing.");
                        PubstuntFound = true;
                    }
                    else
                    {
                        ModRelay.ModType mt = ModRelay.GetModType(s);

                        if (mt == ModRelay.ModType.Patch || mt == ModRelay.ModType.Invalid)
                        {
                            Debug.WriteLine("Found a misplaced mod in Plugins folder: " + fi.Name + "; Type: " + mt.ToString());
                            if (File.Exists(ModFolder + PtModData.GiveMeBackMyName(fi.Name)))
                            {
                                File.Delete(s);
                                Debug.WriteLine("Duplicate exists in Mods folder, deleting.");
                            }
                            else
                            {
                                Debug.WriteLine("Moving to Mods folder.");
                                File.Move(s, ModFolder + PtModData.GiveMeBackMyName(fi.Name));
                            }
                        }
                    }
                }
            }
        }