Пример #1
0
        private List <SaveFile> GatherSaveFiles(int profileID, bool isImport, int boolID, string separateProductName, string separateFilePrefix)
        {
            List <SaveFile> gatheredFiles = new List <SaveFile>();

            string saveDirectory = GetSaveDirectory(separateProductName);
            string filePrefix    = (isImport) ? separateFilePrefix : KickStarter.settingsManager.SavePrefix;

            for (int i = 0; i < 50; i++)
            {
                string filename = filePrefix + KickStarter.saveSystem.GenerateSaveSuffix(i, profileID);
                string filenameWithExtention = filename + KickStarter.saveSystem.GetSaveExtension();
                string fullFilename          = saveDirectory + Path.DirectorySeparatorChar.ToString() + filenameWithExtention;

                if (File.Exists(fullFilename))
                {
                    if (isImport && boolID >= 0)
                    {
                        string allData = Serializer.LoadFile(fullFilename, false);
                        if (!KickStarter.saveSystem.DoImportCheck(allData, boolID))
                        {
                            continue;
                        }
                    }

                    int    updateTime = 0;
                    bool   isAutoSave = false;
                    string label      = ((isImport) ? "Import " : "Save ") + i.ToString();
                    if (i == 0)
                    {
                        label      = "Autosave";
                        isAutoSave = true;
                    }

                    if (KickStarter.settingsManager.saveTimeDisplay != SaveTimeDisplay.None)
                    {
                        DirectoryInfo dir  = new DirectoryInfo(saveDirectory);
                        FileInfo[]    info = dir.GetFiles(filenameWithExtention);

                        if (info != null && info.Length > 0)
                        {
                            if (!isAutoSave)
                            {
                                System.TimeSpan t = info[0].LastWriteTime - new System.DateTime(2015, 1, 1);
                                updateTime = (int)t.TotalSeconds;
                            }

                            label += GetTimeString(info[0].LastWriteTime);
                        }
                    }

                    Texture2D screenShot         = null;
                    string    screenshotFilename = "";
                    if (KickStarter.settingsManager.takeSaveScreenshots)
                    {
                        screenshotFilename = saveDirectory + Path.DirectorySeparatorChar.ToString() + filename + ".jpg";
                        screenShot         = LoadScreenshot(screenshotFilename);
                    }

                    gatheredFiles.Add(new SaveFile(i, profileID, label, fullFilename, isAutoSave, screenShot, screenshotFilename, updateTime));
                }
            }

            return(gatheredFiles);
        }