예제 #1
0
        public bool ValidateBackups()
        {
            main.PrintMessage("Checking backups before proceeding...");
            bool keepGoing    = true;
            bool problemFound = false;

            if (MainClass._backupDirectory == null)
            {
                main.PrintMessage($"No backup directory specified, can't check the status of backups.\nYou are strongly recommended to add a backup directory in {Path.Combine(MainClass._projectconfDirectory.FullName, "config.cfg")} and running the 'backup' command before proceeding", 2);
                problemFound = true;
            }
            else if (MainClass._gameDirectory == null)
            {
                main.PrintMessage("No game directory specified, can't check if backups are up to date", 2);
                problemFound = true;
            }
            else
            {
                var            filesToCheck   = new XivDataFile[] { XivDataFile._01_Bgcommon, XivDataFile._04_Chara, XivDataFile._06_Ui };
                ProblemChecker problemChecker = new ProblemChecker(MainClass._indexDirectory);
                foreach (var file in filesToCheck)
                {
                    if (!File.Exists(Path.Combine(MainClass._backupDirectory.FullName, $"{file.GetDataFileName()}.win32.index")))
                    {
                        main.PrintMessage($"One or more index files could not be found in {MainClass._backupDirectory.FullName}. Creating new ones or downloading them from the TexTools discord is recommended", 2);
                        problemFound = true;
                        break;
                    }
                    var outdatedBackupsCheck = problemChecker.CheckForOutdatedBackups(file, MainClass._backupDirectory);
                    outdatedBackupsCheck.Wait();
                    if (!outdatedBackupsCheck.Result)
                    {
                        main.PrintMessage($"One or more index files are out of date in {MainClass._backupDirectory.FullName}. Recreating or downloading them from the TexTools discord is recommended", 2);
                        problemFound = true;
                        break;
                    }
                }
            }
            if (problemFound)
            {
                if (PromptContinuation("Would you like to back up now?", true))
                {
                    main.BackupIndexes();
                    keepGoing = true;
                }
                else
                {
                    keepGoing = PromptContinuation();
                }
            }
            else
            {
                main.PrintMessage("All backups present and up to date", 1);
            }
            return(keepGoing);
        }
예제 #2
0
 public void SetupDicts()
 {
     fullActions = new Dictionary <string, Dictionary <string, Action> > {
         { "mods", new Dictionary <string, Action> {
               { "refresh", new Action(() => { main.SetModActiveStates(); }) },
               { "enable", new Action(() => { main.ToggleModStates(true); }) },
               { "disable", new Action(() => { main.ToggleModStates(false); }) }
           } },
         { "modpack", new Dictionary <string, Action> {
               { "import", new Action(() => {
                         if (useWizard && importAll)
                         {
                             main.PrintMessage("You can't use the import wizard and skip the wizard at the same time", 3);
                             useWizard = false;
                             importAll = false;
                         }
                         main.ImportModpackHandler(ttmpPaths, useWizard, importAll, skipProblemCheck);
                     }) },
               { "info", new Action(() => { main.GetModpackInfo(ttmpPaths); }) },
           } },
         { "backup", new Dictionary <string, Action> {
               { "", new Action(() => { main.BackupIndexes(); }) }
           } },
         { "reset", new Dictionary <string, Action> {
               { "", new Action(() => { main.ResetMods(); }) }
           } },
         { "problemcheck", new Dictionary <string, Action> {
               { "", new Action(() => { main.ProblemChecker(); }) }
           } },
         { "version", new Dictionary <string, Action> {
               { "", new Action(() => { if (MainClass._gameDirectory == null)
                                        {
                                            MainClass._gameDirectory = new DirectoryInfo(Path.Combine(config.ReadConfig("GameDirectory"), "game"));
                                        }
                                        main.CheckVersions(); }) }
           } },
         { "help", new Dictionary <string, Action> {
               { "", new Action(() => { SendHelpText(); }) }
           } },
         { "setup", new Dictionary <string, Action> {
               { "", new Action(() => { setup.ExecuteSetup(); }) }
           } },
     };
     actionAliases = new Dictionary <string, string> {
         { "mpi", "modpack import" },
         { "mpinfo", "modpack info" },
         { "mr", "mods refresh" },
         { "me", "mods enable" },
         { "md", "mods disable" },
         { "b", "backup" },
         { "r", "reset" },
         { "pc", "problemcheck" },
         { "v", "version" },
         { "h", "help" },
         { "s", "setup" }
     };
     argumentsDict = new Dictionary <List <string>, Action <string> > {
         { new List <string> {
               "-g", "--gamedirectory"
           }, new Action <string>((extraArg) => { MainClass._gameDirectory  = new DirectoryInfo(Path.Combine(extraArg, "game"));
                                                  MainClass._indexDirectory = new DirectoryInfo(Path.Combine(extraArg, "game", "sqpack", "ffxiv")); }) },
         { new List <string> {
               "-c", "--configdirectory"
           }, new Action <string>((extraArg) => { MainClass._configDirectory = new DirectoryInfo(extraArg); }) },
         { new List <string> {
               "-b", "--backupdirectory"
           }, new Action <string>((extraArg) => { MainClass._backupDirectory = new DirectoryInfo(extraArg); }) },
         { new List <string> {
               "-t", "--ttmp"
           }, new Action <string>((extraArg) => { ttmpPaths.Add(new DirectoryInfo(extraArg)); }) },
         { new List <string> {
               "-w", "--wizard"
           }, new Action <string>((extraArg) => { useWizard = true; }) },
         { new List <string> {
               "-a", "--all"
           }, new Action <string>((extraArg) => { importAll = true; }) },
         { new List <string> {
               "-npc", "--noproblemcheck"
           }, new Action <string>((extraArg) => { skipProblemCheck = true; }) },
         { new List <string> {
               "-v", "--version"
           }, new Action <string>((extraArg) => { requestedAction = "version"; }) },
         { new List <string> {
               "-h", "--help"
           }, new Action <string>((extraArg) => { requestedAction = "help"; }) }
     };
 }
예제 #3
0
        public void SetupDicts()
        {
            actionDict = new Dictionary <List <string>, Action> {
                { new List <string> {
                      "mpi", "modpack import"
                  }, new Action(() => {
                        if (useWizard && importAll)
                        {
                            main.PrintMessage("You can't use the import wizard and skip the wizard at the same time", 3);
                            useWizard = false;
                            importAll = false;
                        }
                        main.ImportModpackHandler(new DirectoryInfo(ttmpPath), useWizard, importAll, skipProblemCheck);
                    }) },
                { new List <string> {
                      "mpinfo", "modpack info"
                  }, new Action(() => { Dictionary <string, string> modpackInfo = main.GetModpackInfo(new DirectoryInfo(ttmpPath));
                                        main.PrintMessage($@"Name: {modpackInfo["name"]}
Type: {modpackInfo["type"]}
Author: {modpackInfo["author"]}
Version: {modpackInfo["version"]}
Description: {modpackInfo["description"]}
Number of mods: {modpackInfo["modAmount"]}"); }) },
                { new List <string> {
                      "mr", "mods reset"
                  }, new Action(() => { main.SetModActiveStates(); }) },
                { new List <string> {
                      "me", "mods enable"
                  }, new Action(() => { main.ToggleModStates(true); }) },
                { new List <string> {
                      "md", "mods disable"
                  }, new Action(() => { main.ToggleModStates(false); }) },
                { new List <string> {
                      "b", "backup"
                  }, new Action(() => { main.BackupIndexes(); }) },
                { new List <string> {
                      "r", "reset"
                  }, new Action(() => { main.ResetMods(); }) },
                { new List <string> {
                      "pc", "problemcheck"
                  }, new Action(() => { main.ProblemChecker(); }) },
                { new List <string> {
                      "v", "version"
                  }, new Action(() => { if (MainClass._gameDirectory == null)
                                        {
                                            MainClass._gameDirectory = new DirectoryInfo(Path.Combine(config.ReadConfig("GameDirectory"), "game"));
                                        }
                                        main.CheckVersions(); }) },
                { new List <string> {
                      "h", "help"
                  }, new Action(() => { SendHelpText(); }) }
            };
            argumentDict = new Dictionary <List <string>, Action <string> > {
                { new List <string> {
                      "g", "gamedirectory"
                  }, new Action <string>((extraArg) => { MainClass._gameDirectory  = new DirectoryInfo(Path.Combine(extraArg, "game"));
                                                         MainClass._indexDirectory = new DirectoryInfo(Path.Combine(extraArg, "game", "sqpack", "ffxiv")); }) },
                { new List <string> {
                      "c", "configdirectory"
                  }, new Action <string>((extraArg) => { MainClass._configDirectory = new DirectoryInfo(extraArg); }) },
                { new List <string> {
                      "b", "backupdirectory"
                  }, new Action <string>((extraArg) => { MainClass._backupDirectory = new DirectoryInfo(extraArg); }) },
                { new List <string> {
                      "t", "ttmp"
                  }, new Action <string>((extraArg) => { ttmpPath = extraArg; }) },
                { new List <string> {
                      "w", "wizard"
                  }, new Action <string>((extraArg) => { useWizard = true; }) },
                { new List <string> {
                      "a", "all"
                  }, new Action <string>((extraArg) => { importAll = true; }) },
                { new List <string> {
                      "npc", "noproblemcheck"
                  }, new Action <string>((extraArg) => { skipProblemCheck = true; }) },
                { new List <string> {
                      "v", "version"
                  }, new Action <string>((extraArg) => { if (MainClass._gameDirectory == null)
                                                         {
                                                             MainClass._gameDirectory = new DirectoryInfo(Path.Combine(config.ReadConfig("GameDirectory"), "game"));
                                                         }
                                                         main.CheckVersions(); }) },
                { new List <string> {
                      "h", "help"
                  }, new Action <string>((extraArg) => { SendHelpText(); }) }
            };
        }