--只显示装备信息的tips, 可与showiconitem搭配使用 SealShowTips = SealShowTips or BaseClass(SealToolTips) SealShowTips.ONLY_SHOW = 0 --只展示信息 SealShowTips.COMPOSE_OFF = 1 --显示卸下按钮,点击移除合成物品 SealShowTips.EQUIP_RECOMMAND_TARGET = 2 --显示合成装备的推荐属性 function SealShowTips:__init() self.base_file = "common" self.layout_file = "EquipToolTips" self.layer_name = "Top" self.use_background = true self.click_bg_toClose = true self.close_mode = CloseMode.CloseDestroy self.destroy_imm = true self.dynamic = nil self.is_show_btn = false self:AddPreLoadList("common",{"SealCompareTips"}) self.model = GoodsModel:getInstance() self.seal_item_list = {} self.load_callback = function () self:LoadSuccess() end self.open_callback = function () self:SetData(self.dynamic) end self.close_callback = function () end self.destroy_callback = function () self:Remove() end end --[[ dynamic: 在外部整合好的物品动态信息table,一般获取背包中的动态信息即可 若要实现预览等特殊信息,在外部修改后传入 type: 枚举类型,实现某个界面的特殊需求,显示某些按钮,实现特定功能 ]] function SealShowTips:Open(dynamic, x, y, type) self.dynamic = dynamic self.type = type self.pos_x = x self.pos_y = y BaseView.Open(self) end function SealShowTips:Remove() if self.icon_item then self.icon_item:DeleteMe() self.icon_item = nil end for i,v in ipairs(self.seal_item_list) do v:DeleteMe() v = nil end self.seal_item_list = {} --[[self:DeleteArrowTip() if self.addNumComponent then if self.change_count_id then self.addNumComponent:UnBind(self.change_count_id) self.change_count_id = nil end self.addNumComponent:DeleteMe() self.addNumComponent = nil end--]] end function SealShowTips:InitEvent() local function onBtnClickHandler(target) if target == self.takeBtn then if self.type == SealShowTips.COMPOSE_OFF then ComposeModel:getInstance():Fire(ComposeEvent.COMPOSE_GOODS_OFF, self.dynamic.goods_id) end end self:Close() end AddClickEvent(self.takeBtn, onBtnClickHandler) end function SealShowTips:SetData(dynamic) self.dynamic = dynamic self.goods_vo = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.dynamic.type_id) if self.dynamic == nil or self.goods_vo == nil then return print("SealShowTips里面没有物品数据") end local color_str = ColorUtil.WHITE if self.goods_vo.level > RoleManager.Instance.mainRoleInfo.level then color_str = ColorUtil.RED end self.level.text = "" .. self.goods_vo.level .. "" -- local index = Config.ConfigEquipShow[self.goods_vo.equip_type].index self.equip_pos.text = Trim(Config.Holysealpos[self.goods_vo.subtype].name) self.fight.text = self.goods_vo.combat_power or 0 color_str = (self.goods_vo.career_id == 0 or RoleManager.Instance.mainRoleInfo.career == self.goods_vo.career_id) and ColorUtil.WHITE or ColorUtil.RED local career_name = Config.Career[self.goods_vo.career_id] and Config.Career[self.goods_vo.career_id].career_name or "通用" self.career.text = "" .. career_name .. "" -- self:CreateStar(8) self.depot_conta.gameObject:SetActive(false) local stren = "" self.dynamic.stren = self.dynamic.stren or 0 if self.dynamic.stren > 0 then stren = "+" .. self.dynamic.stren end self.nameText.text = "" .. self.goods_vo.goods_name .. stren .. "" local step = Config.Holysealgoods[self.goods_vo.type_id] and Config.Holysealgoods[self.goods_vo.type_id].stage or 0 self.step_num.text = "" .. step .. "阶" self.icon_item:SetData(self.goods_vo) self.equip_score.text = self.dynamic.rating self.composite_score.text = self.dynamic.overall_rating or self.dynamic.rating local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.goods_vo.type_id) if basic then local base_pro = ErlangParser:GetInstance():Parse(basic.base_attrlist) self:SetProperty(base_pro, self.dynamic.stren, basic.equip_type) self.fight.text = self.dynamic.combat_power or 0 end self:SetAddProperty(self.dynamic) self:SetSpecialProperty(self.goods_vo) self:SetSuitProperty(self.dynamic, self.goods_vo.equip_type) --self:SetSellState(self.dynamic.sell, self.dynamic.price_type, self.dynamic.type_id) self:Refresh() end --按钮显示 function SealShowTips:SetBtns() for i,v in ipairs(self.btn_list) do v:SetActive(false) end if self.type == SealShowTips.COMPOSE_OFF then self.takeBtn:SetActive(true) end end --刷新相关控件的位置 function SealShowTips:Refresh() if self.dynamic then self:RefreshPosAndSize(self.dynamic) self:SetRootPos() self:SetBtns() end end