///returns list of mods in a modlist public static void list(string input) { var jsonname = input + ".json"; var jsonfiles = JsonModList.GetDatabaseURLs(); for (var i = 0; i < jsonfiles.Length; i++) { var _split = jsonfiles[i].Split('/'); jsonfiles[i] = _split[_split.Length - 1]; } var foundmod = false; for (var i = 0; i < jsonfiles.Length; i++) { if (jsonname == jsonfiles[i]) { foundmod = true; var mods = JsonModList.DeserializeModListFormat(jsonname); for (var x = 0; x < mods.Modlist.Length; x++) { Console.WriteLine(mods.Modlist[x].ModId); } } } if (foundmod == false) { Console.WriteLine("List not found!"); } }
public void UpdateCatagories() { var catagories = JsonModList.GetModLists(); for (var i = 0; i < catagories.Length; i++) { CatagoriesComboBox.Items.Add(catagories[i].ModListName); } }
/// <summary> /// Gets all mods, from the JSON files /// </summary> /// <returns><c>ModFile</c> Array</returns> public static ModFile[] GetAllMods() { var result = new ModFile[0]; var jsonfiles = JsonModList.GetModLists(); for (var i = 0; i < jsonfiles.Length; i++) { result = result.Concat(jsonfiles[i].Modlist).ToArray(); } return(result); }
public void UpdateCatagories() { var catagories = JsonModList.GetModLists(); for (int i = 0; i < catagories.Length; i++) { // var mod = new ListViewItem(catagories[i].modlistname, 0); //0 // mod.SubItems.Add(catagories[i].modlistid); //1 CatagoriesComboBox.Items.Add(catagories[i].ModListName); } }
private void LoadGUI(object sender, EventArgs e) { InitTimer(); //progress timer AllocConsole(); //enables console JsonCommon.OverrideModInstallerVariables(); //overrides vars if possible //check if in vs string dir = Directory.GetCurrentDirectory(); for (int i = 0; i < 3; i++) { dir = Directory.GetParent(dir).ToString(); //move up 3 dirs } dir += @"\bin\"; //add bin Console.WriteLine(ModInstallerCommon.Files.MainFiledir); Console.WriteLine("Detecting for" + ModInstallerCommon.Files.execdir); if (!File.Exists(ModInstallerCommon.Files.execdir) && !ModInstallerCommon.BypassExec && !Directory.Exists(dir)) { MessageBox.Show("ModInstaller cannot find the executable! Make sure my location is in a folder inside the h3vr directory! Just in case, I'll pull up a tutorial for you.", "Exectuable not found!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); var psi = new ProcessStartInfo { FileName = "https://youtu.be/LBcxS_mYLFE?t=21", UseShellExecute = true }; Process.Start(psi); Application.Exit(); } var onlineversion = new Version(JsonModList.GetDeserializedModListFormatOnline(JsonCommon.DatabaseInfo).Modlist[0].Version); if (ModInstallerCommon.ModInstallerVersion.CompareTo(onlineversion) < 0) { MessageBox.Show("H3VRModInstaller is out of date! (" + ModInstallerCommon.ModInstallerVersion + " vs " + onlineversion + ")", "Wrong version detected!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); var psi = new ProcessStartInfo { FileName = JsonModList.GetDeserializedModListFormatOnline(JsonCommon.DatabaseInfo).Modlist[0].Website, UseShellExecute = true }; Process.Start(psi); } InstallButton.Hide(); UpdateButton.Hide(); ModVer.Hide(); Delete.Hide(); CheckButton.Hide(); InstalledModsList.Hide(); ModsEnabled.Checked = true; UpdateModList(); UpdateCatagories(); }
/// <summary> /// Backend input /// </summary> /// <param name="inputargs">Input</param> /// public static void doCommand(string[] inputargs) { switch (inputargs[0]) { case "wipe": File.Delete(Utilities.ModCache); Console.WriteLine("Wiped!"); break; case "check": var ml = JsonModList.GetModLists(); for (var i = 0; i < ml.Length; i++) { for (var x = 0; x < ml[i].Modlist.Length; x++) { if (ml[i].Modlist[x].ModId == inputargs[1]) { var link = ml[i].Modlist[x].Website; var psi = new ProcessStartInfo { FileName = link, UseShellExecute = true }; Process.Start(psi); } } } break; case "dl": Downloader.DownloadModDirector(inputargs[1]); break; case "toggledebugging": ModInstallerCommon.enableDebugging = !ModInstallerCommon.enableDebugging; Console.WriteLine("Debugging is now " + ModInstallerCommon.enableDebugging); break; //deletion case "rm": Console.WriteLine($"Deleting {inputargs[1]}"); Uninstaller.DeleteMod(inputargs[1]); break; default: Console.WriteLine("Invalid command!"); break; } }
private void CatagoriesComboBox_SelectedIndexChanged(object sender, EventArgs e) { string name = CatagoriesComboBox.SelectedItem.ToString(); var catagories = JsonModList.GetModLists(); for (int i = 0; i < catagories.Length; i++) { if (catagories[i].ModListName == name) { try { UpdateModList(catagories[i].ModListID); } catch (Exception exception) { Console.WriteLine(exception); } break; } } }
/// <summary> /// Gets the mod info of a deserialized <c>ModFile</c> class /// </summary> /// <param name="modid">Modid of mod you want</param> /// <returns></returns> public static ModFile GetSpecificMod(string modid) { var ml = JsonModList.GetModLists(); for (var i = 0; i < ml.Length; i++) { for (var x = 0; x < ml[i].Modlist.Length; x++) { if (ml[i].Modlist[x].ModId == modid) { return (ml[i].Modlist[x]); //sift through every goddamn modfile and find the one with the matching modid } } } return(null); }
public IEnumerable <ModItem> GetDownloadableItems() { var modList = JsonModList.GetModLists(); var listItems = ( from modlistarr in modList from modfile in modlistarr.Modlist select new ModItem { Name = modfile.Name, Authors = Actions.ArrayToString(modfile.Author), Description = modfile.Description } ).ToList(); return(listItems); }
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())); }
private void CheckButton_Click(object sender, EventArgs e) { var ml = JsonModList.GetModLists(); for (var i = 0; i < ml.Length; i++) { for (var x = 0; x < ml[i].Modlist.Length; x++) { if (ml[i].Modlist[x].ModId == impModID[0]) { var link = ml[i].Modlist[x].Website; var psi = new ProcessStartInfo { FileName = link, UseShellExecute = true }; Process.Start(psi); } } } }
private void LoadGUI(object sender, EventArgs e) { KeyDown += Form_KeyDown; if (!File.Exists(Utilities.ModCache)) { MessageBox.Show("Thank you for downloading H3VRModInstaller!\nIf there are any issues, or if you want a mod added, please hit us up on the Homebrew discord (@Frityet and @Potatoes)", "Thank you!", MessageBoxButtons.OK, MessageBoxIcon.Information); } InitTimer(); //progress timer //AllocConsole(); //enables console JsonCommon.OverrideModInstallerVariables(); //overrides vars if possible var onlineversion = new Version(JsonModList.GetDeserializedModListFormatOnline(JsonCommon.DatabaseInfo) .Modlist[0].Version); if (ModInstallerCommon.ModInstallerVersion.CompareTo(onlineversion) < 0) { MessageBox.Show("H3VRModInstaller is out of date! (" + ModInstallerCommon.ModInstallerVersion + " vs " + onlineversion + ")", "Out of date version detected!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); var psi = new ProcessStartInfo { FileName = JsonModList.GetDeserializedModListFormatOnline(JsonCommon.DatabaseInfo) .Modlist[0] .Website, UseShellExecute = true }; Process.Start(psi); } InstallButton.Hide(); UpdateButton.Hide(); ModVer.Hide(); Delete.Hide(); CheckButton.Hide(); UpdateModList(); UpdateCatagories(); CatagoriesComboBox.SelectedIndex = 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(); } } } }
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; } } }
/// <summary> /// Backend input /// </summary> /// <param name="inputargs">Input</param> public static void doCommand(string[] inputargs) { switch (inputargs[0]) { case "reload": JsonModList.GetModLists(true); break; case "wipe": File.Delete(Directory.GetCurrentDirectory() + @"\installedmods.json"); Console.WriteLine("Wiped!"); break; case "modlists": listmodlists(); break; case "check": var ml = JsonModList.GetModLists(); for (var i = 0; i < ml.Length; i++) { for (var x = 0; x < ml[i].Modlist.Length; x++) { if (ml[i].Modlist[x].ModId == inputargs[1]) { var link = ml[i].Modlist[x].Website; var psi = new ProcessStartInfo { FileName = link, UseShellExecute = true }; Process.Start(psi); } } } break; case "dl": Downloader.DownloadModDirector(inputargs[1]); break; case "install": Downloader.DownloadModDirector(inputargs[1], true); break; case "list": if (inputargs[1] == "installedmods") { var mf = InstalledMods.GetInstalledMods(); for (var i = 0; i < mf.Length; i++) { Console.WriteLine(mf[i].Name); } } else { list(inputargs[1]); } break; case "exit": return; case "help": Console.WriteLine("wipe - Wipes the installed registry (DOES NOT DELETE MODS)"); Console.WriteLine("modlists - Lists all modlists, which are lists of mods."); Console.WriteLine("dl [modname] - Downloads mod listed."); Console.WriteLine("check [modname] - Opens browser to modpage."); Console.WriteLine("list [modlist] - Lists all mods contained in a modlist."); Console.WriteLine("list installedmods - Lists all mods registered as installed."); Console.WriteLine("exit - Close H3VRModInstaller."); break; case "toggledebugging": ModInstallerCommon.enableDebugging = !ModInstallerCommon.enableDebugging; Console.WriteLine("Debugging is now " + ModInstallerCommon.enableDebugging); break; //deletion case "rm": Console.WriteLine($"Deleting {inputargs[1]}"); Uninstaller.DeleteMod(inputargs[1]); break; default: Console.WriteLine("Invalid command!"); break; } }