local BaseTips = require "app/ui/tips/base_tips" local SkillTips = class("SkillTips", BaseTips) local MIN_HEIGHT = 194 function SkillTips:ctor(params) self.params = params self.tarCornerScreenPos = params.tarCornerScreenPos self.location = params.location end function SkillTips:getPrefabPath() return "assets/prefabs/ui/tips/skill_tips.prefab" end function SkillTips:onLoadRootComplete() local uiMap = self.root:genAllChildren() self.descTx = uiMap["skill_tips.bg.desc_tx"] self.skillCell = CellManager:addCellComp(uiMap["skill_tips.bg.skill_cell"], GConst.TYPEOF_LUA_CLASS.SKILL_CELL) self.nameTx = uiMap["skill_tips.bg.name_tx"] self.lvTx = uiMap["skill_tips.bg.lv_tx"] self.bg = uiMap["skill_tips.bg"] local tipsBgTransform = self.bg:getTransform() self.originSizeDelta = tipsBgTransform.sizeDelta self.originPivot = tipsBgTransform.pivot self.originAnchoredPosition = tipsBgTransform.anchoredPosition self.originLocalPosition = tipsBgTransform.localPosition end function SkillTips:onRefresh() self.root:addClickListener(function () self:closeUI() end) self.nameTx:setText(I18N:getText("skill", self.params.id, "name")) self.descTx:setText(GFunc.getSkillEffectStr(self.params.id, self.params.lv)) self.skillCell:refresh(self.params.id) self.skillCell:setLvVisible(false) self.lvTx:setText(I18N:getGlobalText(I18N.GlobalConst.LV_POINT, self.params.lv)) local meshProComp = self.descTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO) local height = meshProComp.preferredHeight local maxHeight = math.max(height + 141, MIN_HEIGHT) self.bg:setSizeDeltaY(maxHeight) if self.tarCornerScreenPos then self:locate(self.location, self.originSizeDelta, self.bg, self.tarCornerScreenPos) end end function SkillTips:onClose() if self.originSizeDelta then local tipsBgTransform = self.bg:getTransform() tipsBgTransform.sizeDelta = self.originSizeDelta tipsBgTransform.pivot = self.originPivot tipsBgTransform.anchoredPosition = self.originAnchoredPosition tipsBgTransform.localPosition = self.originLocalPosition end end return SkillTips