local ActPopUI = class("ActPopUI", BaseUI) function ActPopUI:ctor(parmas) self.parmas = parmas or {} self.data = DataManager[parmas.dataKey] self.actId = self.data:getActId() end function ActPopUI:isFullScreen() return false end function ActPopUI:getOpenSoundId() end function ActPopUI:getPrefabPath() return self.parmas.prefabPath end function ActPopUI:onClose() EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.MAIN_UI_CHECK_POP) end function ActPopUI:onPressBackspace() self:closeUI() end function ActPopUI:onLoadRootComplete() self.uiMap = self.root:genAllChildren() self.uiMap["act_pop_ui.mask"]:addClickListener(function() self:closeUI() end) self.uiMap["act_pop_ui.bg.close_btn"]:addClickListener(function() self:closeUI() end) self.titleTx = self.uiMap["act_pop_ui.bg.title_tx"] self.descTx = self.uiMap["act_pop_ui.bg.desc_tx"] self.funcBtn = self.uiMap["act_pop_ui.bg.func_btn"] self.funcBtnTx = self.uiMap["act_pop_ui.bg.func_btn.text"] self.spineObj = self.uiMap["act_pop_ui.bg.ui_spine_obj"] self.spineObj:playAnimComplete("born", false, true, function() self.spineObj:playAnim("idle", true, true) end) self:setTextVisible(false) self:performWithDelayGlobal(function() self:setTextVisible(true) end,0.2) self.titleTx:setText(self.data:getActNameStr()) self.funcBtnTx:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_GO)) self.funcBtn:addClickListener(function() if self.parmas.callback then self.parmas.callback() end self:closeUI() end) self:refreshShowReward() self:addPopBar() self:scheduleGlobal(function() self:updateTime() end, 1) self:updateTime() self:bind(self.data, "isDirty", function(binder, value) local actId = self.data:getActId() if self.actId == nil or self.actId == 0 then self.actId = actId elseif self.actId ~= actId then self:closeUI() end end) end function ActPopUI:setTextVisible(visible) self.titleTx:setActive(visible) self.descTx:setActive(visible) self.funcBtnTx:setActive(visible) end function ActPopUI:refreshShowReward() local cfg = ConfigManager:getConfig("activity") local actId = self.data:getActId() for i = 1, 5 do local rewardObj = self.uiMap["act_pop_ui.bg.reward_node.reward_cell_" .. i] if rewardObj then local rewardCell = rewardObj:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL) if actId and cfg[actId] then local reward = cfg[actId].show_reward[i] if reward then rewardCell:refreshByConfig(reward) rewardCell:hideRewardNum() rewardCell:setActive(true) else rewardCell:setActive(false) end else rewardCell:setActive(false) end end end local descTx = self.uiMap["act_pop_ui.bg.desc_tx_2"] local currLanguage = I18N:getCurLanguage() if currLanguage == GConst.LANGUAGE.CHINESE_TC or currLanguage == GConst.LANGUAGE.CHINESE then descTx:setSizeDeltaX(520) else descTx:setSizeDeltaX(580) end if actId then local rewardTx = cfg[actId].txt if rewardTx and #rewardTx >= 3 then local name1 = GFunc.getRewardName(rewardTx[1], true) local name2 = GFunc.getRewardName(rewardTx[2], true) local name3 = GFunc.getRewardName(rewardTx[3], true) descTx:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_TURNTABLE_DESC_3, name1, name2, name3)) else descTx:setText(GConst.EMPTY_STRING) end else descTx:setText(GConst.EMPTY_STRING) end end function ActPopUI:updateTime() local remainTime = self.data:getRemainTime() if remainTime <= 0 then self:closeUI() EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.MAIN_UI_CHECK_POP) return end self.descTx:setText(I18N:getGlobalText(I18N.GlobalConst.TIME_END_DESC_1, Time:formatNumTimeStr(remainTime))) end -- 显示今日不再提示 function ActPopUI:addPopBar() ModuleManager.ActivityPopManager:addPopBar(self.root) end return ActPopUI