SUIPanelUpdate.lua.txt 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. local SUIPanelUpdate = SUIPanelUpdate or {}
  2. SUIPanelUpdate.textUpdateStateInfo = nil
  3. SUIPanelUpdate.imageProgress = nil
  4. SUIPanelUpdate.textTipsTitle = nil
  5. SUIPanelUpdate.textTipsInfo = nil
  6. local function OnClickButtonYes()
  7. print("--> Click Yes ~")
  8. SUIPanelUpdate.panelTips:SetActive(false)
  9. local eventDispatchCenter = require("Base/SEventDispatchCenter.lua")
  10. eventDispatchCenter:DispatchEvent(eventDispatchCenter.EventType.UPDATE_RETRY)
  11. end
  12. local function OnClickButtonNo()
  13. print("--> Click No ~")
  14. SUIPanelUpdate.panelTips:SetActive(false)
  15. CS.UnityEngine.Application.Quit()
  16. end
  17. function SUIPanelUpdate.SetProgressPercent(percent)
  18. if percent <= 0 then percent = 0 end
  19. if percent >= 1 then percent = 1 end
  20. SUIPanelUpdate.imageProgress:GetComponent("Image").fillAmount = percent;
  21. end
  22. function SUIPanelUpdate.SetUpdateInfo(information)
  23. SUIPanelUpdate.textUpdateStateInfo:GetComponent("Text").text = information
  24. end
  25. function SUIPanelUpdate.SetTips(title, information)
  26. SUIPanelUpdate.panelTips:SetActive(true)
  27. SUIPanelUpdate.textTipsTitle:GetComponent("Text").text = title
  28. SUIPanelUpdate.textTipsInfo:GetComponent("Text").text = information
  29. end
  30. function SUIPanelUpdate.Awake()
  31. print("SUIPanelUpdate 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. SUIPanelUpdate.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. SUIPanelUpdate.panelTips = panelTips
  44. SUIPanelUpdate.textUpdateStateInfo = textInfo
  45. SUIPanelUpdate.imageProgress = imageProgress
  46. SUIPanelUpdate.textTipsTitle = textTitle
  47. SUIPanelUpdate.textTipsInfo = tipsTextInfo
  48. end
  49. function SUIPanelUpdate.Start()
  50. print("SUIPanelUpdate Start")
  51. local canvasUpdate = SUIPanelUpdate.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. SUIPanelUpdate.RefreshInfo()
  57. local eventDispatchCenter = require("Base/SEventDispatchCenter.lua")
  58. eventDispatchCenter:RegisterEvent(eventDispatchCenter.EventType.UPDATE_STATE_INFO, SUIPanelUpdate.SetUpdateInfo)
  59. eventDispatchCenter:RegisterEvent(eventDispatchCenter.EventType.UPDATE_PROGRESS_PERCENT, SUIPanelUpdate.SetProgressPercent)
  60. eventDispatchCenter:RegisterEvent(eventDispatchCenter.EventType.UPDATE_SHOW_TIPS, SUIPanelUpdate.SetTips)
  61. end
  62. function SUIPanelUpdate.OnDestroy()
  63. print("SUIPanelUpdate.OnDestroy")
  64. local eventDispatchCenter = require("Base/SEventDispatchCenter.lua")
  65. eventDispatchCenter:UnregisterEvent(eventDispatchCenter.EventType.UPDATE_STATE_INFO, SUIPanelUpdate.SetUpdateInfo)
  66. eventDispatchCenter:UnregisterEvent(eventDispatchCenter.EventType.UPDATE_PROGRESS_PERCENT, SUIPanelUpdate.SetProgressPercent)
  67. eventDispatchCenter:UnregisterEvent(eventDispatchCenter.EventType.UPDATE_SHOW_TIPS, SUIPanelUpdate.SetTips)
  68. end
  69. function SUIPanelUpdate.RefreshInfo()
  70. SUIPanelUpdate.textTipsTitle:GetComponent("Text").text = "Update Tips"
  71. SUIPanelUpdate.textTipsInfo:GetComponent("Text").text = "Prepare For Update."
  72. SUIPanelUpdate.textUpdateStateInfo:GetComponent("Text").text = "Wait For Update."
  73. end
  74. return SUIPanelUpdate