BubbleTipsProxy.lua 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. local RemoteProxy = requireProxy("remote/RemoteProxy")
  2. local BubbleTipsProxy = class("BubbleTipsProxy", RemoteProxy)
  3. BubbleTipsProxy.NAME = global.ProxyTable.BubbleTipsProxy
  4. local config = {
  5. [1] = {
  6. idx = 1,
  7. order = 1,
  8. img = 1900012560
  9. },
  10. [2] = {
  11. idx = 2,
  12. order = 2,
  13. img = 1900012564
  14. },
  15. [3] = {
  16. idx = 3,
  17. order = 3,
  18. img = 1900012601
  19. },
  20. [4] = {
  21. idx = 4,
  22. order = 4,
  23. img = 1900012602
  24. },
  25. [5] = {
  26. idx = 5,
  27. order = 5,
  28. img = 1900012603
  29. },
  30. [6] = {
  31. idx = 6,
  32. order = 6,
  33. img = 1900012604
  34. },
  35. [7] = {
  36. idx = 7,
  37. order = 7,
  38. img = 1900012605
  39. },
  40. [8] = {
  41. idx = 8,
  42. order = 8,
  43. img = 1900012562
  44. },
  45. [9] = {
  46. idx = 9,
  47. order = 9,
  48. img = 1900012562
  49. },
  50. [10] = {
  51. idx = 10,
  52. order = 10,
  53. img = 1900012562
  54. },
  55. [11] = {
  56. idx = 11,
  57. order = 11,
  58. img = 1900012562
  59. },
  60. [12] = {
  61. idx = 12,
  62. order = 12,
  63. img = 1900012605
  64. },
  65. [13] = {
  66. idx = 13,
  67. order = 13,
  68. img = 1900012562
  69. },
  70. [14] = {
  71. idx = 14,
  72. order = 14,
  73. img = 1900012607
  74. }
  75. }
  76. function BubbleTipsProxy:ctor()
  77. BubbleTipsProxy.super.ctor(self)
  78. self._config = {}
  79. self._configHash = {}
  80. self:LoadConfig()
  81. end
  82. function BubbleTipsProxy:onRegister()
  83. BubbleTipsProxy.super.onRegister(self)
  84. end
  85. function BubbleTipsProxy:LoadConfig()
  86. self._configHash = config
  87. -- 排序
  88. local temp = {}
  89. for _, v in pairs(self._configHash) do
  90. temp[#temp + 1] = v
  91. end
  92. self._config = temp
  93. local function sortCallback(a, b)
  94. return a.order > b.order
  95. end
  96. table.sort(self._config, sortCallback)
  97. end
  98. function BubbleTipsProxy:GetConfig()
  99. return self._config
  100. end
  101. function BubbleTipsProxy:GetConfigByID(id)
  102. return self._configHash[id]
  103. end
  104. function BubbleTipsProxy:GetOrderByID(id)
  105. return self._configHash[id] and self._configHash[id].order or 1
  106. end
  107. function BubbleTipsProxy:handle_MSG_SC_BUBBLE_TIPS_CUSTOM(msg)
  108. local msgLen = msg:GetDataLength()
  109. local msgHdr = msg:GetHeader()
  110. local str = ""
  111. if msgLen ~= 0 then
  112. str = msg:GetData():ReadString(msgLen)
  113. end
  114. local t = {}
  115. if msgHdr.recog == 0 then
  116. local strs = string.split(str, ",")
  117. local path = strs[1]
  118. local link = strs[2]
  119. local id = msgHdr.param1 or 0
  120. local func = function()
  121. local SUIComponentProxy = global.Facade:retrieveProxy(global.ProxyTable.SUIComponentProxy)
  122. SUIComponentProxy:SubmitAct({Act = link})
  123. end
  124. t = {id = "custom_" .. id, path = path, callback = func, status = true}
  125. else
  126. local id = msgHdr.param1 or 0
  127. t = {id = "custom_" .. id, status = false}
  128. end
  129. global.Facade:sendNotification(global.NoticeTable.BubbleTipsStatusChange, t)
  130. end
  131. function BubbleTipsProxy:RegisterMsgHandler()
  132. BubbleTipsProxy.super.RegisterMsgHandler(self)
  133. LuaRegisterMsgHandler(global.MsgType.MSG_SC_BUBBLE_TIPS_CUSTOM, handler(self, self.handle_MSG_SC_BUBBLE_TIPS_CUSTOM))
  134. end
  135. return BubbleTipsProxy