Example #1
0
File: BOI.cs Project: thalber/BOI
 private void Modlist_DragDrop(object sender, DragEventArgs e)
 {
     string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
     Wood.WriteLine($"Drag&Drop: {files.Length} files were dropped in the mod list.");
     Wood.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))
         {
             Wood.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 (File.Exists(ModFilePath))
         {
             Wood.WriteLine($"Error: {ModFileInfo.Name} was ignored, as it already exists.");
             continue;
         }
         // move the dll file to the Mods folder
         File.Copy(ModFileInfo.FullName, ModFilePath);
         // get mod data
         var mr = new ModRelay(ModFilePath);
         // add the mod to the mod list
         targetFiles.Add(mr);
         Wood.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
     }
     Wood.Unindent();
     Wood.WriteLine("Drag&Drop operation ended.");
 }
Example #2
0
        /// <summary>
        /// Returns if a <see cref="ModRelay"/> is selected by a given mask.
        /// </summary>
        /// <param name="mask">Mask text.</param>
        /// <param name="mr"><see cref="ModRelay"/> to be checked.</param>
        /// <returns></returns>
        private bool ModSelectedByMask(string mask, ModRelay mr)
        {
            if (mask == string.Empty)
            {
                return(true);
            }
            string cmm = MaskModeSelect.Text;

            if (cmm == nameof(Maskmode.Names) || cmm == nameof(Maskmode.NamesAndTags))
            {
                if (mr.ToString().ToLower().Contains(mask.ToLower()))
                {
                    return(true);
                }
            }
            if (cmm == nameof(Maskmode.NamesAndTags) || cmm == nameof(Maskmode.Tags))
            {
                string[] tags = TagManager.GetTagsArray(mr.AssociatedModData.DisplayedName);
                foreach (string tag in tags)
                {
                    if (tag.ToLower().Contains(mask.ToLower()))
                    {
                        return(true);
                    }
                }
            }


            return(false);
        }
Example #3
0
File: BOI.cs Project: thalber/BOI
 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);
         }
     }
 }
Example #4
0
File: BOI.cs Project: thalber/BOI
 //overload for manual checks/unchecks
 private void ApplyModlist(CheckState[] cst)
 {
     Wood.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();
                 }
             }
         }
     }
 }
Example #5
0
File: BOI.cs Project: thalber/BOI
 private void ApplyModlist()
 {
     Wood.WriteLine("Applying modlist.");
     Wood.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();
             }
             Wood.WriteLine(mr.AssociatedModData.DisplayedName + " : " + ((mr.enabled) ? "ON" : "OFF"));
         }
     }
     Wood.Unindent();
 }
Example #6
0
File: BOI.cs Project: thalber/BOI
        private void ApplyMaskToModlist(string mask)
        {
            bool oldrst = ReadyForRefresh;

            ReadyForRefresh = false;
            Modlist.Items.Clear();
            foreach (ModRelay mr in targetFiles)
            {
                if (ModSelectedByMask(mask, mr))
                {
                    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);
                }
            }
            ReadyForRefresh = oldrst;
        }
Example #7
0
File: BOI.cs Project: thalber/BOI
        //deletes Pubstunt and mixmods from where they shouldn't be
        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;
                        Wood.WriteLine("Located PublicityStunt in active Plugins folder, removing.");
                        File.Delete(s);
                    }
                    else
                    {
                        ModRelay.ModType mt = ModRelay.GetModType(s);
                        if (!(mt == ModRelay.ModType.Patch || mt == ModRelay.ModType.Invalid) && !patchBlacklist.Contains(s) && !fi.Attributes.HasFlag(FileAttributes.ReparsePoint))
                        {
                            Wood.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);
                        Wood.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)
                        {
                            Wood.WriteLine("Found a misplaced mod in Plugins folder: " + fi.Name + "; Type: " + mt.ToString());
                            if (File.Exists(ModFolder + PtModData.GiveMeBackMyName(fi.Name)))
                            {
                                File.Delete(s);
                                Wood.WriteLine("Duplicate exists in Mods folder, deleting.");
                            }
                            else
                            {
                                Wood.WriteLine("Moving to Mods folder.");
                                File.Move(s, ModFolder + PtModData.GiveMeBackMyName(fi.Name));
                            }
                        }
                    }
                }
            }
        }