public void SetMods(ModPack pack)
        {
            bool writingMods                  = false;
            IEnumerable <string> data         = File.ReadLines(Helpers.SettingsFilePath);
            List <string>        linesToWrite = new List <string>();

            foreach (string d in data)
            {
                // start element of mod list
                if (d.Equals("last_mods={"))
                {
                    writingMods = true;
                }

                // end element of mod list
                if (writingMods && d.Equals("}"))
                {
                    writingMods = false; linesToWrite.AddRange(GetModsListForSettingsFile(pack));
                }

                // read mod id
                if (!writingMods)
                {
                    linesToWrite.Add(d);
                }
            }

            File.WriteAllLines(Helpers.SettingsFilePath, linesToWrite.ToArray());
        }
 private IEnumerable <string> GetModsListForSettingsFile(ModPack pack)
 {
     return(pack.Mods.Select(m => $"\t\"mod/ugc_{m}.mod\""));
 }
Exemple #3
0
 public void AddOrUpdatePack(ModPack pack)
 {
     // get the pack
     RemovePackByName(pack.Name);
     Packs.Add(pack);
 }