Exemple #1
0
        private void reMakeModListsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var lc = new ListCreator();

            lc.CreateSortedLists();
            lc.SortedFileListComplete();
        }
Exemple #2
0
        private void sortModsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var sort = new ModSorter();
            var lc   = new ListCreator();

            sort.SortMods();
            sort.DoDeepSort();
            lc.CreateSortedLists();
            lc.SortedFileListComplete();
        }
        /// <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);
        }
Exemple #4
0
        /// <summary>
        /// </summary>
        public void MoveMod(string mod)
        {
            var loc = GetLocation();

            if (loc.IsNullOrEmpty())
            {
                return;
            }
            if (!mod.FileExists())
            {
                return;
            }
            FileCopyMove.FileCopy(mod, loc + mod.GetFileName(), true);

            var ls = new ListCreator();

            ls.CreateSortedLists();
            ls.SortedFileListComplete();

            MsgBx.Msg("Operation completed successfully..", "Mod Mover");
        }
Exemple #5
0
        private void DeleteRepoMod(string pth)
        {
            var    reg = new AtsRegWork(true);
            var    gam = reg.Read(RegKeys.CURRENT_GAME);
            var    dic = Serializer.DeserializeDictionary(pth);
            var    lc  = new ListCreator();
            var    key = lstAvailableMods.SelectedItem.ToString();
            string pt;

            if (!dic.Any(v => string.Equals(v.Key, key, StringComparison.OrdinalIgnoreCase)))
            {
                return;
            }
            dic.TryGetValue(key, out pt);
            var mPth = pt + key;

            DeleteFiles.DeleteFilesOrFolders(mPth);
            lstAvailableMods.Items.Remove(key);
            lc.CreateSortedLists();
            lc.SortedFileListComplete();
            switch (gam)
            {
            case "ETS":
                EtsLoad();
                break;

            case "ATS":
                AtsLoad();
                break;

            case "FS15":
                Fs15Load();
                break;

            case "FS17":
                Fs17Load();
                CheckModCount();
                break;
            }
        }
        public void OrganizeMaps()
        {
            var mapLst = new List <string> {
                "map",
                "Map"
            };

            var reg = new AtsRegWork(true);
            var gam = reg.Read(RegKeys.CURRENT_GAME);

            if (gam.IsNullOrEmpty())
            {
                MsgBx.Msg("Mod Sorting is Game specific, you need to choose a game", "Game Error");
                return;
            }

            SetSearchLists();

            string tmp;
            IEnumerable <string> lst;

            switch (gam)
            {
            case "ATS":
                tmp = reg.Read(AtsRegKeys.ATS_REPO);
                lst = GetFilesFolders.GetFiles(tmp, "*.scs");
                if (lst.IsNull())
                {
                    return;
                }
                foreach (var v in lst)
                {
                    foreach (var t in _srchLstTs)
                    {
                        if (!v.Contains(t, StringComparison.OrdinalIgnoreCase))
                        {
                            continue;
                        }
                        FolderCreator.CreatePublicFolders(reg.Read(AtsRegKeys.ATS_GROUPS) + t);
                        FileCopyMove.FileCopy(v, reg.Read(AtsRegKeys.ATS_GROUPS) + t + "\\" + v.GetFileName(),
                                              true);
                    }
                }

                break;

            case "ETS":
                var ets = new EtsRegWork(true);
                tmp = ets.Read(EtsRegKeys.ETS_REPO);
                lst = GetFilesFolders.GetFiles(tmp, "*.scs");
                if (lst.IsNull())
                {
                    return;
                }
                foreach (var v in lst)
                {
                    foreach (var t in _srchLstTs)
                    {
                        if (!v.Contains(t, StringComparison.OrdinalIgnoreCase))
                        {
                            continue;
                        }
                        FolderCreator.CreatePublicFolders(ets.Read(EtsRegKeys.ETS_GROUPS) + t);
                        FileCopyMove.FileCopy(v, ets.Read(EtsRegKeys.ETS_GROUPS) + t + "\\" + v.GetFileName(),
                                              true);
                    }
                }

                break;

            case "FS15":
                var fs15 = new Fs15RegWork(true);
                tmp = fs15.Read(Fs15RegKeys.FS15_REPO);
                lst = GetFilesFolders.GetFiles(tmp, "*.zip");
                if (lst.IsNull())
                {
                    return;
                }
                foreach (var v in lst)
                {
                    foreach (var t in _srchLstFs)
                    {
                        if (!v.Contains(t, StringComparison.OrdinalIgnoreCase))
                        {
                            continue;
                        }
                        FolderCreator.CreatePublicFolders(fs15.Read(Fs15RegKeys.FS15_GROUPS) + t);
                        FileCopyMove.FileCopy(v, fs15.Read(Fs15RegKeys.FS15_GROUPS) + t + "\\" + v.GetFileName(),
                                              true);
                    }
                }

                break;

            case "FS17":
                var fs17      = new Fs17RegWork(true);
                var bypass    = new SortingBypass();
                var byPassDat = bypass.GetBypassList();
                tmp = fs17.Read(Fs17RegKeys.FS17_GROUPS);
                var fldLst  = GetFilesFolders.GetFolders(tmp, "*.*");
                var chkList = new List <string>();
                var enu     = fldLst.ToList();
                foreach (var v in enu)
                {
                    var chk = v.GetLastFolderName();
                    if (byPassDat.ContainsKey(chk))
                    {
                        continue;
                    }
                    chkList.Add(v);
                }

                if (chkList.IsNull())
                {
                    return;
                }
                foreach (var v in chkList)
                {
                    lst = GetFilesFolders.GetFiles(v + "\\", "*.zip");
                    foreach (var f in lst)
                    {
                        foreach (var t in mapLst)
                        {
                            if (!f.Contains(t, StringComparison.OrdinalIgnoreCase))
                            {
                                continue;
                            }
                            var src = tmp + "\\" + "Map" + "\\" + f.GetFileName();
                            if (src.FileExists())
                            {
                                continue;
                            }
                            FileCopyMove.FileCopy(f, src, true);
                        }
                    }
                }

                break;
            }

            var lstCreate = new ListCreator();

            lstCreate.CreateSortedLists();
            lstCreate.SortedFileListComplete();
            MsgBx.Msg("Map Sorting Complete", "Map Sorter");
        }
        private static void DoCleanUp()
        {
            var    reg = new AtsRegWork(true);
            var    gam = reg.Read(RegKeys.CURRENT_GAME);
            string tmp;
            IEnumerable <string> lst;

            switch (gam)
            {
            case "ATS":
                tmp = reg.Read(AtsRegKeys.ATS_REPO);
                lst = GetFilesFolders.GetFiles(tmp, "*.scs");
                FolderCreator.CreatePublicFolders(reg.Read(AtsRegKeys.ATS_GROUPS) + "misc");
                foreach (var v in lst)
                {
                    FileCopyMove.FileCopy(v, reg.Read(AtsRegKeys.ATS_GROUPS) + "misc" + "\\" + v.GetFileName(),
                                          true);
                }

                break;

            case "ETS":
                var ets = new EtsRegWork(true);
                tmp = ets.Read(EtsRegKeys.ETS_REPO);
                lst = GetFilesFolders.GetFiles(tmp, "*.scs");
                FolderCreator.CreatePublicFolders(ets.Read(EtsRegKeys.ETS_GROUPS) + "misc");
                foreach (var t in lst)
                {
                    FileCopyMove.FileCopy(t, ets.Read(EtsRegKeys.ETS_GROUPS) + "misc" + "\\" + t.GetFileName(),
                                          true);
                }

                break;

            case "FS15":
                var fs15 = new Fs15RegWork(true);
                tmp = fs15.Read(Fs15RegKeys.FS15_REPO);
                lst = GetFilesFolders.GetFiles(tmp, "*.zip");
                FolderCreator.CreatePublicFolders(fs15.Read(Fs15RegKeys.FS15_GROUPS) + "misc");
                foreach (var v in lst)
                {
                    FileCopyMove.FileCopy(v, fs15.Read(Fs15RegKeys.FS15_GROUPS) + "misc" + "\\" + v.GetFileName(),
                                          true);
                }

                break;

            case "FS17":
                var fs17 = new Fs17RegWork(true);
                tmp = fs17.Read(Fs17RegKeys.FS17_REPO);
                lst = GetFilesFolders.GetFiles(tmp, "*.zip");
                FolderCreator.CreatePublicFolders(fs17.Read(Fs17RegKeys.FS17_GROUPS) + "misc");
                foreach (var v in lst)
                {
                    FileCopyMove.FileCopy(v, fs17.Read(Fs17RegKeys.FS17_GROUPS) + "misc" + "\\" + v.GetFileName(),
                                          true);
                }

                break;
            }

            var lstCreate = new ListCreator();

            lstCreate.CreateSortedLists();
            lstCreate.SortedFileListComplete();
            MsgBx.Msg("Mod Sorting Complete", "Mod Sorter");
        }
        /// <summary>
        ///     Loads the favorites.
        /// </summary>
        public static Dictionary <string, string> LoadFavorites(string mke)
        {
            var fs17  = new Fs17Loader();
            var reg   = new AtsRegWork(true);
            var gam   = reg.Read(RegKeys.CURRENT_GAME);
            var cProf = reg.Read(RegKeys.CURRENT_PROFILE);

            if (gam.IsNullOrEmpty() || cProf.IsNullOrEmpty())
            {
                MsgBx.Msg("You need to have a Profile / Game active", "Process Error");
                return(null);
            }

            var dic = new Dictionary <string, string>()
            ;

            switch (mke)
            {
            case "Claas":
                dic = Serializer.DeserializeDictionary(reg.Read(Fs17RegKeys.FS17_GROUPS) + @"\claas.xml");
                break;

            case "Krone":
                dic = Serializer.DeserializeDictionary(reg.Read(Fs17RegKeys.FS17_GROUPS) + @"\krone.xml");
                break;

            case "NewHolland":
                dic = Serializer.DeserializeDictionary(reg.Read(Fs17RegKeys.FS17_GROUPS) + @"\newholland.xml");
                break;

            case "JohnDeere":
                dic = Serializer.DeserializeDictionary(reg.Read(Fs17RegKeys.FS17_GROUPS) + @"\johndeere.xml");
                break;

            case "MasseyFerguson":
                dic = Serializer.DeserializeDictionary(reg.Read(Fs17RegKeys.FS17_GROUPS) + @"\masseyferguson.xml");
                break;

            case "Fendt":
                dic = Serializer.DeserializeDictionary(reg.Read(Fs17RegKeys.FS17_GROUPS) + @"\fendt.xml");
                break;

            case "Case":
                dic = Serializer.DeserializeDictionary(reg.Read(Fs17RegKeys.FS17_GROUPS) + @"\case.xml");
                break;

            case "Plows":
                dic = Serializer.DeserializeDictionary(reg.Read(Fs17RegKeys.FS17_GROUPS) + @"\plows.xml");
                break;

            case "Cultivators":
                dic = Serializer.DeserializeDictionary(reg.Read(Fs17RegKeys.FS17_GROUPS) + @"\cultivators.xml");
                break;

            case "Placeables":
                dic = Serializer.DeserializeDictionary(reg.Read(Fs17RegKeys.FS17_GROUPS) + @"\placeables.xml");
                break;

            case "Specials":
                dic = Serializer.DeserializeDictionary(reg.Read(Fs17RegKeys.FS17_GROUPS) + @"\specials.xml");
                break;

            case "TractorsOther":
                dic = Serializer.DeserializeDictionary(reg.Read(Fs17RegKeys.FS17_GROUPS) + @"\tractorsOther.xml");
                break;

            case "Balers":
                dic = Serializer.DeserializeDictionary(reg.Read(Fs17RegKeys.FS17_GROUPS) + @"\balers.xml");
                break;

            case "Trailers":
                dic = Serializer.DeserializeDictionary(reg.Read(Fs17RegKeys.FS17_GROUPS) + @"\trailers.xml");
                break;

            case "Tools":
                dic = Serializer.DeserializeDictionary(reg.Read(Fs17RegKeys.FS17_GROUPS) + @"\tools.xml");
                break;
            }


            var lnkPth = reg.Read(Fs17RegKeys.FS17_PROFILES) + cProf + "\\";

            foreach (var v in dic)
            {
                var tmp = lnkPth + v.Key;
                if (tmp.FileExists())
                {
                    continue;
                }
                var org = v.Value + v.Key;
                if (!org.FileExists())
                {
                    continue;
                }
                //CreateSymbolicLink(tmp, org, SymbolicLink.File);
                //SymLinks.CreateSymLink(tmp, org, 0);
                // FileCopyMove.FileCopy(org, tmp);

                CreateHardLink(tmp, org, IntPtr.Zero);
            }

            var lc = new ListCreator();

            lc.CreateSortedLists();

            var lst = fs17.LoadFs17ProfileMods(reg.Read(RegKeys.CURRENT_PROFILE));

            return(lst);
        }