CardIconItemCtr.lua 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. local CardIconItemCtr = {}
  2. local ConditionJudge = require("Common/ConditionJudge")
  3. local IconItemCtr = require("Common/IconItemCtr")
  4. function CardIconItemCtr:SetData(wnd, item, logicData, enterType, onClickOwner, onClickCB, idx, needName)
  5. local cfgId = logicData == nil and 0 or (logicData.cfgId or 0)
  6. local slotType = logicData == nil and 0 or (logicData.slotType or 0)
  7. local idx = logicData == nil and 0 or (logicData.idx or 0)
  8. local selected = logicData ~= nil and logicData.selected or false
  9. local result = true
  10. if slotType > 0 then
  11. local condition = ManagerContainer.CfgMgr:GetCardUnlockConditionById(slotType * 100 + idx)
  12. if condition == nil then
  13. LogError(slotType.." "..idx.." card slot error")
  14. return
  15. end
  16. result = ConditionJudge:ConditionPassResult1(condition.UnlockingCondition)
  17. if not result then
  18. item.lock.text.uILocalizeScript:SetContentAndValues("LvLack", {condition.UnlockingCondition[2]})
  19. end
  20. end
  21. item.mask:SetActive(cfgId == 0)
  22. item.add:SetActive(cfgId == 0)
  23. item.cardName:SetActive(cfgId > 0 and needName == true)
  24. item.lock:SetActive(slotType > 0 and not result)
  25. item.selected:SetActive(selected)
  26. item.iconItem:SetActive(cfgId > 0)
  27. item.btnRemove:SetActive(false)
  28. if cfgId > 0 then
  29. local cardData = ManagerContainer.CfgMgr:GetCardDataById(cfgId)
  30. item.cardName.text.text = I18N.T(cardData.CardName)
  31. IconItemCtr:SetData(wnd, item.iconItem, logicData, enterType)
  32. item.iconItem.num:SetActive(enterType == Enum.ItemIEnterType.CardRecreate or enterType == Enum.ItemIEnterType.CardCompose
  33. or enterType == Enum.ItemIEnterType.Bag)
  34. if logicData.num ~= nil then
  35. if enterType == Enum.ItemIEnterType.Bag then
  36. item.iconItem.num.text.text = logicData.num
  37. else
  38. --local num = logicData.num > 90 and "..." or logicData.num
  39. item.iconItem.num.text.text = CommonUtil.StringConcat("0/", logicData.num)
  40. end
  41. end
  42. end
  43. if onClickOwner and onClickCB then
  44. if cfgId == 0 then
  45. item.bg.button.enabled = false
  46. item.add.button.enabled = false
  47. else
  48. item.add.button.enabled = false
  49. item.bg.button.enabled = true
  50. onClickOwner.uiBase:AddButtonUniqueEventListener(item.bg.button, onClickOwner, onClickCB, logicData, item, idx)
  51. end
  52. else
  53. item.bg.button.enabled = false
  54. item.add.button.enabled = false
  55. end
  56. end
  57. return CardIconItemCtr