KLFriendMainPanel.lua 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. ---@class KLFriendMainPanel:UIKmlLuaPanelBase
  2. ---@field view KLFriendMainPanelView
  3. ---@field relatePanel KLFriendUIItem
  4. local KLFriendMainPanel = class(UIKmlLuaPanelBase)
  5. local this = KLFriendMainPanel
  6. ---创建时调用一次
  7. function this:Init()
  8. GUI:SetToggleGroup(self.view.Options_friend, self.view.friend_head_common_layout)
  9. GUI:SetToggleGroup(self.view.Options_archenemy, self.view.friend_head_common_layout)
  10. GUI:SetToggleGroup(self.view.Options_blacklist, self.view.friend_head_common_layout)
  11. self.relationShip = {
  12. [EFriendRelation.Friend] = self.view.Options_friend,
  13. [EFriendRelation.BlackList] = self.view.Options_blacklist,
  14. }
  15. SL:onLUAEvent(LUA_EVENT_BUBBLETIPS_DEL,{id=PopoverType.Tip_friends})
  16. end
  17. ---创建或者刷新界面数据时调用
  18. function this:Refresh()
  19. local defaultType = EFriendRelation.Friend
  20. if self.args and self.args.type and self.relationShip[self.args.type] then
  21. defaultType = self.args.type
  22. end
  23. --self.relationShip[defaultType]:SetTogDefaultThis()
  24. GUI:SetTogDefaultThis(self.relationShip[defaultType])
  25. end
  26. ---注册UI事件和服务器消息
  27. function this:RegistEvents()
  28. GUI:AddOnClickEvent(self.view.BtnClose, self, self.CloseSelf)
  29. GUI:SetToggleOnValueChange(self.view.Options_friend, self, self.ChangeOptions, EFriendRelation.Friend)
  30. GUI:SetToggleOnValueChange(self.view.Options_archenemy, self, self.ChangeOptions, EFriendRelation.Enemy)
  31. GUI:SetToggleOnValueChange(self.view.Options_blacklist, self, self.ChangeOptions, EFriendRelation.BlackList)
  32. GUI:AddOnClickEvent(self.view.add_friend, self, self.AddFriendOnClick)
  33. GUI:AddOnClickEvent(self.view.BtnHelp, self, self.OpenFriendTips)
  34. end
  35. ---打开帮助面板
  36. function this:OpenFriendTips()
  37. local content = "1、添加好友时需对方同意后才会成为好友。\n2、好友互动可以增加亲密度。\n3、屏蔽后将无法接收该玩家的信息。\n4、被陌生人击杀后会自动将其加入宿敌。"
  38. SL:CommonStrTipsMessage({title = "提示",str = content})
  39. --GUI:UIPanel_Open("dev/ui/FriendSys/Panel/KLFriendTips/KLFriendTipsPanel")
  40. end
  41. function this:CloseSelf()
  42. GUI:UIPanel_Close(self.filePath)
  43. end
  44. function this:ChangeOptions(control, type, data)
  45. if data[1] then
  46. if not self.relatePanel then
  47. GUI:UIPanel_Open("dev/ui/FriendSys/Item/KLFriendUI/KLFriendUIItem", self.view.root, self,self.args,true,function(win)
  48. self.relatePanel = win
  49. if self.relatePanel:SetType(type) then
  50. SL.Friend:ReqOpenFriendPanelMessage(type)
  51. end
  52. end)
  53. else
  54. if self.relatePanel:SetType(type) then
  55. SL.Friend:ReqOpenFriendPanelMessage(type)
  56. end
  57. end
  58. end
  59. end
  60. function this:AddFriendOnClick()
  61. GUI:UIPanel_Open("dev/ui/FriendSys/Panel/KLFriendAdd/KLFriendAddPanel")
  62. end
  63. function this:Close()
  64. SL.ShowMainPanel()
  65. end
  66. return this