TaskItemMainCtr.lua 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. local TaskItemMainCtr = {}
  2. local IconItemCtr = require("Common/IconItemCtr")
  3. local _rewardItemCountMax = 5;
  4. function TaskItemMainCtr:SetData(wnd, itemLua, logicData, onClickOwner, onClickCB)
  5. local _itemData = logicData.itemData;
  6. local _buttonName = logicData.buttonName;
  7. local _getState = logicData._getState;
  8. local _jumpType = logicData.jumpType;
  9. local _canJump = _jumpType > 0;
  10. itemLua.btnGoto.gameObject:SetActive(_getState == Enum.TaskState.NotGot and _canJump);
  11. itemLua.btnGet.gameObject:SetActive(_getState == Enum.TaskState.Got);
  12. itemLua.bgActive:SetActive(_getState == Enum.TaskState.Got);
  13. itemLua.btnNotFinish:SetActive(_getState == Enum.TaskState.NotGot and (not _canJump))
  14. itemLua.taskName.text.text = I18N.T(_itemData._cfgData.TargetTaskDescribe);
  15. itemLua.scrollbar.scrollbar.size = _itemData._progressNum;
  16. local _value, _total = _itemData:GetProgressData();
  17. itemLua.ratio.text.text = _value .. "/" .. _total;
  18. if _getState == Enum.TaskState.NotGot then
  19. itemLua.btnGoto.text.text = _buttonName;
  20. end
  21. local _button;
  22. if _getState == Enum.TaskState.NotGot then
  23. _button = itemLua.btnGoto.button;
  24. if _jumpType > 0 then
  25. _button = itemLua.btnGoto.button;
  26. else
  27. _button = itemLua.btnGet.button;
  28. end
  29. elseif _getState == Enum.TaskState.Got then
  30. _button = itemLua.btnGet.button;
  31. end
  32. if _getState == Enum.TaskState.NotGot and (not _canJump) then
  33. onClickOwner.uiBase:AddButtonUniqueEventListener(itemLua.btnNotFinish.button, onClickOwner, function ()
  34. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(I18N.T("MissionUnFinish"));
  35. end, nil)
  36. CommonUtil.SetTotalChildrenGray(itemLua.btnNotFinish.gameObject, true);
  37. else
  38. if onClickOwner and onClickCB then
  39. _button.interactable = true
  40. onClickOwner.uiBase:AddButtonUniqueEventListener(_button, onClickOwner, onClickCB, logicData)
  41. else
  42. _button.onClick:RemoveAllListeners();
  43. _button.interactable = false
  44. end
  45. end
  46. local _rewardList = _itemData._cfgData.Reward;
  47. for _i = 1, _rewardItemCountMax, 1 do
  48. local _item = itemLua["item" .. tostring(_i)];
  49. if _i <= #_rewardList then
  50. _item.gameObject:SetActive(true);
  51. local _data = _rewardList[_i];
  52. local _logicData = {
  53. cfgId = _data[1];
  54. num = _data[2];
  55. }
  56. IconItemCtr:SetData(wnd, _item, _logicData, Enum.ItemIEnterType.Bag, wnd, wnd.ShowItemTips)
  57. else
  58. _item.gameObject:SetActive(false);
  59. end
  60. end
  61. end
  62. return TaskItemMainCtr