源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

71 行
2.0 KiB

  1. FuliLimitPackageItem = FuliLimitPackageItem or BaseClass(BaseItem)
  2. function FuliLimitPackageItem:__init(parent_wnd, prefab_asset, layer_name)
  3. self.base_file = "fuli"
  4. self.layout_file = "FuliLimitPackageItem"
  5. self.is_delay_callback = true
  6. self.cur_layout = lua_viewM.cur_layout or "" --公共组件,要判断是否对应界面
  7. self.data = false
  8. self.load_success_callback = false
  9. self.width = 360
  10. self:Load()
  11. end
  12. function FuliLimitPackageItem:Load_callback()
  13. local nodes = {
  14. "icon:raw",
  15. "des:txt",
  16. "sex:img",
  17. "name:txt",
  18. }
  19. self:GetChildren(nodes)
  20. self:InitEvent()
  21. if self.load_success_callback then
  22. self.load_success_callback()
  23. end
  24. if self.need_refreshData then
  25. self:SetData(self.data)
  26. end
  27. end
  28. function FuliLimitPackageItem:InitEvent()
  29. end
  30. function FuliLimitPackageItem:SetData(data)
  31. self.data = data
  32. if self.is_loaded then
  33. if not self.data then return end
  34. self.name_txt.gameObject:SetActive(true)
  35. self.des_txt.gameObject:SetActive(true)
  36. self.icon_raw.gameObject:SetActive(true)
  37. self.sex_img.gameObject:SetActive(true)
  38. self.name_txt.text = self.data.name
  39. self.des_txt.text = string.format("抢到了%s", HtmlColorTxt(self.data.packag_name, "#fb4717"))
  40. local w1 = self.name_txt.preferredWidth
  41. local w2 = self.des_txt.preferredWidth
  42. CustomRoleHead:getInstance():Create(self, self.icon_raw, self.data.role_id, self.data.career, self.data.sex, self.data.turn, nil, self.data.picture_ver, self.data.picture, false, self.data.profile_photo_id)
  43. lua_resM:setImageSprite(self, self.sex_img, "uiComponent_asset", "headrole_sex_"..(self.data.sex or 1))
  44. SetAnchoredPositionX(self.sex, 70 + w1 - 15)
  45. SetAnchoredPositionX(self.des, 70 + w1 + 50)
  46. self.width = w1 + w2 + 90
  47. else
  48. self.need_refreshData = true
  49. end
  50. end
  51. function FuliLimitPackageItem:__delete()
  52. self.load_success_callback = false
  53. end
  54. function FuliLimitPackageItem:SetLoadCallBack(cb)
  55. self.load_success_callback = cb
  56. end
  57. function FuliLimitPackageItem:GetWidth()
  58. return self.width
  59. end