示例#1
0
        private static void RunApplication(string[] args)
        {
            var programParams = ProgramParameters.Parse(args);

            SimpleLogger.SetDefaultLogger(new SimpleLogger(Console.Error, (LogLevel)programParams.Verbosity));

            PrintHello(programParams);
            var hellbladeTracker = new HellbladeGameSaveTracker(programParams.TrackingConfig);

            SimpleLogger.Default.Info("STARTING TRACKING APPLICATION ...");
            SimpleLogger.Default.Info("YOU CAN PRESS 'Q' ANY TIME TO EXIT");

            hellbladeTracker.Run();

            WaitForExitKey();

            SimpleLogger.Default.Info("EXITING ...");
            hellbladeTracker.Cancel();
        }
        public static ProgramParameters Parse(params string[] args)
        {
            /* Default path where Hellblade data is stored */
            string defaultPathBase =
                PathHelper.AddBackslash(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)) + @"HellbladeGame\Saved\SaveGames";

            var prm  = new ProgramParameters();
            var tcfg = new HellbladeTrackingConfig()
            {
                SaveGamePath            = defaultPathBase,
                SaveGameFilter          = "*.sav",
                SaveBackupPath          = defaultPathBase + "\\Backup",
                DefaultNameFormat       = "hellblade_{0:yyMMdd_HHmmss}_{1:000}_{2}",
                HellbladeExecutablePath = "HellbladeGame-Win64-Shipping",
                TargetImageSize         = null
            };

            prm.Verbosity = 1;
            var optionSet = new OptionSet()
            {
                { "h|help", p => prm.ShowHelp = true },
                { "f|format=", p => tcfg.DefaultNameFormat = p },
                { "p|process-name=", p => tcfg.HellbladeExecutablePath = p },
                { "o|output-path=", p => tcfg.SaveBackupPath = p },
                { "i|input-path=", p => tcfg.SaveGamePath = p },
                { "w|wildcard=", p => tcfg.SaveGameFilter = p },
                { "s|image-size=", p => tcfg.TargetImageSize = ParseSize(p.ToString()) },
                { "v|verbosity=", p => prm.Verbosity = int.Parse(p) }
            };

            var positional = optionSet.Parse(args);

            prm.ProgramOptionsSet = optionSet;
            prm.TrackingConfig    = tcfg;

            return(prm);
        }
示例#3
0
 private static void PrintHello(ProgramParameters p)
 {
     Console.WriteLine(":::: HELLBLADE SAVER ::::");
     Console.WriteLine("-------------------------------------");
     if (p.ShowHelp)
     {
         var fvi = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
         Console.WriteLine("  Application version: {0}", fvi.FileVersion);
         Console.WriteLine();
         Console.WriteLine("  Command line parameters:");
         p.ProgramOptionsSet.WriteOptionDescriptions(Console.Error);
         Console.WriteLine("-------------------------------------");
         Environment.Exit(1);
     }
     else
     {
         Console.WriteLine("Origin:          {0}", p.TrackingConfig.SaveGamePath);
         Console.WriteLine("Search pattern:  {0}", p.TrackingConfig.SaveGameFilter);
         Console.WriteLine("Backup path:     {0}", p.TrackingConfig.SaveBackupPath);
         Console.WriteLine("Backup format:   {0}", p.TrackingConfig.DefaultNameFormat);
         Console.WriteLine("Process name:    {0}", p.TrackingConfig.HellbladeExecutablePath);
         Console.WriteLine("-------------------------------------");
     }
 }