local ActPvpMatchUI = class("ActPvpMatchUI", BaseUI)

function ActPvpMatchUI:getPrefabPath()
    return "assets/prefabs/ui/activity/act_pvp/act_pvp_match_ui.prefab"
end

function ActPvpMatchUI:ctor()
    self:addEventListener(EventManager.CUSTOM_EVENT.ACT_PVP_EVENT, function(parmas)
        if self.dealySid then
            return
        end

        if parmas and parmas.matchOver then
            self.dealySid = self:performWithDelayGlobal(function()
                self:closeUI()
                ModuleManager.ActPvpManager:showMatchResultUI()
            end, 1.5)
        end
    end)
end

function ActPvpMatchUI:onLoadRootComplete()
    self:_display()
end

function ActPvpMatchUI:_display()
    local uiMap = self.root:genAllChildren()
    -- uiMap["act_pvp_match_ui.match_loading.tx_title"]:setText()
    local tx = uiMap["act_pvp_match_ui.match_loading.tx_loading"]
    tx:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_22))
    tx:setSizeDeltaX(tx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredWidth)
    uiMap["act_pvp_match_ui.match_loading.spine_battle"]:playAnim("idle", true, false, false)
    uiMap["act_pvp_match_ui.match_loading.tx_loading.ui_spine_obj"]:playAnim("idle", true, false, false)
    uiMap["act_pvp_match_ui.match_loading.btn_cancel.tx_cancel"]:setText(I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_CANCEL))
    uiMap["act_pvp_match_ui.match_loading.btn_cancel"]:addClickListener(function()
        self:closeUI()
    end)
end

return ActPvpMatchUI