public List <string> searchFiles(string[] data) { lock (loadFilesLock) { List <string> urls = new List <string>(); foreach (string file in data) { var dataJson = DatabaseFilesEntity.FromJson(file); if (UtilityTools.ContainsAll(dataJson.Title.ToLower(), UtilityTools.GetWords(txtFilesSearchResults.Text.ToLower())) && dataJson.Title.Contains(selectedFilesQuality) && dataJson.Type.Contains(selectedFilesFileType) && dataJson.Host.Contains(selectedFilesHost)) { urls.Add(dataJson.ToJson()); } } return(urls); } }
public List <string> searchFiles(List <string> dataFiles) { lock (loadFilesLock) { List <string> urls = new List <string>(); foreach (string file in dataFiles) { var dataJson = JsonConvert.DeserializeObject <Models.WebFile>(file); if (UtilityTools.ContainsAll(dataJson.Title.ToLower(), UtilityTools.GetWords(txtSearchFiles.Text.ToLower())) && selectedFilesFileType.Contains(dataJson.Type) && dataJson.Host.Contains(selectedFilesHost)) { urls.Add(JsonConvert.SerializeObject(dataJson)); } } return(urls); } }
private void ctrlMovieDetails_Load(object sender, EventArgs e) { if (TrailerURL == "") { btnWatchTrailer.Visible = false; } if (PosterURL == "") { imgPoster.Image = UtilityTools.SetAlpha(WebCrunch.Properties.Resources.poster_default, 255); } panelTitleFiles.Size = new Size(panelDetails.Size.Width, panelTitleFiles.Size.Height); panelStreams.Size = new Size(panelDetails.Size.Width, panelStreams.Size.Height); foreach (Control ctrl in panelStreams.Controls) { ctrl.Size = new Size(panelDetails.Size.Width - 3, ctrl.Size.Height); } }
protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { UtilityTools.Dispose(); if (this.DbContextTransaction != null) { this.DbContextTransaction.Dispose(); this.DbContextTransaction = null; } this.DbContext.Dispose(); this.DbContext = null; } disposedValue = true; } }
private void ctrlStreamInfo_Load(object sender, EventArgs e) { BackColor = Color.Transparent; VLCToolStripMenuItem.Visible = File.Exists(frmOpenTheatre.pathVLC); MPCToolStripMenuItem.Visible = File.Exists(frmOpenTheatre.pathMPCCodec64) || File.Exists(frmOpenTheatre.pathMPC64) || File.Exists(frmOpenTheatre.pathMPC86); if (Properties.Settings.Default.Bookmarks.Contains(infoFileURL)) { imgAddToBookmarks.Image = Properties.Resources.bookmark_remove; } else { imgAddToBookmarks.Image = Properties.Resources.bookmark_plus; } try { WebRequest req = WebRequest.Create(infoFileURL); req.Method = "HEAD"; req.Timeout = 1500; using (HttpWebResponse fileResponse = (HttpWebResponse)req.GetResponse()) { DateTime fileModifiedTime = fileResponse.LastModified; if (fileModifiedTime != null) { infoFileDateAdded.Text = UtilityTools.getTimeAgo(fileModifiedTime); } else { infoFileDateAdded.Text = "n/a"; } int ContentLength; if (int.TryParse(fileResponse.Headers.Get("Content-Length"), out ContentLength)) { infoFileSize.Text = UtilityTools.ToFileSize(Convert.ToDouble(ContentLength)); } else { infoFileSize.Text = "n/a"; } } } catch { infoFileSize.Text = "n/a"; infoFileDateAdded.Text = "n/a"; } }
private void loadLocalFiles() { dataFilesLocal.Clear(); foreach (var pathFile in Directory.GetFiles(userDownloadsDirectory)) { var dataJson = new Models.WebFile { URL = pathFile, Host = rm.GetString("local"), Title = Path.GetFileNameWithoutExtension(pathFile), Type = Path.GetExtension(pathFile).Replace(".", "").ToUpper(), Size = UtilityTools.bytesToString(new FileInfo(pathFile).Length), DateAdded = File.GetCreationTime(pathFile).ToString() }; dataFilesLocal.Add(JsonConvert.SerializeObject(dataJson)); } }
// Update is called once per frame private void Update() { if (Input.GetKeyDown(KeyCode.R)) { //spawnTriBox(previewBoxes.getCurrentBoxElements()); //previewBoxes.generateNextPreview(); RestartGame(); } if (Input.GetKeyDown(KeyCode.Escape)) { UtilityTools.QuitGame(); } if (Input.GetKeyDown(KeyCode.M)) { toggleMatch3Phase(); } }
private void InfoPoster_MouseEnter(object sender, EventArgs e) { try { if (!(infoPoster2.Image == null)) { infoPoster2.Image.Dispose(); } infoPoster2.Image = new Bitmap(infoPoster.BackgroundImage); infoPoster.BackgroundImage.Dispose(); infoPoster.BackgroundImage = UtilityTools.SetAlpha((Bitmap)infoPoster2.Image, 100); Update(); } catch { infoPoster.BackgroundImage = UtilityTools.SetAlpha(WebCrunch.Properties.Resources.poster_default, 255); } }
private void InfoPoster_ClickButtonArea(object Sender, MouseEventArgs e) { MainForm.form.tabBlank.Controls.Clear(); MovieDetails MovieDetails = new MovieDetails(); MovieDetails.infoTitle.Text = infoTitle.Text; MovieDetails.infoYear.Text = infoYear.Text; MovieDetails.infoGenre.Text = infoGenres; MovieDetails.infoSynopsis.Text = infoSynopsis; MovieDetails.infoRuntime.Text = infoRuntime; MovieDetails.infoRated.Text = infoRated; MovieDetails.infoDirector.Text = infoDirector; MovieDetails.infoCast.Text = infoCast; MovieDetails.infoRatingIMDb.Text = infoImdbRating; MovieDetails.ImdbId = infoImdbId; MovieDetails.TrailerURL = infoTrailer; MovieDetails.FanartURL = infoImageFanart; MovieDetails.PosterURL = infoImagePoster; try { if (infoImagePoster != "") { MovieDetails.imgPoster.Image = UtilityTools.SetAlpha(UtilityTools.LoadPicture(infoImagePoster), 255); } if (infoImageFanart != "") { MovieDetails.BackgroundImage = UtilityTools.SetAlpha(UtilityTools.LoadPicture(infoImageFanart), 50); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\n\n" + infoImageFanart); } foreach (var movieLink in infoMovieStreams) { MovieDetails.AddStream(movieLink, false, MovieDetails.panelStreams); } MovieDetails.Dock = DockStyle.Fill; MainForm.form.tabBlank.Controls.Clear(); MainForm.form.tabBlank.Controls.Add(MovieDetails); MainForm.form.tab.SelectedTab = MainForm.form.tabBlank; }
/// <summary> /// 导出场景 /// </summary> public static bool ExportCurrentScene(bool useSceneFolder, bool compress) { var sceneName = UtilityTools.GetFileName(EditorApplication.currentScene); string pathName; if (useSceneFolder) { pathName = UtilityTools.GenResExportPath(string.Format("scene/{0}", sceneName), sceneName); } else { pathName = UtilityTools.GenResExportPath("scene", sceneName); } if (string.IsNullOrEmpty(pathName)) { return(false); } var options = BuildOptions.None; if (!compress) { options |= BuildOptions.UncompressedAssetBundle; } // 导出 var levels = new string[] { EditorApplication.currentScene }; BuildPipeline.PushAssetDependencies(); string error = BuildPipeline.BuildStreamedSceneAssetBundle(levels, pathName, EditorUserBuildSettings.activeBuildTarget, options); if (!string.IsNullOrEmpty(error)) { EndExportAsset(); Debug.LogErrorFormat("Export Scene \"{0}\" failed! error: {1}", sceneName, error); return(false); } EndExportAsset(); return(true); }
/// <summary> /// 导出资源包 /// </summary> public static bool ExportRes(ResExportDesc rd, bool compress) { // 导出 string pathName = UtilityTools.GenResExportPath(rd.resDir, rd.resName); var names = new string[] { rd.resName }; var assets = new UnityEngine.Object[] { rd.asset }; var options = BuildAssetBundleOptions.DeterministicAssetBundle; if (!compress) { options |= BuildAssetBundleOptions.UncompressedAssetBundle; } if (!BuildPipeline.BuildAssetBundleExplicitAssetNames(assets, names, pathName, options, EditorUserBuildSettings.activeBuildTarget)) { Debug.LogErrorFormat("ExportAssetBundle {0} failed!", pathName); return(false); } return(true); }
public void SetSceneSavePath(int i) { EditorGUILayout.BeginHorizontal(EditorStyles.textArea); EditorGUILayout.LabelField("场景配置文件的路径"); //获得一个长300的框 SavePathRect = EditorGUILayout.GetControlRect(true, GUILayout.ExpandWidth(true)); //将上面的框作为文本输入框 string vaule = EditorGUI.TextField(SavePathRect, _SceneSavePathList[i]).ToString(); UtilityTools.DropToTextFiled(SavePathRect, ref vaule); _SceneSavePathList[i] = vaule; if (GUILayout.Button("拼接")) { Debug.Log(_SceneSavePathList[i]); //打开对应场景,进行拼接 SplitJointCutscene.ReplaceArt("CutSceneArt", "CutScene", _SceneSavePathList[i], _DestiionSceneName, null, "CutScene"); SplitJointCutscene.ReplaceArt("PathArt", "Path", _SceneSavePathList[i], _DestiionSceneName, null, "CutScenePath"); } EditorGUILayout.EndHorizontal(); }
private void InfoPoster_MouseEnter(object sender, EventArgs e) { try { if (!(infoPoster2.Image == null)) { infoPoster2.Image.Dispose(); } infoPoster2.Image = new Bitmap(infoPoster.BackgroundImage); infoPoster.BorderShow = true; infoPoster.BackgroundImage.Dispose(); infoPoster.BackgroundImage = UtilityTools.ChangeOpacity(infoPoster2.Image, 0.4F); Update(); } catch { infoPoster.BackgroundImage = UtilityTools.ChangeOpacity(Properties.Resources.poster_default, 0.4F); } }
private void cmboBoxFilesSort_SelectedIndexChanged(object sender, EventArgs e) { imgSpinner.Visible = true; var startText = btnFilesSort.Text.Split(':'); btnFilesSort.Text = startText[0] + ": " + cmboBoxFilesSort.SelectedItem.ToString(); if (cmboBoxFilesSort.SelectedIndex == 0) { cmboBoxFilesSort.DropDownWidth = UtilityTools.DropDownWidth(cmboBoxFilesSort); showFiles(selectedFiles); } else if (cmboBoxFilesSort.SelectedIndex == 1) { dataGridFiles.Sort(dataGridFiles.Columns[1], ListSortDirection.Ascending); } else if (cmboBoxFilesSort.SelectedIndex == 2) { dataGridFiles.Sort(dataGridFiles.Columns[1], ListSortDirection.Descending); } imgSpinner.Visible = false; }
public void showSelectedFiles(string[] files) { BackGroundWorker.RunWorkAsync <List <string> >(() => searchFiles(files), (data) => { if (tabFiles.InvokeRequired) { loadFilesCallBack b = new loadFilesCallBack(showSelectedFiles); Invoke(b, new object[] { files }); } else { ComponentResourceManager resources = new ComponentResourceManager(typeof(frmOpenTheatre)); cmboBoxFilesSort.SelectedIndex = 0; dataGridFiles.Rows.Clear(); cmboBoxFilesHost.Items.Clear(); cmboBoxFilesHost.Items.Add(resources.GetString("cmboBoxFilesHost.Items")); cmboBoxFilesFormat.Items.Clear(); cmboBoxFilesFormat.Items.Add(resources.GetString("cmboBoxFilesFormat.Items")); foreach (string jsonData in data) { var dataJson = DatabaseFilesEntity.FromJson(jsonData); string dateAdded = dataJson.DateAdded; if (dataJson.DateAdded != "-") { dateAdded = UtilityTools.getTimeAgo(Convert.ToDateTime(dataJson.DateAdded)); } dataGridFiles.Rows.Add(dataJson.Type, dataJson.Title, dataJson.Size, dateAdded, dataJson.Host, dataJson.URL); if (!(cmboBoxFilesFormat.Items.Contains(dataJson.Type))) { cmboBoxFilesFormat.Items.Add(dataJson.Type); } if (!(cmboBoxFilesHost.Items.Contains(dataJson.Host))) { cmboBoxFilesHost.Items.Add(dataJson.Host); } } cmboBoxFilesHost.DropDownWidth = DropDownWidth(cmboBoxFilesHost); imgSpinner.Visible = false; } }); }
private void downloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) { double totalReceivedValue = Convert.ToDouble(e.TotalBytesToReceive); double receivedValue = Convert.ToDouble(e.BytesReceived); progressBar1.Value = e.ProgressPercentage; infoStatus.Text = "Downloading"; infoPercentage.Text = e.ProgressPercentage + "%"; // Get remaining time var elapsedTime = (DateTime.Now - startTime).TotalSeconds; var allTimeFordownloading = (elapsedTime * e.TotalBytesToReceive / e.BytesReceived); var remainingTime = allTimeFordownloading - elapsedTime; TimeSpan time = TimeSpan.FromSeconds(remainingTime); infoEstimatedTime.Text = string.Format("{0} Minutes {1} Seconds", time.Minutes, time.Seconds); infoDownloadedOutOfSize.Text = string.Format("{0}/{1}", UtilityTools.ToFileSize(receivedValue), UtilityTools.ToFileSize(totalReceivedValue)); infoSpeed.Text = string.Format("{0}/s ↓", UtilityTools.ToFileSize((e.BytesReceived / 1024d / sw.Elapsed.TotalSeconds))); Refresh(); }
/// ----------------------------------------------------------------------------------------------------------- /// <summary> /// 初始化窗口的布局 /// </summary> /// ----------------------------------------------------------------------------------------------------------- void OnEnable() { if (Application.isPlaying) { return; } string sceneName = UtilityTools.GetFileName(EditorApplication.currentScene); TerrainPatchPath = "Assets/Export/TearrinPatch/" + sceneName; if (!Directory.Exists(TerrainPatchPath)) { Directory.CreateDirectory(TerrainPatchPath); } /// 属性 lable1 = new GUIContent("选择地图"); lable3 = new GUIContent("分割维度"); lable4 = new GUIContent("保存路径"); lable5 = new GUIContent("重置路径"); lable6 = new GUIContent("覆盖数据"); lable7 = new GUIContent("平滑边缘"); lable8 = new GUIContent("拷贝植被"); lable9 = new GUIContent("拷贝细节"); selection = Selection.activeObject as GameObject; if (selection != null) { baseTerrain = selection.GetComponent <Terrain>(); resolutionPerPatch = baseTerrain.terrainData.detailResolutionPerPatch; } if (baseTerrain == null) { Debug.Log("选择的GameOject 没有 Terrain 属性"); return; } }
protected void btnLoginButton_Click(object sender, EventArgs e) { string loginId = txtBoxUsername.Text; string password = txtBoxPassword.Text; bool isChecked = chkRemeberMe.Checked; SQLHelper helper = new SQLHelper(); bool isLoginedIn = helper.IsUserLogin(loginId, password); if (isLoginedIn) { Session["LoginID"] = loginId; if (isChecked) { UtilityTools.CreateCookies("LoginIDCookie", "LoginID", loginId, 24); } Response.Redirect("~/UI/Orders.aspx"); } else { Response.Write("Login Failed"); } }
void worker_DoWork(object sender, DoWorkEventArgs e) { // Checks if database file exists, if so whether they're the same size, and downloads the latest one if any of them returns false // if (UtilityTools.doUpdateFile(linkOpenDirectories, "open-directories.txt")) { client.DownloadFile(new Uri(linkOpenDirectories), pathData + "open-directories.txt"); } dataOpenDirectories.AddRange(File.ReadAllLines(pathData + "open-directories.txt")); // // if (UtilityTools.doUpdateFile(linkOpenFiles, "open-files.json")) { client.DownloadFile(new Uri(linkOpenFiles), pathData + "open-files.json"); } databaseInfo = File.ReadLines(pathData + "open-files.json").First(); dataOpenFiles.AddRange(File.ReadAllLines(pathData + "open-files.json").Skip(1)); // }
private void ctrlFileDetails_Load(object sender, EventArgs e) { VLCToolStripMenuItem.Visible = File.Exists(MainForm.pathVLC); MPCToolStripMenuItem.Visible = File.Exists(MainForm.pathMPCCodec64) || File.Exists(MainForm.pathMPC64) || File.Exists(MainForm.pathMPC86); if (videoFileTypes.Contains(infoType.Text.ToUpper()) || audioFileTypes.Contains(infoType.Text.ToUpper())) { btnPlayMedia.Visible = true; } if (infoAge.Text == "-") { try { infoAge.Text = UtilityTools.getTimeAgo(Convert.ToDateTime(UtilityTools.getLastModifiedTime(infoFileURL.Text))); } catch { infoAge.Text = "-"; } } if (infoSize.Text == "-") { btnRequestFileSize.Visible = true; } if (infoFileSubtitles == null) { if (UtilityTools.isExistingSubtitlesFile(infoFileURL.Text) == true) { infoFileSubtitles = MainForm.userDownloadsDirectory + Path.GetFileNameWithoutExtension(infoFileURL.Text) + ".srt"; } } if (UtilityTools.isSaved(UtilityTools.fileToJson(infoFileURL.Text, infoName.Text, infoType.Text, infoReferrer.Text))) { btnSaveFile.Image = WebCrunch.Properties.Resources.bookmark_remove; } else { btnSaveFile.Image = WebCrunch.Properties.Resources.bookmark_plus; } }
private void btnRequestFileSize_ClickButtonArea(object Sender, MouseEventArgs e) { try { btnRequestFileSize.Visible = false; WebRequest req = WebRequest.Create(infoFileURL.Text); req.Method = "HEAD"; req.Timeout = 10000; using (HttpWebResponse fileResponse = (HttpWebResponse)req.GetResponse()) { int ContentLength; if (int.TryParse(fileResponse.Headers.Get("Content-Length"), out ContentLength)) { infoSize.Text = UtilityTools.ToFileSize(Convert.ToDouble(ContentLength)); } else { infoSize.Text = "Error"; } } } catch { infoSize.Text = "Error"; } }
private void ctrlStreamInfo_Load(object sender, EventArgs e) { BackColor = Color.Transparent; VLCToolStripMenuItem.Visible = File.Exists(frmOpenTheatre.pathVLC); MPCToolStripMenuItem.Visible = File.Exists(frmOpenTheatre.pathMPCCodec64) || File.Exists(frmOpenTheatre.pathMPC64) || File.Exists(frmOpenTheatre.pathMPC86); if (Properties.Settings.Default.dataBookmarks.Contains(infoFileURL)) { imgAddToBookmarks.Image = Properties.Resources.bookmark_remove; } else { imgAddToBookmarks.Image = Properties.Resources.bookmark_plus; } if (isTorrent == true) { imgReportBroken.Visible = false; imgWatch.Visible = false; imgMagnet.Visible = true; } else if (isLocal == true) { infoFileHost.Text = frmOpenTheatre.rm.GetString("local"); imgDownload.Visible = false; imgReportBroken.Visible = false; imgShare.Visible = false; imgCopyURL.Visible = false; } // Checks for exact file name of a subtitle file that matches the one being loaded (e.g. Media File Name: 'Jigsaw.2017.mp4' > Subtitle File Name: 'Jigsaw.2017.srt' will be loaded) if (infoFileSubtitles == null) { if (UtilityTools.isExistingSubtitlesFile(infoFileURL) == true) { infoFileSubtitles = frmOpenTheatre.userDownloadsDirectory + Path.GetFileNameWithoutExtension(infoFileURL) + ".srt"; } } }
//--------------------------------------------------------------------------------------- // 开启 //--------------------------------------------------------------------------------------- void OnEnable() { _sceneName = UtilityTools.GetFileName(EditorApplication.currentScene); LoadSettings(); }
private void imgReportBroken_Click(object sender, EventArgs e) { UtilityTools.openBrokenFileIssue(infoFileURL); }
public void toggleMatch3Phase() { if (match3Uses < 0 && isMatch3Phase || match3_ref.GetMovingBox() != null) { return; } isMatch3Phase = !isMatch3Phase; if (isMatch3Phase) { match3Uses--; if (match3Uses < 0) { match3Uses = 0; } scoreUI.UpdateMatch3Uses(match3Uses); } else { foreach (Box b in UtilityTools.FindComponentsWithTag <Box>("Box")) { if (b.isHighlighted) { b.Highlight(false); } if (b.transform.localScale.x > 1) { if (b.GetKillSequence() != null) { if (b.GetKillSequence().IsPlaying()) { continue; } } b.transform.DOScale(Vector3.one, TheGrid.moveTime); Vector3 temp = b.transform.position; temp.z = -1; b.transform.position = temp; } } } //darrken some sprites when in this mode float h, s, v; if (gridLayout_ref) { foreach (Transform go in gridLayout_ref.transform) { SpriteRenderer tile = go.GetComponent <SpriteRenderer>(); if (tile != null) { Color normal = Tile.getKindColor(go.GetComponent <Tile>().GetKind()); Color.RGBToHSV(normal, out h, out s, out v); v *= 0.5f; Color desaturated = Color.HSVToRGB(h, s, v); tile.DOColor((isMatch3Phase) ? desaturated : normal, TheGrid.moveTime * 2); } } } player.GetComponent <SpriteRenderer>().DOColor((isMatch3Phase) ? Color.gray : Color.white, TheGrid.moveTime * 2); }
void worker_DoWork(object sender, DoWorkEventArgs e) { try { // if (UtilityTools.doUpdateFile(linkMovies, "movies-posters.json")) { client.DownloadFile(new Uri(linkMovies), pathData + "movies-posters.json"); } dataMovies = File.ReadAllLines(pathData + "movies-posters.json"); // // if (UtilityTools.doUpdateFile(linkFilesVideo, "video-files.json")) { //client.DownloadFile(new Uri(linkFilesVideo), pathData + "video-files.json"); } dataFilesVideo = File.ReadAllLines(pathData + "video-files.json"); // // if (UtilityTools.doUpdateFile(linkFilesAudio, "audio-files.json")) { //client.DownloadFile(new Uri(linkFilesAudio), pathData + "audio-files.json"); } dataFilesAudio = File.ReadAllLines(pathData + "audio-files.json"); // // if (UtilityTools.doUpdateFile(linkFilesEbooks, "ebooks-files.json")) { //client.DownloadFile(new Uri(linkFilesEbooks), pathData + "ebooks-files.json"); } dataFilesEbooks = File.ReadAllLines(pathData + "ebooks-files.json"); // // if (UtilityTools.doUpdateFile(linkFilesSubtitles, "subtitles-files.json")) { //client.DownloadFile(new Uri(linkFilesSubtitles), pathData + "subtitles-files.json"); } dataFilesSubtitles = File.ReadAllLines(pathData + "subtitles-files.json"); // // if (UtilityTools.doUpdateFile(linkFilesTorrents, "torrents-files.json")) { //client.DownloadFile(new Uri(linkFilesTorrents), pathData + "torrents-files.json"); } dataFilesTorrents = File.ReadAllLines(pathData + "torrents-files.json"); // // if (UtilityTools.doUpdateFile(linkFilesArchives, "archives-files.json")) { //client.DownloadFile(new Uri(linkFilesArchives), pathData + "archives-files.json"); } dataFilesArchives = File.ReadAllLines(pathData + "archives-files.json"); // // Get Local Files loadLocalFiles(); } catch (Exception ex) { MessageBox.Show(rm.GetString("errorConnectToServer") + "\n\n" + ex.Message); Directory.Delete(pathData, true); } }
public void Move(UtilityTools.Directions dir) { //after checkups if (isRotating || isMoving) { print("already moving/rotating"); return; } if (!canMove(dir)) { return; } Tile[] destinations = { null, null, null }; bool shouldEmptyPreviousTile = false; switch (dir) { case UtilityTools.Directions.up: if (isVertical) { destinations[0] = getDirectionMostBox(dir).getNeighbourTile(dir); // the uppermost is gonna go to his up neighbour destinations[1] = getDirectionMostBox(dir).GetTile(); // the center is gonna go to current uppermost destinations[2] = getCenterBox().GetTile(); // lowest is going to go to center shouldEmptyPreviousTile = true; } else { for (int i = 0; i < destinations.Length && i < boxes.Length; i++) { destinations[i] = boxes[i].getNeighbourTile(dir); } } break; case UtilityTools.Directions.right: if (!isVertical) { destinations[0] = getCenterBox().GetTile(); // leftmost is going to go to center destinations[1] = getDirectionMostBox(dir).GetTile(); // the center is gonna go to current rightmost destinations[2] = getDirectionMostBox(dir).getNeighbourTile(dir); // the rightmost is gonna go to his right neighbour shouldEmptyPreviousTile = true; } else { for (int i = 0; i < destinations.Length && i < boxes.Length; i++) { destinations[i] = boxes[i].getNeighbourTile(dir); } } break; case UtilityTools.Directions.down: if (isVertical) { destinations[0] = getCenterBox().GetTile(); // highest is going to go to center destinations[1] = getDirectionMostBox(dir).GetTile(); // the center is gonna go to current downmost destinations[2] = getDirectionMostBox(dir).getNeighbourTile(dir); // the downmost is gonna go to his down neighbour shouldEmptyPreviousTile = true; } else { for (int i = 0; i < destinations.Length && i < boxes.Length; i++) { destinations[i] = boxes[i].getNeighbourTile(dir); } } break; case UtilityTools.Directions.left: if (!isVertical) { destinations[0] = getDirectionMostBox(dir).getNeighbourTile(dir); // the leftmost is gonna go to his left neighbour destinations[1] = getDirectionMostBox(dir).GetTile(); // the center is gonna go to current leftmost destinations[2] = getCenterBox().GetTile(); // rightmost is going to go to center shouldEmptyPreviousTile = true; } else { for (int i = 0; i < destinations.Length && i < boxes.Length; i++) { destinations[i] = boxes[i].getNeighbourTile(dir); } } break; default: return; break; } // all destinations are ok if (!System.Array.FindAll(destinations, x => x == null).Any()) { isMoving = true; transform.DOMove(transform.position + UtilityTools.getDirectionVector(dir) * 1, TheGrid.moveTime).OnComplete(() => { isMoving = false; grid_ref.spawnTriBox(); grid_ref.Match(getBoxMatches()); }); for (int i = 0; i < destinations.Length && i < boxes.Length; i++) { //move sprites //update tiles isVertical && dir == UtilityTools.Directions.down && i > 0 //fix when moving down it should not set previous tiles as empties if (shouldEmptyPreviousTile) { boxes[i].setTile(destinations[i], Tile.Status.box); } else { boxes[i].setTile(destinations[i]); } } } else { return; } //print("first box: " + boxes.First() + boxes.First().GetPoint().print() + " is moving to position" + destination1.GetPoint().Clone().print()); rearrangeBoxesArray(); }
private void ctrlStreamInfo_Load(object sender, EventArgs e) { BackColor = Color.Transparent; VLCToolStripMenuItem.Visible = File.Exists(frmOpenTheatre.pathVLC); MPCToolStripMenuItem.Visible = File.Exists(frmOpenTheatre.pathMPCCodec64) || File.Exists(frmOpenTheatre.pathMPC64) || File.Exists(frmOpenTheatre.pathMPC86); if (Properties.Settings.Default.dataBookmarks.Contains(infoFileURL)) { imgAddToBookmarks.Image = Properties.Resources.bookmark_remove; } else { imgAddToBookmarks.Image = Properties.Resources.bookmark_plus; } if (frmOpenTheatre.currentDownloads.Contains(infoFileURL)) { imgDownload.Image = Properties.Resources.cloud_sync; } else if (File.Exists(Properties.Settings.Default.downloadsDirectory + Path.GetFileName(new Uri(infoFileURL).LocalPath)) && infoFileSize.Text == UtilityTools.ToFileSize(Convert.ToDouble(new FileInfo(Properties.Settings.Default.downloadsDirectory + Path.GetFileName(new Uri(infoFileURL).LocalPath)).Length))) { imgDownload.Image = Properties.Resources.cloud_done; } if (isTorrent == true) { imgReportBroken.Visible = false; imgWatch.Visible = false; imgMagnet.Visible = true; } if (isLocal == false) { try { WebRequest req = WebRequest.Create(infoFileURL); req.Method = "HEAD"; req.Timeout = 1500; using (HttpWebResponse fileResponse = (HttpWebResponse)req.GetResponse()) { DateTime fileModifiedTime = fileResponse.LastModified; if (fileModifiedTime != null) { infoFileAge.Text = UtilityTools.getTimeAgo(fileModifiedTime); } else { infoFileAge.Text = "n/a"; } int ContentLength; if (int.TryParse(fileResponse.Headers.Get("Content-Length"), out ContentLength)) { infoFileSize.Text = UtilityTools.ToFileSize(Convert.ToDouble(ContentLength)); } else { infoFileSize.Text = "n/a"; } } } catch { infoFileSize.Text = "n/a"; infoFileAge.Text = "n/a"; } } else { infoFileHost.Text = frmOpenTheatre.rm.GetString("local"); infoFileSize.Text = UtilityTools.ToFileSize(new FileInfo(infoFileURL).Length); infoFileAge.Text = UtilityTools.getTimeAgo(File.GetLastWriteTime(infoFileURL)); imgDownload.Visible = false; imgReportBroken.Visible = false; imgShare.Visible = false; imgCopyURL.Visible = false; } // Checks for exact file name of a subtitle file that matches the one being loaded (e.g. Media File Name: 'Jigsaw.2017.mp4' > Subtitle File Name: 'Jigsaw.2017.srt' will be loaded) if (infoFileSubtitles == null) { if (UtilityTools.isExistingSubtitlesFile(infoFileURL) == true) { infoFileSubtitles = Properties.Settings.Default.downloadsDirectory + Path.GetFileNameWithoutExtension(infoFileURL) + ".srt"; } } }
/// <summary> /// 生成场景 /// </summary> void BuildScene(bool exportScene, bool exportRes, bool compressScene, bool compressRes) { // 先保存场景 EditorApplication.SaveScene(); // 场景名字 var scenePath = EditorApplication.currentScene; string sceneName = UtilityTools.GetFileName(scenePath); // 导出目录 var exportPath = UtilityTools.GenResExportPath(string.Format("scene/{0}", sceneName), sceneName); var exportDir = Path.GetDirectoryName(exportPath); // 删除目录 if (exportRes && exportScene) { Directory.Delete(exportDir, true); } // 创建目录 if (!Directory.Exists(exportDir)) { Directory.CreateDirectory(exportDir); } /// 开始处理数据 try { do { AssetsBackuper.inst.Clear(); if (exportScene) { var outputDir = EditorUtil.GetSceneOutputPath(null); AssetDatabase.DeleteAsset(outputDir); var outputPath = EditorUtil.GetSceneOutputPath(string.Format("{0}.unity", sceneName)); EditorApplication.SaveScene(outputPath); } // 树结构 var meshColliders = new List <MeshCollider>(); var trees = SceneTree.Build(_settings.trees, meshColliders); if (null == trees) { break; } SaveSettings(); SceneTree.Export(trees, meshColliders, exportRes, compressRes); // 准备导出 EditorApplication.SaveScene(); AssetDatabase.SaveAssets(); if (exportScene) { ResExportUtil.ExportCurrentScene(true, compressScene); } }while(false); } catch (Exception e) { Debug.LogException(e); AssetsBackuper.inst.Recover(); AssetDatabase.SaveAssets(); } finally { // 还原修改过的资源和场景 if (_recovertScene) { AssetsBackuper.inst.Recover(); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); EditorApplication.OpenScene(scenePath); Resources.UnloadUnusedAssets(); } } }
//--------------------------------------------------------------------------------------- // OnGUI //--------------------------------------------------------------------------------------- void OnGUI() { // 场景名字 var scenePath = EditorApplication.currentScene; string sceneName = UtilityTools.GetFileName(scenePath); if (_sceneName != sceneName) { _sceneName = sceneName; LoadSettings(); } EditorGUI.BeginChangeCheck(); // 树列表 EditorGUILayout.LabelField("场景树"); for (int i = 0; i < _settings.trees.Count; ++i) { DrawSeparator(1, 1); var tree = _settings.trees[i]; tree.name = EditorGUILayout.TextField("名称", tree.name); tree.splitType = (SceneTreeSplitType)EditorGUILayout.EnumPopup("划分类型", tree.splitType); tree.objType = (SceneTreeObjType)EditorGUILayout.EnumPopup("对象类型", tree.objType); tree.maxDepth = EditorGUILayout.IntField("最大层数", tree.maxDepth); tree.viewDistance = EditorGUILayout.FloatField("可视距离", tree.viewDistance); tree.maxItemBoundsSize = EditorGUILayout.FloatField("最大物体大小", tree.maxItemBoundsSize); } // 导出 GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); _recovertScene = GUILayout.Toggle(_recovertScene, "导出完是否恢复"); _backScene = GUILayout.Toggle(_backScene, "备份场景"); _compressScene = GUILayout.Toggle(_compressScene, "压缩场景"); _compressRes = GUILayout.Toggle(_compressRes, "压缩资源"); GUILayout.EndHorizontal(); GUILayout.Space(20); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("检查设置", GUILayout.Width(100))) { int settingsObjTypeFlag = 0; SceneTree.CheckSettings(_settings.trees, out settingsObjTypeFlag); } else if (GUILayout.Button("导出资源", GUILayout.Width(100))) { BuildScene(_backScene, true, _compressScene, _compressRes); } else { GUILayout.EndHorizontal(); GUILayout.Space(10); if (EditorGUI.EndChangeCheck()) { SaveSettings(); } } }