DualGemstoneTips = DualGemstoneTips or BaseClass(BaseView) local DualGemstoneTips = DualGemstoneTips function DualGemstoneTips:__init() self.base_file = "common" self.layout_file = "goodsTooltips" self.layer_name = "Top" self.is_set_zdepth = true self.use_background = true self.click_bg_toClose = true self.hide_maincancas = false self.pos_x = 0 self.pos_y = 0 self.goods_vo = nil self.is_show_btn = nil self.model = GoodsModel:getInstance() self.mainVo = RoleManager.Instance.mainRoleInfo -- self.use_local_view = true self.curr_height = 0 self.load_callback = function () self:LoadSuccess() end self.open_callback = function () self:SetData() end self.close_callback = function () end self.destroy_callback = function () if self.icon_item then self.icon_item:DeleteMe() end if self.event_odc then GlobalEventSystem:UnBind(self.event_odc) self.event_odc = nil end end end function DualGemstoneTips:LoadSuccess() self.layout, self.bg, self.icon_con, self.btns_con = self:GetChildTransforms({ "layout", "layout/bg", "layout/icon_con", "layout/btns_con" }) self.nameText, self.countText, self.levelText, self.contentText = self:GetChildTexts({ "layout/nameText", "layout/countText", "layout/levelText", "layout/contentText", }) self.btns_con.gameObject:SetActive(false) self.icon_item = AwardItem.New(self.icon_con, false, self.layer_name) self.icon_item:ChangeCountVisible(false) self:InitEvent() end function DualGemstoneTips:InitEvent() self.event_odc = GlobalEventSystem:Bind(EventName.ORIENTATION_DID_CHANGE, function () self:AdjustLayoutPos() end) end function DualGemstoneTips:Open(type_id, x, y, goods_vo) self.type_id = type_id self.goods_vo = goods_vo self.pos_x = x self.pos_y = y BaseView.Open(self) end function DualGemstoneTips:SetData() self.layout.gameObject:SetActive(true) local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.type_id) local a_stone, b_stone if self.goods_vo then a_stone = self.goods_vo.a_stone b_stone = self.goods_vo.b_stone else for _, goods_id in pairs(ComposeModel.Instance.add_goods_list) do local info = GoodsModel:getInstance():GetBagGoodsInfoById(goods_id) if not a_stone then a_stone = info.type_id elseif not b_stone then b_stone = info.type_id end end end self.icon_item:SetData(self.type_id) self.countText.text = "类型:" .. WordManager:GetGoodsTypeStr(basic.type, base.subtype) .. "" local name = Trim(basic.goods_name) local level = 0 if self.goods_vo then level = self.goods_vo.dstone_lv else if a_stone and Config.Equipstonelv[a_stone] then level = level + Config.Equipstonelv[a_stone].lv end if b_stone and Config.Equipstonelv[b_stone] then level = level + Config.Equipstonelv[b_stone].lv end end if level ~= 0 then name = level.."级"..name end self.nameText.text = Language.substitute("{1}", WordManager.GetGoodsColor(basic.color), Trim(name)) if basic.level > 0 then local str = "#6e4737" if self.mainVo.level < basic.level then str = "#f14041" end self.levelText.text = "等级:" .. basic.level .. "" else self.levelText.text = "" end local contentStr = Trim(basic.intro) local str = "" if a_stone then local attr = JewelModel:getInstance():GetJewelAttr(a_stone) str = Language.substitute("{1}", "#f18310", Trim(attr)) contentStr = contentStr.."\n\n"..str end if b_stone then local attr = JewelModel:getInstance():GetJewelAttr(b_stone) str = Language.substitute("{1}", "#f18310", Trim(attr)) contentStr = contentStr.."\n"..str end local stage = self.goods_vo and self.goods_vo.stage or 1 local cfg = Config.Doubleattrgemstage[basic.subtype.."@"..stage] if cfg then contentStr = contentStr.."\n"..Trim(cfg.tips) end self.contentText.text = contentStr local h = 175 + self.contentText.preferredHeight + 30 self.bg.sizeDelta = Vector2(385, h) self:AdjustLayoutPos() end function DualGemstoneTips:AdjustLayoutPos() if self.pos_x and self.pos_y then --自定义显示的按钮 local layout_width = self.bg.sizeDelta.x + self.btns_con.sizeDelta.x local layout_height = self.bg.sizeDelta.y local x, y = ScreenToViewportPoint(self.pos_x, self.pos_y) local iphone_x_offset = math.max(ClientConfig.iphone_x_offset_left, ClientConfig.iphone_x_offset_right) if x + layout_width + 50 + iphone_x_offset * 2 > SrcScreenWidth then x = SrcScreenWidth - layout_width - 90 - iphone_x_offset * 2 end if y < layout_height + 50 then y = layout_height + 50 end self.layout.anchoredPosition = Vector2(x, y) end end