KLMountInfoItem.lua 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. ---@class KLMountInfoItem:UIKmlLuaPanelBase
  2. ---@field view KLMountInfoItemView
  3. ---@field baseUI KLMountStorePanel
  4. local KLMountInfoItem = class(UIKmlLuaPanelBase)
  5. local this =KLMountInfoItem
  6. ---创建时调用一次
  7. function this:Init()
  8. end
  9. ---创建或者刷新界面数据时调用
  10. function this:Refresh()
  11. ---@type cfg_mount_column
  12. local mount_tbl = SL:GetConfig("cfg_mount",self.args.mountId)
  13. ---@type cfg_item_column
  14. local itemTbl = SL:GetConfig("cfg_item",mount_tbl.itemId)
  15. ---@type cfg_color_column
  16. local colorTbl = SL:GetConfig("cfg_color",itemTbl.color)
  17. GUI:SetIsOnWithoutNotify(self.view.selectToggle,self.args.mountId == self.baseUI.curSelectMount)
  18. GUI:Text_setString(self.view.mountName,GUIUtil.GetColorText(self.args.mountName,colorTbl.color))
  19. ---@type cfg_model_charactor_column
  20. local model_tbl = SL:GetConfig("cfg_model_charactor",itemTbl.shape[1],"id")
  21. GUI:Model_setSrc(self.view.item_model,model_tbl.path)
  22. GUI:SetEulerAngles(self.view.item_model,model_tbl.inrotate[1],model_tbl.inrotate[2],model_tbl.inrotate[3])
  23. GUI:setScale(self.view.item_model,model_tbl.inscale)
  24. GUI:setLocalPosition(self.view.item_model,model_tbl.inposition[1],model_tbl.inposition[2],model_tbl.inposition[3])
  25. GUI:setVisible(self.view.wear_mount_icon,self.args.isWear)
  26. if self.endTimer then
  27. SL:UnSchedule(self.endTimer)
  28. self.endTimer = nil
  29. end
  30. local endDayTime = tonumber(self.args.endTime)*1000
  31. local leftTime = endDayTime - Time.GetServerTime()
  32. GUI:setVisible(self.view.endTime,leftTime>0)
  33. if leftTime>0 then
  34. self.endTimer = SL:Schedule(self.endTimer,0,1,-1,function()
  35. local leftTime1 = endDayTime - Time.GetServerTime()
  36. if leftTime1 <= 0 then
  37. SL:UnSchedule(self.endTimer)
  38. self.endTimer = nil
  39. else
  40. local time_str = "<color=#ff2323>剩余:"..GUIUtil.FormatTimeDHM_S(leftTime1//1000) .."</color>"
  41. GUI:Text_setString(self.view.endTime,time_str)
  42. end
  43. end)
  44. end
  45. end
  46. ---注册UI事件和服务器消息
  47. function this:RegistEvents()
  48. GUI:SetToggleOnValueChange(self.view.selectToggle,self,self.OnValueChangeSelectToggle)
  49. GUI:AddOnClickEvent(self.view.tipClick,self,self.OnClickTip)
  50. end
  51. function this:OnValueChangeSelectToggle(_,_,data)
  52. local isToggle = data[1]
  53. if isToggle then
  54. self.baseUI:SelectMount(self.args.mountId,self.args.index)
  55. end
  56. end
  57. function this:OnClickTip()
  58. if self.baseUI.curSelectMount == self.args.mountId then
  59. GUI:UIPanel_Open("dev/outui/Mount/Panel/KLMountTip/KLMountTipPanel",nil,nil,{cfgId=self.args.itemCfgId,type = EMountTipType.OtherUIOpen})
  60. end
  61. end
  62. function this:Close()
  63. if self.endTimer then
  64. SL:UnSchedule(self.endTimer)
  65. self.endTimer = nil
  66. end
  67. end
  68. return this