Пример #1
0
    public int LoadLegacySavesAndReturnTheNumberOfLegacySaves(int NumberOfRegularSaves)
    {
        string[] FilesInSavesDirectory = ES3.GetFiles("saves");

        // get only .tung files and parse out the extension
        List <string> saves = new List <string>();

        foreach (string file in FilesInSavesDirectory)
        {
            if (file.Substring(file.Length - 5, 5) == ".tung") // if the extension is .tung
            {
                saves.Add(file.Substring(0, file.Length - 5));
            }
        }

        // generate the actual menu
        for (int i = 0; i < saves.Count; i++)
        {
            GameObject penis = Instantiate(SavedGamePrefab, Parent);
            penis.name = saves[i];
            // penis.transform.localPosition = new Vector3(0, -10 + i * -110, 0); // old method was to set position here, broken in 2017.3. Details on why in UISaveFile

            UISaveFile v****a = penis.GetComponent <UISaveFile>();
            v****a.FileName   = saves[i];
            v****a.Title.text = saves[i];

            v****a.LegacySave = true;
            v****a.LegacyWarning.SetActive(true);

            v****a.SetPosition(i + NumberOfRegularSaves); // new method of setting position

            // to find the size of the file, we have to load an ES3File instance
            ES3File file = new ES3File("saves/" + saves[i] + ".tung");

            v****a.Info.text =
                (file.Size() / 1024).ToString() + " kb | "                      // get file size
                + ES3.GetTimestamp("saves/" + saves[i] + ".tung").ToLocalTime() // get the local time of the last time the save was modified
                .ToString();

            UISaveFiles.Add(v****a);
        }

        Debug.Log(saves.Count.ToString() + " legacy saves");
        return(saves.Count);
    }
Пример #2
0
            static void Postfix(LoadGame __instance)
            {
                foreach (var saveFile in __instance.UISaveFiles) // Color BetterSaved games
                {
                    string fileName = BetterSaves.GetSaveDirectory() + "/" + saveFile.FileName + ".btung";
                    if (File.Exists(fileName))
                    {
                        saveFile.Title.text = $"<color=#15A51A>{saveFile.Title.text}</color>";
                        FileInfo info   = new FileInfo(fileName);
                        long     kBsize = info.Length / 1000;
                        DateTime time   = info.LastWriteTime;
                        saveFile.Info.text = $"{kBsize} kB | {time}";
                    }
                }
                string[]      files = Directory.GetFiles(BetterSaves.GetSaveDirectory());
                List <string> toAdd = new List <string>();

                foreach (string file in files) // Find bettersaves without regular save
                {
                    string basename = Path.GetFileNameWithoutExtension(file);
                    string tungName = BetterSaves.GetSaveDirectory() + "/" + basename + ".tung";
                    if (file.EndsWith(".btung") && !File.Exists(tungName))
                    {
                        toAdd.Add(basename);
                    }
                }
                int index = __instance.UISaveFiles.Count;

                foreach (string name in toAdd)
                {
                    GameObject obj = UnityEngine.Object.Instantiate(__instance.LoadGamePrefab, __instance.Parent);
                    obj.name = name;
                    UISaveFile entry = obj.GetComponent <UISaveFile>();
                    entry.FileName   = name;
                    entry.Title.text = $"<color=\"blue\">{name}</color>";
                    entry.SetPosition(index);
                    FileInfo info   = new FileInfo(BetterSaves.GetSaveDirectory() + "/" + name + ".btung");
                    long     kBSize = info.Length / 1000;
                    DateTime time   = info.LastWriteTime;
                    entry.Info.text = $"{kBSize} kB | {time}";
                    __instance.UISaveFiles.Add(entry);
                    index++;
                }
                __instance.Parent.sizeDelta = new Vector2(784f, (float)(10 + index * 110));
            }
Пример #3
0
    public int LoadSavesAndReturnTheNumberOfSaves()
    {
        string[] subdirectories = Directory.GetDirectories(Application.persistentDataPath + "/saves");
        PreviousSaveList = subdirectories; // so it doesn't automatically regenerate just after we've generated

        // get valid save directories
        List <string> savepaths = new List <string>();

        foreach (string directory in subdirectories)
        {
            if (File.Exists(directory + "/regions/world.tung"))
            {
                savepaths.Add(directory);
            }
        }

        for (int i = 0; i < savepaths.Count; i++)
        {
            GameObject    penis     = Instantiate(SavedGamePrefab, Parent);
            DirectoryInfo penisinfo = new DirectoryInfo(savepaths[i]);
            penis.name = penisinfo.Name; // get the name of the directory referenced by the path

            // penis.transform.localPosition = new Vector3(0, -10 + i * -110, 0); // old method was to set position here, broken in 2017.3. Details on why in UISaveFile

            UISaveFile v****a = penis.GetComponent <UISaveFile>();
            v****a.FileName   = penisinfo.Name;
            v****a.Title.text = penisinfo.Name;

            v****a.LegacySave = false;
            v****a.LegacyWarning.SetActive(false);

            v****a.SetPosition(i); // new method of setting position


            v****a.Info.text =
                (new FileInfo(savepaths[i] + "/regions/world.tung").Length / 1024).ToString() + " kb | " // get file size
                + penisinfo.LastAccessTime.ToString();                                                   // get the local time of the last time the save was modified

            UISaveFiles.Add(v****a);
        }

        Debug.Log(savepaths.Count.ToString() + " regular saves");
        return(savepaths.Count);
    }