UIHookInfo.lua 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. ---@class UIHookInfo
  2. UIHookInfo = class()
  3. local this = UIHookInfo
  4. function this:ctor()
  5. end
  6. function this:Reset()
  7. self.newMap = false
  8. self.hookReward = false
  9. self.checkOpen = false
  10. self.selectHookPointMapItem = nil
  11. end
  12. function this:Init()
  13. self:InitData()
  14. self:RegistMessages()
  15. end
  16. function this:InitData()
  17. this.mapLvs = {}
  18. local tbl = SL:GetConfigTable("cfg_hanguppoints")
  19. ---@param v cfg_hanguppoints_column
  20. for _, v in pairs(tbl) do
  21. if not this.mapLvs[v.mapMoveID] then
  22. ---@type cfg_mapMove_column
  23. local cfg = SL:GetConfig("cfg_mapMove", v.mapMoveID)
  24. this.mapLvs[v.mapMoveID] = cfg.level
  25. end
  26. end
  27. self.newMap = false
  28. self.hookReward = false
  29. self.selectHookPointMapItem = nil
  30. end
  31. function this:RegistMessages()
  32. SL:AddRedDotConditionFunc("checkHookNewMapAndReward",self.checkHookNewMapAndReward)
  33. SL:AddRedDotConditionFunc("checkHookReward",self.checkHookReward)
  34. SL:RegisterLUAEvent(LUA_EVENT_LEVELCHANGE, self.LUA_EVENT_LEVELCHANGE)
  35. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_OFFLINE_ON_HOOK_INFO, self.RES_OFFLINE_ON_HOOK_INFO)
  36. SL:RegisterLUAEvent(LUA_EVENT_ROLE_LOGIN, self.LUA_EVENT_ROLE_LOGIN)
  37. SL:RegisterLUAEvent(LUA_EVENT_ENTRY_MAP_LOADING_PANEL_CLOSE, self.LUA_EVENT_ENTER_MAP)
  38. end
  39. function this.LUA_EVENT_ROLE_LOGIN()
  40. this.checkOpen = true
  41. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_OFFLINE_ON_HOOK_INFO)
  42. end
  43. function this.LUA_EVENT_ENTER_MAP()
  44. if this.checkOpen then
  45. local tbl = SL:GetConfig("cfg_global", 6002)
  46. local needLv = tonumber(tbl.value)
  47. local myLv = SL:GetMetaValue(EMetaVarGetKey.LEVEL)
  48. if tonumber(myLv) >= needLv then
  49. GUI:UIPanel_Open("dev/outui/Hook/Panel/KLOnHook/KLOnHookPanel", _, _, "HookInfoToggle")
  50. SL.HideMainPanel()
  51. end
  52. end
  53. this.checkOpen = false
  54. end
  55. function this.checkHookNewMapAndReward()
  56. if this.newMap then
  57. return true
  58. end
  59. return this.checkHookReward()
  60. end
  61. function this.checkHookReward()
  62. return this.hookReward
  63. end
  64. function this.LUA_EVENT_LEVELCHANGE(_, level, old)
  65. for _, v in pairs(this.mapLvs) do
  66. if old < v and level >= v then
  67. this.newMap = true
  68. SL:RefreshPanelALLRedPoint("KLUISystemTopPanel")
  69. break
  70. end
  71. end
  72. end
  73. function this.RES_OFFLINE_ON_HOOK_INFO(id, message)
  74. this.hookReward = message.fightExp + message.freeExp > 0 and message.receiveExp == false
  75. SL:RefreshPanelALLRedPoint("KLOnHookPanel")
  76. SL:RefreshPanelALLRedPoint("KLUISystemTopPanel")
  77. end
  78. function this:SetNewMapRedClicked()
  79. this.newMap = false
  80. SL:RefreshPanelALLRedPoint("KLUISystemTopPanel")
  81. end
  82. function this:SetReceiveReward()
  83. self.receiveReward = true
  84. end