123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- ---@class KLMountInfoItem:UIKmlLuaPanelBase
- ---@field view KLMountInfoItemView
- ---@field baseUI KLMountStorePanel
- local KLMountInfoItem = class(UIKmlLuaPanelBase)
- local this =KLMountInfoItem
- ---创建时调用一次
- function this:Init()
-
- end
- ---创建或者刷新界面数据时调用
- function this:Refresh()
- ---@type cfg_mount_column
- local mount_tbl = SL:GetConfig("cfg_mount",self.args.mountId)
- ---@type cfg_item_column
- local itemTbl = SL:GetConfig("cfg_item",mount_tbl.itemId)
- ---@type cfg_color_column
- local colorTbl = SL:GetConfig("cfg_color",itemTbl.color)
- GUI:SetIsOnWithoutNotify(self.view.selectToggle,self.args.mountId == self.baseUI.curSelectMount)
- GUI:Text_setString(self.view.mountName,GUIUtil.GetColorText(self.args.mountName,colorTbl.color))
-
- ---@type cfg_model_charactor_column
- local model_tbl = SL:GetConfig("cfg_model_charactor",itemTbl.shape[1],"id")
- 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:setLocalPosition(self.view.item_model,model_tbl.inposition[1],model_tbl.inposition[2],model_tbl.inposition[3])
-
- GUI:setVisible(self.view.wear_mount_icon,self.args.isWear)
- if self.endTimer then
- SL:UnSchedule(self.endTimer)
- self.endTimer = nil
- end
- local endDayTime = tonumber(self.args.endTime)*1000
- local leftTime = endDayTime - Time.GetServerTime()
- GUI:setVisible(self.view.endTime,leftTime>0)
- if leftTime>0 then
- self.endTimer = SL:Schedule(self.endTimer,0,1,-1,function()
- local leftTime1 = endDayTime - Time.GetServerTime()
- if leftTime1 <= 0 then
- SL:UnSchedule(self.endTimer)
- self.endTimer = nil
- else
- local time_str = "<color=#ff2323>剩余:"..GUIUtil.FormatTimeDHM_S(leftTime1//1000) .."</color>"
- GUI:Text_setString(self.view.endTime,time_str)
- end
- end)
- end
- end
- ---注册UI事件和服务器消息
- function this:RegistEvents()
- GUI:SetToggleOnValueChange(self.view.selectToggle,self,self.OnValueChangeSelectToggle)
- GUI:AddOnClickEvent(self.view.tipClick,self,self.OnClickTip)
- end
- function this:OnValueChangeSelectToggle(_,_,data)
- local isToggle = data[1]
- if isToggle then
- self.baseUI:SelectMount(self.args.mountId,self.args.index)
- end
- end
- function this:OnClickTip()
- if self.baseUI.curSelectMount == self.args.mountId then
- GUI:UIPanel_Open("dev/outui/Mount/Panel/KLMountTip/KLMountTipPanel",nil,nil,{cfgId=self.args.itemCfgId,type = EMountTipType.OtherUIOpen})
- end
- end
- function this:Close()
- if self.endTimer then
- SL:UnSchedule(self.endTimer)
- self.endTimer = nil
- end
- end
- return this
|