local SelectOtherBtnUI = class("SelectOtherBtnUI", BaseUI)

local BTN_OFFSET = -26
local BTN_INTERVAL = 59

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.root:addClickListener(function()
		self:closeUI()
	end)
	self.uiMap["select_other_btn_ui.bg.mail_btn"]:addClickListener(function()
		self:closeUI()
		ModuleManager.MailManager:showMailUI()
	end)

	local line1 = self.uiMap["select_other_btn_ui.bg.line_1"]
	local line2 = self.uiMap["select_other_btn_ui.bg.line_2"]
	local line3 = self.uiMap["select_other_btn_ui.bg.line_3"]

	local cellCount = 0
	local y = -BTN_OFFSET

	cellCount = cellCount + 1
	y = y - BTN_INTERVAL
	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))

	if DataManager.MailData:getIsOpen() then
		line1:setActive(true)
		cellCount = cellCount + 1
		y = y - BTN_INTERVAL
		self.uiMap["select_other_btn_ui.bg.mail_btn"]:setVisible(true)
		self.uiMap["select_other_btn_ui.bg.mail_btn"]:setAnchoredPositionY(y)

		local redPoint, isAdRedPoint = DataManager.MailData:getRedPoint()
		if redPoint then
			if isAdRedPoint then
				self.uiMap["select_other_btn_ui.bg.mail_btn"]:addRedPoint(60, 24, 1, "common_ad_1", nil, true)
			else
				self.uiMap["select_other_btn_ui.bg.mail_btn"]:addRedPoint(60, 24, 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
		line1:setActive(false)
		self.uiMap["select_other_btn_ui.bg.mail_btn"]:setVisible(false)
	end

	if DataManager.BagData:getIsOpen() then
		line2:setActive(true)
		cellCount = cellCount + 1
		y = y - BTN_INTERVAL
		local bagBtn = self.uiMap["select_other_btn_ui.bg.bag_btn"]
		-- if DataManager.AIHelperData:getRp() then
		-- 	bagBtn:addRedPoint(124, 35, 0.8, nil, nil, true)
		-- else
		-- 	bagBtn:removeRedPoint()
		-- end
		bagBtn:setAnchoredPositionY(y)
		bagBtn:addClickListener(function()
			self:closeUI()
			ModuleManager.BagManager:showBagMainUI()
		end)
		self.uiMap["select_other_btn_ui.bg.bag_btn.text"]:setText(I18N:getGlobalText(I18N.GlobalConst.BAG_DESC_1))
	else
		line2:setActive(false)
		self.uiMap["select_other_btn_ui.bg.bag_btn"]:setVisible(false)
	end

	if EDITOR_MODE or Platform:getIsDevChannel() then
		line3:setActive(true)
		cellCount = cellCount + 1
		y = y - BTN_INTERVAL
		local gmBtn = self.uiMap["select_other_btn_ui.bg.gm_btn"]
		gmBtn:setAnchoredPositionY(y)
		gmBtn:addClickListener(function()
			self:closeUI()
			ModuleManager.DevToolManager:showOrHideDevListUI()
		end)
		self.uiMap["select_other_btn_ui.bg.gm_btn.text"]:setText("GM")
	else
		line3:setActive(false)
		self.uiMap["select_other_btn_ui.bg.gm_btn"]:setVisible(false)
	end

	self.uiMap["select_other_btn_ui.bg"]:setSizeDeltaY(cellCount*BTN_INTERVAL + 8)
end

return SelectOtherBtnUI