源战役客户端
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

146 Zeilen
3.6 KiB

  1. require("sysinfo.MessageItem")
  2. require("sysinfo.ChuanwenItem")
  3. require("game.chat.HornTv")
  4. require("sysinfo.SysInfoMiniView")
  5. require("sysinfo.MessageItemNew")
  6. require("sysinfo.SysInfoNoticeView")
  7. require("sysinfo.ExpMessageItem")
  8. require("sysinfo.SysInfoExpView")
  9. require("sysinfo.SysInfoHornView")
  10. require("sysinfo.MiniMessageView")
  11. SysInfoCtrl = SysInfoCtrl or BaseClass()
  12. SysInfoCtrl.SysInfoType = {
  13. MINI = 1,
  14. NOTICE = 2,
  15. EXP = 3,
  16. HORN = 4,
  17. }
  18. function SysInfoCtrl:__init()
  19. if SysInfoCtrl.Instance ~= nil then
  20. LogError("SysInfoCtrl is a singleton class")
  21. end
  22. SysInfoCtrl.Instance = self
  23. self.callback_table = {} --回调列表
  24. self.mini_view = MiniMessageView.New()
  25. self.mini_view:Open()
  26. self.notice_view = SysInfoNoticeView.New()
  27. self.horn_view = SysInfoHornView.New()
  28. self.exp_view = SysInfoExpView.New()
  29. self.count_down_time = 9999999 --倒计时时间
  30. self.down_time_id = false
  31. self.msg_handle_map = {
  32. [SysInfoCtrl.SysInfoType.MINI] = SysInfoCtrl.AppendMiniMsg,
  33. [SysInfoCtrl.SysInfoType.NOTICE] = SysInfoCtrl.AppendNoticeMsg,
  34. [SysInfoCtrl.SysInfoType.HORN] = SysInfoCtrl.AppendHornMsg,
  35. [SysInfoCtrl.SysInfoType.EXP] = SysInfoCtrl.AppendExpMsg,
  36. }
  37. end
  38. function SysInfoCtrl:__delete()
  39. self.mini_view:DeleteMe()
  40. self.notice_view:DeleteMe()
  41. self.horn_view:DeleteMe()
  42. self.exp_view:DeleteMe()
  43. end
  44. function SysInfoCtrl:AppendMsg(msg_type, ...)
  45. local handle_func = self.msg_handle_map[msg_type]
  46. if not handle_func then
  47. print ("Error!SystemInfo Type Error!", msg_type)
  48. return
  49. end
  50. handle_func(self, ...)
  51. end
  52. function SysInfoCtrl:AppendMiniMsg(content)
  53. if content == nil or content == "" then return end
  54. if self.mini_view.can_show then
  55. self.mini_view:AppendMessage(content)
  56. end
  57. end
  58. function SysInfoCtrl:AppendNoticeMsg(content)
  59. if SceneManager:getInstance():IsNoonQuizScene() then return end
  60. self.notice_view:AppendMessage(content)
  61. end
  62. function SysInfoCtrl:AppendHornMsg(content)
  63. if SceneManager:getInstance():IsNoonQuizScene() then return end
  64. self.horn_view:AppendMessage(content)
  65. end
  66. function SysInfoCtrl:AppendExpMsg( content, percent, is_normal, is_score )
  67. if not lua_viewM.main_cancas_last_visible then
  68. return
  69. end
  70. if content == nil or content == "" then
  71. return
  72. end
  73. self.exp_view:AppendMessage(content, percent, is_normal, is_score)
  74. end
  75. function SysInfoCtrl:HideHornView(bool)
  76. if self.horn_view then
  77. self.horn_view:SetHide(bool)
  78. end
  79. end
  80. function SysInfoCtrl:HideNoticeView(bool)
  81. if self.notice_view then
  82. self.notice_view:SetHide(bool)
  83. end
  84. end
  85. function SysInfoCtrl:HideMiniView(bool)
  86. if self.mini_view then
  87. self.mini_view:SetHide(bool)
  88. end
  89. end
  90. function SysInfoCtrl:ShowMiniView()
  91. if self.mini_view then
  92. self.mini_view.can_show = true
  93. end
  94. end
  95. function SysInfoCtrl:TimeLater()
  96. local function on_time_down( )
  97. if self.count_down_time <= 0 or TableSize(self.callback_table) <=0 then
  98. if self.down_time_id then
  99. GlobalTimerQuest:CancelQuest(self.down_time_id)
  100. self.down_time_id = nil
  101. self.count_down_time = 9999999
  102. end
  103. else
  104. self.count_down_time = self.count_down_time - 1
  105. for k,v in pairs(self.callback_table) do
  106. if type(v) == "function" then
  107. v()
  108. end
  109. end
  110. end
  111. end
  112. if not self.down_time_id then
  113. self.down_time_id = GlobalTimerQuest:AddPeriodQuest(on_time_down, 1, -1)
  114. end
  115. end
  116. function SysInfoCtrl:DeleteFuncCallBack( index )--删除计时器方法列表里面的方法
  117. self.callback_table[index] = nil
  118. end
  119. function SysInfoCtrl:SetFuncCallBack( func,index )--添加计时器方法列表里面的方法
  120. if type(func) == "function" then
  121. self.callback_table[index] = func
  122. self:TimeLater()
  123. end
  124. end