You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 rivejä
2.8 KiB

  1. local AutoUpdaterView = {};
  2. AutoUpdaterView.__index = AutoUpdaterView;
  3. --[[
  4. 自动更新的界面,只显示内容,不做任何逻辑处理
  5. -- ]]
  6. -- 创建新对象
  7. function AutoUpdaterView:new(...)
  8. local instance = {}
  9. setmetatable(instance , AutoUpdaterView)
  10. instance:ctor(...)
  11. return instance
  12. end
  13. function AutoUpdaterView:ctor(updater , mainScene)
  14. self.MainScene = mainScene
  15. self:onEnter()
  16. end
  17. function AutoUpdaterView:onEnter()
  18. local uiFile
  19. if isReviewWithMiniGame() then
  20. uiFile = getMiniGameAutoUpdateViewUI()
  21. else
  22. uiFile = "preload/res/preload_gengxin.ui"
  23. end
  24. if not uiFile then
  25. error("Can not found AutoUpdateViewUI")
  26. end
  27. self.ui = loadUI(uiFile)
  28. --检查更新
  29. self.ui.Items.Layout_Loading:setVisible(false)
  30. self.ui.Items.ImageView_ring:playClip("rotate")
  31. self.ui.Items.ImageView:playClip("roateNi")
  32. self.ui.Items.Text_Intro:setString("连接中...")
  33. --进度
  34. self.ui.Items.Layout_Progress:setVisible(false)
  35. self.ui.Items.Text_jindu:setString("")
  36. self.MainScene:addChild(self.ui);
  37. self:showLoading("连接中...")
  38. end
  39. function AutoUpdaterView:onExit()
  40. if tolua.isnull(self.ui) then
  41. return
  42. end
  43. self.ui:removeFromParent();
  44. end
  45. -- 显示加载中
  46. function AutoUpdaterView:showLoading(strMessage)
  47. logD("AutoUpdaterView:showLoading()", tostring(strMessage));
  48. -- 小游戏审核的时候不要显示网络连接
  49. if isReviewWithMiniGame() then
  50. return
  51. end
  52. self.ui.Items.Layout_Loading:setVisible(true)
  53. self.ui.Items.Layout_Progress:setVisible(false)
  54. self.ui.Items.Text_Intro:setString(tostring(strMessage));
  55. end
  56. -- 显示进度条
  57. function AutoUpdaterView:showProgress(eventName , eventValue)
  58. logD("AutoUpdaterView:showProgress()", tostring(eventName));
  59. self.ui.Items.Layout_Loading:setVisible(false)
  60. self.ui.Items.Layout_Progress:setVisible(true)
  61. if eventValue then
  62. if type(eventValue) == "table" then
  63. logD("AutoUpdaterView:onEvent()", eventValue.percent, eventValue.text);
  64. self.ui.Items.Text_jindu:setString(tostring(eventValue.text or ""));
  65. self.ui.Items.Slider:setPercent(tonumber(eventValue.percent or 0) * 100);
  66. else
  67. logD("AutoUpdaterView:onEvent()", tostring(eventValue));
  68. self.ui.Items.Text_jindu:setString(tostring(eventValue));
  69. end
  70. end
  71. end
  72. -- 更新事件
  73. function AutoUpdaterView:onEvent(eventName , eventValue)
  74. if tolua.isnull(self.ui.Items.Text_Intro) then
  75. return
  76. end
  77. if eventValue then
  78. if type(eventValue) == "table" then
  79. logD("AutoUpdaterView:onEvent()", eventValue.percent, eventValue.text);
  80. self.ui.Items.Text_jindu:setString(tostring(eventValue.text or ""));
  81. self.ui.Items.Slider:setPercent(tonumber(eventValue.percent or 0) * 100);
  82. else
  83. logD("AutoUpdaterView:onEvent()", tostring(eventValue));
  84. self.ui.Items.Text_Intro:setString(tostring(eventValue));
  85. end
  86. end
  87. end
  88. return AutoUpdaterView;