ChipItemCtr.lua 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. local ChipItemCtr = {}
  2. function ChipItemCtr:SetData(wnd, itemlua, logicData, enterType, onClickOwner, onClickCB)
  3. local cfgId = logicData.cfgId
  4. local num = logicData.num
  5. local itemCfgData = ManagerContainer.CfgMgr:GetItemById(cfgId)
  6. if itemCfgData.Icon and itemCfgData.Icon ~= '' then
  7. CommonUtil.LoadIcon(wnd, itemCfgData.Icon, function (sprite)
  8. itemlua.icon.image.sprite = sprite
  9. end)
  10. end
  11. local quality = itemCfgData.Quality
  12. CommonUtil.LoadIcon(wnd, Constant.Quality_Chip_Frame_Icons[quality], function (sprite)
  13. itemlua.frame.image.sprite = sprite
  14. end)
  15. local composeItem = itemCfgData.ComposeItem
  16. local multi = false
  17. local limit = 0
  18. local parterId = nil
  19. if composeItem and #composeItem > 0 then
  20. if type(composeItem[1]) == 'number' then
  21. -- 单个
  22. parterId = composeItem[1]
  23. limit = composeItem[2]
  24. else
  25. -- 多个
  26. parterId = composeItem[1][1]
  27. limit = composeItem[1][2]
  28. multi = true
  29. end
  30. end
  31. local parterCfgData = ManagerContainer.CfgMgr:GetPartnerDataById(parterId)
  32. local natureData = ManagerContainer.CfgMgr:GetNatureDataById(parterCfgData.NatureId)
  33. CommonUtil.LoadIcon(wnd, natureData.Icon, function (sprite)
  34. itemlua.natureIcon.image.sprite = sprite
  35. end)
  36. if enterType == Enum.ItemIEnterType.Bag then
  37. itemlua.num.text.text = num
  38. itemlua.num:SetActive(true)
  39. local data = ManagerContainer.DataMgr.PartnerData:GetPartnerDataById(parterId)
  40. local owned = ((data and data.owned) and data.owned or false)
  41. itemlua.redPoint:SetActive(not owned and num >= limit)
  42. else
  43. itemlua.redPoint:SetActive(false)
  44. itemlua.num:SetActive(false)
  45. end
  46. if onClickOwner and onClickCB then
  47. itemlua.bg.button.interactable = true
  48. onClickOwner.uiBase:AddButtonUniqueEventListener(itemlua.bg.button, onClickOwner, onClickCB, logicData)
  49. else
  50. itemlua.bg.button.interactable = false
  51. end
  52. end
  53. return ChipItemCtr