KLGemEquipUIPanel.lua 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. ---@class KLGemEquipUIPanel:UIKmlLuaPanelBase
  2. ---@field view KLGemEquipUIPanelView
  3. local KLGemEquipUIPanel = class(UIKmlLuaPanelBase)
  4. local this =KLGemEquipUIPanel
  5. ---@class ESlotCondition
  6. local ESlotCondition = {
  7. [EEquipSlotType.FashionHelmet] = EEquipSlotType.Helmet,
  8. [EEquipSlotType.FashionArmor] = EEquipSlotType.Armor,
  9. [EEquipSlotType.FashionWeapon] = EEquipSlotType.Weapon,
  10. [EEquipSlotType.TwoHandWeapon] = EEquipSlotType.Weapon,
  11. [EEquipSlotType.FashionTwoHandWeapon] = EEquipSlotType.Weapon,
  12. [EEquipSlotType.FashionOffHandWeapon] = EEquipSlotType.OffHandWeapon,
  13. [EEquipSlotType.FashionGlove] = EEquipSlotType.Glove,
  14. [EEquipSlotType.FashionPant] = EEquipSlotType.Pant,
  15. [EEquipSlotType.FashionBoot] = EEquipSlotType.Boot,
  16. [EEquipSlotType.FashionWing] = EEquipSlotType.Wing,
  17. [EEquipSlotType.FashionGuard] = EEquipSlotType.Guard,
  18. [EEquipSlotType.FashionNecklace] = EEquipSlotType.Necklace,
  19. [EEquipSlotType.FashionLeftEarring] = EEquipSlotType.LeftEarring,
  20. [EEquipSlotType.FashionRightEarring] = EEquipSlotType.RightRing,
  21. [EEquipSlotType.FashionLeftRing] = EEquipSlotType.LeftRing,
  22. [EEquipSlotType.FashionRightRing] = EEquipSlotType.RightRing
  23. }
  24. ---@class EEquipGridDefaultData
  25. ---@field width number @grid的宽度
  26. ---@field height number @grid的高度
  27. ---@field x number @grid的x坐标
  28. ---@field y number @grid的y坐标
  29. ---@field qualityX number @品阶角标x坐标
  30. ---@field qualityY number @品阶角标y坐标
  31. ---@field strengthX number @强化追加x坐标
  32. local jewelryDefaultId = {
  33. [EEquipSlotType.Necklace] = 21000021,
  34. [EEquipSlotType.LeftEarring] = 21200121,
  35. [EEquipSlotType.RightEarring] = 21200121,
  36. [EEquipSlotType.LeftRing] = 21100031,
  37. [EEquipSlotType.RightRing] = 21100031,
  38. }
  39. function this:AsyncLoadUI(...)
  40. SL:LoadUIAssetAsync('UI/UIEquipPanel.prefab', self)
  41. end
  42. ---创建时调用一次
  43. function this:Init()
  44. GUI:setVisible(self.view.WearArchange,false)
  45. self.slotToGrid = {}
  46. self.equips = {}
  47. self.wearBarItems = {}
  48. self.selectItem = nil
  49. self.equipSlotTypeList = {}
  50. for i, v in pairs(EEquipSlotType) do
  51. table.insert(self.equipSlotTypeList, { name = i, type = v })
  52. end
  53. table.sort(self.equipSlotTypeList, function(a, b)
  54. return a.type < b.type
  55. end)
  56. local config = SL:GetConfigTable("cfg_wearing_bar")
  57. ---@param v cfg_wearing_bar_column
  58. for k, v in pairs(config) do
  59. if string.contains(v.tag, "时装穿戴栏") then
  60. local width = 81
  61. local height = 82
  62. if k == EEquipWearBarType.Angel then
  63. width = 168
  64. height = 85
  65. end
  66. GUI:UIPanel_Open('dev/ui/Equip/Item/KLWearBarBtn/KLWearBarBtnItem', self.view.Content, self,
  67. { sprite = v.icon, altas = "Atlas/UIzhuangbeixt.spriteatlas", selectSprite = string.replace(v.icon, "01", "02"),
  68. onClick = self.SetSelfWearBarType, clickData = self, wearBar = k,
  69. width = width, height = height, toggleGroup = self.view.Content }, true,
  70. function(item)
  71. self.wearBarItems[k] = item
  72. end)
  73. end
  74. end
  75. self.gridData = {
  76. [EEquipSlotType.Weapon] = { bg = "img_player_weapon1", width = 97, height = 228, x = 28, y = -157, qualityX = 3, qualityY = -3, strengthX = -16, selectX = 5, selectY = -2, selectWidth = 78, selectHeight = 211 },
  77. [EEquipSlotType.OffHandWeapon] = { bg = "img_player_weapon2", width = 98, height = 228, x = 328, y = -157,qualityX = 5.2, qualityY = -2.8, strengthX = -10, selectX = 8.5, selectY = -5, selectWidth = 80, selectHeight = 210 },
  78. [EEquipSlotType.Helmet] = { bg = "img_player_helm", width = 124, height = 115, x = 166, y = -15, qualityX = 7, qualityY = -2, strengthX = -12, selectX = 7, selectY = -2, selectWidth = 107, selectHeight = 102 },
  79. [EEquipSlotType.Armor] = { bg = "img_player_armor", width = 124, height = 228, x = 166, y = -157, qualityX = 7, qualityY = -2, strengthX = -12, selectX = 7, selectY = -3, selectWidth = 105, selectHeight = 210 },
  80. [EEquipSlotType.Glove] = { bg = "img_player_glove", width = 96, height = 116, x = 30, y = -411, qualityX = 3, qualityY = -2, strengthX = -12, selectX = 2, selectY = -2, selectWidth = 86, selectHeight = 101 },
  81. [EEquipSlotType.Pant] = { bg = "img_player_pant", width = 124, height = 115, x = 166, y = -411, qualityX = 7, qualityY = -2, strengthX = -12, selectX = 7, selectY = -3, selectWidth = 105, selectHeight = 100 },
  82. [EEquipSlotType.Boot] = { bg = "img_player_boot", width = 96, height = 116, x = 330, y = -411, qualityX = 3, qualityY = -2, strengthX = -12, selectX = 3, selectY = -3, selectWidth = 83, selectHeight = 100 },
  83. [EEquipSlotType.Necklace] = { bg = "img_player_necklace", width = 55, height = 57, x = 118, y = -19, qualityX = 0, qualityY = 0, strengthX = -3, selectX = 0, selectY = 0, selectWidth = 54, selectHeight = 50 },
  84. [EEquipSlotType.LeftEarring] = { bg = "img_player_earrings", width = 55, height = 57, x = 118, y = -322, qualityX = 0, qualityY = 0, strengthX = -3, selectX = 0, selectY = 0, selectWidth = 54, selectHeight = 50 },
  85. [EEquipSlotType.RightEarring] = { bg = "img_player_earrings", width = 55, height = 57, x = 279, y = -322, qualityX = 0, qualityY = 0, strengthX = -3, selectX = 0, selectY = 0, selectWidth = 51, selectHeight = 50 },
  86. [EEquipSlotType.LeftRing] = { bg = "img_player_ring", width = 55, height = 57, x = 118, y = -413, qualityX = 0, qualityY = 0, strengthX = -3, selectX = 0, selectY = 0, selectWidth = 54, selectHeight = 50 },
  87. [EEquipSlotType.RightRing] = { bg = "img_player_ring", width = 55, height = 57, x = 279, y = -413, qualityX = 0, qualityY = 0, strengthX = -3, selectX = 3, selectY = -1, selectWidth = 50, selectHeight = 48 },
  88. [EEquipSlotType.Guard] = { bg = "img_player_pet", width = 96, height = 116, x = 30, y = -15, qualityX = 3, qualityY = -2, strengthX = -12, selectX = 3, selectY = -2, selectWidth = 84, selectHeight = 100 },
  89. [EEquipSlotType.Wing] = { bg = "img_player_wing", width = 96, height = 116, x = 330, y = -15, qualityX = 3, qualityY = -2, strengthX = -12, selectX = 3, selectY = -2, selectWidth = 82, selectHeight = 100 },
  90. [EEquipSlotType.PriestHawk] = { bg = "img_player_washi", width = 96, height = 116, x = 330, y = -157, qualityX = 3, qualityY = -2, strengthX = -10 }
  91. }
  92. self.specialData = { bg = "img_player_gemstone", width = 96, height = 116, x = 330, y = -270, qualityX = 3, qualityY = -2, strengthX = -10 }
  93. if not self.args then
  94. self.args = {}
  95. end
  96. local x = self.args.x or -400
  97. local y = self.args.y or 0
  98. GUI:setPosition(self.view.UIEquipPanel_Root, x, y)
  99. self.relatePanel = self.args.relatePanel
  100. ---是否隐藏主界面
  101. self.isHideMainUI = self.args.isHideMainUI
  102. self.hideTips = self.args.hideTips
  103. self.closeCallBack = self.args.callBack
  104. self.closeCallBackData = self.args.callBackData
  105. self.selectType = self.args.selectType
  106. --是否是查看其他玩家装备
  107. self.isOtherPlayer = self.args.isOther
  108. self.otherRid = self.args.rid
  109. self.otherEquips = nil
  110. if self.isOtherPlayer then
  111. SL.Friend:ReqOtherRoleInfoMessage(self.otherRid, 4)
  112. end
  113. self:SetBaseWearBar()
  114. end
  115. function this:SetBaseWearBar(career)
  116. --基础穿戴栏
  117. local wearBars
  118. if self.isOtherPlayer and career then
  119. wearBars = self:GetCareerOpenWearBar(career)
  120. else
  121. wearBars = self:GetCareerOpenWearBar(SL:MeData_GetCareer())
  122. end
  123. self.baseWearBar = EEquipWearBarType.BaseEquip
  124. if wearBars and wearBars[1] then
  125. self.baseWearBar = wearBars[1]
  126. end
  127. end
  128. function this:GetCareerOpenWearBar(career)
  129. ---@type cfg_career_column
  130. local tbl = SL:GetConfigMultiKeys('cfg_career',career.baseCareer, career.careerRank,
  131. 'baseCareer', 'careerRank')
  132. if tbl == nil then
  133. return nil
  134. end
  135. return tbl.careerWearBar
  136. end
  137. function this:Show(...)
  138. self.relatePanel = self.args.relatePanel
  139. end
  140. ---创建或者刷新界面数据时调用
  141. function this:Refresh()
  142. if not self.isOtherPlayer then
  143. self:UpdatePanel()
  144. end
  145. if not self.args or (self.args and not self.args.isPreLoad) then
  146. SL.HideMainPanel()
  147. end
  148. end
  149. function this:SetSelectIndex(index)
  150. local item = self.slotToGrid[index]
  151. if item then
  152. if self.selectItem then
  153. self.selectItem:SetSelect(false)
  154. end
  155. item:SetSelect(true)
  156. self.selectItem = item
  157. end
  158. end
  159. ---@刷新界面
  160. function this:UpdatePanel()
  161. --拥有时装时才显示切换时装穿戴栏按钮
  162. local ownFashion
  163. if self.isOtherPlayer then
  164. --查看他人装备只查看基础穿戴栏装备
  165. ownFashion = false
  166. else
  167. ownFashion = false
  168. self:UpdateMoney()
  169. end
  170. GUI:setVisible(self.view.wearBarChange, ownFashion)
  171. local wearBar = self.args and self.args.wearBar or self.baseWearBar
  172. if not ownFashion then
  173. wearBar = self.baseWearBar
  174. end
  175. self:SetSelfWearBarType(wearBar)
  176. end
  177. ---@param wearBarType EEquipWearBarType
  178. function this:SetSelfWearBarType(wearBarType)
  179. self.wearBar = wearBarType
  180. local equips
  181. if self.isOtherPlayer then
  182. --别人装备
  183. equips = self.otherEquips and self.otherEquips[wearBarType] or {}
  184. GUI:setVisible(self.view.MoneyList, false)
  185. GUI:setVisible(self.view.WearBarList, false)
  186. else
  187. --自己装备
  188. equips = SL:GetWearBarsData(wearBarType)
  189. local show = false
  190. if wearBarType == self.baseWearBar then
  191. show = true
  192. GUI:Image_loadTexture(self.view.wearBarChange, "sz_01", "Atlas/UIzhuangbeixt.spriteatlas")
  193. else
  194. GUI:Image_loadTexture(self.view.wearBarChange, "zb_01", "Atlas/UIEquipPanel.spriteatlas")
  195. end
  196. GUI:setVisible(self.view.MoneyList, show)
  197. GUI:setVisible(self.view.WearBarList, not show)
  198. end
  199. self.equips = equips
  200. if self.wearBarItems[wearBarType] then
  201. self.wearBarItems[wearBarType]:SetSelected()
  202. end
  203. self:UpdateEquips()
  204. end
  205. --更下当前穿戴栏装备
  206. function this:UpdateEquips()
  207. if self.isUpdateEquips then
  208. return
  209. end
  210. local wearBarType = self.wearBar
  211. --根据穿戴栏更新装备数据以及需要显示的装备grid
  212. local noShowSlot = {
  213. EEquipSlotType.None,
  214. EEquipSlotType.Banner,
  215. EEquipSlotType.FashionTotalArmor
  216. }
  217. ---@type cfg_wearing_bar_column
  218. local tbl = SL:GetConfig("cfg_wearing_bar", wearBarType)
  219. for k, data in ipairs(self.equipSlotTypeList) do
  220. --类型
  221. local v = data.type
  222. --双手武器和双手时装武器 跟对应主武器共用一个
  223. if v ~= EEquipSlotType.TwoHandWeapon and v ~= EEquipSlotType.FashionTwoHandWeapon and v ~= EEquipSlotType.ArchangelTwoHandWeapon then
  224. if not table.contains(noShowSlot, v) and not table.contains(tbl.hideArea, v) then
  225. local p = v
  226. if ESlotCondition[v] then
  227. p = ESlotCondition[v]
  228. end
  229. if not self.slotToGrid[v] then
  230. self.isUpdateEquips = true
  231. self.endEquipSlotTypeListIndex = k
  232. local default = self.gridData[v] or self.gridData[p]
  233. if self.wearBar == EEquipWearBarType.ShengDaoShi and v == EEquipSlotType.OffHandWeapon then
  234. default = self.specialData
  235. end
  236. local args = { equipPos = v, isOtherPlayer = self.isOtherPlayer, isEquipGrid = true, item = nil, default = default or {}, x = default.x, y = default.y, click = self.OnGridItemClick, callBackUI = self }
  237. GUI:UIPanel_Open("dev/ui/Common/Item/KLBagItem/KLBagItemItem", self.view.EquipGrid, self, args, true, function(win)
  238. self.slotToGrid[v] = win
  239. GUI:setName(self.slotToGrid[v].view.root, "Grid_" .. data.name)
  240. GUI:setVisible(self.slotToGrid[v].view.root, true)
  241. self.slotToGrid[v]:SetItem(self.equips[v], self.forgeGroupType)
  242. --双手武器没进来 正常双手武器跟主手武器不会同时出现,主武器空就设置一下双手武器
  243. if v== EEquipSlotType.Weapon then
  244. self.slotToGrid[EEquipSlotType.TwoHandWeapon] = self.slotToGrid[EEquipSlotType.Weapon] --双手武器和主武器用同一个
  245. if self.equips[v] == nil then
  246. self.slotToGrid[EEquipSlotType.TwoHandWeapon]:SetItem(self.equips[EEquipSlotType.TwoHandWeapon], self.forgeGroupType)
  247. end
  248. elseif v== EEquipSlotType.FashionWeapon then
  249. self.slotToGrid[EEquipSlotType.FashionTwoHandWeapon] = self.slotToGrid[EEquipSlotType.FashionWeapon] --时装双手武器和时装主武器用同一个
  250. if self.equips[v] == nil then
  251. self.slotToGrid[EEquipSlotType.FashionTwoHandWeapon]:SetItem(self.equips[EEquipSlotType.FashionTwoHandWeapon], self.forgeGroupType)
  252. end
  253. elseif v== EEquipSlotType.ArchangelWeapon then
  254. self.slotToGrid[EEquipSlotType.ArchangelTwoHandWeapon] = self.slotToGrid[EEquipSlotType.ArchangelWeapon] -- 天使装备同上
  255. if self.equips[v] == nil then
  256. self.slotToGrid[EEquipSlotType.ArchangelTwoHandWeapon]:SetItem(self.equips[EEquipSlotType.ArchangelTwoHandWeapon], self.forgeGroupType)
  257. end
  258. elseif v== EEquipSlotType.Pant or v == EEquipSlotType.Glove then
  259. -- Glove和Pant和右侧的装备栏贴的太近 需要调下层级(主要是加了红点会被遮挡)
  260. GUI:SetAsLastSibling(self.slotToGrid[v].view.root)
  261. end
  262. if k == self.endEquipSlotTypeListIndex then
  263. self.isUpdateEquips = false
  264. end
  265. self.slotToGrid[v]:SetSelect(self.selectType == v)
  266. if self.selectType == v then
  267. self.selectItem = self.slotToGrid[v]
  268. end
  269. end)
  270. else
  271. local default = self.gridData[v] or self.gridData[p]
  272. if self.wearBar == EEquipWearBarType.ShengDaoShi and v == EEquipSlotType.OffHandWeapon then
  273. default = self.specialData
  274. end
  275. local args = { equipPos = v, isOtherPlayer = self.isOtherPlayer, isEquipGrid = true, item = nil, default = default or {}, x = default.x, y = default.y, click = self.OnGridItemClick, callBackUI = self }
  276. self.slotToGrid[v]:set_args(args)
  277. self.slotToGrid[v]:SetItem(self.equips[v], self.forgeGroupType)
  278. if self.equips[v] == nil then
  279. --双手武器没进来 只能在设置主武器时同时设置一下
  280. if v== EEquipSlotType.Weapon then
  281. self.slotToGrid[EEquipSlotType.TwoHandWeapon]:SetItem(self.equips[EEquipSlotType.TwoHandWeapon], self.forgeGroupType)
  282. elseif v== EEquipSlotType.FashionWeapon then
  283. self.slotToGrid[EEquipSlotType.FashionTwoHandWeapon]:SetItem(self.equips[EEquipSlotType.FashionTwoHandWeapon], self.forgeGroupType)
  284. elseif v== EEquipSlotType.ArchangelWeapon then
  285. self.slotToGrid[EEquipSlotType.ArchangelTwoHandWeapon]:SetItem(self.equips[EEquipSlotType.ArchangelTwoHandWeapon], self.forgeGroupType)
  286. end
  287. end
  288. -- 预加载重新调用下这个
  289. self.slotToGrid[v]:RegistEvents()
  290. GUI:setVisible(self.slotToGrid[v].view.root, true)
  291. end
  292. else
  293. if self.slotToGrid[v] then
  294. GUI:setVisible(self.slotToGrid[v].view.root, false)
  295. end
  296. end
  297. end
  298. end
  299. end
  300. --装备穿戴栏点击回调
  301. function this:OnGridItemClick(view, item)
  302. if not self.hideTips and item then
  303. local bag = self.isOtherPlayer and "otherEquip" or "equip"
  304. SL:OpenTips(bag, item.cfgId, item.id)
  305. end
  306. if self.hideTips then
  307. if GUI:getVisible(view.selectImg) then
  308. local bag = self.isOtherPlayer and "otherEquip" or "equip"
  309. SL:OpenTips(bag, item.cfgId, item.id,nil,nil,{hideBtn = true})
  310. end
  311. end
  312. if not self.isOtherPlayer then
  313. for pos, v in pairs(self.slotToGrid) do
  314. if v.view and v.view == view then
  315. if not self.hideTips and item == nil and jewelryDefaultId[pos] then
  316. SL:CommonItemGetPath("", jewelryDefaultId[pos])
  317. --SL:OpenTips("", jewelryDefaultId[pos])
  318. end
  319. SL:onLUAEvent(LUA_EVENT_EQUIP_GRID_CLICK, pos)
  320. break
  321. end
  322. end
  323. end
  324. end
  325. --刷新货币数据
  326. function this:UpdateMoney()
  327. if self.isOtherPlayer then
  328. return
  329. end
  330. GUI:Text_setString(self.view.moneyText, tostring(SL:GetMetaValue(EMetaVarGetKey.MONEY, MUEResourceType.GoldMoney)))
  331. GUI:Text_setString(self.view.muCoinText, tostring(SL:GetMetaValue(EMetaVarGetKey.MONEY, MUEResourceType.MiracleCurrency)))
  332. GUI:Text_setString(self.view.muBindCoinText, tostring(SL:GetMetaValue(EMetaVarGetKey.MONEY, MUEResourceType.BindMiracleCurrency)))
  333. GUI:Text_setString(self.view.diamondText, tostring(SL:GetMetaValue(EMetaVarGetKey.MONEY, MUEResourceType.DiaMond)))
  334. end
  335. ---注册UI事件和服务器消息
  336. function this:RegistEvents()
  337. GUI:AddOnClickEvent(self.view.CloseButton, self, self.CloseOnClick)
  338. GUI:AddOnClickEvent(self.view.wearBarChange, self, self.WearBarChangeOnClick)
  339. SL:RegisterLUAEvent(LUA_EVENT_MONEYCHANGE, self.UpdateMoney, self)
  340. SL:RegisterLUAEvent(LUA_EVENT_PLAYER_EQUIP_CHANGE, self.EquipChange, self)
  341. GUI:AddOnClickEvent(self.view.moneyBackground, self, self.ShowMoneyTips, MUEResourceType.GoldMoney)
  342. GUI:AddOnClickEvent(self.view.MUCoinBackground, self, self.ShowMoneyTips, MUEResourceType.MiracleCurrency)
  343. GUI:AddOnClickEvent(self.view.MUBindCoinBackground, self, self.ShowMoneyTips, MUEResourceType.BindMiracleCurrency)
  344. GUI:AddOnClickEvent(self.view.diamondBackground, self, self.ShowMoneyTips, MUEResourceType.DiaMond)
  345. SL:RegisterLuaNetMsg(MessageDef.ResOtherRoleInfoMessage, self.ResOtherRoleInfoMessage, self)
  346. end
  347. ---@param message UserProtos.OtherRoleInfoRes
  348. function this:ResOtherRoleInfoMessage(id, message)
  349. if message.type == 4 and message.role.rid == self.otherRid then
  350. SL:FriendInfo_SetOtherPlayerEquips(message.equipIndex)
  351. local equips = {}
  352. for _, v in pairs(message.equipIndex) do
  353. local wearBar, pos = SL:GetWearBarAndPosBaseEquipIndex(v.index)
  354. if not equips[wearBar] then
  355. equips[wearBar] = {}
  356. end
  357. equips[wearBar][pos] = v.equip
  358. end
  359. self.otherEquips = equips
  360. self:SetBaseWearBar(message.role.career)
  361. self:UpdatePanel()
  362. end
  363. end
  364. ---@param moneyId number @货币id
  365. function this:ShowMoneyTips(_, moneyId)
  366. SL:OpenTips("bag", moneyId)
  367. end
  368. ---@param data table {MakeIndex = 唯一ID, Where = 装备位置, opera = 操作类型 ( 0:初始化 1:增加 2:删除 3:改变), ItemData = 装备数据, WearBar = 穿戴栏id}
  369. function this:EquipChange(_, data)
  370. if self.isOtherPlayer then
  371. return
  372. end
  373. if not table.isNullOrEmpty(data) then
  374. if data.WearBar ~= self.wearBar then
  375. --跳转到穿戴装备的穿戴栏
  376. if self.wearBarItems[data.WearBar] then
  377. self.wearBarItems[data.WearBar]:SetSelectedIgnoreIsOn()
  378. end
  379. else
  380. self.equips = SL:GetWearBarsData(self.wearBar)
  381. local pos = data.Where
  382. if self.slotToGrid[pos] then
  383. self.slotToGrid[pos]:SetItem(self.equips[pos], self.forgeGroupType)
  384. end
  385. end
  386. end
  387. end
  388. function this:WearBarChangeOnClick()
  389. if self.wearBar == self.baseWearBar then
  390. --切换时装优先切换到穿有时装的穿戴栏
  391. local tbl = SL:GetConfigTable("cfg_wearing_bar")
  392. local first
  393. local ownFashion = false
  394. ---@param v cfg_wearing_bar_column
  395. for k, v in pairs(tbl) do
  396. if self.wearBarItems[v.id] then
  397. --判断有没有该穿戴栏的装备数据包括背包里
  398. if SL:CheckOwnTargetWearbarFashion(v.id) then
  399. if not first then
  400. first = self.wearBarItems[v.id]
  401. end
  402. if not ownFashion then
  403. local equips = SL:GetWearBarsData(v.id)
  404. if table.count(equips) > 0 then
  405. ownFashion = true
  406. self.wearBarItems[v.id]:SetSelectedIgnoreIsOn()
  407. end
  408. end
  409. GUI:setVisible(self.wearBarItems[v.id].view.root,true)
  410. else
  411. GUI:setVisible(self.wearBarItems[v.id].view.root,false)
  412. end
  413. end
  414. end
  415. --没时装默认选中第一个
  416. if not ownFashion and first then
  417. first:SetSelectedIgnoreIsOn()
  418. end
  419. else
  420. self:SetSelfWearBarType(self.baseWearBar)
  421. end
  422. end
  423. function this:CloseOnClick()
  424. GUI:UIPanel_Close("dev/ui/Equip/Panel/KLEquipUI/KLGemEquipUIPanel")
  425. if self.relatePanel then
  426. GUI:UIPanel_Close(self.relatePanel)
  427. end
  428. self.relatePanel = nil
  429. if self.closeCallBack then
  430. self.closeCallBack(self.closeCallBackData)
  431. end
  432. if not self.isHideMainUI then
  433. SL.ShowMainPanel()
  434. end
  435. end
  436. function this:Close()
  437. for i, v in pairs(self.slotToGrid) do
  438. GUI:UIPanel_Close(nil,v)
  439. end
  440. for i, v in pairs(self.wearBarItems) do
  441. GUI:UIPanel_Close(nil,v)
  442. end
  443. self.slotToGrid = {}
  444. self.wearBarItems = {}
  445. -- GUI:Image_loadTexture(self.view.btn_level, "Texture/tower_top.png")
  446. end
  447. return this