123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- ---@class KLAppearPreviewPanel:UIKmlLuaPanelBase
- ---@field view KLAppearPreviewPanelView
- local KLAppearPreviewPanel = class(UIKmlLuaPanelBase)
- local this = KLAppearPreviewPanel
- ---创建时调用一次
- function this:Init()
- end
- ---创建或者刷新界面数据时调用
- function this:Refresh()
- self.isHideWing = GUI:Toggle_getIsOn(self.view.TogHideWing) =="1"
- end
- ---注册UI事件和服务器消息
- function this:RegistEvents()
- GUI:AddOnClickEvent(self.view.BtnClose, self, self.BtnCloseOnClick)
- GUI:SetToggleOnValueChange(self.view.TogHideWing,self,self.OnTogHideWingChange)
- SL:RegisterLUAEvent(APPEAR_PREVIEW_SELECT_CHANGE, self.OnAppearPreviewChange, self)
- SL:RegisterLUAEvent(TITLE_PREVIEW_SELECT_CHANGE, self.OnTitlePreviewChange, self)
- SL:RegisterLUAEvent(TRANSFER_RING_PREVIEW_SELECT_CHANGE, self.OnRingPreviewChange, self)
- end
- function this:OnTogHideWingChange()
- self.isHideWing = GUI:Toggle_getIsOn(self.view.TogHideWing) =="1"
- self:OnPreview(self.appearList,self.curMonsterId,self.curTitleId)
- end
- function this:OnAppearPreviewChange(_, appearList)
- local cfgIds = appearList
- if not cfgIds then
- cfgIds = InfoManager.appearInfo.GetCurAppearList()
- end
- local curMonsterId = InfoManager.appearInfo.GetCurMonsterId()
- local curTitleId = InfoManager.appearInfo.GetCurTitleId()
- return self:OnPreview(cfgIds, curMonsterId, curTitleId)
- end
- function this:OnRingPreviewChange(_, ringId)
- local monsterId
- local appearList = InfoManager.appearInfo.GetCurAppearList()
- local curTitleId = InfoManager.appearInfo.GetCurTitleId()
- if ringId and ringId > 0 then
- ---@type cfg_item_column
- local itemTbl = SL:GetConfig("cfg_item", ringId)
- monsterId = tonumber(itemTbl.useParam)
- end
- return self:OnPreview(appearList, monsterId, curTitleId)
- end
- function this:OnTitlePreviewChange(_, titleId)
- local appearList = InfoManager.appearInfo.GetCurAppearList()
- local curMonsterId = InfoManager.appearInfo.GetCurMonsterId()
- return self:OnPreview(appearList, curMonsterId, titleId)
- end
- function this:OnPreview(appearList, curMonsterId, curTitleId)
- self.appearList = appearList
- self.curMonsterId = curMonsterId
- self.curTitleId = curTitleId
- if curMonsterId and curMonsterId > 0 then
- GUI:SetActive(self.view.MonsterModle, true)
- GUI:SetActive(self.view.RoleModel, false)
- GUI:SetActive(self.view.GuardModel, false)
- ---@type cfg_monster_column
- local monsterTbl = SL:GetConfig('cfg_monster', curMonsterId)
- ---@type cfg_model_monster_column
- local modelTbl = SL:GetConfig('cfg_model_monster', monsterTbl.appr)
- GUI:Model_setSrc(self.view.MonsterModle, modelTbl.path)
- else
- GUI:SetActive(self.view.RoleModel, true)
- GUI:SetActive(self.view.MonsterModle, false)
- local model_list, equip_list, guardCfgId = self:GetPlayerRoleInfo(appearList)
- GUI:SetPlayerRoleInfo(self.view.RoleModel, model_list, equip_list)
- if guardCfgId then
- GUI:SetActive(self.view.GuardModel, true)
- ---@type cfg_item_column
- local itemTbl = SL:GetConfig("cfg_item", guardCfgId)
- local modelId = itemTbl.field[1]
- ---@type cfg_model_charactor_column
- local modelTbl = SL:GetConfig('cfg_model_charactor', modelId)
- GUI:Model_setSrc(self.view.GuardModel, modelTbl.path)
- else
- GUI:SetActive(self.view.GuardModel, false)
- end
- end
- if curTitleId and curTitleId > 0 and SL:HasConfig("cfg_item", curTitleId) then
- GUI:SetActive(self.view.TitleModel, true)
- ---@type cfg_item_column
- local itemTbl = SL:GetConfig("cfg_item", curTitleId)
- ---@type cfg_model_charactor_column
- local modelTbl = SL:GetConfig('cfg_model_charactor', itemTbl.shape[1])
- ---@type cfg_fashion_column
- local fashionTbl = SL:GetConfig("cfg_fashion", curTitleId)
- local scale = "300,300,300"
- if fashionTbl.modelScale > 0 then
- scale = string.replace(scale, "300", tostring(fashionTbl.modelScale))
- end
- GUI:Model_setSrc(self.view.TitleModel, modelTbl.path, scale)
-
- else
- GUI:Model_setSrc(self.view.TitleModel, "")
- GUI:SetActive(self.view.TitleModel, false)
- end
- end
- function this:BtnCloseOnClick()
- GUI:UIPanel_Close("dev/outui/AppearGroup/Panel/KLAppearPreview/KLAppearPreviewPanel")
- end
- function this:Close()
- GUI:UIPanel_Close("dev/outui/AppearGroup/Panel/KLAppear/KLAppearPanel")
- GUI:UIPanel_Close("dev/outui/AppearGroup/Panel/KLTitle/KLTitlePanel")
- GUI:UIPanel_Close("dev/outui/AppearGroup/Panel/KLSuit/KLSuitPanel")
- GUI:UIPanel_Close("dev/outui/AppearGroup/Panel/KLRender/KLRenderPanel")
- GUI:UIPanel_Close("dev/outui/AppearGroup/Panel/KLTransferRing/KLTransferRingPanel")
- GUI:UIPanel_Close("dev/outui/AppearGroup/Panel/KLAppearGroup/KLAppearGroupPanel")
- end
- function this:GetPlayerRoleInfo(cfgIds)
- local role_param = { "body", "head", "head1", "armor", "hand", "pants", "boot" }
- local wear_list_str = ""
- local model_list_str = ""
- local guardCfgId
- local baseCareer = SL:GetMetaValue("JOB")
- local default_tbl = SL:GetConfig("cfg_model_default", baseCareer)
- local model_list = {}
- for _, v in pairs(role_param) do
- model_list[v] = default_tbl[v]
- end
- --修复背了两把短剑只显示一把
- local lastSub2Id = {}
- for _, cfgId in pairs(cfgIds) do
- if SL:HasConfig("cfg_item", cfgId) then
- ---@type cfg_item_column
- local itemInfo = SL:GetConfig("cfg_item", cfgId)
- if itemInfo.type == E_ItemType.Equip then
- if itemInfo.subType == E_ItemSubType_Equip.MainWeapon then
- if not lastSub2Id[itemInfo.subType] then
- if wear_list_str == "" then
- wear_list_str = "WeaponRspineParent#" .. itemInfo.field[1]
- else
- wear_list_str = wear_list_str .. ",WeaponRspineParent#" .. itemInfo.field[1]
- end
- lastSub2Id[itemInfo.subType] = cfgId
- else
- if wear_list_str == "" then
- wear_list_str = "WeaponLspineParent#" .. itemInfo.field[1]
- else
- wear_list_str = wear_list_str .. ",WeaponLspineParent#" .. itemInfo.field[1]
- end
- end
- elseif itemInfo.subType == E_ItemSubType_Equip.SecWeapon then
- if not lastSub2Id[itemInfo.subType] then
- if wear_list_str == "" then
- wear_list_str = "WeaponLspineParent#" .. itemInfo.field[1]
- else
- wear_list_str = wear_list_str .. ",WeaponLspineParent#" .. itemInfo.field[1]
- end
- lastSub2Id[itemInfo.subType] = cfgId
- else
- if wear_list_str == "" then
- wear_list_str = "WeaponRspineParent#" .. itemInfo.field[1]
- else
- wear_list_str = wear_list_str .. ",WeaponRspineParent#" .. itemInfo.field[1]
- end
- end
- elseif itemInfo.subType == E_ItemSubType_Equip.MainSecWeapon then
- if not lastSub2Id[itemInfo.subType] then
- if wear_list_str == "" then
- wear_list_str = "WeaponRspineParent#" .. itemInfo.field[1]
- else
- wear_list_str = wear_list_str .. ",WeaponRspineParent#" .. itemInfo.field[1]
- end
- lastSub2Id[itemInfo.subType] = cfgId
- else
- if wear_list_str == "" then
- wear_list_str = "WeaponLspineParent#" .. itemInfo.field[1]
- else
- wear_list_str = wear_list_str .. ",WeaponLspineParent#" .. itemInfo.field[1]
- end
- end
- elseif itemInfo.subType == E_ItemSubType_Equip.ChiBang then
- if not self.isHideWing then
- if wear_list_str == "" then
- wear_list_str = "Wing#" .. itemInfo.field[1]
- else
- wear_list_str = wear_list_str .. ",Wing#" .. itemInfo.field[1]
- end
- end
- elseif itemInfo.subType == E_ItemSubType_Equip.ShouHu then
- guardCfgId = itemInfo.id
- elseif itemInfo.subType == 30 then
- if wear_list_str == "" then
- wear_list_str = "BuffspineParent#" .. itemInfo.field[1]
- else
- wear_list_str = wear_list_str .. ",BuffspineParent#" .. itemInfo.field[1]
- end
- else
- local point = ""
- ---@type cfg_model_charactor_column
- local model_tbl = SL:GetConfig("cfg_model_charactor", itemInfo.field[1])
- if model_tbl then
- if model_tbl.part == 23 then
- point = "body"
- elseif model_tbl.part == 11 then
- if itemInfo.subType == E_ItemSubType_Equip.MianJin then
- point = "head1"
- else
- point = "head"
- end
- elseif model_tbl.part == 2 then
- point = "armor"
- elseif model_tbl.part == 9 then
- point = "hand"
- elseif model_tbl.part == 15 then
- point = "pants"
- elseif model_tbl.part == 5 then
- point = "boot"
- end
- if point ~= "" then
- model_list[point] = itemInfo.field[1]
- end
- end
- end
- elseif itemInfo.type == E_ItemType.TriggerItem and itemInfo.subType == E_OutTriggerItemType.GuardSkin then
- guardCfgId = itemInfo.id
- end
- end
- end
- for _, v in pairs(model_list) do
- if model_list_str == "" then
- model_list_str = v
- else
- model_list_str = model_list_str .. "#" .. v
- end
- end
- return model_list_str, wear_list_str, guardCfgId
- end
- return this
|