Exemplo n.º 1
0
 private static void Print()
 {
     using (Stream contentStream = OpenMeta(_loadedFilePath))
     {
         var saveData = EU4SaveMeta.Load(contentStream);
         Out($"SaveType: {saveData.SaveType}");
         using (var reader = new StringReader(saveData.ToString()))
         {
             string line;
             while ((line = reader.ReadLine()) != null)
             {
                 Out("  " + line);
             }
         }
     }
 }
Exemplo n.º 2
0
        private static void ShowBackups()
        {
            string backupDirName             = GetBackupPath(_loadedFilePath);
            string ext                       = Path.GetExtension(_loadedFilePath);
            IEnumerable <string> backupFiles = Directory.EnumerateFileSystemEntries(backupDirName, $"*{ext}");
            var saveMetas                    = backupFiles.ToDictionary <string, string, EU4SaveMeta>(
                filePath => filePath,
                filePath =>
            {
                using (var stream = OpenMeta(filePath))
                {
                    return(EU4SaveMeta.Load(stream));
                }
            },
                StringComparer.OrdinalIgnoreCase);

            int i = 1;

            Out($"Backup Path: {backupDirName}");
            Out(string.Empty);
            Out("|     | Date       | Tag | IronMan | Hash                             | Version  |");
            Out("| --- | ---------- | --- | ------- | -------------------------------- | -------- |");

            var outputBuilder = new StringBuilder(100);

            foreach (var saveWithMeta in saveMetas.OrderByDescending(x => new FileInfo(x.Key).LastWriteTimeUtc))
            {
                string      backupFilePath = saveWithMeta.Key;
                EU4SaveMeta save           = saveWithMeta.Value;

                string hash = Path.GetFileNameWithoutExtension(saveWithMeta.Key);

                outputBuilder.Clear();
                outputBuilder.Append($"| {i,-3} ");
                outputBuilder.Append($"| {save.Date.ToString().PadRight(10)} ");
                outputBuilder.Append($"| {save.PlayerTag} ");
                outputBuilder.Append($"| {BoolYesNo(save.IronMan),-7} ");
                outputBuilder.Append($"| {hash} ");
                outputBuilder.Append($"| {save.SaveGameVersion.ToString("s")} ");
                outputBuilder.Append("|");

                Out(outputBuilder.ToString());
                ++i;
            }
        }