public void addMod(Mod m) { XElement modElement = new XElement("Mod", new XElement("Name", Path.GetFileNameWithoutExtension(m.FilePath)), new XElement("Destination", m.Destination), new XElement("Path", m.FilePath), new XElement("ID", m.ID), new XElement("Active", m.Active) ); XElement installActions = new XElement("InstallActions"); foreach (IFSAction act in m.InstallActions) { installActions.Add(new XElement(act.GetType().ToString(), new XElement("source", act.source), new XElement("target", act.target))); } modElement.Add(installActions); IEnumerable<XElement> modTest = from c in document.Descendants("Mod") where (string)c.Element("Path") == m.FilePath select c; if (modTest.Count() > 0) { throw new exceptions.DuplicateItemException("mod: " + m.Name + "is already in the config file"); } document.Root.Add(modElement); m_numMods++; save(); }
public EditActions(Mod m) { targetMod = m; ModTempDir = m.ExtractedRoot.FullName; MinecraftBase = StateProvider.ActiveInstancePaths.minecraftRoot; ModName = m.Name; Actions = new ObservableCollection<IFSAction>(m.InstallActions); InitializeComponent(); }
private List<Mod> processXMods(IEnumerable<XElement> xmods ) { List<Mod> retval = new List<Mod>(); foreach (XElement x in xmods) { Mod current = new Mod(x); current.IDChanged += IDChangeHandler; current.ActiveChanged += ActiveChangeHandler; current.TempPath = paths.tempDir; retval.Add(current); } return retval; }
public void updateMod(Mod m) { removeMod(m); addMod(m); }
public void updateID(Mod m) { XElement xMod = getXMod(m.Name).Element("ID"); try { Mod modInID = getMod(m.ID); if (modInID.FilePath != m.FilePath) { modInID.ID++; } } catch (exceptions.ElementNotFoundException e) { StreamWriter log = new StreamWriter(Path.Combine(paths.appLogDir, "log.txt")); log.WriteLine("mod not found, reached the end of ID update"); log.Close(); } xMod.Value = m.ID.ToString(); save(); }
public void removeMod(Mod m) { removeMod(m.FilePath); }
public Mod getMod(int id) { XElement xE = getXMod(id); Mod retVal = new Mod(xE); retVal.IDChanged += IDChangeHandler; retVal.TempPath = paths.tempDir; return retVal; }
public void addFileCopyAction(Mod m, string source, string dest) { FileCopyAction act = new FileCopyAction(source, dest); m.InstallActions.Add(act); m_config.updateMod(m); }
public void addDirCopyAction(Mod m, string source, string dest) { DirectoryCopyAction act = new DirectoryCopyAction(source, dest); m.InstallActions.Add(act); m_config.updateMod(m); }
public void addAction(Mod m, IFSAction action) { m.InstallActions.Add(action); }
public void removeMod(Mod m) { DirectoryInfo tempRoot = m.ExtractedRoot; if (m.Destination == ModDestinations.COMPLEX) { foreach (IFSAction act in m.InstallActions) { if (act is IReversibleFSAction) { (act as IReversibleFSAction).reverse(Paths); } } } tempRoot.Delete(true); }