KLBigMapTransferItemItem.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. ---@class KLBigMapTransferItemItem:UIKmlLuaPanelBase
  2. ---@field view KLBigMapTransferItemItemView
  3. local KLBigMapTransferItemItem = class(UIKmlLuaPanelBase)
  4. local this =KLBigMapTransferItemItem
  5. ---创建时调用一次
  6. function this:Init()
  7. self.hight = GUI:GetControlHeight(self.view.ButtonCommon)
  8. end
  9. ---创建或者刷新界面数据时调用
  10. function this:Refresh()
  11. end
  12. ---@param itemData MapMoveListItemData
  13. function this:RefreshUI(itemData,clickCallback)
  14. local mapMoveTbl = itemData.data
  15. self.clickCallback = clickCallback
  16. self.itemData = itemData
  17. self.mapMoveTbl = mapMoveTbl
  18. GUI:Text_setString(self.view.Label, itemData.isGroup and mapMoveTbl.groupName or mapMoveTbl.mapName)
  19. --GUI:Text_setTextAlignment(self.view.Label,itemData.isRoot and "01" or "11")
  20. GUI:Text_setString(self.view.TextLevel, itemData.isRoot and mapMoveTbl.level .. "级" or "")
  21. self.conditionCheck = mapMoveTbl.level <= SL:MeData_GetLevel()
  22. GUI:Text_setTextColor(self.view.TextLevel,self.conditionCheck and "#DCE1E5" or "#ED2E2E")
  23. self.equipConditionCheck,_,self.conditionInfo = SL:CheckCalculateConditionGroup(mapMoveTbl.conditions)
  24. self.isGoldmap = SL:GetConfig("cfg_map_info",self.mapMoveTbl.mapID).goldmap == 1
  25. GUI:setVisible(self.view.ImgVip,false)
  26. local width = GUI:GetControlWidth(self.view.ButtonCommon)
  27. GUI:setContentSize(self.view.ButtonCommon,width,self.hight)
  28. if self.isGoldmap then
  29. if itemData.isRoot then
  30. GUI:Image_loadTexture(self.view.ButtonCommon,"Bg_map_btn_big","Atlas/UIMapPanel.spriteatlas")
  31. else
  32. GUI:Image_loadTexture(self.view.ButtonCommon,"bg_gold","Atlas/KLMapPanel.spriteatlas")
  33. GUI:setVisible(self.view.ImgVip,true)
  34. GUI:setContentSize(self.view.ButtonCommon,width,30)
  35. end
  36. else
  37. GUI:Image_loadTexture(self.view.ButtonCommon,itemData.isRoot and "Bg_map_btn_big" or "Bg_map_btn_small","Atlas/UIMapPanel.spriteatlas")
  38. end
  39. GUI:SetID(self.view.ButtonCommon,(itemData.isGroup and"btn_transfer_group_" or "btn_transfer_") .. itemData.data.id)
  40. end
  41. ---注册UI事件和服务器消息
  42. function this:RegistEvents()
  43. GUI:AddOnClickEvent(self.view.ButtonCommon,self,self.ButtonCommonOnClick)
  44. end
  45. function this:ButtonCommonOnClick()
  46. if self.itemData.isGroup then
  47. self:ExpandGroup()
  48. else
  49. self:MapMove()
  50. end
  51. end
  52. function this:ExpandGroup()
  53. self.itemData.groupExpand = not self.itemData.groupExpand
  54. self.clickCallback()
  55. end
  56. function this:MapMove()
  57. GUI:UIPanel_Close("dev/ui/Map/Panel/KLBigMap/KLBigMapPanel")
  58. SL:HideBigMap()
  59. SL.ShowMainPanel()
  60. if InfoManager.redNameInfo:IsLimitTransferById(SL:GetMetaValue("MAIN_ACTOR_ID")) then
  61. SL:TipMessage(SL:GetConfig('cfg_string',262).text,1,NoticeType.NoticeMid)--pk值较高,无法传送
  62. return
  63. end
  64. if self.isGoldmap then
  65. if not self.itemData.isRoot and InfoManager.newVipInfo.vipLevel <= 0 then
  66. SL:CommonTipsMessage({ stringTblID=228, ui = self, sureBtnText = "确定", cancelBtnText = "取消",
  67. callback = function()
  68. SL.HideMainPanel()
  69. GUI:UIPanel_Open("dev/outui/VIP/Panel/KLNewVIPMain/KLNewVIPMainPanel")
  70. end })
  71. return
  72. end
  73. end
  74. if self.conditionCheck and self.equipConditionCheck then
  75. SL:showTransferAnimation()
  76. SL:ScheduleOnce(0.8, function()
  77. SL:MapTransfer(nil, 1, self.mapMoveTbl.id)
  78. end)
  79. else
  80. if not self.conditionCheck then
  81. SL:TipMessage( string.format("等级不满足,%s等级后开启", self.mapMoveTbl.level), 1, NoticeType.NoticeMid )
  82. return
  83. end
  84. if not self.equipConditionCheck then
  85. if #self.conditionInfo.childs > 0 then
  86. SL:TipMessage( self.conditionInfo.childs[1].errorMsg, 1, NoticeType.NoticeMid )
  87. end
  88. return
  89. end
  90. end
  91. end
  92. function this:Close()
  93. end
  94. return this