예제 #1
0
        public void Delete()
        {
            string prefix = ModConfigurationInfo.Active ? Program.GamePath : Program.ModsDisabledPath;

            foreach (FileInfo fi in CurrentVersionFiles)
            {
                File.Delete(prefix + fi.Path);
                fi.IsOK = false;
            }
            LauncherConfig.InstalledMods.Remove(ModConfigurationInfo);
            ModConfigurationInfo = null;
            LauncherConfig.SaveMods();
        }
예제 #2
0
        public void Install()
        {
            List <string> fileList = new List <string>();

            foreach (FileInfo fi in CurrentVersionFiles)
            {
                fileList.Add(fi.Path);
            }
            ModConfigurationInfo = new ModCfgInfo(Name, Program.GameVersion, fileList, true);
            int oldModConfInfoIdx = LauncherConfig.InstalledMods.FindIndex(x => x.Name.Equals(Name));

            if (oldModConfInfoIdx > -1)
            {
                LauncherConfig.InstalledMods.RemoveAt(oldModConfInfoIdx);
            }
            LauncherConfig.InstalledMods.Add(ModConfigurationInfo);
            LauncherConfig.SaveMods();
        }
예제 #3
0
        public void DisableOld()
        {
            List <FileInfo> oldVersionFiles = new List <FileInfo>();
            GameVersion     gv     = null;
            string          curVer = ModConfigurationInfo.GameVersion;

            if (GameVersions.ContainsKey(curVer))
            {
                gv = GameVersions[curVer];
            }
            if (gv is null)
            {
                if (GameVersions.ContainsKey("DEFAULT"))
                {
                    gv = GameVersions["DEFAULT"];
                }
                else if (GameVersions.ContainsKey("OTHER"))
                {
                    gv = GameVersions["OTHER"];
                }
            }
            if (gv is null)
            {
                oldVersionFiles = null;
            }
            else
            {
                foreach (FileGroup fileGroup in gv.FileGroups)
                {
                    if (fileGroup.Files != null)
                    {
                        oldVersionFiles.AddRange(fileGroup.Files);
                    }
                }
                if (gv.Files != null)
                {
                    oldVersionFiles.AddRange(gv.Files);
                }
            }
            MoveToDisabled(oldVersionFiles);
            ModConfigurationInfo.Active = false;
            ModConfigurationInfo        = null;
        }
예제 #4
0
 public static void Load()
 {
     GalaxyDir = YU.GetGogGalaxyPath();
     try {
         if (File.Exists(CFGFILE))
         {
             string[] lines = File.ReadAllLines(CFGFILE);
             foreach (string line in lines)
             {
                 if (line.Length > 0)
                 {
                     if (line.StartsWith("path"))
                     {
                         string[] vals = line.Split('=');
                         if (vals.Length > 1)
                         {
                             GameDir = vals[1].Trim();
                         }
                     }
                     else if (line.StartsWith("startpage"))
                     {
                         string[] vals = line.Split('=');
                         if (vals.Length > 1)
                         {
                             if (int.TryParse(vals[1].Trim(), out int intval) && intval > -1 && intval < 4)
                             {
                                 StartPage = (StartPageEnum)intval;
                             }
                         }
                     }
                     else if (line.StartsWith("lastsrvchk"))
                     {
                         string[] vals = line.Split('=');
                         if (vals.Length > 1)
                         {
                             LastSurveyId = vals[1].Trim();
                         }
                     }
                     else if (line.StartsWith("startviagalaxy"))
                     {
                         if (GalaxyDir != null)
                         {
                             LaunchFromGalaxy = ParseBooleanParam(line);
                         }
                     }
                     else if (line.StartsWith("offlinemode"))
                     {
                         StartOffline = ParseBooleanParam(line);
                     }
                     else if (line.StartsWith("closeonlaunch"))
                     {
                         CloseOnLaunch = ParseBooleanParam(line);
                     }
                 }
             }
         }
         if (File.Exists(MODINFOFILE))
         {
             InstalledMods = JsonConvert.DeserializeObject <List <ModCfgInfo> >(File.ReadAllText(MODINFOFILE));
             List <string> names = new List <string>();
             for (int i = InstalledMods.Count - 1; i > -1; i--)
             {
                 ModCfgInfo mci = InstalledMods[i];
                 if (names.FindIndex(x => x.Equals(mci.Name)) > -1)
                 {
                     InstalledMods.RemoveAt(i);
                 }
                 else
                 {
                     names.Add(mci.Name);
                 }
             }
         }
     }
     catch (Exception ex) {
         YobaDialog.ShowDialog(Locale.Get("CannotReadCfg") + ":\r\n" + ex.Message);
     }
 }
예제 #5
0
 public void InitCurrentVersion(string curVer)
 {
     ModConfigurationInfo = LauncherConfig.InstalledMods.Find(x => x.Name.Equals(Name));
     CurrentVersionData   = null;
     CurrentVersionFiles  = new List <FileInfo>();
     if (YU.stringHasText(curVer))
     {
         if (GameVersions.ContainsKey(curVer))
         {
             CurrentVersionData = GameVersions[curVer];
         }
     }
     if (CurrentVersionData is null)
     {
         if (GameVersions.ContainsKey("DEFAULT"))
         {
             CurrentVersionData = GameVersions["DEFAULT"];
         }
         else if (GameVersions.ContainsKey("OTHER"))
         {
             CurrentVersionData = GameVersions["OTHER"];
         }
     }
     if (CurrentVersionData is null)
     {
         CurrentVersionFiles = null;
     }
     else
     {
         foreach (FileGroup fileGroup in CurrentVersionData.FileGroups)
         {
             if (fileGroup.Files != null)
             {
                 CurrentVersionFiles.AddRange(fileGroup.Files);
             }
         }
         if (CurrentVersionData.Files != null)
         {
             CurrentVersionFiles.AddRange(CurrentVersionData.Files);
         }
         if (CurrentVersionFiles.Count > 0)
         {
             CurrentVersionFiles[CurrentVersionFiles.Count - 1].LastFileOfMod = this;
         }
         else
         {
             CurrentVersionFiles = null;
         }
     }
     if (ModConfigurationInfo != null)
     {
         if (CurrentVersionFiles is null)
         {
             if (ModConfigurationInfo.Active)
             {
                 DisableOld();
             }
             else
             {
                 ModConfigurationInfo = null;
             }
         }
         else if (ModConfigurationInfo.Active)
         {
             foreach (string file in ModConfigurationInfo.FileList)
             {
                 if (CurrentVersionFiles.FindIndex(x => x.Path.Equals(file)) < 0)
                 {
                     Program.LoncherSettings.zzModFilesToDelete.Add(file);                            //File.Delete(Program.GamePath + file);
                     ModConfigurationInfo.Altered = true;
                 }
                 else
                 {
                     Program.LoncherSettings.zzModFilesInUse.Add(file);
                 }
             }
             if (ModConfigurationInfo.Altered)
             {
                 ModConfigurationInfo.FileList = new List <string>();
                 foreach (FileInfo fi in CurrentVersionFiles)
                 {
                     ModConfigurationInfo.FileList.Add(fi.Path);
                 }
             }
         }
     }
 }