KLMountDisplayPanel.lua 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. ---@class KLMountDisplayPanel:UIKmlLuaPanelBase
  2. ---@field view KLMountDisplayPanelView
  3. local KLMountDisplayPanel = class(UIKmlLuaPanelBase)
  4. local this =KLMountDisplayPanel
  5. ---创建时调用一次
  6. function this:Init()
  7. self.attTxtList = {}
  8. self.mountAtt_all_item = {}
  9. end
  10. ---创建或者刷新界面数据时调用
  11. function this:Refresh()
  12. SL.HideMainPanel()
  13. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_MOUNT_DETAIL_INFO,{self.args.mountId})
  14. GUI:setVisible(self.view.ownerMountRoot,self.args.mountId~=-1)
  15. if self.args.mountId ~= -1 then
  16. ---@type cfg_mount_column
  17. local tbl = SL:GetConfig("cfg_mount",self.args.mountId,"id")
  18. ---@type cfg_mount_model_column
  19. local mount_model_tbl = SL:GetConfig("cfg_mount_model",tbl.mountId,"id")
  20. ---@type cfg_mount_behaviour_column
  21. local behaviour_tbl = SL:GetConfigMultiKeys("cfg_mount_behaviour",tbl.motion,1,"id","state")
  22. GUI:HideAllChilds(self.view.model)
  23. self.cur_mount_model = GUI:Model_Create(self.view.model,{
  24. id="cur_mount_model",
  25. mscale=tbl.scale2.. ",".. tbl.scale2 ..",".. tbl.scale2,
  26. mrotate="0,200,0",
  27. x="0",
  28. y="-120",
  29. z="-1000",
  30. a="00",
  31. src=mount_model_tbl.path,
  32. ani=behaviour_tbl.name,
  33. })
  34. GUI:setVisible(self.view.cancelRideBtn,self.args.isWear)
  35. GUI:setVisible(self.view.rideBtn,not self.args.isWear)
  36. GUI:setVisible(self.view.rideTip,self.args.isWear or self.args.auto)
  37. GUI:setVisible(self.view.tapToggleGroup,tbl.mountEquip == 1)
  38. if tbl.mountEquip == 1 then
  39. GUI:SetIsOnWithoutNotify(self.view.mountInfoToggle,true)
  40. GUI:SetIsOnWithoutNotify(self.view.mountEquipToggle,false)
  41. end
  42. GUI:SetIsOnWithoutNotify(self.view.isRankShowMount,InfoManager.mountInfo.isRankShowMount)
  43. else
  44. GUI:setVisible(self.view.skillContainer,false)
  45. end
  46. end
  47. ---注册UI事件和服务器消息
  48. function this:RegistEvents()
  49. GUI:AddOnClickEvent(self.view.closeBtn,self,self.OnClickCloseBtn)
  50. GUI:AddOnClickEvent(self.view.desBtn,self,self.OnClickDesBtn)
  51. GUI:AddOnClickEvent(self.view.cancelRideBtn,self,self.OnClickCancelRideBtn)
  52. GUI:AddOnClickEvent(self.view.rideBtn,self,self.OnClickRideBtn)
  53. GUI:SetToggleOnValueChange(self.view.isRankShowMount,self,self.OnValueChangeIsRankShowMount)
  54. GUI:SetToggleOnValueChange(self.view.mountInfoToggle,self,self.OnValueChangeMountInfoToggle)
  55. GUI:SetToggleOnValueChange(self.view.mountEquipToggle,self,self.OnValueChangeMountEquipToggle)
  56. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_RIDING_MOUNT,self.RES_RIDING_MOUNT,self)
  57. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_CANCEL_RIDING_MOUNT,self.RES_CANCEL_RIDING_MOUNT,self)
  58. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_MOUNT_DETAIL_INFO,self.RES_MOUNT_DETAIL_INFO,self)
  59. end
  60. function this:OnClickCloseBtn()
  61. GUI:UIPanel_Close("dev/outui/Mount/Panel/KLMountEquip/KLMountEquipPanel")
  62. GUI:UIPanel_Close("dev/outui/Mount/Panel/KLMountStore/KLMountStorePanel")
  63. GUI:UIPanel_Close("dev/outui/Mount/Panel/KLMountDisplay/KLMountDisplayPanel")
  64. end
  65. function this:OnClickDesBtn()
  66. GUI:UIPanel_Open("dev/outui/Mount/Panel/KLMountDes/KLMountDesPanel")
  67. end
  68. function this:OnClickCancelRideBtn()
  69. GUI:setVisible(self.view.cancelRideBtn,false)
  70. GUI:setVisible(self.view.rideBtn,true)
  71. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_CANCEL_RIDING_MOUNT,{self.args.mountId})
  72. end
  73. function this:OnClickRideBtn()
  74. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_RIDING_MOUNT,{self.args.mountId})
  75. end
  76. function this:OnValueChangeMountInfoToggle(_,_,data)
  77. end
  78. function this:OnValueChangeIsRankShowMount(_,_,data)
  79. local isToggle = data[1]
  80. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_SET_MOUNT_RANK,isToggle and self.args.mountId or 0)
  81. end
  82. function this:OnValueChangeMountEquipToggle(_,_,data)
  83. local isToggle = data[1]
  84. if isToggle then
  85. self:SetVisible(false)
  86. ---@type KLMountStorePanel
  87. local panel = GUI:GetUI("dev/outui/Mount/Panel/KLMountStore/KLMountStorePanel")
  88. if panel then
  89. panel:Refresh()
  90. end
  91. local data = {mountId = self.args.mountId}
  92. ---@type KLMountStorePanel
  93. panel = GUI:GetUI("dev/outui/Mount/Panel/KLMountEquip/KLMountEquipPanel")
  94. if panel then
  95. panel.args = data
  96. panel:SetVisible(true)
  97. panel:Refresh()
  98. else
  99. GUI:UIPanel_Open("dev/outui/Mount/Panel/KLMountEquip/KLMountEquipPanel",nil,nil,data)
  100. end
  101. end
  102. end
  103. function this:RES_RIDING_MOUNT(id,message)
  104. GUI:setVisible(self.view.cancelRideBtn,true)
  105. GUI:setVisible(self.view.rideBtn,false)
  106. GUI:setVisible(self.view.rideTip,true)
  107. end
  108. function this:RES_CANCEL_RIDING_MOUNT(id,message)
  109. GUI:setVisible(self.view.cancelRideBtn,false)
  110. GUI:setVisible(self.view.rideBtn,true)
  111. GUI:setVisible(self.view.rideTip,false)
  112. end
  113. function this:RES_MOUNT_DETAIL_INFO(id,message)
  114. self:RefreshAttInfoList(message.att)
  115. end
  116. function this:RefreshAttInfoList(attribute)
  117. if self.args.mountId == -1 then return end
  118. local attInfo = {}
  119. self.attTxtList = {}
  120. for i, v in pairs(attribute) do
  121. local isSkip = false
  122. local attId = tonumber(i)
  123. local attNum = v
  124. ---@type cfg_att_info_column
  125. local tbl = SL:GetConfig("cfg_att_info",attId,"id")
  126. local attTxt
  127. if tbl.remarks ~= EAttrRemarkType.Number then
  128. attTxt = attNum/100 .."%"
  129. else
  130. attTxt = attNum
  131. end
  132. if attId == 200011 then--最小
  133. attInfo[1] = "攻击力#"..attTxt.."~"
  134. elseif attId == 200021 then--最大
  135. attInfo[2] = attTxt
  136. elseif attId == 202021 then--最小
  137. attInfo[3] = "魔法攻击力#"..attTxt.."~"
  138. elseif attId == 202011 then--最大
  139. attInfo[4] = attTxt
  140. elseif attId == 205011 then--最小
  141. attInfo[5] = "诅咒攻击力#"..attTxt.."~"
  142. elseif attId == 205021 then--最大
  143. attInfo[6] = attTxt
  144. else
  145. attTxt = tbl.name.."#" ..attTxt
  146. table.insert(self.attTxtList,attTxt)
  147. isSkip = true
  148. end
  149. if not isSkip then
  150. if attInfo[1] and attInfo[2] then
  151. table.insert(self.attTxtList,attInfo[1]..attInfo[2])
  152. attInfo[1] = nil
  153. attInfo[2] = nil
  154. elseif attInfo[3] and attInfo[4] then
  155. table.insert(self.attTxtList,attInfo[3]..attInfo[4])
  156. attInfo[3] = nil
  157. attInfo[4] = nil
  158. elseif attInfo[5] and attInfo[6] then
  159. table.insert(self.attTxtList,attInfo[5]..attInfo[6])
  160. attInfo[5] = nil
  161. attInfo[6] = nil
  162. end
  163. end
  164. end
  165. ---@type cfg_mount_column
  166. local tbl = SL:GetConfig("cfg_mount",self.args.mountId,"id")
  167. local height = #self.attTxtList * 38 + 35
  168. if tbl.mountEquip ~= 1 and tbl.skillID~=0 then
  169. height = #self.attTxtList * 38 + 185 + 35
  170. end
  171. GUI:setContentSize(self.view.mountDesList,385,height)
  172. for i = 1, #self.mountAtt_all_item do
  173. GUI:UIPanel_Close("",self.mountAtt_all_item[i])
  174. end
  175. for i = 1, #self.attTxtList do
  176. local item = GUI:UIPanel_Open("dev/outui/Mount/Item/KLMountAttInfo/KLMountAttInfoItem",self.view.mount_att_info_list,self,{width=385,attInfo=self.attTxtList[i]},true)
  177. self.mountAtt_all_item[i] = item
  178. end
  179. GUI:setPositionY(self.view.skillContainer,0)
  180. self:ShowSkillInfo(tbl.skillID,tbl.skillLevel,tbl.mountEquip)
  181. end
  182. function this:ShowSkillInfo(skillId,level,mountEquip)
  183. GUI:setVisible(self.view.skillContainer,mountEquip ~= 1 and skillId~=0)
  184. if skillId ~= 0 then
  185. ---@type cfg_skill_info_column
  186. local tbl = SL:GetConfigMultiKeys("cfg_skill_info",skillId,level,"skillID","skillLevel")
  187. GUI:Image_loadTexture(self.view.skillIcon,tbl.icon,"Atlas/Skill_icon.spriteatlas")
  188. GUI:Text_setString(self.view.skillName,tbl.name.." Lv."..level)
  189. GUI:Text_setString(self.view.skillDes,tbl.tips)
  190. end
  191. end
  192. function this:SetVisible(isVisible)
  193. GUI:setVisible(self.view.root,isVisible)
  194. end
  195. function this:GetVisible()
  196. return GUI:getVisible(self.view.root)
  197. end
  198. function this:Close()
  199. SL.ShowMainPanel()
  200. end
  201. return this