PrivateMessageItem.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class PrivateMessageData
  7. {
  8. public string SerialNumber;
  9. public string Nickname;
  10. public string Content;
  11. public DateTime Date;
  12. public PrivateMessageData(string serialNumber, string nickname, string content, DateTime date)
  13. {
  14. SerialNumber = serialNumber;
  15. Nickname = nickname;
  16. Content = content;
  17. Date = date;
  18. }
  19. }
  20. public class PrivateMessageItemLabel
  21. {
  22. public static string MessageItem = "MessageItem";
  23. public static string Nickname = "Nickname";
  24. public static string Content = "Content";
  25. public static string Time = "Time";
  26. public static string Frame = "Frame";
  27. }
  28. public class PrivateMessageItem : VirtualScrollRectItem
  29. {
  30. #region Config
  31. public Text NicknameTitle;
  32. public Text ContentTitle;
  33. public Text TimeTitle;
  34. public PrivateMessageData PrivateMessageData;
  35. #endregion
  36. public override bool Init()
  37. {
  38. if (base.Init())
  39. {
  40. return true;
  41. }
  42. Dictionary<string, Transform> childDictionary = new Dictionary<string, Transform>();
  43. Auxiliary.CompileDic(transform, childDictionary);
  44. NicknameTitle = childDictionary[PrivateMessageItemLabel.Nickname].GetComponent<Text>();
  45. ContentTitle = childDictionary[PrivateMessageItemLabel.Content].GetComponent<Text>();
  46. TimeTitle = childDictionary[PrivateMessageItemLabel.Time].GetComponent<Text>();
  47. return false;
  48. }
  49. public void Reset(PrivateMessageData privateMessageData)
  50. {
  51. PrivateMessageData = privateMessageData;
  52. ContentTitle.text = privateMessageData.Content;
  53. TimeTitle.text = HttpManager.GetTimespanAndTransfer(privateMessageData.Date);
  54. if (privateMessageData.SerialNumber == HttpManager.SerialNumber)
  55. {
  56. NicknameTitle.text = Language.GetStr(LanguageLabel.CommentItem__Me);
  57. NicknameTitle.color = Lib.PrivateMessageSelfGreen;
  58. }
  59. else
  60. {
  61. NicknameTitle.text = privateMessageData.Nickname;
  62. NicknameTitle.color = Lib.PrivateMessageOtherBlack;
  63. }
  64. }
  65. }