public void GoToThreadByNotification() { if (frameThread != null) { Destroy(frameThread.gameObject); } frameThread = ((GameObject)Instantiate(prfbGUIFrameThread)).GetComponent<FresviiGUIThread>(); frameThread.SetThread(this); frameThread.Init(null, postFix, scaleFactor, Forum.GuiDepth); frameThread.SetScrollPositionLast = true; frameThread.transform.parent = this.transform; Forum.GoToThread(frameThread, false); }
public void Draw(float cardWidth) { if(deleteAnimationDone) return; if(Thread.User != null) { if (!string.IsNullOrEmpty(Thread.User.ProfileImageUrl) && userIcon == null && !userIconLoading) { LoadUserIcon(); } else if (userProfileUrl != Thread.User.ProfileImageUrl && !userIconLoading) { FresviiGUIManager.Instance.resourceManager.ReleaseTexture(userProfileUrl); LoadUserIcon(); } } menuButtonPosition = new Rect(cardWidth - menuButtonMargin - FresviiGUIForum.TexForumMenu.width, menuButtonMargin, FresviiGUIForum.TexForumMenu.width, FresviiGUIForum.TexForumMenu.height); menuButtonHitPosition = new Rect(cardWidth - 44f * scaleFactor, 0f, 44f * scaleFactor, 44f * scaleFactor); userNamePosition.width = cardWidth - userNamePosition.x - menuButtonHitPosition.width; SetUserName(); Rect drawPosition = GetPosition(); if (drawPosition.y + drawPosition.height < 0 || drawPosition.y > Screen.height) { return; } Event e = Event.current; Color origColor = GUI.color; GUI.color = new Color(origColor.r, origColor.g, origColor.b, cardAlpha); if ((!string.IsNullOrEmpty(Thread.Comment.ImageThumbnailUrl) || Thread.Comment.VideoState != Fresvii.AppSteroid.Models.Comment.VideoStatus.NA) && clipImage == null && !clipImageLoading) { ClipImageLoad(); } // Update proc if(Thread.User != null) { if (contentUserName.text != Thread.User.Name || preCardWidth != cardWidth) { SetUserName(); } } if (contentCommentText.text != Thread.Comment.Text || preCardWidth != cardWidth) { SetCommentText(cardWidth); } GUI.BeginGroup(position); // background GUI.DrawTextureWithTexCoords(new Rect(0, 0, position.width, position.height), palette, texCoordsLine); GUI.DrawTextureWithTexCoords(new Rect(position.width * 0.5f - lineWidth * 0.5f, position.height - bottomButtonHeight, lineWidth, bottomButtonHeight), palette, texCoordsLine); GUI.DrawTextureWithTexCoords(new Rect(0, 0, position.width, position.height - bottomButtonHeight - lineWidth), palette, texCoordsBackground); GUI.DrawTextureWithTexCoords(new Rect(0f, position.height - bottomButtonHeight, position.width, bottomButtonHeight), palette, texCoordsBackground); if(buttonUserIcon.IsTap(e, userIconHitPosition)) //if (buttonUserIcon.IsTap(e, userIconPosition, userIconHitPosition, FresviiGUIButton.ButtonType.TextureOnly, textureUserIcon, textureUserIcon, textureUserIcon)) { if(Application.internetReachability == NetworkReachability.NotReachable){ Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("Offline"), FresviiGUIText.Get("OK"), FresviiGUIText.Get("OK"), FresviiGUIText.Get("OK"),delegate(bool del) { }); return; } if (frameProfile == null) { if (Thread.User.Id == FAS.CurrentUser.Id) { frameProfile = ((GameObject)Instantiate(prfbGUIFrameMyProfile)).GetComponent<FresviiGUIFrame>(); } else { frameProfile = ((GameObject)Instantiate(prfbGUIFrameUserProfile)).GetComponent<FresviiGUIFrame>(); frameProfile.gameObject.GetComponent<FresviiGUIUserProfile>().SetUser(Thread.User); } frameProfile.Init(null, postFix, scaleFactor, Forum.GuiDepth); frameProfile.transform.parent = this.transform; } Forum.GoToUserProfile(frameProfile); } // User Name GUI.Label(userNamePosition, contentUserName, guiStyleUserName); // Menu button if(buttonMenu.IsTap(e, menuButtonPosition, menuButtonHitPosition, FresviiGUIButton.ButtonType.TextureOnly, FresviiGUIForum.TexForumMenu, FresviiGUIForum.TexForumMenu, FresviiGUIForum.TexForumMenuH)) { List<string> buttons = new List<string>(); buttons.Add((IsSubscribed()) ? FresviiGUIText.Get("Unsubscribe") : FresviiGUIText.Get("Subscribe")); if(IsMine()) buttons.Add(FresviiGUIText.Get("Delete")); popUpBaloonMenu = ((GameObject)Instantiate(Resources.Load("GuiPrefabs/PopUpBalloonMenu"))).GetComponent<Fresvii.AppSteroid.Gui.PopUpBalloonMenu>(); Vector2 popupBalloonPosition = popUpOffset + new Vector2(scrollViewRect.x + menuButtonPosition.x, scrollViewRect.y - Forum.forumTopMenu.height + menuButtonPosition.y) + FresviiGUIFrame.OffsetPosition; popUpBaloonMenu.Show(buttons.ToArray(), popupBalloonPosition, scaleFactor, postFix, Forum.GuiDepth - 10, Color.black, Color.white, Color.white, delegate(string selectedButton) { if (selectedButton == FresviiGUIText.Get("Unsubscribe")) { this.Unsubscribe(); } else if (selectedButton == FresviiGUIText.Get("Subscribe")) { this.Subscribe(); } else if (selectedButton == FresviiGUIText.Get("Delete")) { this.DeleteThread(false); } }); } if (popUpBaloonMenu != null) { popUpBaloonMenu.SetPosition(popUpOffset + new Vector2(scrollViewRect.x + position.x + menuButtonPosition.x, scrollViewRect.y - Forum.forumTopMenu.height + position.y + menuButtonPosition.y + FresviiGUIFrame.OffsetPosition.y)); } // ----------------------- System.TimeSpan ts = Thread.CreateTimeSpan(); GUIContent contentTimeSpan; if (ts.Days > 1) contentTimeSpan = new GUIContent(ts.Days + " " + FresviiGUIText.Get("days") + FresviiGUIText.Get("ago")); else if (ts.Days > 0) contentTimeSpan = new GUIContent(ts.Days + " " + FresviiGUIText.Get("day") + FresviiGUIText.Get("ago")); else if (ts.Hours > 1) contentTimeSpan = new GUIContent(ts.Hours + " " + FresviiGUIText.Get("hours") + FresviiGUIText.Get("ago")); else if (ts.Hours > 0) contentTimeSpan = new GUIContent(ts.Hours + " " + FresviiGUIText.Get("hour") + FresviiGUIText.Get("ago")); else if (ts.Minutes > 1) contentTimeSpan = new GUIContent(ts.Minutes + " " + FresviiGUIText.Get("minutes") + FresviiGUIText.Get("ago")); else if (ts.Minutes > 0) contentTimeSpan = new GUIContent(ts.Minutes + " " + FresviiGUIText.Get("minute") + FresviiGUIText.Get("ago")); else contentTimeSpan = new GUIContent(FresviiGUIText.Get("now")); timespanPosition.width = guiStyleTimeSpan.CalcSize(contentTimeSpan).x; GUI.Label(timespanPosition, contentTimeSpan, guiStyleTimeSpan); likeCountIconPosition.x = timespanPosition.x + timespanPosition.width + margin; GUI.DrawTexture(likeCountIconPosition, FresviiGUIForum.TexForumLikeS); likeCountLabelPosition.x = likeCountIconPosition.x + FresviiGUIForum.TexForumLikeS.width + miniMargin; GUIContent contentLabelLikeCount = new GUIContent(Thread.Comment.LikeCount.ToString()); GUI.Label(likeCountLabelPosition, contentLabelLikeCount, guiStyleTimeSpan); commentCountIconPosition.x = likeCountLabelPosition.x + guiStyleTimeSpan.CalcSize(contentLabelLikeCount).x + margin; GUI.DrawTexture(commentCountIconPosition, FresviiGUIForum.TexForumCommentS); commentCountLabelPosition.x = commentCountIconPosition.x + FresviiGUIForum.TexForumCommentS.width + miniMargin; GUI.Label(commentCountLabelPosition, Thread.CommentCount.ToString(), guiStyleTimeSpan); // ----------------------- GUI.Label(commentTextPosition, contentCommentText, guiStyleCommentText); if (clipImage != null) { Color tmpColor = GUI.color; GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, Mathf.Min(cardAlpha, clipAlpha)); clipImagePosition.x = drawPosition.width * 0.5f - imageHeight * 0.5f; clipImagePosition.width = clipImagePosition.height = imageHeight; GUI.DrawTexture(clipImagePosition, clipImage, ScaleMode.ScaleAndCrop); GUI.color = tmpColor; if (IsVideo && clipAlpha >= 0.9f && Thread.Comment.VideoState != Fresvii.AppSteroid.Models.Comment.VideoStatus.Removed) { videoPlaybackIconPosition = new Rect(clipImagePosition.x + 0.4f * clipImagePosition.width, clipImagePosition.y + 0.4f * clipImagePosition.height, 0.2f * clipImagePosition.width, 0.2f * clipImagePosition.height); GUI.DrawTexture(videoPlaybackIconPosition, FresviiGUIForum.TexVideoPlaybackIcon, ScaleMode.ScaleToFit); } if (dataUploading) { progressBarPosition = new Rect(clipImagePosition.x, clipImagePosition.y + clipImagePosition.height - scaleFactor * 1.0f, clipImagePosition.width * dataUploadingProgress, scaleFactor * 1.0f); GUI.DrawTextureWithTexCoords(progressBarPosition, palette, texCoodsProgressBar); } } // Line //GUI.DrawTextureWithTexCoords(new Rect(0, position.height - bottomButtonHeight - lineWidth, position.width, lineWidth), palette, texCoordsLine); // Comment button if (!string.IsNullOrEmpty(Thread.Id)) { Texture2D texComenntButton = FresviiGUIForum.TexForumCommentL; Rect commentButtonPosition = new Rect(position.width * 0.25f - texComenntButton.width * 0.5f, position.height - 0.5f * bottomButtonHeight - texComenntButton.height * 0.5f, texComenntButton.width, texComenntButton.height); Rect commentButtonHitPosition = new Rect(0f, position.height - bottomButtonHeight, position.width * 0.5f, bottomButtonHeight); if (buttonComment.IsTap(e, commentButtonPosition, commentButtonHitPosition, FresviiGUIButton.ButtonType.TextureOnly, FresviiGUIForum.TexForumCommentL, FresviiGUIForum.TexForumCommentL, FresviiGUIForum.TexForumCommentLH)) { if (frameThread == null) { frameThread = ((GameObject)Instantiate(prfbGUIFrameThread)).GetComponent<FresviiGUIThread>(); frameThread.SetThread(this); frameThread.Init(null, postFix, scaleFactor, Forum.GuiDepth); frameThread.transform.parent = this.transform; } Forum.GoToThread(frameThread, true); } } Texture2D texLikeButton = (isLike) ? FresviiGUIForum.TexForumLikeLH : FresviiGUIForum.TexForumLikeL; Rect likeButtonHitPosition = new Rect(position.width * 0.5f, position.height - bottomButtonHeight, position.width * 0.5f, bottomButtonHeight); Rect likeButtonPosition = new Rect(position.width * 0.75f - texLikeButton.width * 0.5f, position.height - 0.5f * bottomButtonHeight - texLikeButton.height * 0.5f, texLikeButton.width, texLikeButton.height); if(buttonLike.IsTap(e, likeButtonPosition, likeButtonHitPosition, FresviiGUIButton.ButtonType.TextureOnly, texLikeButton, texLikeButton, texLikeButton)) { isLike = !isLike; if (isLike) { Thread.Comment.LikeCount++; StartCoroutine(ThreadLikeCoroutine()); } else { if (Thread.Comment.LikeCount > 0) Thread.Comment.LikeCount--; StartCoroutine(ThreadUnlikeCoroutine()); } if (frameThread != null) { if (frameThread.Thread.Id == Thread.Id) { if (frameThread.cards.Count > 0) { frameThread.cards[0].isLike = isLike; if (isLike) { frameThread.cards[0].Comment.LikeCount++; } else { if (frameThread.cards[0].Comment.LikeCount > 0) { frameThread.cards[0].Comment.LikeCount--; } } } } } } // Line GUI.DrawTextureWithTexCoords(new Rect(position.width * 0.5f - lineWidth * 0.5f, position.height - bottomButtonHeight, lineWidth, bottomButtonHeight), palette, texCoordsLine); if (buttonCard.IsTap(e, new Rect(0, 0, position.width, position.height)) && !string.IsNullOrEmpty(Thread.Id)) { if(Application.internetReachability == NetworkReachability.NotReachable){ Fresvii.AppSteroid.Util.DialogManager.Instance.ShowSubmitDialog(FresviiGUIText.Get("Offline"), FresviiGUIText.Get("OK"), FresviiGUIText.Get("OK"), FresviiGUIText.Get("OK"),delegate(bool del) { }); return; } if (frameThread == null) { frameThread = ((GameObject)Instantiate(prfbGUIFrameThread)).GetComponent<FresviiGUIThread>(); frameThread.SetThread(this); frameThread.Init(null, postFix, scaleFactor, Forum.GuiDepth); frameThread.transform.parent = this.transform; } else { frameThread.gameObject.SetActive(true); } Forum.GoToThread(frameThread, true); } // User Icon if (Event.current.type == EventType.Repaint) { userIconMaterial.color = new Color(1f, 1f, 1f, cardAlpha); Graphics.DrawTexture(userIconPosition, ((userIcon == null) ? userIconDefault : userIcon), userIconMaterial); } GUI.EndGroup(); GUI.color = origColor; preCardWidth = cardWidth; }