//Add a new empty mod to the list private void buttonAddMod_Click(object sender, EventArgs e) { MM_ModData newMod = new MM_ModData(); newMod.enabled = false; newMod.mcVersion = settings.mainMcVersion; newMod.repoFolder = settings.repo; repo.modlist.Add(newMod); ReloadModList(); }
//Reloads the mod list view and selected mod info private void ReloadModList() { updatingData = true; listViewMods.Items.Clear(); listViewMods.SelectedIndices.Clear(); selectedMod = new MM_ModData(); foreach (MM_ModData mod in repo.modlist) { ListViewItem lvi = new ListViewItem(mod.mcVersion); lvi.SubItems.Add(mod.modslug); lvi.SubItems.Add(mod.urlState); lvi.SubItems.Add(mod.versionLocal); lvi.SubItems.Add(mod.versionOnline); lvi.SubItems.Add(mod.actionState); lvi.SubItems.Add(mod.website1); lvi.SubItems.Add(mod.website2); lvi.SubItems.Add(mod.website3); lvi.SubItems.Add(mod.website4); lvi.SubItems.Add(mod.website5); lvi.Checked = mod.enabled; listViewMods.Items.Add(lvi); } if (selectedIndex < repo.modlist.Count && selectedIndex > -1) { listViewMods.SelectedIndices.Add(selectedIndex); selectedMod = repo.modlist[selectedIndex]; } SetModInfoBox(); updatingData = false; }
//Selects a new mod and reloads information private void listViewMods_SelectedIndexChanged(object sender, EventArgs e) { if (!updatingData && listViewMods.SelectedIndices.Count > 0) { selectedIndex = listViewMods.SelectedIndices[0]; selectedMod = repo.modlist[selectedIndex]; SetModInfoBox(); } }
//Creates a duplicate of the currently selected mod with a nem mc version private void buttonOneDuplicate_Click(object sender, EventArgs e) { MM_ModData newMod = new MM_ModData(); newMod.modslug = selectedMod.modslug; newMod.enabled = selectedMod.enabled; newMod.websiteCheck = selectedMod.websiteCheck; newMod.versionLocal = selectedMod.versionLocal; newMod.mcVersion = textBoxModNewMcVersion.Text; repo.modlist.Add(newMod); ReloadModList(); }
//Adds all missing mods from the downloaded solder list private void solderDownloadCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e != null && e.Error == null && !String.IsNullOrEmpty(e.Result)) { List<string> modslugs = new List<string>(); List<int> modids = new List<int>(); using (StringReader sr = new StringReader(e.Result)) { string currentline = sr.ReadLine(); while (currentline != null) { currentline = currentline.Trim(); if (currentline.Contains("<a href=\"" + solderUrl + "mod/view/")) { modslugs.Add(MiscFunctions.ExtractSection(currentline, "</a> (", ")")); modids.Add(Convert.ToInt32(MiscFunctions.ExtractSection(currentline, "/view/", "\""))); } currentline = sr.ReadLine(); } } for (int i = 0; i < modslugs.Count; i++) { string slug = modslugs[i]; int id = modids[i]; if (slug != "") { MM_ModData mod = GetModWithSlug(slug); if (mod == null) { MM_ModData newMod = new MM_ModData(); newMod.modslug = slug; newMod.mcVersion = repoMcVersion; newMod.repoFolder = repoDir; newMod.solderID = id; modlist.Add(newMod); } else mod.solderID = id; } } } mustReloadListView = true; }
//Updates the moddata of the current repo private void UpdateRepoData() { if (Directory.Exists(repoDir)) { List<string> modSlugFolders = new List<string>(Directory.GetDirectories(repoDir + "/mods")); foreach (string folder in modSlugFolders) { string slug = folder.Replace(repoDir + "/mods\\", ""); if (GetModWithSlug(slug) == null) { MM_ModData mod = new MM_ModData(); mod.modslug = slug; mod.mcVersion = repoMcVersion; modlist.Add(mod); } } } foreach (MM_ModData mod in modlist) { mod.repoFolder = repoDir; mod.Initialise(); } }