예제 #1
0
        private void InstalledModsList_SelectedIndexChanged(object sender, EventArgs e)
        {
            UpdateButton.Show();
            Delete.Show();
            CheckButton.Show();


            ModVer.Show();
            try
            {
                trycatchtext(SelectedModText, "Selected Mod: " + DownloadableModsList.SelectedItems[0].Text);
                trycatchtext(ModInfo, DownloadableModsList.SelectedItems[0].SubItems[3].Text);
                impModID = DownloadableModsList.SelectedItems[0].SubItems[4].Text;
            }
            catch (Exception exception)
            {
                //sike lmao
            }

            try
            {
                impModID             = InstalledModsList.SelectedItems[0].SubItems[4].Text;
                SelectedModText.Text = "Selected Mod: " + InstalledModsList.SelectedItems[0].Text;
                ModInfo.Text         = InstalledModsList.SelectedItems[0].SubItems[3].Text;
                ModVer.Text          = "Current Ver: " + InstalledModsList.SelectedItems[0].SubItems[1].Text +
                                       ", Online Version: " + ModParsing
                                       .GetSpecificMod(InstalledModsList.SelectedItems[0].SubItems[4].Text).Version;
            }
            catch
            {
            }
        }
예제 #2
0
        public static void CheckForManualInstalledMods()
        {
            ModFile[] mods      = ModParsing.GetAllMods();
            ModFile[] instmods  = InstalledMods.GetInstalledMods();
            string    addedmods = "";

            for (int i = 0; i < mods.Length; i++)
            {
                if (!string.IsNullOrEmpty(mods[i].DelInfo))
                {
                    if (File.Exists(Path.Combine(Utilities.GameDirectory, mods[i].DelInfo)))
                    {
                        bool IsInstalled = false;
                        for (int x = 0; x < instmods.Length; x++)
                        {
                            if (mods[i].ModId == instmods[x].ModId)
                            {
                                IsInstalled = true;
                                break;
                            }
                        }
                        if (!IsInstalled)
                        {
                            addedmods += mods[i].ModId + ", ";
                            InstalledMods.AddInstalledMod(mods[i].ModId);
                        }
                    }
                }
            }
            if (!String.IsNullOrEmpty(addedmods))
            {
                var conf = MessageBox.Show($"Some manually installed mods have been detected, adding it to database. Detected mods: {addedmods.Split(',').Length} \n" + addedmods, "Installed mods detected!", MessageBoxButtons.OK);
            }
        }
예제 #3
0
        /// <summary>
        ///     Adds a <c>ModFile</c> to the InstalledMods JSON file
        /// </summary>
        /// <param name="addmod">Mod to add</param>
        public static void AddInstalledMod(string addmod)
        {
            var file = GetInstalledMods();                             //gets the installed mods file

            Array.Resize(ref file, file.Length + 1);                   //adds new room for new mod
            file[file.Length - 1] = ModParsing.GetSpecificMod(addmod); //sets new room in array to modinfo of addmod
            writeInstalledModToJson(file);
        }
예제 #4
0
        public static bool CheckIfILmodOutOfDate(ModFile mf)
        {
            Version ILver = new Version(mf.Version);
            Version DLver = new Version(ModParsing.GetSpecificMod(mf.ModId).Version);

            if (ILver.CompareTo(DLver) < 0) //if out of date
            {
                return(true);
            }
            return(false);
        }
예제 #5
0
        private void Delete_Click(object sender, EventArgs e)
        {
            string mods = "";

            for (int i = 0; i < impModID.Length; i++)
            {
                mods += ModParsing.GetSpecificMod(impModID[i]).Name + ", ";
            }
            var conf = MessageBox.Show($"Are you sure you want to delete mod(s) {mods}? A total of " + ModParsing.GetDependents(ModParsing.GetSpecificMod(impModID[0])).Length + " downloaded mods rely on this.", "Deletion Confirmation", MessageBoxButtons.YesNo);

            if (conf == DialogResult.Yes)
            {
                StartTerminator("rm");
            }
            else
            {
                return;
            }
        }
예제 #6
0
        public static Tuple <ModFile[], ModFile[]> GetRelevantMods(string category)
        {
            relevantCategory = category; //set new relevantcat
            ModFile[] DLmods = new ModFile[0];

            //get downloadable mods, all or select category
            if (category == "" || category == "all")
            {
                DLmods = ModParsing.GetAllMods();
            }
            else
            {
                DLmods = JsonModList.GetDeserializedModListFormatOnline(category).Modlist;
            }
            ModFile[] ILmods = InstalledMods.GetInstalledMods(); //get all installed mods

            List <ModFile> resultDLmods = new List <ModFile>();  //i've never actually used a List before! --potatoes
            List <ModFile> resultILmods = new List <ModFile>();  //that's why 95% of my array code uses resize. oh well, who needs speed!

            for (int i = 0; i < DLmods.Length; i++)
            {
                bool inILmods = false;
                for (int x = 0; x < ILmods.Length; x++)
                {
                    if (DLmods[i].ModId == ILmods[i].ModId)
                    {
                        inILmods = true; break;
                    }                                                                   //if in ilmods, set to true
                }
                if (inILmods)
                {
                    resultILmods.Add(ILmods[i]);
                }                                              //if overlap btwn dl&il, put to il
                else
                {
                    resultDLmods.Add(DLmods[i]);
                }                                     //otherwise, put to dl
                //this also means that if there is an il but no dl, it is discarded.
            }

            return(new Tuple <ModFile[], ModFile[]>(resultDLmods.ToArray(), resultILmods.ToArray()));
        }
예제 #7
0
        public void UpdateModList(string dispcat = "n/a", string filter = "")
        {
            Program.CheckForManuallyUninstalledMods();
            DownloadableModsList.Items.Clear();
            InstalledModsList.Items.Clear();

            if (dispcat == "n/a")
            {
                dispcat = publicdispcat;
            }
            publicdispcat = dispcat;

            var totalmods = ModParsing.GetAllMods();

            if (dispcat == "n/a")
            {
                dispcat = "dependencies";
            }

            Console.WriteLine(dispcat);

            var dispmods = JsonModList.GetDeserializedModListFormatOnline(dispcat).Modlist;

            var installedMods = InstalledMods.GetInstalledMods(); //f**k you

            ModFile[] list = null;

            var relevantint = 0;

            for (var i = 0; i < totalmods.Length; i++)
            {
                //this just checks if the mod we're working with is an installedmod, or a dl mod in isinstldmod
                var isinstldmod = false;
                var x           = 0;
                for (x = 0; x < installedMods.Length; x++)
                {
                    if (totalmods[i].ModId == installedMods[x].ModId)
                    {
                        isinstldmod = true;
                        break;
                    }
                }

                var isdispmod = false;
                for (var y = 0; y < dispmods.Length; y++)
                {
                    if (totalmods[i].ModId == dispmods[y].ModId)
                    {
                        isdispmod = true;
                        break;
                    }
                }

                //sets vars to installedmods or input
                if (isinstldmod)
                {
                    list        = installedMods;
                    relevantint = x;
                }
                else
                {
                    if (publicdispcat == "n/a")
                    {
                        goto Finish;
                    }
                    list        = totalmods;
                    relevantint = i;
                }


                var mod = new ListViewItem(list[relevantint].Name, 0);         //0
                mod.SubItems.Add(list[relevantint].Version);                   //1
                mod.SubItems.Add(string.Join(", ", list[relevantint].Author)); //2
                mod.SubItems.Add(list[relevantint].Description);               //3
                mod.SubItems.Add(list[relevantint].ModId);                     //4

                if (String.IsNullOrEmpty(filter))
                {
                    if (!isinstldmod && isdispmod)
                    {
                        DownloadableModsList.Items.Add(mod);
                    }
                    if (isinstldmod)
                    {
                        InstalledModsList.Items.Add(mod);
                    }
                }
                else
                {
                    //search bar functionality
                    filter = filter.ToLower();
                    var modname      = list[relevantint].Name.ToLower();
                    var authorString = string.Join("", list[relevantint].Author).ToLower();
                    if (modname.Contains(filter) || authorString.Contains(filter))
                    {
                        Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
                        AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

                        Console.WriteLine("");
                        switch (isinstldmod)
                        {
                        case false when isdispmod:
                            DownloadableModsList.Items.Add(mod);
                            break;

                        case true:
                            InstalledModsList.Items.Add(mod);
                            break;
                        }
                    }
                }

                Finish :;
            }

            for (var i = 0; i < InstalledModsList.Items.Count; i++)
            {
                //if cached installed mod is a older version than the database
                if (new Version(InstalledModsList.Items[i].SubItems[1].Text).CompareTo(
                        new Version(ModParsing.GetSpecificMod(InstalledModsList.Items[i].SubItems[4].Text).Version)) < 0)
                {
                    InstalledModsList.Items[i].BackColor = Color.Yellow;
                }

                string delinfo = ModParsing.GetSpecificMod(InstalledModsList.Items[i].SubItems[4].Text).DelInfo; //if cached mod is disabled

                if (!String.IsNullOrEmpty(delinfo))
                {
                    string path =
                        Path.Combine(Utilities.GameDirectory,
                                     delinfo.Split('?')[0]);                                    //split to get the first delinfo arg
                    string path2 = Path.Combine(Utilities.DisableCache,
                                                new DirectoryInfo(delinfo.Split('?')[0]).Name); //basically loc of the cache area
                    if ((!File.Exists(path) && !Directory.Exists(path)) &&
                        (File.Exists(path2) || Directory.Exists(path2)))                        //if it is not disabled
                    {
                        InstalledModsList.Items[i].BackColor = Color.Gray;
                        UpdateButton.Hide();
                    }
                    else
                    {
                        UpdateButton.Show();
                    }
                }
            }
        }
예제 #8
0
        private void InstalledModsList_SelectedIndexChanged(object sender, EventArgs e)
        {
            UpdateButton.Show();
            Delete.Show();
            CheckButton.Show();
            DisEnaButton.Show();
            try
            {
                ModFile modinfo = ModParsing.GetSpecificMod(InstalledModsList.SelectedItems[0].SubItems[4].Text);

                //if cached mod is disabled
                if (!String.IsNullOrEmpty(modinfo.DelInfo))
                {
                    string path =
                        Path.Combine(Utilities.GameDirectory,
                                     modinfo.DelInfo.Split('?')[0]);   //split to get the first delinfo arg
                    if (!File.Exists(path) && !Directory.Exists(path)) //if it is not disabled
                    {
                        DisEnaButton.Text = "Enable";
                        if (modinfo.Version == "0.0.0")
                        {
                            UpdateButton.Hide();
                        }
                    }
                    else
                    {
                        DisEnaButton.Text = "Disable";
                        UpdateButton.Show();
                    }
                }
            } catch {}


            ModVer.Show();
            try
            {
                trycatchtext(SelectedModText, "Selected Mod: " + DownloadableModsList.SelectedItems[0].Text);
                trycatchtext(ModInfo, DownloadableModsList.SelectedItems[0].SubItems[3].Text);
                impModID = new string[DownloadableModsList.SelectedItems.Count];
                for (int i = 0; i < DownloadableModsList.SelectedItems.Count; i++)
                {
                    impModID[i] = DownloadableModsList.SelectedItems[i].SubItems[4].Text;
                }
            }
            catch
            {
                // ignored
            }

            try
            {
                impModID = new string[InstalledModsList.SelectedItems.Count];
                for (int i = 0; i < InstalledModsList.SelectedItems.Count; i++)
                {
                    impModID[i] = InstalledModsList.SelectedItems[i].SubItems[4].Text;
                }
//                impModID = InstalledModsList.SelectedItems[0].SubItems[4].Text;
                SelectedModText.Text = "Selected Mod: " + InstalledModsList.SelectedItems[0].Text;
                ModInfo.Text         = InstalledModsList.SelectedItems[0].SubItems[3].Text;
                ModVer.Text          = "Current Ver: " + InstalledModsList.SelectedItems[0].SubItems[1].Text +
                                       ", Online Version: " + ModParsing
                                       .GetSpecificMod(InstalledModsList.SelectedItems[0].SubItems[4].Text).Version;
            }
            catch
            {
            }
        }
예제 #9
0
        public void UpdateModList(string dispcat = "n/a")
        {
            DownloadableModsList.Items.Clear();
            InstalledModsList.Items.Clear();

            if (dispcat == "n/a")
            {
                dispcat = publicdispcat;
            }
            publicdispcat = dispcat;

            var totalmods = JsonCommon.GetAllMods();

            if (dispcat == "n/a")
            {
                dispcat = "dependencies";
            }

            Console.WriteLine(dispcat);

            var dispmods = JsonModList.GetDeserializedModListFormatOnline(dispcat).Modlist;

            var installedMods = H3VRModInstaller.Backend.JSON.InstalledMods.GetInstalledMods(); //f**k you

            ModFile[] list = null;

            var relevantint = 0;

            for (var i = 0; i < totalmods.Length; i++)
            {
                //this just checks if the mod we're working with is an installedmod, or a dl mod in isinstldmod
                var isinstldmod = false;
                var x           = 0;
                for (x = 0; x < installedMods.Length; x++)
                {
                    if (totalmods[i].ModId == installedMods[x].ModId)
                    {
                        isinstldmod = true;
                        break;
                    }
                }

                var isdispmod = false;
                for (int y = 0; y < dispmods.Length; y++)
                {
                    if (totalmods[i].ModId == dispmods[y].ModId)
                    {
                        isdispmod = true;
                        break;
                    }
                }

                //sets vars to installedmods or input
                if (isinstldmod)
                {
                    list        = installedMods;
                    relevantint = x;
                }
                else
                {
                    if (publicdispcat == "n/a")
                    {
                        goto Finish;
                    }
                    list        = totalmods;
                    relevantint = i;
                }


                var mod = new ListViewItem(list[relevantint].Name, 0); //0
                mod.SubItems.Add(list[relevantint].Version);           //1
                mod.SubItems.Add(list[relevantint].Author[0]);         //2
                mod.SubItems.Add(list[relevantint].Description);       //3
                mod.SubItems.Add(list[relevantint].ModId);             //4


                if (!isinstldmod && isdispmod)
                {
                    DownloadableModsList.Items.Add(mod);
                }
                if (isinstldmod)
                {
                    InstalledModsList.Items.Add(mod);
                }
                Finish :;
            }

            for (int i = 0; i < InstalledModsList.Items.Count; i++)
            {
                //if cached installed mod is a older version than the database
                if (new Version(InstalledModsList.Items[i].SubItems[1].Text).CompareTo(new Version(ModParsing.GetSpecificMod(InstalledModsList.Items[i].SubItems[4].Text).Version)) < 0)
                {
                    InstalledModsList.Items[i].BackColor = System.Drawing.Color.Yellow;
                }
            }
        }