local ActPvpHelpUI = class("ActPvpHelpUI", BaseUI)

-- 响应安卓后退事件
function ActPvpHelpUI:onPressBackspace()
    self:closeUI()
end

function ActPvpHelpUI:isFullScreen()
    return false
end

function ActPvpHelpUI:showCommonBG()
    return false
end

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

function ActPvpHelpUI:ctor()
end

function ActPvpHelpUI:onClose()
end

function ActPvpHelpUI:onLoadRootComplete()
    self:_display()
    self:_addListeners()
end

function ActPvpHelpUI:_display()
    local uiMap = self.root:genAllChildren()
    self.videoNode = uiMap["act_pvp_help_ui.skill_node.video_node"]
    uiMap["act_pvp_help_ui.skill_node.title"]:setText(I18N:getGlobalText(I18N.GlobalConst.COLLECTION_DESC_11))
    uiMap["act_pvp_help_ui.skill_node.last_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_BATTLE_DESC_9))
    uiMap["act_pvp_help_ui.skill_node.next_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_BATTLE_DESC_10))

    self.curIndex = 1
    self:showTips()
end

function ActPvpHelpUI:_addListeners()
    local uiMap = self.root:genAllChildren()
    uiMap["act_pvp_help_ui.close_btn"]:addClickListener(function()
        self:closeUI()
    end)

    uiMap["act_pvp_help_ui.skill_node.last_btn"]:addClickListener(function()
        self.curIndex = math.max(1, self.curIndex - 1)
        self:showTips()
    end)

    uiMap["act_pvp_help_ui.skill_node.next_btn"]:addClickListener(function()
        self.curIndex = math.min(3, self.curIndex + 1)
        self:showTips()
    end)
end

function ActPvpHelpUI:showTips()
    local uiMap = self.root:genAllChildren()
    for i = 1, 3 do
        local obj = uiMap["act_pvp_help_ui.skill_node.video_node.pause_video_0" .. i]
        obj:setVisible(i == self.curIndex)
    end

    local lastBtn = uiMap["act_pvp_help_ui.skill_node.last_btn"]
    local nextBtn = uiMap["act_pvp_help_ui.skill_node.next_btn"]

    local str
    if self.curIndex == 1 then
        str = I18N:getGlobalText(I18N.GlobalConst.ACT_PVP_DESC_21)
        lastBtn:setActive(false)
        nextBtn:setActive(true)
        nextBtn:setAnchoredPositionX(0)
    elseif self.curIndex == 2 then
        str = I18N:getGlobalText(I18N.GlobalConst.ACT_PVP_DESC_22)
        lastBtn:setActive(true)
        nextBtn:setActive(true)
        lastBtn:setAnchoredPositionX(-137.5)
        nextBtn:setAnchoredPositionX(137.5)
    else
        str = I18N:getGlobalText(I18N.GlobalConst.ACT_PVP_DESC_23)
        lastBtn:setActive(true)
        nextBtn:setActive(false)
        lastBtn:setAnchoredPositionX(0)
    end
    local descObj = uiMap["act_pvp_help_ui.skill_node.scrollrect.viewport.desc"]
    descObj:setText(str)
    descObj:setSizeDeltaY(descObj:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredHeight)
    descObj:setAnchoredPositionY(0)
end

return ActPvpHelpUI