KLMountTipPanel.lua 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. ---@class KLMountTipPanel:UIKmlLuaPanelBase
  2. ---@field view KLMountTipPanelView
  3. local KLMountTipPanel = class(UIKmlLuaPanelBase)
  4. local this =KLMountTipPanel
  5. ---创建时调用一次
  6. function this:Init()
  7. end
  8. ---注册UI事件和服务器消息
  9. function this:RegistEvents()
  10. GUI:AddOnClickEvent(self.view.bgMask,self,self.OnClickCancelBtn)
  11. GUI:AddOnClickEvent(self.view.cancelBtn,self,self.OnClickCancelBtn)
  12. GUI:AddOnClickEvent(self.view.takeOffBtn,self,self.OnClickTakeOffBtn)
  13. GUI:AddOnClickEvent(self.view.putOnBtn,self,self.OnClickPutOnBtn)
  14. GUI:AddOnClickEvent(self.view.putOnStoreBtn,self,self.OnClickPutOnStoreBtn)
  15. GUI:AddOnClickEvent(self.view.takeOutStoreBtn,self,self.OnClickTakeOutStoreBtn)
  16. end
  17. function this:OnClickCancelBtn()
  18. GUI:UIPanel_Close("dev/outui/Mount/Panel/KLMountTip/KLMountTipPanel")
  19. end
  20. function this:OnClickTakeOffBtn()
  21. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_MOUNT_STORE_TO_BAG,{self.mountTbl.id,0})
  22. self:OnClickCancelBtn()
  23. end
  24. function this:OnClickPutOnBtn()
  25. local BagIndex = SL:GetBagIndex(self.args.id)
  26. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_MOUNT_BAG_TO_STORE,{BagIndex,self.mountTbl.itemId})
  27. self:OnClickCancelBtn()
  28. end
  29. function this:OnClickPutOnStoreBtn()
  30. local BagIndex = SL:GetBagIndex(self.args.id)
  31. SL.Equip:ReqBagPutStoreButtonMessage(BagIndex, SL:GetDepotsCurPage())
  32. self:OnClickCancelBtn()
  33. end
  34. function this:OnClickTakeOutStoreBtn()
  35. local storeIndex = SL:GetDepotsIndex(self.args.id)
  36. SL.Equip:ReqStoreTakeButtonMessage(storeIndex)
  37. self:OnClickCancelBtn()
  38. end
  39. ---创建或者刷新界面数据时调用
  40. function this:Refresh()
  41. GUI:UIPanel_Close("dev/ui/Tips/Panel/KLUIEquipTips/KLUIEquipTipsPanel")
  42. if self.args.equip_pos == "bag" then
  43. self.args.type = EMountTipType.BagUIOpen
  44. elseif self.args.equip_pos == "depots" then
  45. self.args.type = EMountTipType.StoreUIOpen
  46. elseif not self.args.type then
  47. self.args.type = EMountTipType.OtherUIOpen
  48. end
  49. local panel = GUI:GetUI("dev/ui/Bag/Panel/KLDepots/KLDepotsPanel")
  50. GUI:setVisible(self.view.cancelBtn, self.args.type ~= EMountTipType.OtherUIOpen)
  51. GUI:setVisible(self.view.takeOffBtn,self.args.type == EMountTipType.MountUIOpen)
  52. GUI:setVisible(self.view.putOnBtn,self.args.type == EMountTipType.BagUIOpen and not panel)
  53. GUI:setVisible(self.view.putOnStoreBtn,self.args.type == EMountTipType.BagUIOpen and panel)
  54. GUI:setVisible(self.view.takeOutStoreBtn,self.args.type == EMountTipType.StoreUIOpen)
  55. local tblList =SL:GetConfigTable("cfg_mount")
  56. ---@param v cfg_mount_column
  57. for i, v in pairs(tblList) do
  58. if self.args.cfgId == v.itemId then
  59. self.mountTbl = v
  60. break
  61. end
  62. end
  63. if not self.mountTbl then
  64. logError("cfg_mount not exist itemId = ",self.args.cfgId)
  65. return
  66. end
  67. ---@type cfg_item_column
  68. local itemTbl = SL:GetConfig("cfg_item", self.args.cfgId,"id")
  69. GUI:Text_setString(self.view.title,itemTbl.name)
  70. local careerDes = ""
  71. if #itemTbl.job ~= 0 then
  72. local career = SL:GetMetaValue(EMetaVarGetKey.JOB)
  73. for i, v in pairs(itemTbl.job[1]) do
  74. if v == 0 then
  75. break
  76. end
  77. ---@type cfg_career_column
  78. local careerTbl = SL:GetConfig("cfg_career",v,"baseCareer")
  79. local color = "#ffffff"
  80. if v == career then
  81. color = "#ff2323"
  82. end
  83. if string.isNullOrEmpty(careerDes) then
  84. careerDes = GUIUtil.GetColorText(careerTbl.name,color)
  85. else
  86. careerDes = careerDes .."," .. GUIUtil.GetColorText(careerTbl.name,color)
  87. end
  88. end
  89. if not string.isNullOrEmpty(careerDes) then
  90. careerDes = "所需职业:" .. careerDes
  91. end
  92. end
  93. ---@type cfg_color_column
  94. local tbl = SL:GetColorCfg(itemTbl.color)
  95. GUI:Text_setString(self.view.careerName,careerDes)
  96. GUI:Text_setString(self.view.title,GUIUtil.GetColorText(itemTbl.name,tbl and tbl.color or ""))
  97. ---@type cfg_mount_model_column
  98. local mount_model_tbl = SL:GetConfig("cfg_mount_model",self.mountTbl.mountId,"id")
  99. ---@type cfg_model_charactor_column
  100. local model_tbl = SL:GetConfig("cfg_model_charactor",itemTbl.shape[1],"id")
  101. ---@type cfg_mount_behaviour_column
  102. local behaviour_tbl = SL:GetConfigMultiKeys("cfg_mount_behaviour",self.mountTbl.motion,1,"id","state")
  103. GUI:Model_setSrc(self.view.item_model,model_tbl.path)
  104. GUI:SetEulerAngles(self.view.item_model,model_tbl.inrotate[1],model_tbl.inrotate[2],model_tbl.inrotate[3])
  105. GUI:setScale(self.view.item_model,model_tbl.inscale)
  106. GUI:HideAllChilds(self.view.mount_model)
  107. self.cur_mount_model = GUI:Model_Create(self.view.mount_model,{
  108. id="cur_mount_model",
  109. mscale=self.mountTbl.scale2.. ",".. self.mountTbl.scale2 ..",".. self.mountTbl.scale2,
  110. mrotate="0,200,0",
  111. x="0",
  112. y="-120",
  113. z="0",
  114. a="00",
  115. src=mount_model_tbl.path,
  116. ani=behaviour_tbl.name,
  117. })
  118. self:RefreshAttInfoList(self.mountTbl.attribute)
  119. end
  120. function this:RefreshAttInfoList(attribute)
  121. local attInfo = {}
  122. local attTxtList = {}
  123. GUI:HideAllChilds(self.view.attList)
  124. table.insert(attribute,{318022,self.mountTbl.speed})
  125. for i, v in pairs(attribute) do
  126. local isSkip = false
  127. ---@type cfg_att_info_column
  128. local tbl = SL:GetConfig("cfg_att_info",v[1],"id")
  129. local attTxt
  130. if tbl.remarks ~= EAttrRemarkType.Number then
  131. attTxt = v[2]/100 .."%"
  132. else
  133. attTxt = v[2]
  134. end
  135. if v[1] == 200011 then--最小
  136. attInfo[1] = "攻击力:"..attTxt.."~"
  137. elseif v[1] == 200021 then--最大
  138. attInfo[2] = attTxt
  139. elseif v[1] == 202021 then--最小
  140. attInfo[3] = "魔法攻击力:"..attTxt.."~"
  141. elseif v[1] == 202011 then--最大
  142. attInfo[4] = attTxt
  143. elseif v[1] == 205011 then--最小
  144. attInfo[5] = "诅咒攻击力:"..attTxt.."~"
  145. elseif v[1] == 205021 then--最大
  146. attInfo[6] = attTxt
  147. else
  148. attTxt = tbl.name..":" ..attTxt
  149. if v[1] == 313012 or v[1] == 311012 or v[1] == 318022 then
  150. attTxt = GUIUtil.GetColorText(attTxt,"#4ba7e8")
  151. end
  152. table.insert(attTxtList,attTxt)
  153. isSkip = true
  154. end
  155. if not isSkip then
  156. if attInfo[1] and attInfo[2] then
  157. table.insert(attTxtList,attInfo[1]..attInfo[2])
  158. attInfo[1] = nil
  159. attInfo[2] = nil
  160. elseif attInfo[3] and attInfo[4] then
  161. table.insert(attTxtList,attInfo[3]..attInfo[4])
  162. attInfo[3] = nil
  163. attInfo[4] = nil
  164. elseif attInfo[5] and attInfo[6] then
  165. table.insert(attTxtList,attInfo[5]..attInfo[6])
  166. attInfo[5] = nil
  167. attInfo[6] = nil
  168. end
  169. end
  170. end
  171. table.remove(attribute,#attribute)
  172. for i = 1, #attTxtList do
  173. GUI:Text_Create(self.view.attList, {
  174. id = "attTxt",
  175. text = attTxtList[i],
  176. width = 295,
  177. height = 20,
  178. ta="02",
  179. x = 0,
  180. y = 0,
  181. })
  182. end
  183. end
  184. function this:Close()
  185. end
  186. return this