Exemplo n.º 1
0
    public async void BuildLayestaFile()
    {
        if (!LimTunerManager.Instance.isInitialized)
        {
            MessageBoxManager.Instance.ShowMessage(LimLanguageManager.TextDict["Layesta_NoProject"]);
            return;
        }
        string path = WindowsDialogUtility.SaveFileDialog(LimLanguageManager.TextDict["Layesta_Build_Window"], "Layesta Level|*.layesta", LimProjectManager.LapFolder);

        if (path == null)
        {
            return;
        }
        if (!path.EndsWith(".layesta"))
        {
            path += ".layesta";
        }
        filesToZip.Clear();
        Directory.CreateDirectory(LimProjectManager.LapFolder + "/Layesta");
        EncodeBackgrounds(true);
        await PrepareLayestaFileAsync(true);

        if (File.Exists(path))
        {
            File.Delete(path);
        }
        File.Move(LimProjectManager.LapFolder + "/instance.layesta", path);
        WindowsDialogUtility.OpenExplorer(path);
    }
Exemplo n.º 2
0
    public void SaveAsProject()
    {
        if (LimSystem.ChartContainer == null)
        {
            return;
        }
        string ChartPath = WindowsDialogUtility.SaveFileDialog("", "Chart (*.txt)|*.txt", "");

        if (ChartPath == null)
        {
            return;
        }
        if (!ChartPath.EndsWith(".txt"))
        {
            ChartPath += ".txt";
        }
        File.WriteAllText(ChartPath, LimSystem.ChartContainer.ChartData.ToString());
        LimNotifyIcon.ShowMessage(LimLanguageManager.NotificationDict["Project_Saved"]);
        if (LimSystem.Preferences.CloudAutosave)
        {
            CloudManager.UploadChart();
        }
        ChartSaveLocation        = ChartPath;
        CurrentProject.ChartPath = ChartPath;
        SaveProjectFile();
    }
Exemplo n.º 3
0
    IEnumerator DownloadChart()
    {
        isDownloading = true;
        WWW Download = new WWW(LimSystem.LanotaliumServer + "/lanotalium/chartzone/" + Data.ChartName + "/" + Data.ChartName + ".zip");

        DownloadSlider.value = 0;
        while (!Download.isDone)
        {
            DownloadSlider.value = Download.progress;
            SizeText.text        = (Download.progress * 100).ToString("f2") + "%";
            yield return(null);
        }
        DownloadSlider.value = 1;
        SizeText.text        = "100.00%";
        SizeText.text        = Data.Size;
        byte[] Chart = Download.bytes;
#if UNITY_STANDALONE
        string SavePath = WindowsDialogUtility.SaveFileDialog("", "(.zip)|*.zip", Data.ChartName + ".zip");
        if (SavePath == null)
        {
            yield break;
        }
        File.WriteAllBytes(SavePath, Chart);
        Process.Start("explorer.exe", "/select," + SavePath.Replace("/", "\\"));
#endif
#if UNITY_IOS
        string SaveDirectory = UnityEngine.Application.persistentDataPath + "/chartzone/" + Data.ChartName;
        string SavePath      = UnityEngine.Application.persistentDataPath + "/chartzone/" + Data.ChartName + "/" + Data.ChartName + ".zip";
        Directory.CreateDirectory(Directory.GetParent(SavePath).FullName);
        File.WriteAllBytes(SavePath, Chart);
        ICSharpCode.SharpZipLib.Zip.FastZip fastZip = new ICSharpCode.SharpZipLib.Zip.FastZip();
        Task ExtractTask = new Task(() => fastZip.ExtractZip(SavePath, SaveDirectory, ""));
        ExtractTask.Start();
        while (ExtractTask.Status == TaskStatus.Running)
        {
            yield return(null);
        }
        Lanotalium.Project.LanotaliumProject lanotaliumProject = new Lanotalium.Project.LanotaliumProject
        {
            Name      = Data.ChartName,
            Designer  = Data.Designer,
            BGA0Path  = SaveDirectory + "/background0.png",
            ChartPath = SaveDirectory + "/chart.txt",
            MusicPath = SaveDirectory + "/music.ogg"
        };
        File.WriteAllText(SaveDirectory + "/project.lap", Newtonsoft.Json.JsonConvert.SerializeObject(lanotaliumProject));
        LimChartZoneManager.OpenDownloadedChart    = true;
        LimChartZoneManager.DownloadedChartLapPath = SaveDirectory + "/project.lap";
        isDownloading = false;
        SceneManager.LoadScene("LimTuner");
#endif
        isDownloading = false;
    }
Exemplo n.º 4
0
    IEnumerator DownloadCoroutine(TransferType Type)
    {
        WWWForm DownloadForm = new WWWForm();

        DownloadForm.AddField("UserId", UserId);
        switch (Type)
        {
        case TransferType.Backup:
            DownloadForm.AddField("FileName", "backup.txt");
            break;

        case TransferType.Chart:
            DownloadForm.AddField("FileName", "chart.txt");
            break;
        }
        DownloadForm.AddField("ProjectName", LimSystem.ChartContainer.ChartProperty.ChartName);
        WWW Download = new WWW(LimSystem.LanotaliumServer + "/lanotalium/cloud/LimCloudDownloader.php", DownloadForm);

        ProgressSlider.value = 0;
        EntryText.text       = LimLanguageManager.TextDict["Cloud_Downloading"];
        while (!Download.isDone)
        {
            ProgressSlider.value = Download.progress;
            yield return(null);
        }
        string Chart = Download.text;

        if (Chart == "F A Q!")
        {
            yield break;
        }

        string ChartPath = WindowsDialogUtility.SaveFileDialog("", "Chart (*.txt)|*.txt", "");

        if (!string.IsNullOrWhiteSpace(ChartPath))
        {
            if (!ChartPath.EndsWith(".txt"))
            {
                ChartPath += ".txt";
            }
            File.WriteAllText(ChartPath, Chart);
            Process.Start("explorer.exe", "/select," + ChartPath);
        }
        ProgressSlider.value = 0;
        EntryText.text       = LimLanguageManager.TextDict["Cloud_Cloud"];
    }
Exemplo n.º 5
0
    IEnumerator DownloadCoroutine()
    {
        string path = WindowsDialogUtility.SaveFileDialog(LimLanguageManager.TextDict["Layesta_Submission_Save"],
#if UNITY_EDITOR
                                                          "layesta"
#else
                                                          "Layesta File|*.layesta"
#endif
                                                          , null);

        if (path == null)
        {
            yield break;
        }
        UnityWebRequest web = new UnityWebRequest
        {
            downloadHandler = new DownloadHandlerBuffer(),
            url             = $"https://la.schwarzer.wang/auth/oss/download/layesta/{level.Guid}",
            method          = "GET"
        };

        web.SetRequestHeader("Authorization", $"Bearer {LimLayestaSubmissionManager.Instance.Bearer}");
        yield return(web.SendWebRequest());

        if (web.responseCode == 401)
        {
            LimLayestaSubmissionManager.Instance.TokenInvalid();
            yield break;
        }
        if (!string.IsNullOrWhiteSpace(web.error))
        {
            Debug.Log(web.error);
            yield break;
        }
        string  ret      = web.downloadHandler.text;
        JObject response = JObject.Parse(ret);

        if (!response["Succeed"].Value <bool>())
        {
            MessageBoxManager.Instance.ShowMessage(((ErrorCode)response["ErrorCode"].Value <int>()).ToString());
            yield break;
        }
        string url = response["Uri"].Value <string>();

        web = new UnityWebRequest
        {
            downloadHandler = new DownloadHandlerFile(path),
            url             = url,
            method          = "GET"
        };
        web.SetRequestHeader("User-Agent", LimLayestaSubmissionManager.Instance.Id);
        ProgressBarManager.Instance.ShowProgress(() => web.isDone, () => web.downloadProgress);
        yield return(web.SendWebRequest());

        if (!string.IsNullOrWhiteSpace(web.error))
        {
            Debug.Log(web.error);
            yield break;
        }
        WindowsDialogUtility.OpenExplorer(path);
    }