-- 竞技场:最近战报 local ArenaRecentBattleUI = class("ArenaRecentBattleUI", BaseUI) function ArenaRecentBattleUI:isFullScreen() return false end function ArenaRecentBattleUI:showCommonBG() return false end function ArenaRecentBattleUI:getPrefabPath() return "assets/prefabs/ui/arena/arena_recent_battle_ui.prefab" end function ArenaRecentBattleUI:onPressBackspace() self:closeUI() end function ArenaRecentBattleUI:ctor() ModuleManager.ArenaManager:reqRecord() end function ArenaRecentBattleUI:onCover() end function ArenaRecentBattleUI:onReshow() end function ArenaRecentBattleUI:onClose() end function ArenaRecentBattleUI:onLoadRootComplete() local uiMap = self.root:genAllChildren() self.txTitle = uiMap["arena_recent_battle_ui.bg.title.tx_title"] self.btnClose = uiMap["arena_recent_battle_ui.bg.btn_close"] self.txResult = uiMap["arena_recent_battle_ui.bg.tab.tx_result"] self.txName = uiMap["arena_recent_battle_ui.bg.tab.tx_name"] self.txScore = uiMap["arena_recent_battle_ui.bg.tab.tx_score"] self.txNone = uiMap["arena_recent_battle_ui.bg.tx_none"] self.records = {} for i = 1, 5 do self.records[i] = uiMap["arena_recent_battle_ui.bg.records.battle_record_cell_"..i] end self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_7)) self.txResult:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_14)) self.txName:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_15)) self.txScore:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_16)) self.btnClose:addClickListener(function() self:closeUI() end) self:bind(DataManager.ArenaData, "isDirty", function() self:onRefresh() end) end function ArenaRecentBattleUI:onRefresh() local showCount = 0 for idx, obj in pairs(self.records) do local info = DataManager.ArenaData:getRecentBattleByIdx(idx) if info then showCount = showCount + 1 obj:setActive(true) self:refreshRecord(obj, info) else obj:setActive(false) end end Logger.logHighlight(showCount) if showCount == 0 then self.txNone:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_8)) else self.txNone:setText("") end end function ArenaRecentBattleUI:refreshRecord(obj, info) local uiMap = obj:genAllChildren() local playerHeadCell = CellManager:addCellComp(uiMap["player_head_cell"], GConst.TYPEOF_LUA_CLASS.PLAYER_HEAD_CELL) playerHeadCell:refresh(info.match_info.avatar, info.match_info.avatar_frame) uiMap["tx_name"]:setText(info.match_info.name) if info.win then obj:setSprite(GConst.ATLAS_PATH.ARENA,"arena_bg_3") uiMap["tx_score"]:setText(""..info.incr_score.."") uiMap["img_result"]:setSprite(GConst.ATLAS_PATH.ARENA, "arena_dec_2") if info.attacker then uiMap["tx_result"]:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_19)) else uiMap["tx_result"]:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_17)) end else obj:setSprite(GConst.ATLAS_PATH.ARENA,"arena_bg_4") uiMap["tx_score"]:setText(""..info.incr_score.."") uiMap["img_result"]:setSprite(GConst.ATLAS_PATH.ARENA, "arena_dec_3") if info.attacker then uiMap["tx_result"]:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_20)) else uiMap["tx_result"]:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_18)) end end end return ArenaRecentBattleUI