Ejemplo n.º 1
0
        /// <summary>
        ///     Changes the silo total amount.
        /// </summary>
        public void ChangeSiloTotalAmount(string saveGame)
        {
            if (saveGame.IsNullOrEmpty())
            {
                MsgBx.Msg("You did not choose a SaveGame to Modify", "Profile Error");
                return;
            }

            var pth = saveGame + "careerSavegame.xml";

            if (!pth.FileExists())
            {
                return;
            }

            var doc = XDocument.Load(pth);
            var q   = from node in doc.Descendants()
                      where node.Name == "totalAmount"
                      where node.Attributes().Any()
                      select new { NodeName = node.Name, Attributes = node.Attributes() };

            foreach (var node in q)
            {
                foreach (var attribute in node.Attributes)
                {
                    if (attribute.Name == "value")
                    {
                        attribute.SetValue(AMOUNT);
                    }
                }
            }
            doc.Save(pth);

            MsgBx.Msg("Cheat - Change Silo Capacity - has been applied to " + saveGame.GetLastFolderName(), "Cheat");
        }
Ejemplo n.º 2
0
        private static void DeleteMods()
        {
            var    reg = new AtsRegWork(true);
            var    gam = reg.Read(RegKeys.CURRENT_GAME);
            string pth;
            IEnumerable <string> lst;

            switch (gam)
            {
            case "ATS":
                pth = reg.Read(AtsRegKeys.ATS_GAME_MOD_FOLDER);
                if (!pth.FolderExists())
                {
                    return;
                }
                lst = GetFilesFolders.GetFiles(pth, "*.*");
                foreach (var t in lst)
                {
                    try {
                        DeleteFile(t);
                    }
                    catch (Exception g) {
                        MsgBx.Msg(g.ToString(), "Error");
                    }
                }

                FolderCreator.CreatePublicFolders(reg.Read(AtsRegKeys.ATS_GAME_MOD_FOLDER));
                break;

            case "ETS":
                pth = reg.Read(EtsRegKeys.ETS_GAME_MOD_FOLDER);
                if (!pth.FolderExists())
                {
                    return;
                }
                lst = GetFilesFolders.GetFiles(pth, "*.*");
                foreach (var s in lst)
                {
                    try {
                        DeleteFile(s);
                    }
                    catch (Exception g) {
                        MsgBx.Msg(g.ToString(), "Error");
                    }
                }

                FolderCreator.CreatePublicFolders(reg.Read(EtsRegKeys.ETS_GAME_MOD_FOLDER));
                break;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Creates the sym link.
        /// </summary>
        /// <param name="symLinkFileName">Name of the file.</param>
        /// <param name="targetName">Name of the target.</param>
        /// <param name="num">The number.</param>
        /// <exception cref="Win32Exception"></exception>
        public static void CreateSymLink(string symLinkFileName, string targetName, uint num)
        {
            if (symLinkFileName.FileExists())
            {
                return;
            }
            var success = CreateSymbolicLink(symLinkFileName, targetName, num);

            if (success)
            {
                return;
            }
            // var error = Marshal.GetLastWin32Error();
            MsgBx.Msg("There was a problem with the path creating the link, link creation failure", "Link Creator");
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Removes the mod.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns></returns>
        public Dictionary <string, string> ProfileRemoveMod(string key)
        {
            var reg     = new AtsRegWork(true);
            var gam     = reg.Read(RegKeys.CURRENT_GAME);
            var profile = reg.Read(RegKeys.CURRENT_PROFILE);
            var modPath = string.Empty;

            switch (gam)
            {
            case "ATS":
                modPath = reg.Read(AtsRegKeys.ATS_PROFILES) + profile + "\\" + profile + XML_EXT;
                break;

            case "ETS":
                modPath = reg.Read(EtsRegKeys.ETS_PROFILES) + profile + "\\" + profile + XML_EXT;
                break;

            case "FS15":
                modPath = reg.Read(Fs15RegKeys.FS15_PROFILES) + profile + "\\" + profile + XML_EXT;
                break;

            case "FS17":
                modPath = reg.Read(Fs17RegKeys.FS17_PROFILES) + profile + "\\" + profile + XML_EXT;
                break;
            }

            var dic = Serializer.DeserializeDictionary(modPath);

            if (dic.Any(v => string.Equals(v.Key, key, StringComparison.OrdinalIgnoreCase)))
            {
                var mod = reg.Read(Fs17RegKeys.FS17_PROFILES) + profile + "\\" + key;
                dic.Remove(key);
                DeleteFiles.DeleteFilesOrFolders(mod);

                var ls = new ListCreator();
                ls.CreateSortedLists();
                ls.SortedFileListComplete();
                MsgBx.Msg("Operation completed successfully", "Mod Remover");
            }

            Serializer.SerializeDictionary(modPath, dic);

            return(dic);
        }