示例#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
    /// <summary>Uploads a local file to the server, overwriting any existing file.</summary>
    /// <param name="settings">The settings we want to use to override the default settings.</param>
    /// <param name="user">The unique name of the user this file belongs to, if the file isn't globally accessible.</param>
    /// <param name="password">The password of the user this file belongs to.</param>
    private IEnumerator UploadFile(ES3Settings settings, string user, string password)
    {
        Reset();

        var form = CreateWWWForm();

        form.AddField("apiKey", apiKey);
        form.AddField("putFile", settings.path);
        form.AddField("timestamp", DateTimeToUnixTimestamp(ES3.GetTimestamp(settings)).ToString());
        form.AddField("user", GetUser(user, password));
        form.AddBinaryData("data", ES3.LoadRawBytes(settings), "data.dat", "multipart/form-data");

        using (var webRequest = UnityWebRequest.Post(url, form))
        {
            yield return(webRequest.Send());

            HandleError(webRequest, true);
        }

        isDone = true;
    }
示例#3
0
 private long GetFileTimestamp(ES3Settings settings)
 {
     return(DateTimeToUnixTimestamp(ES3.GetTimestamp(settings)));
 }
示例#4
0
 private IEnumerator UploadFile(byte[] bytes, ES3Settings settings, string user, string password)
 {
     return(UploadFile(bytes, settings, user, password, DateTimeToUnixTimestamp(ES3.GetTimestamp(settings))));
 }