KLAppearPreviewPanel.lua 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. ---@class KLAppearPreviewPanel:UIKmlLuaPanelBase
  2. ---@field view KLAppearPreviewPanelView
  3. local KLAppearPreviewPanel = class(UIKmlLuaPanelBase)
  4. local this = KLAppearPreviewPanel
  5. ---创建时调用一次
  6. function this:Init()
  7. end
  8. ---创建或者刷新界面数据时调用
  9. function this:Refresh()
  10. self.isHideWing = GUI:Toggle_getIsOn(self.view.TogHideWing) =="1"
  11. end
  12. ---注册UI事件和服务器消息
  13. function this:RegistEvents()
  14. GUI:AddOnClickEvent(self.view.BtnClose, self, self.BtnCloseOnClick)
  15. GUI:SetToggleOnValueChange(self.view.TogHideWing,self,self.OnTogHideWingChange)
  16. SL:RegisterLUAEvent(APPEAR_PREVIEW_SELECT_CHANGE, self.OnAppearPreviewChange, self)
  17. SL:RegisterLUAEvent(TITLE_PREVIEW_SELECT_CHANGE, self.OnTitlePreviewChange, self)
  18. SL:RegisterLUAEvent(TRANSFER_RING_PREVIEW_SELECT_CHANGE, self.OnRingPreviewChange, self)
  19. end
  20. function this:OnTogHideWingChange()
  21. self.isHideWing = GUI:Toggle_getIsOn(self.view.TogHideWing) =="1"
  22. self:OnPreview(self.appearList,self.curMonsterId,self.curTitleId)
  23. end
  24. function this:OnAppearPreviewChange(_, appearList)
  25. local cfgIds = appearList
  26. if not cfgIds then
  27. cfgIds = InfoManager.appearInfo.GetCurAppearList()
  28. end
  29. local curMonsterId = InfoManager.appearInfo.GetCurMonsterId()
  30. local curTitleId = InfoManager.appearInfo.GetCurTitleId()
  31. return self:OnPreview(cfgIds, curMonsterId, curTitleId)
  32. end
  33. function this:OnRingPreviewChange(_, ringId)
  34. local monsterId
  35. local appearList = InfoManager.appearInfo.GetCurAppearList()
  36. local curTitleId = InfoManager.appearInfo.GetCurTitleId()
  37. if ringId and ringId > 0 then
  38. ---@type cfg_item_column
  39. local itemTbl = SL:GetConfig("cfg_item", ringId)
  40. monsterId = tonumber(itemTbl.useParam)
  41. end
  42. return self:OnPreview(appearList, monsterId, curTitleId)
  43. end
  44. function this:OnTitlePreviewChange(_, titleId)
  45. local appearList = InfoManager.appearInfo.GetCurAppearList()
  46. local curMonsterId = InfoManager.appearInfo.GetCurMonsterId()
  47. return self:OnPreview(appearList, curMonsterId, titleId)
  48. end
  49. function this:OnPreview(appearList, curMonsterId, curTitleId)
  50. self.appearList = appearList
  51. self.curMonsterId = curMonsterId
  52. self.curTitleId = curTitleId
  53. if curMonsterId and curMonsterId > 0 then
  54. GUI:SetActive(self.view.MonsterModle, true)
  55. GUI:SetActive(self.view.RoleModel, false)
  56. GUI:SetActive(self.view.GuardModel, false)
  57. ---@type cfg_monster_column
  58. local monsterTbl = SL:GetConfig('cfg_monster', curMonsterId)
  59. ---@type cfg_model_monster_column
  60. local modelTbl = SL:GetConfig('cfg_model_monster', monsterTbl.appr)
  61. GUI:Model_setSrc(self.view.MonsterModle, modelTbl.path)
  62. else
  63. GUI:SetActive(self.view.RoleModel, true)
  64. GUI:SetActive(self.view.MonsterModle, false)
  65. local model_list, equip_list, guardCfgId = self:GetPlayerRoleInfo(appearList)
  66. GUI:SetPlayerRoleInfo(self.view.RoleModel, model_list, equip_list)
  67. if guardCfgId then
  68. GUI:SetActive(self.view.GuardModel, true)
  69. ---@type cfg_item_column
  70. local itemTbl = SL:GetConfig("cfg_item", guardCfgId)
  71. local modelId = itemTbl.field[1]
  72. ---@type cfg_model_charactor_column
  73. local modelTbl = SL:GetConfig('cfg_model_charactor', modelId)
  74. GUI:Model_setSrc(self.view.GuardModel, modelTbl.path)
  75. else
  76. GUI:SetActive(self.view.GuardModel, false)
  77. end
  78. end
  79. if curTitleId and curTitleId > 0 and SL:HasConfig("cfg_item", curTitleId) then
  80. GUI:SetActive(self.view.TitleModel, true)
  81. ---@type cfg_item_column
  82. local itemTbl = SL:GetConfig("cfg_item", curTitleId)
  83. ---@type cfg_model_charactor_column
  84. local modelTbl = SL:GetConfig('cfg_model_charactor', itemTbl.shape[1])
  85. ---@type cfg_fashion_column
  86. local fashionTbl = SL:GetConfig("cfg_fashion", curTitleId)
  87. local scale = "300,300,300"
  88. if fashionTbl.modelScale > 0 then
  89. scale = string.replace(scale, "300", tostring(fashionTbl.modelScale))
  90. end
  91. GUI:Model_setSrc(self.view.TitleModel, modelTbl.path, scale)
  92. else
  93. GUI:Model_setSrc(self.view.TitleModel, "")
  94. GUI:SetActive(self.view.TitleModel, false)
  95. end
  96. end
  97. function this:BtnCloseOnClick()
  98. GUI:UIPanel_Close("dev/outui/AppearGroup/Panel/KLAppearPreview/KLAppearPreviewPanel")
  99. end
  100. function this:Close()
  101. GUI:UIPanel_Close("dev/outui/AppearGroup/Panel/KLAppear/KLAppearPanel")
  102. GUI:UIPanel_Close("dev/outui/AppearGroup/Panel/KLTitle/KLTitlePanel")
  103. GUI:UIPanel_Close("dev/outui/AppearGroup/Panel/KLSuit/KLSuitPanel")
  104. GUI:UIPanel_Close("dev/outui/AppearGroup/Panel/KLRender/KLRenderPanel")
  105. GUI:UIPanel_Close("dev/outui/AppearGroup/Panel/KLTransferRing/KLTransferRingPanel")
  106. GUI:UIPanel_Close("dev/outui/AppearGroup/Panel/KLAppearGroup/KLAppearGroupPanel")
  107. end
  108. function this:GetPlayerRoleInfo(cfgIds)
  109. local role_param = { "body", "head", "head1", "armor", "hand", "pants", "boot" }
  110. local wear_list_str = ""
  111. local model_list_str = ""
  112. local guardCfgId
  113. local baseCareer = SL:GetMetaValue("JOB")
  114. local default_tbl = SL:GetConfig("cfg_model_default", baseCareer)
  115. local model_list = {}
  116. for _, v in pairs(role_param) do
  117. model_list[v] = default_tbl[v]
  118. end
  119. --修复背了两把短剑只显示一把
  120. local lastSub2Id = {}
  121. for _, cfgId in pairs(cfgIds) do
  122. if SL:HasConfig("cfg_item", cfgId) then
  123. ---@type cfg_item_column
  124. local itemInfo = SL:GetConfig("cfg_item", cfgId)
  125. if itemInfo.type == E_ItemType.Equip then
  126. if itemInfo.subType == E_ItemSubType_Equip.MainWeapon then
  127. if not lastSub2Id[itemInfo.subType] then
  128. if wear_list_str == "" then
  129. wear_list_str = "WeaponRspineParent#" .. itemInfo.field[1]
  130. else
  131. wear_list_str = wear_list_str .. ",WeaponRspineParent#" .. itemInfo.field[1]
  132. end
  133. lastSub2Id[itemInfo.subType] = cfgId
  134. else
  135. if wear_list_str == "" then
  136. wear_list_str = "WeaponLspineParent#" .. itemInfo.field[1]
  137. else
  138. wear_list_str = wear_list_str .. ",WeaponLspineParent#" .. itemInfo.field[1]
  139. end
  140. end
  141. elseif itemInfo.subType == E_ItemSubType_Equip.SecWeapon then
  142. if not lastSub2Id[itemInfo.subType] then
  143. if wear_list_str == "" then
  144. wear_list_str = "WeaponLspineParent#" .. itemInfo.field[1]
  145. else
  146. wear_list_str = wear_list_str .. ",WeaponLspineParent#" .. itemInfo.field[1]
  147. end
  148. lastSub2Id[itemInfo.subType] = cfgId
  149. else
  150. if wear_list_str == "" then
  151. wear_list_str = "WeaponRspineParent#" .. itemInfo.field[1]
  152. else
  153. wear_list_str = wear_list_str .. ",WeaponRspineParent#" .. itemInfo.field[1]
  154. end
  155. end
  156. elseif itemInfo.subType == E_ItemSubType_Equip.MainSecWeapon then
  157. if not lastSub2Id[itemInfo.subType] then
  158. if wear_list_str == "" then
  159. wear_list_str = "WeaponRspineParent#" .. itemInfo.field[1]
  160. else
  161. wear_list_str = wear_list_str .. ",WeaponRspineParent#" .. itemInfo.field[1]
  162. end
  163. lastSub2Id[itemInfo.subType] = cfgId
  164. else
  165. if wear_list_str == "" then
  166. wear_list_str = "WeaponLspineParent#" .. itemInfo.field[1]
  167. else
  168. wear_list_str = wear_list_str .. ",WeaponLspineParent#" .. itemInfo.field[1]
  169. end
  170. end
  171. elseif itemInfo.subType == E_ItemSubType_Equip.ChiBang then
  172. if not self.isHideWing then
  173. if wear_list_str == "" then
  174. wear_list_str = "Wing#" .. itemInfo.field[1]
  175. else
  176. wear_list_str = wear_list_str .. ",Wing#" .. itemInfo.field[1]
  177. end
  178. end
  179. elseif itemInfo.subType == E_ItemSubType_Equip.ShouHu then
  180. guardCfgId = itemInfo.id
  181. elseif itemInfo.subType == 30 then
  182. if wear_list_str == "" then
  183. wear_list_str = "BuffspineParent#" .. itemInfo.field[1]
  184. else
  185. wear_list_str = wear_list_str .. ",BuffspineParent#" .. itemInfo.field[1]
  186. end
  187. else
  188. local point = ""
  189. ---@type cfg_model_charactor_column
  190. local model_tbl = SL:GetConfig("cfg_model_charactor", itemInfo.field[1])
  191. if model_tbl then
  192. if model_tbl.part == 23 then
  193. point = "body"
  194. elseif model_tbl.part == 11 then
  195. if itemInfo.subType == E_ItemSubType_Equip.MianJin then
  196. point = "head1"
  197. else
  198. point = "head"
  199. end
  200. elseif model_tbl.part == 2 then
  201. point = "armor"
  202. elseif model_tbl.part == 9 then
  203. point = "hand"
  204. elseif model_tbl.part == 15 then
  205. point = "pants"
  206. elseif model_tbl.part == 5 then
  207. point = "boot"
  208. end
  209. if point ~= "" then
  210. model_list[point] = itemInfo.field[1]
  211. end
  212. end
  213. end
  214. elseif itemInfo.type == E_ItemType.TriggerItem and itemInfo.subType == E_OutTriggerItemType.GuardSkin then
  215. guardCfgId = itemInfo.id
  216. end
  217. end
  218. end
  219. for _, v in pairs(model_list) do
  220. if model_list_str == "" then
  221. model_list_str = v
  222. else
  223. model_list_str = model_list_str .. "#" .. v
  224. end
  225. end
  226. return model_list_str, wear_list_str, guardCfgId
  227. end
  228. return this