ZUIPanelUpdate.lua.txt 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. local ZUIPanelUpdate = ZUIPanelUpdate or {}
  2. ZUIPanelUpdate.textUpdateStateInfo = nil
  3. ZUIPanelUpdate.imageProgress = nil
  4. ZUIPanelUpdate.textTipsTitle = nil
  5. ZUIPanelUpdate.textTipsInfo = nil
  6. local function OnClickButtonYes()
  7. print("--> Click Yes ~")
  8. ZUIPanelUpdate.panelTips:SetActive(false)
  9. local eventDispatchCenter = require("Base/ZEventDispatchCenter.lua")
  10. eventDispatchCenter:DispatchEvent(eventDispatchCenter.EventType.UPDATE_RETRY)
  11. end
  12. local function OnClickButtonNo()
  13. print("--> Click No ~")
  14. ZUIPanelUpdate.panelTips:SetActive(false)
  15. CS.UnityEngine.Application.Quit()
  16. end
  17. function ZUIPanelUpdate.SetProgressPercent(percent)
  18. if percent <= 0 then percent = 0 end
  19. if percent >= 1 then percent = 1 end
  20. ZUIPanelUpdate.imageProgress:GetComponent("Image").fillAmount = percent;
  21. end
  22. function ZUIPanelUpdate.SetUpdateInfo(information)
  23. ZUIPanelUpdate.textUpdateStateInfo:GetComponent("Text").text = information
  24. end
  25. function ZUIPanelUpdate.SetTips(title, information)
  26. ZUIPanelUpdate.panelTips:SetActive(true)
  27. ZUIPanelUpdate.textTipsTitle:GetComponent("Text").text = title
  28. ZUIPanelUpdate.textTipsInfo:GetComponent("Text").text = information
  29. end
  30. function ZUIPanelUpdate.Awake()
  31. print("ZUIPanelUpdate Awake")
  32. --local prefabCanvasUpdate = CS.SFramework.SResourceManagerR.LoadResource("Prefabs/Canvas_Update.prefab")
  33. local prefabCanvasUpdate = LoadResource("Prefabs/Canvas_Update.prefab")
  34. local canvasUpdate = CS.UnityEngine.GameObject.Instantiate(prefabCanvasUpdate)
  35. ZUIPanelUpdate.canvasUpdate = canvasUpdate
  36. local panelUpdate = canvasUpdate.transform:Find("Panel_Update").gameObject
  37. local textInfo = panelUpdate.transform:Find("Text_Info").gameObject
  38. local imageProgress = panelUpdate.transform:Find("Image_Progress").gameObject
  39. local panelTips = canvasUpdate.transform:Find("Panel_Tips").gameObject
  40. local textTitle = panelTips.transform:Find("Text_Title").gameObject
  41. local tipsTextInfo = panelTips.transform:Find("Text_Info").gameObject
  42. panelTips:SetActive(false)
  43. ZUIPanelUpdate.panelTips = panelTips
  44. ZUIPanelUpdate.textUpdateStateInfo = textInfo
  45. ZUIPanelUpdate.imageProgress = imageProgress
  46. ZUIPanelUpdate.textTipsTitle = textTitle
  47. ZUIPanelUpdate.textTipsInfo = tipsTextInfo
  48. end
  49. function ZUIPanelUpdate.Start()
  50. print("ZUIPanelUpdate Start")
  51. local canvasUpdate = ZUIPanelUpdate.canvasUpdate
  52. local buttonYes = canvasUpdate.transform:Find("Panel_Tips/Button_Yes").gameObject
  53. buttonYes:GetComponent("Button").onClick:AddListener(OnClickButtonYes)
  54. local buttonNo = canvasUpdate.transform:Find("Panel_Tips/Button_No").gameObject
  55. buttonNo:GetComponent("Button").onClick:AddListener(OnClickButtonNo)
  56. ZUIPanelUpdate.RefreshInfo()
  57. local eventDispatchCenter = require("Base/ZEventDispatchCenter.lua")
  58. eventDispatchCenter:RegisterEvent(eventDispatchCenter.EventType.UPDATE_STATE_INFO, ZUIPanelUpdate.SetUpdateInfo)
  59. eventDispatchCenter:RegisterEvent(eventDispatchCenter.EventType.UPDATE_PROGRESS_PERCENT, ZUIPanelUpdate.SetProgressPercent)
  60. eventDispatchCenter:RegisterEvent(eventDispatchCenter.EventType.UPDATE_SHOW_TIPS, ZUIPanelUpdate.SetTips)
  61. end
  62. function ZUIPanelUpdate.OnDestroy()
  63. print("ZUIPanelUpdate.OnDestroy")
  64. local eventDispatchCenter = require("Base/ZEventDispatchCenter.lua")
  65. eventDispatchCenter:UnregisterEvent(eventDispatchCenter.EventType.UPDATE_STATE_INFO, ZUIPanelUpdate.SetUpdateInfo)
  66. eventDispatchCenter:UnregisterEvent(eventDispatchCenter.EventType.UPDATE_PROGRESS_PERCENT, ZUIPanelUpdate.SetProgressPercent)
  67. eventDispatchCenter:UnregisterEvent(eventDispatchCenter.EventType.UPDATE_SHOW_TIPS, ZUIPanelUpdate.SetTips)
  68. end
  69. function ZUIPanelUpdate.RefreshInfo()
  70. ZUIPanelUpdate.textTipsTitle:GetComponent("Text").text = "Update Tips"
  71. ZUIPanelUpdate.textTipsInfo:GetComponent("Text").text = "Prepare For Update."
  72. ZUIPanelUpdate.textUpdateStateInfo:GetComponent("Text").text = "Wait For Update."
  73. end
  74. return ZUIPanelUpdate