源战役客户端
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

122 líneas
3.5 KiB

  1. CecretChatItem = CecretChatItem or BaseClass(BaseItem)
  2. function CecretChatItem:__init()
  3. self.base_file = "chat"
  4. self.layout_file = "cecretChatItem"
  5. self.model = ChatModel:getInstance()
  6. self.vo = nil
  7. self.index = nil
  8. self:Load()
  9. end
  10. function CecretChatItem:Load_callback()
  11. self.headIcon = self:GetChild("headIcon"):GetComponent("Image")
  12. self.deleteBtn = self:GetChild("deleteBtn").gameObject
  13. self.chatBtn = self:GetChild("chatBtn").gameObject
  14. self.titleIcon = self:GetChild("titleIcon"):GetComponent("Image")
  15. self.nameText = self:GetChild("nameText"):GetComponent("Text")
  16. self.levelText = self:GetChild("levelText"):GetComponent("Text")
  17. self.vipIcon = self:GetChild("vipIcon"):GetComponent("Image")
  18. self.vip_con = self:GetChild("vipIcon").gameObject
  19. self.redPoint = self:GetChild("redPoint").gameObject
  20. self.amount = self:GetChild("redPoint/amount"):GetComponent("Text")
  21. self.title_con = self:GetChild("titleIcon")
  22. self.name_con = self:GetChild("nameText")
  23. if self.need_refreshData then
  24. self:SetData()
  25. end
  26. local function onClickBtnHandler(target)
  27. if target == self.deleteBtn then
  28. local function ok()
  29. self.model:Fire(ChatModel.DELETE_CECRET_CHAT_ITEM,self.index,self.vo.key_id)
  30. end
  31. Alert.show("是否确定删除?",Alert.Type.Two,ok)
  32. elseif target == self.chatBtn then
  33. if self.vo then
  34. GlobalEventSystem:Fire(EventName.OPEN_CHAT_CECRET_CHANNEL,self.vo.key_id,self.vo.key_name)
  35. end
  36. end
  37. end
  38. AddClickEvent(self.deleteBtn,onClickBtnHandler)
  39. AddClickEvent(self.chatBtn,onClickBtnHandler)
  40. end
  41. function CecretChatItem:SetData(index,vo)
  42. self.vo = vo or self.vo
  43. self.index = index or self.index
  44. local info = self:GetPlayerInfo()
  45. if info == nil then return end
  46. self.vo.key_name = info.name
  47. self.vo.key_vip = info.vip_flag
  48. self.vo.key_touxian = info.touxian
  49. if self.is_loaded then
  50. self.need_refreshData = false
  51. self.nameText.text = info.name
  52. self.levelText.text = info.level
  53. lua_resM:setImageSprite(self,self.headIcon,"mainUI_asset","head_circle_" .. info.career, true)
  54. local result,num = self.model:NeedShowCecretItemRedPoint(self.vo.key_id)
  55. self:SetRedPointState(result,num)
  56. local config = Config.Title[self.vo.key_touxian]
  57. if config then
  58. RoleTitleModel:getInstance():SetTitleImage(self,self.titleIcon,config.icon_name)
  59. end
  60. self:SetPositionFormat()
  61. self.transform.localPosition = Vector3(0, -(self.index-1) * 100, 0)
  62. else
  63. self.need_refreshData = true
  64. end
  65. end
  66. --设置VIP 头衔 位置的格式
  67. function CecretChatItem:SetPositionFormat()
  68. if self.vo then
  69. local is_vip = self.vo.key_vip > 0
  70. local x = is_vip and 140 or 105
  71. self.vip_con:SetActive(is_vip)
  72. if self.vo.key_touxian == 0 then
  73. self.title_con.gameObject:SetActive(false)
  74. self.name_con.localPosition = Vector3(x ,-34,0)
  75. else
  76. self.title_con.gameObject:SetActive(true)
  77. self.title_con.localPosition = Vector3(x ,-32,0)
  78. self.name_con.localPosition = Vector3(x + self.titleIcon.preferredWidth + 14,-34,0)
  79. end
  80. end
  81. end
  82. function CecretChatItem:SetSelect(bool)
  83. end
  84. function CecretChatItem:ShowRedPoint()
  85. if self.redPoint ~= nil then
  86. self.redPoint:SetActive(true)
  87. end
  88. end
  89. function CecretChatItem:HideRedPoint()
  90. if self.redPoint ~= nil then
  91. self.redPoint:SetActive(false)
  92. end
  93. end
  94. function CecretChatItem:SetRedPointState(result,num)
  95. if result then
  96. self:ShowRedPoint()
  97. self.amount.text = num
  98. else
  99. self:HideRedPoint()
  100. end
  101. end
  102. function CecretChatItem:GetPlayerInfo()
  103. if self.vo ~= nil then
  104. if self.vo.key_id == self.vo.player_list[1].player_id then
  105. return self.vo.player_list[1]
  106. else
  107. return self.vo.player_list[2]
  108. end
  109. end
  110. end