KLMapBranchItem.lua 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. ---@class KLMapBranchItem:UIKmlLuaPanelBase
  2. ---@field view KLMapBranchItemView
  3. local KLMapBranchItem = class(UIKmlLuaPanelBase)
  4. local this = KLMapBranchItem
  5. ---创建时调用一次
  6. function this:Init()
  7. end
  8. ---创建或者刷新界面数据时调用
  9. function this:Refresh()
  10. end
  11. function this:RefreshUI(line, count, limit, isGold,pkLine)
  12. GUI:setVisible(self.view.root,true)
  13. self.mapLine = tonumber(line[2])
  14. self.isGoldMap = isGold
  15. GUI:Text_setString(self.view.line_name, line[1])
  16. GUI:SetLoadingbar_startper(self.view.line_state,count/limit*100)
  17. if self.mapLine == SL:GetMetaValue(EMetaVarGetKey.MAP_LINE) and ((not isGold and not self:CurrentIsInGoldMap()) or (isGold and self:CurrentIsInGoldMap())) then
  18. GUI:Toggle_setIsOn(self.view.branch_toggle, true)
  19. GUI:setVisible(self.view.btn_switch, true)
  20. else
  21. GUI:setVisible(self.view.btn_switch, false)
  22. GUI:Toggle_setIsOn(self.view.branch_toggle, false)
  23. end
  24. pkLine = string.split(pkLine,"|")
  25. if table.contains(pkLine,line[2]) then
  26. GUI:Toggle_setSrc(self.view.branch_toggle,nil,"Texture/branchMap_new_button_3.png","Texture/branchMap_new_button_2.png")
  27. GUI:setVisible(self.view.img_pk,true)
  28. else
  29. GUI:setVisible(self.view.img_pk,false)
  30. GUI:Toggle_setSrc(self.view.branch_toggle,nil,"Texture/branchMap_new_button_1.png","Texture/branchMap_new_button_2.png")
  31. end
  32. end
  33. function this:SetOnValueChange(func, ui)
  34. GUI:SetToggleOnValueChange(self.view.branch_toggle, ui, function(_,_,eventData,value)
  35. func(ui,_,eventData)
  36. if value[1] then
  37. GUI:setVisible(self.view.btn_switch, true)
  38. else
  39. GUI:setVisible(self.view.btn_switch, false)
  40. end
  41. end, { data = self.mapLine })
  42. end
  43. ---注册UI事件和服务器消息
  44. function this:RegistEvents()
  45. GUI:AddOnClickEvent(self.view.btn_switch,self,self.SwitchBranchClick)
  46. end
  47. function this:SwitchBranchClick()
  48. if self.isGoldMap and InfoManager.newVipInfo.vipLevel <= 0 then
  49. SL:CommonTipsMessage({ stringTblID=228, ui = self, sureBtnText = "确定", cancelBtnText = "取消",
  50. callback = function()
  51. SL.HideMainPanel()
  52. GUI:UIPanel_Open("dev/outui/VIP/Panel/KLNewVIPMain/KLNewVIPMainPanel")
  53. GUI:UIPanel_Close("dev/ui/Map/Panel/KLUIMapBranch/KLUIMapBranchPanel")
  54. end })
  55. return
  56. end
  57. ---@type KLUIMapBranchPanel
  58. local panel = GUI:GetUI("dev/ui/Map/Panel/KLUIMapBranch/KLUIMapBranchPanel")
  59. panel:SwitchBranchClick(self.isGoldMap)
  60. end
  61. function this:CurrentIsInGoldMap()
  62. ---@type cfg_map_info_column
  63. local infoCfg = SL:GetConfig("cfg_map_info",tonumber(SL:GetMetaValue(EMetaVarGetKey.MAP_ID)))
  64. return infoCfg.goldmap == 1
  65. end
  66. function this:Close()
  67. end
  68. function this:HideItemUI()
  69. GUI:setVisible(self.view.root,false)
  70. end
  71. return this