public void CreateComment(bool abort = false) { ShowCommentMenu(); if (abort) { commentField.text = ""; return; } CommentStructure cs = Instantiate(commentPrefab, commentsContent).GetComponent <CommentStructure>(); cs.SetCommentInfo(currentUsername, commentField.text); lastLevelShown.comments.Add(new KeyValuePair <string, string>(currentUsername, commentField.text)); scrollbar.enabled = lastLevelShown.comments.Count > 2; commentsContent.GetComponent <VerticalLayoutGroup>().padding.right = lastLevelShown.comments.Count > 2 ? 50 : 20; Invoke(nameof(SetCommentsSize), 0.1f); commentField.text = ""; }
public void ApplyLevelInfo(LevelInfo level, LevelSummary ls, bool setActiveFalse = false) { if ((lastLevelShown != null && level == null) || setActiveFalse) { lastLevelShown = null; puzzleInfo.SetActive(false); return; } else if (lastLevelShown == null && level != null) { puzzleInfo.SetActive(true); } levelname.text = level.levelname; size.text = "Size: " + level.size + "x" + level.size; username.text = "MADE BY " + level.username; description.text = level.description; likeGO.SetActive(level.type == LevelInfo.LevelType.Online); commentsGO.SetActive(level.type == LevelInfo.LevelType.Online); commentGOButton.SetActive(level.type == LevelInfo.LevelType.Online); if (level.type == LevelInfo.LevelType.Online) { string likesS = level.likesNumber < 10 ? "0" + level.likesNumber.ToString() : level.likesNumber.ToString(); likes.text = likesS; ls.ApplyInfo(level); string user = ""; string usersLiked = level.usersLiked; heartLike.color = Color.white; for (int i = 0; i < usersLiked.Length; ++i) { if (usersLiked[i] == ',') { if (user == currentUsername) { heartLike.color = Color.green; } user = ""; continue; } user += usersLiked[i]; } for (int i = 0; i < commentsContent.childCount; ++i) { Destroy(commentsContent.GetChild(i).gameObject); } for (int i = 0; i < level.comments.Count; ++i) { CommentStructure cs = Instantiate(commentPrefab, commentsContent).GetComponent <CommentStructure>(); cs.SetCommentInfo(level.comments[i].Key, level.comments[i].Value); } scrollbar.enabled = level.comments.Count > 2; commentsContent.GetComponent <VerticalLayoutGroup>().padding.right = level.comments.Count > 2 ? 50 : 20; Invoke(nameof(SetCommentsSize), 0.1f); } editButton.SetActive(level.type == LevelInfo.LevelType.Local); deleteButton.SetActive(level.username == currentUsername || level.type == LevelInfo.LevelType.Local); lastLevelShown = level; }