123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- ---@class KLMountEquipPanel:UIKmlLuaPanelBase
- ---@field view KLMountEquipPanelView
- local KLMountEquipPanel = class(UIKmlLuaPanelBase)
- local this =KLMountEquipPanel
- ---创建时调用一次
- function this:Init()
- self.equipItemData = {}
- self.selectEquipPos = nil
- end
- ---注册UI事件和服务器消息
- function this:RegistEvents()
- GUI:AddOnClickEvent(self.view.closeBtn,self,self.OnClickCloseBtn)
- GUI:AddOnClickEvent(self.view.closeBtn2,self,self.OnClickClose2Btn)
- GUI:AddOnClickEvent(self.view.desBtn,self,self.OnClickDesBtn)
- GUI:AddOnClickEvent(self.view.pos51,self,self.OnClickEquipPosBtn,EMountEquipPos.HeadPos)
- GUI:AddOnClickEvent(self.view.pos52,self,self.OnClickEquipPosBtn,EMountEquipPos.NecklancePos)
- GUI:AddOnClickEvent(self.view.pos53,self,self.OnClickEquipPosBtn,EMountEquipPos.FrontLegPos)
- GUI:AddOnClickEvent(self.view.pos54,self,self.OnClickEquipPosBtn,EMountEquipPos.HindLegPos)
- GUI:AddOnClickEvent(self.view.pos55,self,self.OnClickEquipPosBtn,EMountEquipPos.TailPos)
- GUI:SetToggleOnValueChange(self.view.mountInfoToggle,self,self.OnValueChangeMountInfoToggle)
- GUI:SetToggleOnValueChange(self.view.mountEquipToggle,self,self.OnValueChangeMountEquipToggle)
- SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_MOUNT_DETAIL_INFO,self.RES_MOUNT_DETAIL_INFO,self)
- SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_MOUNT_TAKE_OFF_ITEM,self.RES_MOUNT_TAKE_OFF_ITEM,self)
- end
- function this:OnClickCloseBtn()
- GUI:UIPanel_Close("dev/outui/Mount/Panel/KLMountEquip/KLMountEquipPanel")
- GUI:UIPanel_Close("dev/outui/Mount/Panel/KLMountStore/KLMountStorePanel")
- GUI:UIPanel_Close("dev/outui/Mount/Panel/KLMountDisplay/KLMountDisplayPanel")
- end
- function this:OnClickClose2Btn()
- ---@type KLMountStorePanel
- local panel = GUI:GetUI("dev/outui/Mount/Panel/KLMountStore/KLMountStorePanel")
- if panel then
- panel:SetVisible(true)
- end
- GUI:setVisible(self.view.bagItemRoot,false)
- end
- function this:OnClickDesBtn()
- GUI:UIPanel_Open("dev/outui/Mount/Panel/KLMountDes/KLMountDesPanel")
- end
- function this:OnClickEquipPosBtn(control,pos)
- self.selectEquipPos = pos
- if not self.equipItemData[pos] then
- self:ShowItem()
- ---@type KLMountStorePanel
- local panel = GUI:GetUI("dev/outui/Mount/Panel/KLMountStore/KLMountStorePanel")
- if panel then
- panel:SetVisible(false)
- end
- SL.HideMainPanel()
- else
- GUI:UIPanel_Open("dev/ui/Tips/Panel/KLUIEquipTips/KLUIEquipTipsPanel", nil, nil, { mountId = self.args.mountId,equip_pos = "equip", cfgId = self.equipItemData[pos].itemcfgid, id = self.equipItemData[pos].itemid })
- end
- end
- function this:OnValueChangeMountInfoToggle(_,_,data)
- local isToggle = data[1]
- if isToggle then
- ---@type KLMountDisplayPanel
- local panel = GUI:GetUI("dev/outui/Mount/Panel/KLMountDisplay/KLMountDisplayPanel")
- if panel then
- panel:SetVisible(true)
- end
- ---@type KLMountStorePanel
- panel = GUI:GetUI("dev/outui/Mount/Panel/KLMountStore/KLMountStorePanel")
- if panel then
- panel:SetVisible(true)
- end
- self:SetVisible(false)
- end
- end
- function this:OnValueChangeMountEquipToggle(_,_,data)
- end
- function this:RES_MOUNT_DETAIL_INFO(id,message)
- local isVisible = GUI:getVisible(self.view.bagItemRoot)
- if isVisible then
- self:ShowItem()
- end
- self:ShowMountEquip(message.item)
- end
- function this:RES_MOUNT_TAKE_OFF_ITEM(id,message)
- local isVisible = GUI:getVisible(self.view.bagItemRoot)
- if isVisible then
- self:ShowItem()
- end
- end
- ---创建或者刷新界面数据时调用
- function this:Refresh()
- SL.HideMainPanel()
- SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_MOUNT_DETAIL_INFO,{self.args.mountId})
- GUI:setVisible(self.view.ownerMountRoot,self.args.mountId~=-1)
- GUI:setVisible(self.view.bagItemRoot,false)
- if self.args.mountId~=-1 then
- ---@type cfg_mount_column
- local tbl = SL:GetConfig("cfg_mount",self.args.mountId,"id")
- ---@type cfg_mount_model_column
- local mount_model_tbl = SL:GetConfig("cfg_mount_model",tbl.mountId,"id")
- ---@type cfg_mount_behaviour_column
- local behaviour_tbl = SL:GetConfigMultiKeys("cfg_mount_behaviour",tbl.motion,1,"id","state")
- self.view.model.kmlControl:HideAllChilds()
- self.cur_mount_model = GUI:Model_Create(self.view.model,{
- id="cur_mount_model",
- mscale=tbl.scale2.. ",".. tbl.scale2 ..",".. tbl.scale2,
- mrotate="0,200,0",
- x="0",
- y="-120",
- z="-1000",
- a="00",
- src=mount_model_tbl.path,
- ani=behaviour_tbl.name,
- })
- GUI:SetIsOnWithoutNotify(self.view.mountInfoToggle,false)
- GUI:SetIsOnWithoutNotify(self.view.mountEquipToggle,true)
- self:ShowSkillInfo(tbl.skillID,tbl.skillLevel)
- end
- end
- function this:ShowMountEquip(equipList)
- for i = 51, 55 do
- ---@type UIKmlLuaControl
- local control = self.view["pos"..i]
- if control then
- control.kmlControl:HideAllChilds()
- end
- end
- table.clear(self.equipItemData)
- for i, v in pairs(equipList) do
- local pos = tonumber(v.pos)
- local itemCfgId = tonumber(v.itemcfgid)
- self.equipItemData[pos] = v
- self:RefreshOneEquipPos(pos,itemCfgId)
- end
- end
- function this:RefreshOneEquipPos(pos,itemCfgId)
- GUI:Item_Create(self.view["pos"..pos], {
- width = "53",
- height = "56",
- itemid = itemCfgId,
- tips = "1",
- noclip = "1",
- bgtype = "0",
- mfixsize = "53,56"
- })
- end
- function this:ShowSkillInfo(skillId,level)
- GUI:setVisible(self.view.skillBg,skillId ~= 0)
- if skillId ~= 0 then
- ---@type cfg_skill_info_column
- local tbl = SL:GetConfigMultiKeys("cfg_skill_info",skillId,level,"skillID","skillLevel")
- GUI:Image_loadTexture(self.view.skillIcon,tbl.icon,"Atlas/Skill_icon.spriteatlas")
- GUI:Text_setString(self.view.skillName,tbl.name.." Lv."..level)
- GUI:Text_setString(self.view.skillDes,tbl.tips)
- end
- end
- function this:ShowItem()
- GUI:setVisible(self.view.bagItemRoot,true)
- local bag_info = string.split(SL:GetConfig("cfg_global",6).value,'#')
- self.maxHor = tonumber(bag_info[1])
- self.maxVet = tonumber(bag_info[2])
- local itemList_ = {}
- local show_id = EBagTileScrollViewId.Bag
- local itemList_1 = SL:GetMetaValue("BAG_DATA")[1]
- ---@param item CommonProtos.Item
- for _, item in pairs(itemList_1 or {}) do
- ---@type cfg_item_column
- local tbl = SL:GetConfig("cfg_item",item.cfgId,"id")
- if tbl and tbl.type == 2 and tbl.subType >=51 and tbl.subType<=55 then
- table.insert(itemList_, item)
- end
- end
- itemList_ = BagCellUtil.SortItemList(itemList_)
- if not self.bagTileScrollView then
- ---@type KLUIBagTileScrollViewItem
- self.bagTileScrollView = GUI:UIPanel_Open("dev/ui/Common/Item/KLUIBagTileScrollView/KLUIBagTileScrollViewItem", self.view.bagGrid, self,
- {
- itemList = itemList_,
- id = show_id,
- --forbidCount = SL:GetMetaValue("BAG_FORBID_COUNT"),
- hor = self.maxHor,
- vet = self.maxVet,
- canDrag = false,
- --forbidClickCallback = self.forbidClick,
- itemClick = self.ClickItemCallBack,
- parent = self,
- callBackUI = self,
- })
- self.bagTileScrollView:RefreshInfo()
- else
- self.bagTileScrollView:ClearBagItem()
- self.bagTileScrollView:RefreshItemByItem(itemList_)
- end
- end
- ---点击背包item回调
- ---@param itemControl KLBagItemItemView
- ---@param itemData CommonProtos.Item
- function this:ClickItemCallBack(itemControl,itemData)
- GUI:UIPanel_Open("dev/ui/Tips/Panel/KLUIEquipTips/KLUIEquipTipsPanel", nil, nil, { mountId = self.args.mountId,equip_pos = "bag", cfgId = itemData.cfgId, id = itemData.id })
- end
- function this:SetVisible(isVisible)
- GUI:setVisible(self.view.root,isVisible)
- end
- function this:GetVisible()
- return GUI:getVisible(self.view.root)
- end
- function this:Close()
- self.selectEquipPos = nil
- SL.ShowMainPanel()
- end
- return this
|