Beispiel #1
0
        private static bool CheckPath(string t)
        {
            var inFo = new DirectoryInfo(t);
            var fnd  = SymLinks.GetSymbolicLinkTarget(inFo);

            return(fnd.IsNullOrEmpty());
        }
Beispiel #2
0
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            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;
            }

            string tmp;
            string profPath;
            Dictionary <string, string> lst = null;

            lstProfileMods.Items.Clear();

            switch (gam)
            {
            case "ATS":
                var ats  = new AtsLoader();
                var atsp = new AtsRegWork(true);
                var prof = new ProfileWorker();
                tmp      = ats.LoadAtsModChoice(lstAvailableMods.SelectedItem.ToString());
                profPath = atsp.Read(AtsRegKeys.ATS_GAME_MOD_FOLDER) + tmp.GetFileName();
                prof.BuildProfileList(lstAvailableMods.SelectedItem.ToString());
                SymLinks.CreateSymLink(profPath, tmp, 0);
                lst = ats.LoadAtsProfileMods(reg.Read(RegKeys.CURRENT_PROFILE));
                break;

            case "ETS":
                var ets  = new EtsLoader();
                var etsp = new EtsRegWork(true);
                prof     = new ProfileWorker();
                tmp      = ets.LoadEtsModChoice(lstAvailableMods.SelectedItem.ToString());
                profPath = etsp.Read(EtsRegKeys.ETS_GAME_MOD_FOLDER) + tmp.GetFileName();
                prof.BuildProfileList(lstAvailableMods.SelectedItem.ToString());
                SymLinks.CreateSymLink(profPath, tmp, 0);
                lst = ets.LoadEtsProfileMods(reg.Read(RegKeys.CURRENT_PROFILE));
                break;

            case "FS15":
                var fs15  = new Fs15Loader();
                var fs15P = new Fs15RegWork(true);
                tmp      = fs15.LoadFs15ModChoice(lstAvailableMods.SelectedItem.ToString());
                profPath = fs15P.Read(Fs15RegKeys.FS15_PROFILES) + reg.Read(RegKeys.CURRENT_PROFILE) + "\\" +
                           tmp.GetFileName();
                prof = new ProfileWorker();
                prof.BuildProfileList(lstAvailableMods.SelectedItem.ToString());
                SymLinks.CreateSymLink(profPath, tmp, 0);
                lst = fs15.LoadFs15ProfileMods(reg.Read(RegKeys.CURRENT_PROFILE));
                break;

            case "FS17":
                var fs17  = new Fs17Loader();
                var fs17P = new Fs17RegWork(true);
                tmp      = fs17.LoadFs17ModChoice(lstAvailableMods.SelectedItem.ToString());
                profPath = fs17P.Read(Fs17RegKeys.FS17_PROFILES) + reg.Read(RegKeys.CURRENT_PROFILE) + "\\" +
                           tmp.GetFileName();
                prof = new ProfileWorker();
                prof.BuildProfileList(lstAvailableMods.SelectedItem.ToString());
                SymLinks.CreateSymLink(profPath, tmp, 0);
                lst = fs17.LoadFs17ProfileMods(reg.Read(RegKeys.CURRENT_PROFILE));
                break;
            }

            if (lst == null)
            {
                return;
            }
            foreach (var v in lst)
            {
                lstProfileMods.Items.Add(v.Key);
            }

            CheckModCount();
            label2.Text = @"Active Mods: " + lstProfileMods.Items.Count;

            // MsgBx.Msg("Profile Link Created", "Linker");
        }
Beispiel #3
0
        private static Dictionary <string, string> CreateLinks(IEnumerable <string> lst)
        {
            var reg      = new AtsRegWork(true);
            var pf       = new ProfileWorker();
            var gam      = reg.Read(RegKeys.CURRENT_GAME);
            var profile  = reg.Read(RegKeys.CURRENT_PROFILE);
            var pth      = string.Empty;
            var dic      = new Dictionary <string, string>();
            var linkPath = string.Empty;

            switch (gam)
            {
            case "ATS":
                pth      = reg.Read(AtsRegKeys.ATS_PROFILES) + profile + "\\" + profile + ".xml";
                linkPath = reg.Read(AtsRegKeys.ATS_GAME_MOD_FOLDER);
                break;

            case "ETS":
                pth      = reg.Read(EtsRegKeys.ETS_PROFILES) + profile + "\\" + profile + ".xml";
                linkPath = reg.Read(EtsRegKeys.ETS_GAME_MOD_FOLDER);
                break;

            case "FS15":
                pth      = reg.Read(Fs15RegKeys.FS15_PROFILES) + profile + "\\" + profile + ".xml";
                linkPath = reg.Read(Fs15RegKeys.FS15_PROFILES) + profile + "\\";
                break;

            case "FS17":
                pth      = reg.Read(Fs17RegKeys.FS17_PROFILES) + profile + "\\" + profile + ".xml";
                linkPath = reg.Read(Fs17RegKeys.FS17_PROFILES) + profile + "\\";
                break;
            }

            if (pth.FileExists())
            {
                dic = Serializer.DeserializeDictionary(pth);
                foreach (var v in lst)
                {
                    var file = v.GetFileName();
                    var pt   = Path.GetDirectoryName(v) + "\\";
                    SymLinks.CreateSymLink(linkPath + file, v, 0);
                    dic.Add(file, pt);
                }

                Serializer.SerializeDictionary(pth, dic);
            }
            else if (!pth.FileExists())
            {
                foreach (var v in lst)
                {
                    var file = v.GetFileName();
                    var pt   = Path.GetDirectoryName(v) + "\\";
                    SymLinks.CreateSymLink(linkPath + file, v, 0);
                    dic.Add(file, pt);
                }

                Serializer.SerializeDictionary(pth, dic);
            }

            pf.SetProfileActive();

            return(dic);
        }
        /// <summary>
        ///     Sets the profile active.
        /// </summary>
        public void SetProfileActive()
        {
            var    reg     = new AtsRegWork(true);
            var    gam     = reg.Read(RegKeys.CURRENT_GAME);
            var    profile = reg.Read(RegKeys.CURRENT_PROFILE);
            string path;
            string xmlPath;
            Dictionary <string, string> dic;
            Dictionary <string, string> dicRealPath;
            string origModPath;

            switch (gam)
            {
            case "ATS":
                path        = reg.Read(AtsRegKeys.ATS_GAME_MOD_FOLDER);
                xmlPath     = reg.Read(AtsRegKeys.ATS_PROFILES) + profile + "\\" + profile + XML_EXT;
                dicRealPath =
                    Serializer.DeserializeDictionary(reg.Read(AtsRegKeys.ATS_XML) + "sortedFileListComplete.xml");
                DeleteMods();
                string tmp;
                if (!xmlPath.FileExists())
                {
                    return;
                }
                dic = Serializer.DeserializeDictionary(xmlPath);
                foreach (var k in dic)
                {
                    dicRealPath.TryGetValue(k.Key, out tmp);
                    origModPath = tmp + k.Key;
                    if (!origModPath.FileExists())
                    {
                        continue;
                    }
                    SymLinks.CreateSymLink(path + k.Key, origModPath, 0);
                }

                Serializer.SerializeDictionary(path + profile + XML_EXT, dic);
                break;

            case "ETS":
                path        = reg.Read(EtsRegKeys.ETS_GAME_MOD_FOLDER);
                xmlPath     = reg.Read(EtsRegKeys.ETS_PROFILES) + profile + "\\" + profile + XML_EXT;
                dicRealPath =
                    Serializer.DeserializeDictionary(reg.Read(EtsRegKeys.ETS_XML) + "sortedFileListComplete.xml");
                DeleteMods();
                if (!xmlPath.FileExists())
                {
                    return;
                }
                dic = Serializer.DeserializeDictionary(xmlPath);
                foreach (var k in dic)
                {
                    dicRealPath.TryGetValue(k.Key, out tmp);
                    origModPath = tmp + k.Key;
                    if (!origModPath.FileExists())
                    {
                        continue;
                    }
                    SymLinks.CreateSymLink(path + k.Key, origModPath, 0);
                }

                Serializer.SerializeDictionary(path + profile + XML_EXT, dic);
                break;

            case "FS15":
                ModifyGameSettings();
                break;

            case "FS17":
                ModifyGameSettings();
                break;
            }
        }