private static void CheckForManualInstalledMods() { ModFile[] mods = JsonCommon.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); } }
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; } } }