源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.2 KiB

  1. HistoryTextItem = HistoryTextItem or BaseClass(BaseItem)
  2. function HistoryTextItem:__init()
  3. self.base_file = "chat"
  4. self.layout_file = "HistoryTextItem"
  5. -- self.use_local_view = true
  6. self.model = ChatModel:getInstance()
  7. self.str = false
  8. self:Load()
  9. end
  10. function HistoryTextItem:Load_callback()
  11. self.select ,
  12. self.textObj,
  13. self.bg
  14. = GetChildGameObjects(self.transform,{
  15. "Select",
  16. "Text",
  17. "bg"
  18. })
  19. self.select:SetActive(false)
  20. self.text
  21. = GetChildTexts(self.transform,{
  22. "Text"
  23. })
  24. local function onClickBtnHandler(target)
  25. if target == self.textObj then
  26. if self.str then
  27. self.model:SeletedHistoryTextItem(self)
  28. end
  29. -- elseif target == self.addBtn then
  30. -- GlobalEventSystem:Fire(EventName.OPEN_CHAT_CUSTOM_TEXT_VIEW, self.index)
  31. -- elseif target == self.delBtn then
  32. -- local cookie = CookieWrapper.Instance:GetCookie(CookieLevelType.Account, CookieKey.CHAT_CUSTOM_TEXT)
  33. -- if cookie and cookie[self.index] then
  34. -- cookie[self.index] = nil
  35. -- CookieWrapper.Instance:SaveCookie(CookieLevelType.Account, CookieTimeType.TYPE_ALWAYS, CookieKey.CHAT_CUSTOM_TEXT, cookie)
  36. -- Message.show("删除成功")
  37. -- self.model:Fire(ChatModel.UPDATE_INDIVID_VIEW)
  38. -- end
  39. end
  40. end
  41. AddClickEvent(self.textObj, onClickBtnHandler)
  42. if self.need_refreshData then
  43. self:SetData(self.str)
  44. end
  45. end
  46. function HistoryTextItem:SetData(str)
  47. self.str = str
  48. if self.is_loaded then
  49. SetInlineText(self.text, str)
  50. -- self.text.text = str
  51. self.need_refreshData = false
  52. -- local cookie = CookieWrapper.Instance:GetCookie(CookieLevelType.Account, ChatModel.SAVE_CHAT_HISTORY_INFO)
  53. -- if cookie and cookie[self.index] then
  54. -- self.save_text = cookie[self.index]
  55. -- end
  56. else
  57. self.need_refreshData = true
  58. end
  59. end
  60. function HistoryTextItem:SetSelect(bool)
  61. if bool then
  62. self.select:SetActive(true)
  63. else
  64. self.select:SetActive(false)
  65. end
  66. end