UILoadingCtr.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. local UILoadingCtr = class("UILoadingCtr", require("UICtrBase"))
  2. local _tipIndexRecord; --这个是记录上一次显示的tip的index
  3. function UILoadingCtr:Init(view)
  4. self.view = view
  5. end
  6. function UILoadingCtr:SetData(data)
  7. _tipIndexRecord = -1;
  8. self.data = data
  9. self.asyncIdx = 0
  10. if self.data ~= nil and nil ~= self.data.loadingId then
  11. self.loadingId = self.data.loadingId
  12. else
  13. self.loadingId = 3 --进入迅游的loading id
  14. end
  15. local loadingCfg = ManagerContainer.CfgMgr:GetLoadingCfg(self.loadingId)
  16. if loadingCfg ~= nil and loadingCfg.imgs~= nil then
  17. --loading图数据
  18. self._bgsName = CommonUtil.StringSplit(loadingCfg.imgs,";")
  19. --小提示数据
  20. local _tipsId = CommonUtil.StringSplit(loadingCfg.tips, ";");
  21. self._tips = {};
  22. for i = 1, #_tipsId do
  23. local _tip = I18N.T(_tipsId[i]);
  24. if _tip == nil or _tip == "" then
  25. DebugHelper.LogError("没有找到id为:" .. _tipsId[i] .. " 的语言内容,请检查LoadingCfg和UIConfig表");
  26. end
  27. table.insert(self._tips, _tip);
  28. end
  29. end
  30. end
  31. --获取背景图片的名字
  32. function UILoadingCtr:GetBgName()
  33. local _outPut = "Bg/img_loading_01";
  34. if self._bgsName then
  35. local _bgNameCount = #self._bgsName;
  36. if _bgNameCount == 1 then
  37. _outPut = self._bgsName[1];
  38. elseif _bgNameCount > 1 then
  39. local _outPutIndex = math.random(_bgNameCount);
  40. _outPut = self._bgsName[_outPutIndex];
  41. end
  42. end
  43. return _outPut;
  44. end
  45. --获取小提示
  46. function UILoadingCtr:GetTipString()
  47. local _outPut = "没有配置小提示哦!";
  48. if self._tips then
  49. local _tipsCount = #self._tips;
  50. if _tipsCount == 1 then
  51. _outPut = self._tips[1];
  52. elseif _tipsCount > 1 then
  53. local _outPutIndex = _tipIndexRecord;
  54. while _outPutIndex == _tipIndexRecord do
  55. _outPutIndex = math.random(_tipsCount);
  56. end
  57. _tipIndexRecord = _outPutIndex;
  58. _outPut = self._tips[_tipIndexRecord];
  59. end
  60. end
  61. return _outPut;
  62. end
  63. function UILoadingCtr:GetAsyncIdx()
  64. self.asyncIdx = self.asyncIdx + 1
  65. return self.asyncIdx
  66. end
  67. function UILoadingCtr:OnDispose()
  68. self.data = nil
  69. self.view = nil
  70. end
  71. return UILoadingCtr