local SelectOtherBtnUI = class("SelectOtherBtnUI", BaseUI)

local BTN_OFFSET = 32
local BTN_INTERVAL = 16

function SelectOtherBtnUI:ctor()
end

function SelectOtherBtnUI:isFullScreen()
    return false
end

function SelectOtherBtnUI:getPrefabPath()
    return "assets/prefabs/ui/setting/select_other_btn_ui.prefab"
end

function SelectOtherBtnUI:onPressBackspace()
	self:closeUI()
end

function SelectOtherBtnUI:onLoadRootComplete()
    self.uiMap = self.root:genAllChildren()
    self.uiMap["select_other_btn_ui.mask"]:addClickListener(function()
        self:closeUI()
    end)
    self.uiMap["select_other_btn_ui.bg.mail_btn"]:addClickListener(function()
        self:closeUI()
        ModuleManager.MailManager:showMailUI()
    end)

    local cellHeight = self.uiMap["select_other_btn_ui.bg.setting_btn"]:getRectHeight()
    local cellCount = 0
    local y = -BTN_OFFSET
    if DataManager.MailData:getIsOpen() then
        cellCount = cellCount + 1
        self.uiMap["select_other_btn_ui.bg.mail_btn"]:setVisible(true)
        self.uiMap["select_other_btn_ui.bg.mail_btn"]:setAnchoredPositionY(y)
        y = y - BTN_INTERVAL - cellHeight
        local redPoint, isAdRedPoint = DataManager.MailData:getRedPoint()
        if redPoint then
            if isAdRedPoint then
                self.uiMap["select_other_btn_ui.bg.mail_btn"]:addRedPoint(124, 35, 1, "common_ad_3", nil, true)
            else
                self.uiMap["select_other_btn_ui.bg.mail_btn"]:addRedPoint(124, 35, 0.8, nil, nil, true)
            end
        else
            self.uiMap["select_other_btn_ui.bg.mail_btn"]:removeRedPoint()
        end
        self.uiMap["select_other_btn_ui.bg.mail_btn.text"]:setText(I18N:getGlobalText(I18N.GlobalConst.MAIL_NAME))
    else
        self.uiMap["select_other_btn_ui.bg.mail_btn"]:setVisible(false)
    end
    cellCount = cellCount + 1
    local settingBtn = self.uiMap["select_other_btn_ui.bg.setting_btn"]
    if DataManager.AIHelperData:getRp() then
        settingBtn:addRedPoint(124, 35, 0.8, nil, nil, true)
    else
        settingBtn:removeRedPoint()
    end
    settingBtn:setAnchoredPositionY(y)
    settingBtn:addClickListener(function()
        self:closeUI()
        ModuleManager.GameSettingManager:showSettingUI()
    end)
    self.uiMap["select_other_btn_ui.bg.setting_btn.text"]:setText(I18N:getGlobalText(I18N.GlobalConst.SETTING_DESC))

    self.uiMap["select_other_btn_ui.bg"]:setSizeDeltaY(cellCount*cellHeight + (cellCount - 1)*BTN_INTERVAL + BTN_OFFSET*2)
end

return SelectOtherBtnUI