RedDotInfo.lua 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. ---@class RedDotInfo
  2. RedDotInfo = class()
  3. local this = RedDotInfo
  4. function this:ctor()
  5. end
  6. function this:Reset()
  7. self.commonRedPointInfo = {}
  8. end
  9. local conditionEnum = {
  10. Test = "test",
  11. checkFruitItem = "checkFruitItem",
  12. checkJewelryUpgraded = "checkJewelryUpgraded",
  13. checkJewelryActive = "checkJewelryActive",
  14. checkBossOfferReward = "checkBossOfferReward",
  15. checkMasterTalent = "checkMasterTalent",
  16. checkGodDescentMonster = "checkGodDescentMonster",
  17. checkEquipStrength = "checkEquipStrength",
  18. checkEquipAppend = "checkEquipAppend",
  19. checkMainRechargeRed = "checkMainRechargeRed",
  20. checkMainActivityRed = "checkMainActivityRed",
  21. checkEfficiencyNewRed = "checkEfficiencyNewRed",
  22. checkVIPRedDot = "checkVIPRedDot",
  23. checkRechargeLinkRedDot = "checkRechargeLinkRedDot",
  24. checkShapeShiftCardRedDot = "checkShapeShiftCardRedDot",
  25. checkOpenServerAthleticsDot = "checkOpenServerAthleticsDot",
  26. checkMail = "checkMail",
  27. checkComboSkillUpgrade = "checkComboSkillUpgrade",
  28. checkArchangelBreakthrough = "checkArchangelBreakthrough",
  29. checkArchangelTalentPoint = "checkArchangelTalentPoint",
  30. checkActionArchangelTalent = "checkActionArchangelTalent",
  31. checkGrailCanStrength = "checkGrailCanStrength",
  32. serverControl = "serverControl",
  33. checkLuckyTurnTable = "checkLuckyTurnTable",
  34. checkMainOperateActivityRed = "checkMainOperateActivityRed",
  35. checkReceiveAddFriend = "checkReceiveAddFriend"
  36. }
  37. function this:Init()
  38. SL:AddRedDotConditionFunc(conditionEnum.Test, function()
  39. return true
  40. end)
  41. SL:AddRedDotConditionFunc(conditionEnum.checkFruitItem, self.checkFruitItem)
  42. SL:AddRedDotConditionFunc(conditionEnum.checkJewelryUpgraded, self.checkJewelryUpgraded)
  43. SL:AddRedDotConditionFunc(conditionEnum.checkJewelryActive, self.checkJewelryActive)
  44. SL:AddRedDotConditionFunc(conditionEnum.checkBossOfferReward, self.checkBossOfferReward)
  45. SL:AddRedDotConditionFunc(conditionEnum.checkMasterTalent, self.checkMasterTalent)
  46. SL:AddRedDotConditionFunc(conditionEnum.checkGodDescentMonster, self.checkGodDescentMonster)
  47. SL:AddRedDotConditionFunc(conditionEnum.checkEquipStrength, self.checkEquipStrength)
  48. SL:AddRedDotConditionFunc(conditionEnum.checkEquipAppend, self.checkEquipAppend)
  49. SL:AddRedDotConditionFunc(conditionEnum.checkMainRechargeRed, self.checkMainRechargeRedFuc)
  50. SL:AddRedDotConditionFunc(conditionEnum.checkMainActivityRed, self.checkMainActivityRedFuc)
  51. SL:AddRedDotConditionFunc(conditionEnum.checkEfficiencyNewRed, self.checkEfficiencyNewRed)
  52. SL:AddRedDotConditionFunc(conditionEnum.checkVIPRedDot, self.checkVIPNewRed)
  53. SL:AddRedDotConditionFunc(conditionEnum.checkRechargeLinkRedDot, self.checkRechargeLinkRedDot)
  54. SL:AddRedDotConditionFunc(conditionEnum.checkShapeShiftCardRedDot, self.checkShapeShiftCardRedDot)
  55. SL:AddRedDotConditionFunc(conditionEnum.checkOpenServerAthleticsDot, self.checkOpenServerAthleticsDot)
  56. SL:AddRedDotConditionFunc(conditionEnum.checkMail, self.checkMail)
  57. SL:AddRedDotConditionFunc(conditionEnum.checkComboSkillUpgrade, self.checkComboSkillUpgrade)
  58. SL:AddRedDotConditionFunc(conditionEnum.checkArchangelBreakthrough, self.checkArchangelBreakthrough)
  59. SL:AddRedDotConditionFunc(conditionEnum.checkArchangelTalentPoint, self.checkArchangelTalentPoint)
  60. SL:AddRedDotConditionFunc(conditionEnum.checkActionArchangelTalent, self.checkActionArchangelTalent)
  61. SL:AddRedDotConditionFunc(conditionEnum.checkGrailCanStrength, self.checkGrailCanStrength)
  62. SL:AddRedDotConditionFunc(conditionEnum.checkLuckyTurnTable, self.checkLuckyTurnTable)
  63. SL:AddRedDotConditionFunc(conditionEnum.checkMainOperateActivityRed, self.checkMainOperateActivityRedFuc)
  64. SL:AddRedDotConditionFunc(conditionEnum.serverControl, function(condition)
  65. return self.ServerControl(self, condition)
  66. end)
  67. SL:AddRedDotConditionFunc(conditionEnum.checkReceiveAddFriend, self.checkReceiveAddFriend)
  68. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_COMMON_RED_POINT_MESSAGE, self.CommonRedPointMessage, self)
  69. ---通用红点使用,1.服务器通知红点信息 RES_COMMON_RED_POINT_MESSAGE 2.策划配置condition为serverControl=红点id
  70. ---@type table<number,boolean>
  71. self.commonRedPointInfo = {} -- 通用红点信息,key为红点ID,value为是否显示(新增,并不包含所有红点信息)
  72. end
  73. function this:CommonRedPointMessage(_, message)
  74. local refreshPanel = {}
  75. for k, v in pairs(message) do
  76. local redPointId = tonumber(k)
  77. ---@type cfg_redDot_new_column
  78. local redDotTbl = SL:GetConfig("cfg_redDot_new", redPointId)
  79. if redDotTbl then
  80. self.commonRedPointInfo[redPointId] = v
  81. if #redDotTbl.windowsWidgetID > 0 then
  82. local panelName = redDotTbl.windowsWidgetID[#redDotTbl.windowsWidgetID][1]
  83. refreshPanel[panelName] = true
  84. end
  85. end
  86. end
  87. for panelName, _ in pairs(refreshPanel) do
  88. SL:RefreshPanelALLRedPoint(panelName)
  89. end
  90. end
  91. ---是否有果实
  92. function this:checkRechargeLinkRedDot()
  93. return InfoManager.rechargeLinkInfo:IsShowRed()
  94. end
  95. ---是否有果实
  96. function this:checkFruitItem()
  97. return InfoManager.fruitInfo:IsFruitCanUse()
  98. end
  99. ---是否能够升级首饰
  100. function this:checkJewelryUpgraded()
  101. ---@type cfg_system_switch_column
  102. local systemCfg = SL:GetConfig("cfg_system_switch", 10407)
  103. local isMeet = SL:GetMetaValue(EMetaVarGetKey.IS_OPEN_SYSTEMFUNCTION, systemCfg.systemName)
  104. if not isMeet then
  105. return false
  106. end
  107. return InfoManager.equipJewelryInfo:IsShowLevelRedDot()
  108. end
  109. ---是否能够激活首饰卓越词条
  110. function this:checkJewelryActive()
  111. ---@type cfg_system_switch_column
  112. local systemCfg = SL:GetConfig("cfg_system_switch", 10407)
  113. local isMeet = SL:GetMetaValue(EMetaVarGetKey.IS_OPEN_SYSTEMFUNCTION, systemCfg.systemName)
  114. if not isMeet then
  115. return false
  116. end
  117. return InfoManager.equipJewelryInfo:IsShowActiveRedDot()
  118. end
  119. ---是否有可领取的奖励
  120. function this:checkBossOfferReward()
  121. return InfoManager.bossOfferRewardInfo:IsHasBossOfferReward()
  122. end
  123. ---是否可兑换经验(职业天赋 技能天赋)或者有加点的(通用天赋)
  124. function this:checkMasterTalent()
  125. return InfoManager.masterTalentInfo:GetIsMainRed()
  126. end
  127. function this:checkGodDescentMonster()
  128. return InfoManager.godsDescendInfo.GetRedState()
  129. end
  130. ---装备是否可强化
  131. function this:checkEquipStrength()
  132. ---@type cfg_system_switch_column
  133. local systemCfg = SL:GetConfig("cfg_system_switch", 10401)
  134. local isMeet = SL:GetMetaValue(EMetaVarGetKey.IS_OPEN_SYSTEMFUNCTION, systemCfg.systemName)
  135. if not isMeet then
  136. return false
  137. end
  138. for index = 1, 15 do
  139. local equip = SL:GetMetaValue("EQUIP_TARGET_DATA", 1, index)
  140. if equip and EquipFunc.EquipIsCanStrength(equip) then
  141. return true
  142. end
  143. end
  144. return false
  145. end
  146. ---装备是否可追加
  147. function this:checkEquipAppend()
  148. ---@type cfg_system_switch_column
  149. local systemCfg = SL:GetConfig("cfg_system_switch", 10402)
  150. local isMeet = SL:GetMetaValue(EMetaVarGetKey.IS_OPEN_SYSTEMFUNCTION, systemCfg.systemName)
  151. if not isMeet then
  152. return false
  153. end
  154. for index = 1, 15 do
  155. local equip = SL:GetMetaValue("EQUIP_TARGET_DATA", 1, index)
  156. if equip and EquipFunc.EquipIsCanAppend(equip) then
  157. return true
  158. end
  159. end
  160. return false
  161. end
  162. -- 大天使装备是否可以突破
  163. function this:checkArchangelBreakthrough()
  164. return table.count(InfoManager.archangeEquipInfo.canBreakthrough) > 0
  165. end
  166. -- 是否有可点大天使装备天赋点
  167. function this:checkArchangelTalentPoint()
  168. return InfoManager.archangeEquipInfo.isTalent
  169. end
  170. -- 是否有可激活的大天使大师天赋
  171. function this:checkActionArchangelTalent()
  172. return InfoManager.archangeEquipInfo.isMasterRed
  173. end
  174. function this:checkGrailCanStrength()
  175. return table.count(InfoManager.archangeEquipInfo.canGrailStrength) > 0
  176. end
  177. --主界面福利按钮红点逻辑:子页签有红点则亮红点
  178. function this:checkMainRechargeRedFuc()
  179. for k, v in pairs(InfoManager.mainRechargeInfo.mainRechargeRedsTbl) do
  180. if v then
  181. local cfgData = SL:GetConfigMultiKeys("sub_mainRecharge", k, "togName")
  182. if not table.isNullOrEmpty(cfgData) then
  183. if cfgData.showCondition == "" or ConditionManager.Check4D(cfgData.showCondition) then
  184. return true
  185. end
  186. end
  187. end
  188. end
  189. return false
  190. end
  191. --主界面活动按钮红点逻辑:子页签有红点则亮红点
  192. function this:checkMainActivityRedFuc()
  193. for k, v in pairs(InfoManager.mainActivityInfo.mainActivityRedsTbl) do
  194. if v then
  195. local cfgData = SL:GetConfigMultiKeys("sub_mainActivity", k, "togName")
  196. if not table.isNullOrEmpty(cfgData) then
  197. if cfgData.showCondition == "" or ConditionManager.Check4D(cfgData.showCondition) then
  198. return true
  199. end
  200. end
  201. end
  202. end
  203. return false
  204. end
  205. --主界面运营活动按钮红点逻辑:子页签有红点则亮红点
  206. function this:checkMainOperateActivityRedFuc()
  207. if InfoManager.mainOperateActivityInfo.isOperateActivityMainBtnShow then
  208. if not table.isNullOrEmpty(InfoManager.mainOperateActivityInfo.operateMainActivityRedsTbl) then
  209. for k, v in pairs(InfoManager.mainOperateActivityInfo.operateMainActivityRedsTbl) do
  210. if v then
  211. local cfgData = SL:GetConfigMultiKeys("cfg_sub_OperateActivity", k, "togName")
  212. if not table.isNullOrEmpty(cfgData) then
  213. if InfoManager.mainOperateActivityInfo:JudgeThisSubtypeActivityIsOpen(cfgData.subType) then
  214. return true
  215. end
  216. end
  217. end
  218. end
  219. end
  220. end
  221. return false
  222. end
  223. ---效率红点
  224. function this:checkEfficiencyNewRed()
  225. return InfoManager.uiEfficiencyNewInfo:GetAllIsEfficiencyRedDot()
  226. end
  227. function this:checkVIPNewRed()
  228. local isShow = false
  229. for key, value in pairs(InfoManager.newVipInfo.allVIPRedPoint) do
  230. if value then
  231. isShow = true
  232. break
  233. end
  234. end
  235. return isShow
  236. end
  237. function this:checkShapeShiftCardRedDot()
  238. return InfoManager.shapeShiftCardInfo:RefreshMainIconRedPoint()
  239. end
  240. ---是否有果实
  241. function this:checkOpenServerAthleticsDot()
  242. return InfoManager.openServerAthleticsInfo:IsShowRed()
  243. end
  244. function this:checkMail()
  245. local no_read_mails = SL:GetMetaValue(EMetaVarGetKey.GET_MAIL_UNREAD)
  246. local no_receive_mails = SL:GetMetaValue(EMetaVarGetKey.GET_MAIL_ITEMS)
  247. if (no_read_mails and table.count(no_read_mails) > 0) or (no_receive_mails and table.count(no_receive_mails) > 0) then
  248. return true
  249. end
  250. return false
  251. end
  252. --连击技能是否能升级
  253. function this:checkComboSkillUpgrade()
  254. return InfoManager.dragonSoulSkillInfo:GetRedPointShowStateInMainPanel()
  255. end
  256. function this:ServerControl(condition)
  257. local conditionValue = string.split(condition, "=")[2]
  258. return self.commonRedPointInfo[tonumber(conditionValue)]
  259. end
  260. function this:checkLuckyTurnTable()
  261. return InfoManager.luckyTurnTableInfo:IsRedDot()
  262. end
  263. --检查是否接收到好友申请
  264. function this:checkReceiveAddFriend()
  265. local friendApplyList = SL:GetFriendData(EFriendRelation.ApplyList)
  266. if friendApplyList and table.count(friendApplyList) > 0 then
  267. return true
  268. end
  269. return false
  270. end