コード例 #1
0
    private void GetFilesList()
    {
        saveFiles = new Dictionary <string, List <SaveGameFileDetails> >();
        List <string> allFiles = SaveLoader.GetAllFiles();

        if (allFiles.Count > 0)
        {
            for (int i = 0; i < allFiles.Count; i++)
            {
                if (IsFileValid(allFiles[i]))
                {
                    Tuple <SaveGame.Header, SaveGame.GameInfo> fileInfo = GetFileInfo(allFiles[i]);
                    SaveGame.Header   first         = fileInfo.first;
                    SaveGame.GameInfo second        = fileInfo.second;
                    System.DateTime   lastWriteTime = File.GetLastWriteTime(allFiles[i]);
                    string            path          = (!(second.originalSaveName != string.Empty)) ? allFiles[i] : second.originalSaveName;
                    path = Path.GetFileNameWithoutExtension(path);
                    SaveGameFileDetails item = default(SaveGameFileDetails);
                    item.BaseName   = second.baseName;
                    item.FileName   = allFiles[i];
                    item.FileDate   = lastWriteTime;
                    item.FileHeader = first;
                    item.FileInfo   = second;
                    if (!saveFiles.ContainsKey(path))
                    {
                        saveFiles.Add(path, new List <SaveGameFileDetails>());
                    }
                    saveFiles[path].Add(item);
                }
            }
        }
    }
コード例 #2
0
 public static SaveGame.GameInfo LoadHeader(string filename, out SaveGame.Header header)
 {
     using (BinaryReader binaryReader = new BinaryReader(File.Open(filename, FileMode.Open)))
     {
         header = SaveGame.GetHeader(binaryReader);
         byte[] data = binaryReader.ReadBytes(header.headerSize);
         return(SaveGame.GetGameInfo(data));
     }
 }
コード例 #3
0
        /// <summary>
        /// Applied before LoadHeader runs.
        /// </summary>
        internal static bool Prefix(string filename, ref SaveGame.Header header,
                                    ref SaveGame.GameInfo __result)
        {
            // Klei does not catch the IOException at this level
            var reader = new FileStream(filename, FileMode.Open, FileAccess.Read,
                                        FileShare.Read);

            try {
                __result = SaveGame.GetHeader(new KBinaryReader(reader), out header, filename);
            } finally {
                reader.Close();
                reader.Dispose();
            }
            return(false);
        }
コード例 #4
0
    private void RefreshResumeButton()
    {
        string latestSaveFile = SaveLoader.GetLatestSaveFile();
        bool   flag           = !string.IsNullOrEmpty(latestSaveFile) && File.Exists(latestSaveFile);

        if (flag)
        {
            try
            {
                if (GenericGameSettings.instance.demoMode)
                {
                    flag = false;
                }
                System.DateTime   lastWriteTime = File.GetLastWriteTime(latestSaveFile);
                SaveFileEntry     value         = default(SaveFileEntry);
                SaveGame.Header   header        = default(SaveGame.Header);
                SaveGame.GameInfo gameInfo      = default(SaveGame.GameInfo);
                if (!saveFileEntries.TryGetValue(latestSaveFile, out value) || value.timeStamp != lastWriteTime)
                {
                    gameInfo = SaveLoader.LoadHeader(latestSaveFile, out header);
                    SaveFileEntry saveFileEntry = default(SaveFileEntry);
                    saveFileEntry.timeStamp  = lastWriteTime;
                    saveFileEntry.header     = header;
                    saveFileEntry.headerData = gameInfo;
                    value = saveFileEntry;
                    saveFileEntries[latestSaveFile] = value;
                }
                else
                {
                    header   = value.header;
                    gameInfo = value.headerData;
                }
                if (header.buildVersion > 365655 || gameInfo.saveMajorVersion < 7)
                {
                    flag = false;
                }
                string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(latestSaveFile);
                if (!string.IsNullOrEmpty(gameInfo.baseName))
                {
                    Button_ResumeGame.GetComponentsInChildren <LocText>()[1].text = string.Format(UI.FRONTEND.MAINMENU.RESUMEBUTTON_BASENAME, gameInfo.baseName, gameInfo.numberOfCycles + 1);
                }
                else
                {
                    Button_ResumeGame.GetComponentsInChildren <LocText>()[1].text = fileNameWithoutExtension;
                }
            }
            catch (Exception obj)
            {
                Debug.LogWarning(obj);
                flag = false;
            }
        }
        if ((UnityEngine.Object)Button_ResumeGame != (UnityEngine.Object)null && (UnityEngine.Object)Button_ResumeGame.gameObject != (UnityEngine.Object)null)
        {
            Button_ResumeGame.gameObject.SetActive(flag);
        }
        else
        {
            Debug.LogWarning("Why is the resume game button null?");
        }
    }
コード例 #5
0
 private static bool IsSaveFileFromUnsupportedFutureBuild(SaveGame.Header header)
 {
     return(header.buildVersion > 260525u);
 }