123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- ---@class KLMountTipPanel:UIKmlLuaPanelBase
- ---@field view KLMountTipPanelView
- local KLMountTipPanel = class(UIKmlLuaPanelBase)
- local this =KLMountTipPanel
- ---创建时调用一次
- function this:Init()
- end
- ---注册UI事件和服务器消息
- function this:RegistEvents()
- GUI:AddOnClickEvent(self.view.bgMask,self,self.OnClickCancelBtn)
- GUI:AddOnClickEvent(self.view.cancelBtn,self,self.OnClickCancelBtn)
- GUI:AddOnClickEvent(self.view.takeOffBtn,self,self.OnClickTakeOffBtn)
- GUI:AddOnClickEvent(self.view.putOnBtn,self,self.OnClickPutOnBtn)
- GUI:AddOnClickEvent(self.view.putOnStoreBtn,self,self.OnClickPutOnStoreBtn)
- GUI:AddOnClickEvent(self.view.takeOutStoreBtn,self,self.OnClickTakeOutStoreBtn)
- end
- function this:OnClickCancelBtn()
- GUI:UIPanel_Close("dev/outui/Mount/Panel/KLMountTip/KLMountTipPanel")
- end
- function this:OnClickTakeOffBtn()
- SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_MOUNT_STORE_TO_BAG,{self.mountTbl.id,0})
- self:OnClickCancelBtn()
- end
- function this:OnClickPutOnBtn()
- local BagIndex = SL:GetBagIndex(self.args.id)
- SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_MOUNT_BAG_TO_STORE,{BagIndex,self.mountTbl.itemId})
- self:OnClickCancelBtn()
- end
- function this:OnClickPutOnStoreBtn()
- local BagIndex = SL:GetBagIndex(self.args.id)
- SL.Equip:ReqBagPutStoreButtonMessage(BagIndex, SL:GetDepotsCurPage())
- self:OnClickCancelBtn()
- end
- function this:OnClickTakeOutStoreBtn()
- local storeIndex = SL:GetDepotsIndex(self.args.id)
- SL.Equip:ReqStoreTakeButtonMessage(storeIndex)
- self:OnClickCancelBtn()
- end
- ---创建或者刷新界面数据时调用
- function this:Refresh()
- GUI:UIPanel_Close("dev/ui/Tips/Panel/KLUIEquipTips/KLUIEquipTipsPanel")
- if self.args.equip_pos == "bag" then
- self.args.type = EMountTipType.BagUIOpen
- elseif self.args.equip_pos == "depots" then
- self.args.type = EMountTipType.StoreUIOpen
- elseif not self.args.type then
- self.args.type = EMountTipType.OtherUIOpen
- end
- local panel = GUI:GetUI("dev/ui/Bag/Panel/KLDepots/KLDepotsPanel")
-
- GUI:setVisible(self.view.cancelBtn, self.args.type ~= EMountTipType.OtherUIOpen)
- GUI:setVisible(self.view.takeOffBtn,self.args.type == EMountTipType.MountUIOpen)
- GUI:setVisible(self.view.putOnBtn,self.args.type == EMountTipType.BagUIOpen and not panel)
- GUI:setVisible(self.view.putOnStoreBtn,self.args.type == EMountTipType.BagUIOpen and panel)
- GUI:setVisible(self.view.takeOutStoreBtn,self.args.type == EMountTipType.StoreUIOpen)
-
- local tblList =SL:GetConfigTable("cfg_mount")
- ---@param v cfg_mount_column
- for i, v in pairs(tblList) do
- if self.args.cfgId == v.itemId then
- self.mountTbl = v
- break
- end
- end
- if not self.mountTbl then
- logError("cfg_mount not exist itemId = ",self.args.cfgId)
- return
- end
-
- ---@type cfg_item_column
- local itemTbl = SL:GetConfig("cfg_item", self.args.cfgId,"id")
- GUI:Text_setString(self.view.title,itemTbl.name)
-
- local careerDes = ""
- if #itemTbl.job ~= 0 then
- local career = SL:GetMetaValue(EMetaVarGetKey.JOB)
- for i, v in pairs(itemTbl.job[1]) do
- if v == 0 then
- break
- end
- ---@type cfg_career_column
- local careerTbl = SL:GetConfig("cfg_career",v,"baseCareer")
- local color = "#ffffff"
- if v == career then
- color = "#ff2323"
- end
- if string.isNullOrEmpty(careerDes) then
- careerDes = GUIUtil.GetColorText(careerTbl.name,color)
- else
- careerDes = careerDes .."," .. GUIUtil.GetColorText(careerTbl.name,color)
- end
- end
- if not string.isNullOrEmpty(careerDes) then
- careerDes = "所需职业:" .. careerDes
- end
- end
- ---@type cfg_color_column
- local tbl = SL:GetColorCfg(itemTbl.color)
- GUI:Text_setString(self.view.careerName,careerDes)
- GUI:Text_setString(self.view.title,GUIUtil.GetColorText(itemTbl.name,tbl and tbl.color or ""))
- ---@type cfg_mount_model_column
- local mount_model_tbl = SL:GetConfig("cfg_mount_model",self.mountTbl.mountId,"id")
- ---@type cfg_model_charactor_column
- local model_tbl = SL:GetConfig("cfg_model_charactor",itemTbl.shape[1],"id")
- ---@type cfg_mount_behaviour_column
- local behaviour_tbl = SL:GetConfigMultiKeys("cfg_mount_behaviour",self.mountTbl.motion,1,"id","state")
- GUI:Model_setSrc(self.view.item_model,model_tbl.path)
- GUI:SetEulerAngles(self.view.item_model,model_tbl.inrotate[1],model_tbl.inrotate[2],model_tbl.inrotate[3])
- GUI:setScale(self.view.item_model,model_tbl.inscale)
- GUI:HideAllChilds(self.view.mount_model)
- self.cur_mount_model = GUI:Model_Create(self.view.mount_model,{
- id="cur_mount_model",
- mscale=self.mountTbl.scale2.. ",".. self.mountTbl.scale2 ..",".. self.mountTbl.scale2,
- mrotate="0,200,0",
- x="0",
- y="-120",
- z="0",
- a="00",
- src=mount_model_tbl.path,
- ani=behaviour_tbl.name,
- })
-
- self:RefreshAttInfoList(self.mountTbl.attribute)
-
- end
- function this:RefreshAttInfoList(attribute)
- local attInfo = {}
- local attTxtList = {}
- GUI:HideAllChilds(self.view.attList)
- table.insert(attribute,{318022,self.mountTbl.speed})
- for i, v in pairs(attribute) do
- local isSkip = false
- ---@type cfg_att_info_column
- local tbl = SL:GetConfig("cfg_att_info",v[1],"id")
- local attTxt
- if tbl.remarks ~= EAttrRemarkType.Number then
- attTxt = v[2]/100 .."%"
- else
- attTxt = v[2]
- end
- if v[1] == 200011 then--最小
- attInfo[1] = "攻击力:"..attTxt.."~"
- elseif v[1] == 200021 then--最大
- attInfo[2] = attTxt
- elseif v[1] == 202021 then--最小
- attInfo[3] = "魔法攻击力:"..attTxt.."~"
- elseif v[1] == 202011 then--最大
- attInfo[4] = attTxt
- elseif v[1] == 205011 then--最小
- attInfo[5] = "诅咒攻击力:"..attTxt.."~"
- elseif v[1] == 205021 then--最大
- attInfo[6] = attTxt
- else
- attTxt = tbl.name..":" ..attTxt
- if v[1] == 313012 or v[1] == 311012 or v[1] == 318022 then
- attTxt = GUIUtil.GetColorText(attTxt,"#4ba7e8")
- end
- table.insert(attTxtList,attTxt)
- isSkip = true
- end
-
- if not isSkip then
- if attInfo[1] and attInfo[2] then
- table.insert(attTxtList,attInfo[1]..attInfo[2])
- attInfo[1] = nil
- attInfo[2] = nil
- elseif attInfo[3] and attInfo[4] then
- table.insert(attTxtList,attInfo[3]..attInfo[4])
- attInfo[3] = nil
- attInfo[4] = nil
- elseif attInfo[5] and attInfo[6] then
- table.insert(attTxtList,attInfo[5]..attInfo[6])
- attInfo[5] = nil
- attInfo[6] = nil
- end
- end
- end
- table.remove(attribute,#attribute)
- for i = 1, #attTxtList do
- GUI:Text_Create(self.view.attList, {
- id = "attTxt",
- text = attTxtList[i],
- width = 295,
- height = 20,
- ta="02",
- x = 0,
- y = 0,
- })
- end
- end
- function this:Close()
- end
- return this
|