public SelectModsForm(Mod[] optional, Mod[] selectedOptional) { InitializeComponent(); selected = new List<Mod>(selectedOptional); unselected = new List<Mod>(); foreach (Mod m in optional) { if (!selectedOptional.Contains(m)) { unselected.Add(m); } } }
private void UnselectMod(Mod m) { string requiredBy = ""; foreach (Mod mod in m.RequiredBy.ToArray()) { if (m.RequiredBy.Contains(mod)) requiredBy += mod.Name + ", "; } if (requiredBy != "") { MessageBox.Show("This mod is required by other mods! \nYou must remove " + requiredBy.Remove(requiredBy.Length - 2) + " before removing this one."); } selected.Remove(m); lsSelected.Items.Remove(m); lsUnselected.Items.Add(m); unselected.Add(m); }
private void SelectMod(Mod m) { foreach (Mod mod in unselected.ToArray()) { if (m.Requires.Contains(mod.Identifier)) { SelectMod(mod); } } selected.Add(m); lsSelected.Items.Add(m); lsUnselected.Items.Remove(m); unselected.Remove(m); }
void ph_NextDownload(Packet pa) { NextDownloadPacket p = pa as NextDownloadPacket; Thread.Sleep(100); progress[1] = 0; progress[2] = p.ChunkSize; CurrentDownload = Mods.Find(p.Identifier); CurrentDownload.Contents = new byte[CurrentDownload.Size]; if(!Server.Shutdown) SplashScreen.UpdateStatusText("Downloading " + CurrentDownload.Name); else SplashScreen.UpdateStatusTextWithStatus("Downloading " + CurrentDownload.Name + "(Server Shutdown Mode)", TypeOfMessage.Warning); MinecraftModUpdater.Logger.Log(Logger.Level.Info, "Starting download of " + CurrentDownload.Name); if(modImages.Images.ContainsKey(CurrentDownload.File)) SplashScreen.GetScreen().setDownloadPicture(modImages.Images[CurrentDownload.File]); CurrentDownload.PostDownload = p.PostDownloadCLI; string path = Properties.Settings.Default.MinecraftPath + "\\" + CurrentDownload.File.Replace(CurrentDownload.File.Split('\\').Last(), "").TrimEnd('\\').Replace("clientmods", "mods"); bool exists = Directory.Exists(path); if (!exists) Directory.CreateDirectory(path); }
void ph_ModInfo(Packet pa) { ModInfoPacket p = pa as ModInfoPacket; Mod m = new Mod { Author = p.Author, File = p.File, Name = p.ModName, Hash = p.Hash, Size = p.FileSize, Description = p.Description, Identifier = p.Identifier, Optional = p.Optional, Requires = p.Requires.ToList() }; if (m.Optional) { OptionalMods.Add(m); } else { Mods.Add(m); } string path = Path.GetDirectoryName(Properties.Settings.Default.MinecraftPath + "\\" + p.File); string s = ""; bool exists = File.Exists(path + "\\" + Path.GetFileName(m.File)); if (exists) { try { s = Extras.GenerateHash(path + "\\" + Path.GetFileName(m.File)); } catch (Exception e) { MinecraftModUpdater.Logger.Log(e); } } if ((!exists && !m.Optional) || (s != m.Hash && !m.Optional)) { Program.RunOnUIThread(delegate { lsModsToUpdate.Items.Add(m); }); } else if (!m.Optional) { Program.RunOnUIThread(delegate { lsMods.Items.Add(m); }); } if (exists && m.Optional && s == m.Hash) { Mods.Add(m); Program.RunOnUIThread(delegate { lsMods.Items.Add(m); }); } else if (exists && m.Optional && s != m.Hash) { Mods.Add(m); Program.RunOnUIThread(delegate { lsModsToUpdate.Items.Add(m); }); } MinecraftModUpdater.Logger.Log(Logger.Level.Debug, "Info: " + m.Name); string str = GetLastModId(); if (str == m.Identifier) { foreach (string str1 in Directory.GetFiles(Properties.Settings.Default.MinecraftPath + @"\mods")) { string str2 = @"mods\" + Path.GetFileName(str1); Mod mod = Mods.FindFromFile(str2); bool file = mod != null; if (!file) Program.RunOnUIThread(delegate { lsModsToDelete.Items.Add(Path.GetFileName(str1)); }); } } if (str == m.Identifier && Properties.Settings.Default.AutoUpdate) { Program.RunOnUIThread(delegate { btnConfirm_Click(null, null); }); } else if (str == m.Identifier) { List<Mod> allMods = new List<Mod>(); allMods.AddRange(Mods); allMods.AddRange(OptionalMods); foreach (Mod mod in Mods) { mod.BuildRequiredByList(allMods.ToArray().ToList()); //Just so that we don't modify the mod list. } foreach (Mod mod in OptionalMods) { mod.BuildRequiredByList(allMods.ToArray().ToList()); //Just so that we don't modify the mod list. } Program.RunOnUIThread(delegate { SplashScreen.CloseSplashScreen(); Show(); }); } else if(str != m.Identifier && !Properties.Settings.Default.AutoUpdate) { Program.RunOnUIThread(delegate { if (Visible) Hide(); }); } }
public ModInfoForm(Mod m) { mod = m; InitializeComponent(); }