123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 |
- ---@class KLMountStorePanel:UIKmlLuaPanelBase
- ---@field view KLMountStorePanelView
- local KLMountStorePanel = class(UIKmlLuaPanelBase)
- local this =KLMountStorePanel
- ---创建时调用一次
- function this:Init()
- self.mountAttItemList = {}
- self.mountInfo_all_item = {}
- self.mountInfoData = {}
- GUI:DataListInitData(self.view.mount_all_info_list,function()
- return self:MountDataListItemCountFunc()
- end,function(realIndex)
- return self:MountDataListItemGetFunc(realIndex)
- end,function(realIndex, kmlcontrol)
- return self:MountDataListItemInitFunc(realIndex, kmlcontrol)
- end, function(realIndex, kmlcontrol)
- return self:MountDataListItemUpdateFunc(realIndex, kmlcontrol)
- end)
- end
- ---创建或者刷新界面数据时调用
- function this:Refresh()
- SL.HideMainPanel()
- SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_ALL_MOUNT_INFO)
- end
- ---注册UI事件和服务器消息
- function this:RegistEvents()
- GUI:AddOnClickEvent(self.view.closeBtn,self,self.OnClickCloseBtn)
- --GUI:AddOnClickEvent(self.view.expandBtn,self,self.OnClickExpandBtn)
- --GUI:AddOnClickEvent(self.view.foldBtn,self,self.OnClickFoldBtn)
-
- SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_ALL_MOUNT_INFO,self.RES_ALL_MOUNT_INFO,self)
- SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_ALL_MOUNT_ATT_INFO,self.RES_ALL_MOUNT_ATT_INFO,self)
- SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_RIDING_MOUNT,self.RES_RIDING_MOUNT,self)
- SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_CANCEL_RIDING_MOUNT,self.RES_CANCEL_RIDING_MOUNT,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:OnClickExpandBtn()
- GUI:setVisible(self.view.attInfoRoot,true)
- GUI:setVisible(self.view.expandBtn,false)
- GUI:setVisible(self.view.foldBtn,true)
- local y = 50 - #self.attTxtList*38
- GUI:setPositionY(self.view.btnRoot,y)
- y = -130 - #self.attTxtList*38
- GUI:setPositionY(self.view.mountInfoRoot,y)
- local h = 600 - #self.attTxtList*38
- GUI:setContentSize(self.view.mount_info_scrollview,256,h)
- end
- function this:OnClickFoldBtn()
- GUI:setVisible(self.view.attInfoRoot,false)
- GUI:setVisible(self.view.expandBtn,true)
- GUI:setVisible(self.view.foldBtn,false)
- GUI:setPositionY(self.view.btnRoot,50)
- GUI:setPositionY(self.view.mountInfoRoot,-120)
- GUI:setContentSize(self.view.mount_info_scrollview,256,600)
- end
- function this:RES_ALL_MOUNT_INFO(id,message)
- self:RefreshMountInfoList(message)
- end
- function this:RES_ALL_MOUNT_ATT_INFO(id,message)
- self:RefreshAttInfoList(message)
- --local isVisible = GUI:getVisible(self.view.attInfoRoot)
- --local y = isVisible and (50 - #self.attTxtList*38) or 50
- --GUI:setPositionY(self.view.btnRoot,y)
- --y = isVisible and (-130 - #self.attTxtList*38) or -130
- --GUI:setPositionY(self.view.mountInfoRoot,y)
- --local h = isVisible and (600 - #self.attTxtList*38) or 600
- --GUI:setContentSize(self.view.mount_info_scrollview,256,h)
- end
- function this:RES_RIDING_MOUNT(id,message)
- for i, v in pairs(self.mountInfoData) do
- v.isWear = self.curSelectIndex == i
- end
- self.wearIndex = self.curSelectIndex
- GUI:DataListUpdateData(self.view.mount_all_info_list)
- end
- function this:RES_CANCEL_RIDING_MOUNT(id,message)
- for i, v in pairs(self.mountInfoData) do
- v.isWear = false
- end
- self.wearIndex = -1
- GUI:DataListUpdateData(self.view.mount_all_info_list)
- end
- function this:SelectMount(mountId,index)
- if self.curSelectIndex == index then return end
- self.curSelectMount = mountId
- self.curSelectIndex = index
- ---@type cfg_mount_column
- local tbl = SL:GetConfig("cfg_mount",mountId,"id")
- ---@type KLMountDisplayPanel
- local panel = GUI:GetUI("dev/outui/Mount/Panel/KLMountDisplay/KLMountDisplayPanel")
- if panel and panel:GetVisible() then
- panel.args.mountId = self.curSelectMount
- panel.args.isWear = self.wearIndex == self.curSelectIndex
- panel.args.auto = self.mountInfoData[index].auto
- panel:Refresh()
- elseif tbl.mountEquip == 1 then
- panel = GUI:GetUI("dev/outui/Mount/Panel/KLMountEquip/KLMountEquipPanel")
- if panel and panel:GetVisible() then
- panel.args.mountId = self.curSelectMount
- panel:Refresh()
- end
- end
- end
- function this:RefreshAttInfoList(attribute)
- local attInfo = {}
- self.attTxtList = {}
- for i, v in pairs(self.mountAttItemList) do
- GUI:UIPanel_Close(nil,v)
- end
- table.clear(self.mountAttItemList)
- for i, v in pairs(attribute) do
- local isSkip = false
- local attId = tonumber(i)
- local attNum = v
- ---@type cfg_att_info_column
- local tbl = SL:GetConfig("cfg_att_info",attId,"id")
- local attTxt
- if tbl.remarks ~= EAttrRemarkType.Number then
- attTxt = attNum/100 .."%"
- else
- attTxt = attNum
- end
- if attId == 200011 then--最小
- attInfo[1] = "攻击力#"..attTxt.."~"
- elseif attId == 200021 then--最大
- attInfo[2] = attTxt
- elseif attId == 202021 then--最小
- attInfo[3] = "魔法攻击力#"..attTxt.."~"
- elseif attId == 202011 then--最大
- attInfo[4] = attTxt
- elseif attId == 205011 then--最小
- attInfo[5] = "诅咒攻击力#"..attTxt.."~"
- elseif attId == 205021 then--最大
- attInfo[6] = attTxt
- else
- attTxt = tbl.name.."#" ..attTxt
- table.insert(self.attTxtList,attTxt)
- isSkip = true
- end
- if not isSkip then
- if attInfo[1] and attInfo[2] then
- table.insert(self.attTxtList,attInfo[1]..attInfo[2])
- attInfo[1] = nil
- attInfo[2] = nil
- elseif attInfo[3] and attInfo[4] then
- table.insert(self.attTxtList,attInfo[3]..attInfo[4])
- attInfo[3] = nil
- attInfo[4] = nil
- elseif attInfo[5] and attInfo[6] then
- table.insert(self.attTxtList,attInfo[5]..attInfo[6])
- attInfo[5] = nil
- attInfo[6] = nil
- end
- end
- end
- for i = 1, #self.attTxtList do
- local panel = GUI:UIPanel_Open("dev/outui/Mount/Item/KLMountAttInfo/KLMountAttInfoItem",self.view.att_list,self,{width=250,attInfo=self.attTxtList[i]},true)
- table.insert(self.mountAttItemList,panel)
- end
- end
- function this:RefreshMountInfoList(mountInfoList)
- self.mountInfoData = {}
- self.curSelectMount = -1
- self.curSelectIndex = -1
- local index = 1
- local mountEquipList = {}
- for i, v in pairs(mountInfoList) do
- local isWear = v.wear == 1
- local mountId = v.mountcfgid
- ---@type cfg_mount_column
- local tbl = SL:GetConfig("cfg_mount",mountId,"id")
-
- if isWear then
- self.wearIndex = index
- end
- if index == 1 then
- self.curSelectMount = mountId
- self.curSelectIndex = 1
- end
-
- local data = {index=index,mountId=mountId,mountName=tbl.name,itemCfgId=tbl.itemId,isWear=isWear,auto = v.auto == 1,endTime= v.time and tonumber(v.time) or 0}
- if tbl.mountEquip == 1 then
- table.insert(mountEquipList,data)
- end
- table.insert(self.mountInfoData,data)
- index = index + 1
- end
-
- local panel = GUI:GetUI("dev/outui/Mount/Panel/KLMountEquip/KLMountEquipPanel")
- if panel and panel:GetVisible() and #mountEquipList>0 then
- self.mountInfoData = mountEquipList
- for i, v in pairs(mountEquipList) do
- if v.isWear then
- self.wearIndex = i
- end
- if i == 1 then
- self.curSelectMount = v.mountId
- self.curSelectIndex = 1
- end
- end
- end
-
- local panel = GUI:GetUI("dev/outui/Mount/Panel/KLMountEquip/KLMountEquipPanel")
- if panel and panel:GetVisible() and #mountEquipList > 0 then
- panel.args.mountId = self.curSelectMount
- panel:Refresh()
- else
- local isSkip = false
- if panel then
- GUI:UIPanel_Close("dev/outui/Mount/Panel/KLMountEquip/KLMountEquipPanel")
- SL.ShowMainPanel()
- isSkip = true
- end
- local data = {mountId=self.curSelectMount,isWear = self.wearIndex == self.curSelectIndex}
- data.auto = self.mountInfoData[self.curSelectIndex] and self.mountInfoData[self.curSelectIndex].auto or false
- ---@type KLMountDisplayPanel
- panel = GUI:GetUI("dev/outui/Mount/Panel/KLMountDisplay/KLMountDisplayPanel")
- if not panel then
- GUI:UIPanel_Open("dev/outui/Mount/Panel/KLMountDisplay/KLMountDisplayPanel",nil,nil,data)
- elseif panel:GetVisible() or isSkip then
- panel.args = data
- panel:SetVisible(true)
- panel:Refresh()
- end
- end
- local count = #self.mountInfoData
- GUI:DataListUpdateData(self.view.mount_all_info_list)
-
- GUI:setVisible(self.view.attInfoRoot,count > 0)
- --GUI:setVisible(self.view.btnRoot,count > 0)
- GUI:setVisible(self.view.onMount,count == 0)
- GUI:setVisible(self.view.mountInfoRoot,count > 0)
- end
- function this:MountDataListItemCountFunc()
- return #self.mountInfoData
- end
- function this:MountDataListItemGetFunc(realIndex)
- local data = self.mountInfoData[realIndex + 1]
- data.index = realIndex + 1
- local item = GUI:UIPanel_Open("dev/outui/Mount/Item/KLMountInfo/KLMountInfoItem",self.view.mount_all_info_list,self,data,true)
- self.mountInfo_all_item[item.view.root] = item
- return item.view.root
- end
- function this:MountDataListItemInitFunc(realIndex, kmlcontrol)
- end
- function this:MountDataListItemUpdateFunc(realIndex, kmlcontrol)
- local data = self.mountInfoData[realIndex + 1]
- self.mountInfo_all_item[kmlcontrol].args = data
- self.mountInfo_all_item[kmlcontrol]:Refresh()
- end
- function this:SetVisible(isVisible)
- if isVisible then
- SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_ALL_MOUNT_INFO)
- end
- GUI:setVisible(self.view.root,isVisible)
- end
- function this:Close()
- self.mountAttItemList = {}
- SL.ShowMainPanel()
- end
- return this
|