ZUIPanelUpdate.lua.txt 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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.transform:GetComponent("Image").fillAmount = percent;
  21. end
  22. function ZUIPanelUpdate.SetUpdateInfo(information)
  23. ZUIPanelUpdate.panelUpdateInfo:SetActive(false)
  24. ZUIPanelUpdate.textUpdateStateInfo:SetActive(true)
  25. ZUIPanelUpdate.textUpdateStateInfo:GetComponent("Text").text = information
  26. end
  27. function ZUIPanelUpdate.SetTips(title, information)
  28. ZUIPanelUpdate.panelUpdateInfo:SetActive(false)
  29. ZUIPanelUpdate.panelTips:SetActive(true)
  30. ZUIPanelUpdate.textTipsTitle:GetComponent("Text").text = title
  31. ZUIPanelUpdate.textTipsInfo:GetComponent("Text").text = information
  32. end
  33. function ZUIPanelUpdate.SetUpdateDetail(szPercent, szUpdateDetail, szUpdateSpeed)
  34. ZUIPanelUpdate.panelTips:SetActive(false)
  35. ZUIPanelUpdate.textUpdateStateInfo:SetActive(false)
  36. ZUIPanelUpdate.panelUpdateInfo:SetActive(true)
  37. ZUIPanelUpdate.textUpdatePercent:GetComponent("Text").text = szPercent
  38. ZUIPanelUpdate.textUpdateDetail:GetComponent("Text").text = szUpdateDetail
  39. ZUIPanelUpdate.textUpdateSpeed:GetComponent("Text").text = szUpdateSpeed
  40. end
  41. function ZUIPanelUpdate.Awake()
  42. print("ZUIPanelUpdate Awake")
  43. --local prefabCanvasUpdate = CS.SFramework.SResourceManagerR.LoadResource("Prefabs/Canvas_Update.prefab")
  44. local prefabCanvasUpdate = LoadResource("Prefabs/Canvas_Update.prefab")
  45. local canvasUpdate = CS.UnityEngine.GameObject.Instantiate(prefabCanvasUpdate)
  46. ZUIPanelUpdate.canvasUpdate = canvasUpdate
  47. local panelUpdate = canvasUpdate.transform:Find("Panel_Update").gameObject
  48. local textInfo = panelUpdate.transform:Find("Text_Info").gameObject
  49. local imageProgress = panelUpdate.transform:Find("Image_Progress").gameObject
  50. local panelUpdateInfo = panelUpdate.transform:Find("Panel_UpdateInfo").gameObject
  51. local textUpdatePercent = panelUpdateInfo.transform:Find("Text_UpdatePercent").gameObject
  52. local textUpdateDetail = panelUpdateInfo.transform:Find("Text_UpdateDetail").gameObject
  53. local textUpdateSpeed = panelUpdateInfo.transform:Find("Text_UpdateSpeed").gameObject
  54. local panelTips = canvasUpdate.transform:Find("Panel_Tips").gameObject
  55. local textTitle = panelTips.transform:Find("Text_Title").gameObject
  56. local tipsTextInfo = panelTips.transform:Find("Text_Info").gameObject
  57. panelTips:SetActive(false)
  58. panelUpdateInfo:SetActive(false)
  59. ZUIPanelUpdate.panelTips = panelTips
  60. ZUIPanelUpdate.textUpdateStateInfo = textInfo
  61. ZUIPanelUpdate.imageProgress = imageProgress
  62. ZUIPanelUpdate.panelUpdateInfo = panelUpdateInfo
  63. ZUIPanelUpdate.textUpdatePercent = textUpdatePercent
  64. ZUIPanelUpdate.textUpdateDetail = textUpdateDetail
  65. ZUIPanelUpdate.textUpdateSpeed = textUpdateSpeed
  66. ZUIPanelUpdate.textTipsTitle = textTitle
  67. ZUIPanelUpdate.textTipsInfo = tipsTextInfo
  68. end
  69. function ZUIPanelUpdate.Start()
  70. print("ZUIPanelUpdate Start")
  71. local canvasUpdate = ZUIPanelUpdate.canvasUpdate
  72. local buttonYes = canvasUpdate.transform:Find("Panel_Tips/Button_Yes").gameObject
  73. buttonYes:GetComponent("Button").onClick:AddListener(OnClickButtonYes)
  74. local buttonNo = canvasUpdate.transform:Find("Panel_Tips/Button_No").gameObject
  75. buttonNo:GetComponent("Button").onClick:AddListener(OnClickButtonNo)
  76. ZUIPanelUpdate.RefreshInfo()
  77. local eventDispatchCenter = require("Base/ZEventDispatchCenter.lua")
  78. eventDispatchCenter:RegisterEvent(eventDispatchCenter.EventType.UPDATE_STATE_INFO, ZUIPanelUpdate.SetUpdateInfo)
  79. eventDispatchCenter:RegisterEvent(eventDispatchCenter.EventType.UPDATE_PROGRESS_PERCENT, ZUIPanelUpdate.SetProgressPercent)
  80. eventDispatchCenter:RegisterEvent(eventDispatchCenter.EventType.UPDATE_SHOW_TIPS, ZUIPanelUpdate.SetTips)
  81. eventDispatchCenter:RegisterEvent(eventDispatchCenter.EventType.UPDATE_SHOW_UPDATE_DETAIL, ZUIPanelUpdate.SetUpdateDetail)
  82. end
  83. function ZUIPanelUpdate.OnDestroy()
  84. print("ZUIPanelUpdate.OnDestroy")
  85. local eventDispatchCenter = require("Base/ZEventDispatchCenter.lua")
  86. eventDispatchCenter:UnregisterEvent(eventDispatchCenter.EventType.UPDATE_SHOW_UPDATE_DETAIL, ZUIPanelUpdate.SetUpdateDetail)
  87. eventDispatchCenter:UnregisterEvent(eventDispatchCenter.EventType.UPDATE_SHOW_TIPS, ZUIPanelUpdate.SetTips)
  88. eventDispatchCenter:UnregisterEvent(eventDispatchCenter.EventType.UPDATE_PROGRESS_PERCENT, ZUIPanelUpdate.SetProgressPercent)
  89. eventDispatchCenter:UnregisterEvent(eventDispatchCenter.EventType.UPDATE_STATE_INFO, ZUIPanelUpdate.SetUpdateInfo)
  90. end
  91. function ZUIPanelUpdate.RefreshInfo()
  92. ZUIPanelUpdate.textTipsTitle:GetComponent("Text").text = "更新提示"
  93. ZUIPanelUpdate.textTipsInfo:GetComponent("Text").text = "准备更新..."
  94. ZUIPanelUpdate.textUpdateStateInfo:GetComponent("Text").text = "等待更新..."
  95. end
  96. return ZUIPanelUpdate