local HeroFragmentTips = class("HeroFragmentTips", BaseUI) function HeroFragmentTips:ctor(params) self.itemId = params.itemId end function HeroFragmentTips:getPrefabPath() return "assets/prefabs/ui/tips/hero_fragment_tips.prefab" end function HeroFragmentTips:isFullScreen() return false end function HeroFragmentTips:onLoadRootComplete() local cfg = ConfigManager:getConfig("item")[self.itemId] if cfg == nil then return self:closeUI() end local drop = cfg.hero_drop if drop == nil then return self:closeUI() end self.heroList = {} for _, v in ipairs(drop) do if DataManager.HeroData:getHeroIsUnlock(v.id) then table.insert(self.heroList, v.id) end end local heroCfg = ConfigManager:getConfig("hero") local heroA local heroB table.sort(self.heroList, function(a, b) heroA = heroCfg[a] heroB = heroCfg[b] if heroA.qlt == heroB.qlt then return a > b else return heroA.qlt > heroB.qlt end end) local uiMap = self.root:genAllChildren() self.uiMap = uiMap uiMap["hero_fragment_tips.title_bg_img.card"]:setSprite(GConst.ATLAS_PATH.ICON_ITEM, cfg.icon) uiMap["hero_fragment_tips.title_bg_img.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_CARD_TIPS_DESC)) uiMap["hero_fragment_tips.title_bg_img.title_text"]:setText(I18N:getGlobalText(I18N.GlobalConst["HERO_CARD_DESC_QLT_" .. cfg.qlt])) uiMap["hero_fragment_tips.title_bg_img.ok_btn"]:addClickListener(function() self:closeUI() end) uiMap["hero_fragment_tips.title_bg_img.ok_btn.text"]:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK)) self:initScrollRect() end function HeroFragmentTips:initScrollRect() local scrollRectComp = self.uiMap["hero_fragment_tips.title_bg_img.scroll_rect"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE) scrollRectComp:addInitCallback(function() return GConst.TYPEOF_LUA_CLASS.REWARD_CELL end) scrollRectComp:addRefreshCallback(function(index, cell) cell:refreshItemById(self.heroList[index], 0) end) scrollRectComp:clearCells() scrollRectComp:refillCells(#self.heroList) end return HeroFragmentTips