Example #1
0
 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();
 }
Example #2
0
        public EditActions(Mod m)
        {
            targetMod = m;
            ModTempDir = m.ExtractedRoot.FullName;
            MinecraftBase = StateProvider.ActiveInstancePaths.minecraftRoot;
            ModName = m.Name;
            Actions = new ObservableCollection<IFSAction>(m.InstallActions);

            InitializeComponent();
        }
Example #3
0
 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;
 }
Example #4
0
 public void updateMod(Mod m)
 {
     removeMod(m);
     addMod(m);
 }
Example #5
0
        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();
        }
Example #6
0
 public void removeMod(Mod m)
 {
     removeMod(m.FilePath);
 }
Example #7
0
        public Mod getMod(int id)
        {
            XElement xE = getXMod(id);

            Mod retVal = new Mod(xE);
            retVal.IDChanged += IDChangeHandler;
            retVal.TempPath = paths.tempDir;
            return retVal;
        }
Example #8
0
 public void addFileCopyAction(Mod m, string source, string dest)
 {
     FileCopyAction act = new FileCopyAction(source, dest);
     m.InstallActions.Add(act);
     m_config.updateMod(m);
 }
Example #9
0
 public void addDirCopyAction(Mod m, string source, string dest)
 {
     DirectoryCopyAction act = new DirectoryCopyAction(source, dest);
     m.InstallActions.Add(act);
     m_config.updateMod(m);
 }
Example #10
0
 public void addAction(Mod m, IFSAction action)
 {
     m.InstallActions.Add(action);
 }
Example #11
0
 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);
 }