public async void GenerateOnly() { if (!LimTunerManager.Instance.isInitialized) { MessageBoxManager.Instance.ShowMessage(LimLanguageManager.TextDict["Layesta_NoProject"]); return; } string path = WindowsDialogUtility.OpenFileDialog(LimLanguageManager.TextDict["Layesta_Export"], "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); File.Move(LimProjectManager.LapFolder + "/instance.layesta", path); WindowsDialogUtility.OpenExplorer(path); }
public void OpenProjectFolderDialog() { string Path = WindowsDialogUtility.OpenFolderDialog(""); if (Path == null) { return; } ProjectFolderPath.text = Path; if (isCreateProject) { ChartPath.text = LimLanguageManager.TextDict["Project_ChartWillGenerate"]; string EmptyChartPath = Path + "/EmptyChart.txt"; if (File.Exists(EmptyChartPath)) { EmptyChartPath = Path + "/EmptyChart_" + (new System.Random().Next(1000, 9999)).ToString() + ".txt"; } File.WriteAllText(Path + "/EmptyChart.txt", "{\"events\":null,\"eos\":0,\"bpm\":null,\"scroll\":null}"); CurrentProject.ChartPath = Path + "/EmptyChart.txt"; Name.text = new DirectoryInfo(Path).Name; CurrentProject.Name = Name.text; LapPath = Path + "/" + Name.text + ".lap"; } LimTutorialManager.ShowTutorial("FirstProject4"); }
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(); }
//Wizard public void AddBGA() { if (CurrentProject.BGACount() >= 3) { return; } string Path = WindowsDialogUtility.OpenFileDialog("", "", CurrentProject.ProjectFolder); StartCoroutine(AddBGACoroutine(Path)); }
public void OpenChartDialog() { string Path = WindowsDialogUtility.OpenFileDialog("", "", CurrentProject.ProjectFolder); if (Path == null) { return; } ChartPath.text = Path; CurrentProject.ChartPath = Path; }
public void LoadProject() { string Path = WindowsDialogUtility.OpenFileDialog("", LimLanguageManager.TextDict["Project_LoadFilter"], LimSystem.Preferences.LastOpenedChartFolder); if (Path == null) { return; } LapPath = Path; InitializeProjectWizard(Path); }
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; }
public void OpenMusicDialog() { string Path = WindowsDialogUtility.OpenFileDialog("", "", CurrentProject.ProjectFolder); if (Path == null) { return; } MusicPath.text = Path; CurrentProject.MusicPath = Path; LimTutorialManager.ShowTutorial("FirstProject5"); }
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"]; }
public void BuildAddChartFromFile() { if (!LimTunerManager.Instance.isInitialized) { return; } string path = WindowsDialogUtility.OpenFileDialog("", "*.txt|*.txt", LimProjectManager.LapFolder); if (path == null) { return; } GameObject temp = Instantiate(BuildChartPrefab, BuildChartListContent); LimLayestaBuildChart chart = temp.GetComponent <LimLayestaBuildChart>(); chart.Initialize(path); buildChartViews.Insert(0, chart); BuildRefreshChartList(); }
public void UploadFile() { if (_IsUploading) { return; } if (_SubmitDto == null) { return; } MessageBoxManager.Instance.ShowMessage(LimLanguageManager.TextDict["Submission_UploadRequest"], () => { string FilePath = WindowsDialogUtility.OpenFileDialog(LimLanguageManager.TextDict["Submission_File_Title"], "*.zip|*.zip", null); if (FilePath == null) { return; } StartCoroutine(UploadFileCoroutine(FilePath)); }); }
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); }
IEnumerator UploadCoroutine() { MessageBoxManager.Instance.ShowMessage(LimLanguageManager.TextDict["Layesta_Submission_Upload1"].Replace("<br>", "\n")); yield return(null); string path = WindowsDialogUtility.OpenFileDialog(LimLanguageManager.TextDict["Layesta_Submission_Load"], #if UNITY_EDITOR "layesta" #else "Layesta File|*.layesta" #endif , null); if (path == null) { yield break; } bool validate = LimLayestaReader.Validate(path); if (!validate) { UpdateUploadStatus("Layesta_Submission_UploadErr1"); yield break; } byte[] img = LimLayestaReader.LoadBackgroundImage(path); MemoryStream ms = new MemoryStream(img); MemoryStream msOut = new MemoryStream(); Kaliko.ImageLibrary.KalikoImage k = new Kaliko.ImageLibrary.KalikoImage(ms); k = k.Scale(new Kaliko.ImageLibrary.Scaling.PadScaling(640, 360)); k.SaveJpg(msOut, 80); ms.Close(); byte[] cov = msOut.GetBuffer(); msOut.Close(); UpdateUploadStatus("Layesta_Submission_Upload6"); #region Update Info byte[] buf = lzip.entry2Buffer(path, "info.bytes"); ms = new MemoryStream(buf); BinaryReader br = new BinaryReader(ms); level.ShouldDisplay = ShouldDisplay.isOn; level.Title = br.ReadString(); level.Difficulties = ""; br.ReadString(); int count = br.ReadInt32(); for (int i = 0; i < count; ++i) { level.Difficulties += (br.ReadString() + ((i == count - 1) ? "" : " ")); } br.ReadInt32(); br.ReadInt32(); if (br.BaseStream.Length > br.BaseStream.Position) { level.SongArtist = br.ReadString(); } if (br.BaseStream.Length > br.BaseStream.Position) { br.ReadInt32(); } br.Close(); ms.Close(); UnityWebRequest web = new UnityWebRequest { downloadHandler = new DownloadHandlerBuffer(), uploadHandler = new UploadHandlerRaw(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(level))), url = $"https://la.schwarzer.wang/layestalevel/update", method = "POST" }; web.SetRequestHeader("Authorization", $"Bearer {LimLayestaSubmissionManager.Instance.Bearer}"); web.SetRequestHeader("Content-Type", $"application/json; charset=utf-8"); web.SetRequestHeader("Accept", $"application/json; charset=utf-8"); yield return(web.SendWebRequest()); if (!string.IsNullOrWhiteSpace(web.error)) { UpdateUploadStatus("Layesta_Submission_UploadErr2"); yield break; } Debug.Log(web.downloadHandler.text); LayestaLevelResponse infoRet = JsonConvert.DeserializeObject <LayestaLevelResponse>(web.downloadHandler.text); if (!infoRet.Succeed) { if (infoRet.ErrorCode == ErrorCode.MissingInfo) { UpdateUploadStatus("Layesta_Submission_UploadErr3"); } else { UpdateUploadStatus("Layesta_Submission_UploadErr2"); } yield break; } #endregion UpdateUploadStatus("Layesta_Submission_Upload2"); #region Get Layesta Upload web = new UnityWebRequest { downloadHandler = new DownloadHandlerBuffer(), url = $"https://la.schwarzer.wang/auth/oss/upload/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)) { 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; } #endregion string layestaUrl = response["Uri"].Value <string>(); string layestaCb = response["Callback"].Value <string>(); UpdateUploadStatus("Layesta_Submission_Upload3"); #region Get Cover Upload web = new UnityWebRequest { downloadHandler = new DownloadHandlerBuffer(), url = $"https://la.schwarzer.wang/auth/oss/upload/cover/{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)) { yield break; } ret = web.downloadHandler.text; response = JObject.Parse(ret); if (!response["Succeed"].Value <bool>()) { MessageBoxManager.Instance.ShowMessage(((ErrorCode)response["ErrorCode"].Value <int>()).ToString()); yield break; } #endregion string coverUrl = response["Uri"].Value <string>(); string coverCb = response["Callback"].Value <string>(); UpdateUploadStatus("Layesta_Submission_Upload4"); #region Upload Layesta web = new UnityWebRequest { downloadHandler = new DownloadHandlerBuffer(), uploadHandler = new UploadHandlerRaw(File.ReadAllBytes(path)), url = layestaUrl, method = "PUT" }; web.SetRequestHeader("Content-Type", ""); web.SetRequestHeader("User-Agent", LimLayestaSubmissionManager.Instance.Id); web.SetRequestHeader("x-oss-callback", layestaCb); ProgressBarManager.Instance.ShowProgress(() => web.isDone, () => web.uploadProgress); yield return(web.SendWebRequest()); if (!string.IsNullOrWhiteSpace(web.error)) { UpdateUploadStatus("Layesta_Submission_UploadErr2"); Debug.Log(web.downloadHandler.text); yield break; } ret = web.downloadHandler.text; Debug.Log(ret); response = JObject.Parse(ret); if (response["Message"].Value <string>() != "Succeed") { UpdateUploadStatus("Layesta_Submission_UploadErr2"); MessageBoxManager.Instance.Message.text += response["Message"].Value <string>(); yield break; } #endregion UpdateUploadStatus("Layesta_Submission_Upload5"); #region Upload Cover web = new UnityWebRequest { downloadHandler = new DownloadHandlerBuffer(), uploadHandler = new UploadHandlerRaw(cov), url = coverUrl, method = "PUT" }; web.SetRequestHeader("Content-Type", ""); web.SetRequestHeader("User-Agent", LimLayestaSubmissionManager.Instance.Id); web.SetRequestHeader("x-oss-callback", coverCb); ProgressBarManager.Instance.ShowProgress(() => web.isDone, () => web.uploadProgress); yield return(web.SendWebRequest()); if (!string.IsNullOrWhiteSpace(web.error)) { UpdateUploadStatus("Layesta_Submission_UploadErr2"); Debug.Log(web.downloadHandler.text); yield break; } ret = web.downloadHandler.text; Debug.Log(ret); response = JObject.Parse(ret); if (response["Message"].Value <string>() != "Succeed") { UpdateUploadStatus("Layesta_Submission_UploadErr2"); MessageBoxManager.Instance.Message.text += response["Message"].Value <string>(); yield break; } #endregion UpdateUploadStatus("Layesta_Submission_Upload7"); LimLayestaSubmissionManager.Instance.EmptyList(); LimLayestaSubmissionManager.Instance.Refresh(); }