Esempio n. 1
0
        //used to update the overriding data when a mod is moved ONE up or ONE down.
        public void UpdateModOverridingdata(List <ModItem> items, ModItem movedMod, bool movedUp)
        {
            string modA = movedMod.SubItems[2].Text;

            //Console.WriteLine("UpdateModOverridingdata");
            //Console.WriteLine("--" + modA);

            int indexToCheck = 0;

            if (movedUp)
            {
                indexToCheck = movedMod.Index + 1;
            }
            else
            {
                indexToCheck = movedMod.Index - 1;
            }

            ModItem itemB = items[indexToCheck];
            string  modB  = itemB.SubItems[2].Text;

            //Console.WriteLine("++" + modB);

            if (!this.OverrridingData.ContainsKey(modA))
            {
                this.OverrridingData[modA] = new OverridingData
                {
                    mod          = modA,
                    overrides    = new Dictionary <string, List <string> >(),
                    overriddenBy = new Dictionary <string, List <string> >()
                };
            }
            if (!this.OverrridingData.ContainsKey(modB))
            {
                this.OverrridingData[modB] = new OverridingData
                {
                    mod          = modB,
                    overrides    = new Dictionary <string, List <string> >(),
                    overriddenBy = new Dictionary <string, List <string> >()
                };
            }

            ResetOverrdingBetweenMods(movedMod, itemB);

            GetModOverridingData(movedMod, items[indexToCheck], items.Count, OverrridingData[modA], OverrridingData[modA]);

            OverridingData A = OverrridingData[modA];
            OverridingData B = OverrridingData[modB];

            ColorItemsOnOverridingData(items);
        }
Esempio n. 2
0
        //Color the list view items based on data
        public void ColorItemsOnOverridingData(List <ModItem> items)
        {
            foreach (ListViewItem item in items)
            {
                string mod = item.SubItems[2].Text;

                //market for removal so don't color.
                if (item.SubItems[1].ForeColor == Color.Red)
                {
                    continue;
                }

                ////Console.WriteLine("Coloring mod: " + mod);
                if (!this.OverrridingData.ContainsKey(mod))
                {
                    item.SubItems[1].ForeColor = Color.Black;
                    ////Console.WriteLine("Black");

                    continue;
                }
                OverridingData A = OverrridingData[mod];
                if (A.isOverriden)
                {
                    ////Console.WriteLine("OrangeRed");
                    item.SubItems[1].ForeColor = Color.OrangeRed;
                }
                if (A.isOverriding)
                {
                    ////Console.WriteLine("Green");
                    item.SubItems[1].ForeColor = Color.Green;
                }
                if (A.isOverriding && A.isOverriden)
                {
                    ////Console.WriteLine("Orange");
                    item.SubItems[1].ForeColor = Color.Orange;
                }
                if (!A.isOverriding && !A.isOverriden)
                {
                    ////Console.WriteLine("Black");
                    item.SubItems[1].ForeColor = Color.Black;
                }
            }
        }
Esempio n. 3
0
        //Return a dict of all overriden mods with a list of overriden files as values.
        //else returns an empty string.
        public void GetOverridingData(List <ModItem> items)
        {
            ////Console.WriteLine(Environment.StackTrace);
            ////Console.WriteLine("Starting Overriding data check");
            this.OverrridingData.Clear();

            foreach (ModItem itemA in items)
            {
                //We only wanna check this for items actually enabled.
                if (!itemA.Checked)
                {
                    continue;
                }

                string modA      = itemA.FolderName;
                int    priorityA = items.Count - items.IndexOf(itemA);

                //Check if we allready have this mod in the dict if not create an entry for it.
                if (!this.OverrridingData.ContainsKey(modA))
                {
                    this.OverrridingData[modA] = new OverridingData
                    {
                        mod          = modA,
                        overrides    = new Dictionary <string, List <string> >(),
                        overriddenBy = new Dictionary <string, List <string> >()
                    };
                }
                OverridingData A = this.OverrridingData[modA];

                //Console.WriteLine("Checking: " + modA + " : " + priorityA.ToString());
                foreach (ModItem itemB in items)
                {
                    string modB = itemB.FolderName;

                    if (modA == modB)
                    {
                        continue;
                    }

                    if (!itemB.Checked)
                    {
                        continue;
                    }

                    //If we have allready seen modb in comparison to modA we don't need to compare because the comparison is bi-directionary.
                    if (
                        A.overriddenBy.ContainsKey(modB) ||
                        A.overrides.ContainsKey(modB)
                        )
                    {
                        ////Console.WriteLine("--" + modA + "has allready been compared to: " + modB);
                        continue;
                    }

                    //Check if we have allready seen modB before.
                    if (this.OverrridingData.ContainsKey(modB))
                    {
                        //If we have allready seen modB and we have allready compared modB and modA we don't need to compare because the comparison is bi-directionary.
                        if (
                            this.OverrridingData[modB].overriddenBy.ContainsKey(modA) ||
                            this.OverrridingData[modB].overrides.ContainsKey(modA)
                            )
                        {
                            ////Console.WriteLine("--" + modB + "has allready been compared to: " + modA);
                            continue;
                        }
                    }
                    else
                    {
                        //If we have not make a new modB overridingDatas
                        this.OverrridingData[modB] = new OverridingData
                        {
                            mod          = modB,
                            overrides    = new Dictionary <string, List <string> >(),
                            overriddenBy = new Dictionary <string, List <string> >()
                        };
                    }
                    GetModOverridingData(itemA, itemB, items.Count, this.OverrridingData[modA], this.OverrridingData[modB]);
                }
            }

            #region debug output

            //Debug output
            //foreach(string key in this.OverrridingData.Keys)
            //{
            //    //Console.WriteLine("MOD: " + key);
            //    //Console.WriteLine("--Overriden:");
            //    foreach (string mod in OverrridingData[key].overriddenBy.Keys)
            //    {
            //        //Console.WriteLine("----" + OverrridingData[key].isOverriden);
            //    }
            //    //Console.WriteLine("--Overrides:");
            //    foreach (string mod in OverrridingData[key].overrides.Keys)
            //    {
            //        //Console.WriteLine("----" + OverrridingData[key].isOverriding);
            //    }
            //}

            #endregion debug output

            ColorItemsOnOverridingData(items);
        }
Esempio n. 4
0
        //See if items A and B are interacting in terms of manifest and return the intersect
        public void GetModOverridingData(ModItem itemA, ModItem itemB, int itemCount, OverridingData A, OverridingData B)
        {
            string modA = itemA.SubItems[2].Text;
            string modB = itemB.SubItems[2].Text;

            if (modA == modB)
            {
                return;
            }

            int priorityA = itemCount - itemA.Index;
            int priorityB = itemCount - itemB.Index;

            //Now we have a mod that is not the mod we are looking at is enbabled.
            //Lets compare the manifest!
            List <string> manifestA = this.ModDetails[this.DirectoryToPathDict[modA]].manifest;
            List <string> manifestB = this.ModDetails[this.DirectoryToPathDict[modB]].manifest;
            List <string> intersect = manifestA.Intersect(manifestB).ToList();

            //If the intersects elements are greater then zero we have shared parts of the manifest
            if (intersect.Count() == 0)
            {
                return;
            }

            ////Console.WriteLine("---Intersection: " + modB + " : " + priorityB.ToString());

            //If we are loaded after the mod we are looking at we are overriding it.
            if (priorityA > priorityB)
            {
                if (!(A.mod == modB))
                {
                    A.isOverriding    = true;
                    A.overrides[modB] = intersect;
                }
                if (!(B.mod == modA))
                {
                    B.isOverriden        = true;
                    B.overriddenBy[modA] = intersect;
                }
            }
            else
            {
                if (!(A.mod == modB))
                {
                    A.isOverriden        = true;
                    A.overriddenBy[modB] = intersect;
                }
                if (!(B.mod == modA))
                {
                    B.isOverriding    = true;
                    B.overrides[modA] = intersect;
                }
            }
            this.OverrridingData[modA] = A;
            this.OverrridingData[modB] = B;
        }