201 lines
6.4 KiB
Lua
201 lines
6.4 KiB
Lua
local GameSettingUI = class("GameSettingUI", BaseUI)
|
||
|
||
local BG_HEIGHT = {
|
||
NORMAL = 930,
|
||
[GConst.LANGUAGE.VIETNAMESE] = 812
|
||
}
|
||
|
||
local SWITCH_TX_COLOR = "#707390"
|
||
local IOS_ICON = "setting_decoration_8"
|
||
local GOOGLE_ICON = "setting_decoration_9"
|
||
|
||
local CHECK_WHITE_LIST_COUNT = 5
|
||
|
||
function GameSettingUI:ctor()
|
||
self.clickMusicCount = 0
|
||
end
|
||
|
||
function GameSettingUI:isFullScreen()
|
||
return false
|
||
end
|
||
|
||
function GameSettingUI:getPrefabPath()
|
||
return "assets/prefabs/ui/setting/game_setting_ui.prefab"
|
||
end
|
||
|
||
function GameSettingUI:onLoadRootComplete()
|
||
self:_display()
|
||
self:_addListeners()
|
||
self:_bind()
|
||
end
|
||
|
||
function GameSettingUI:onPressBackspace()
|
||
self:closeUI()
|
||
end
|
||
|
||
function GameSettingUI:_display()
|
||
local uiMap = self.root:genAllChildren()
|
||
uiMap["game_setting_ui.bg.title"]:setText(I18N:getGlobalText(I18N.GlobalConst.SETTING_DESC))
|
||
uiMap["game_setting_ui.bg.support_btn.status"]:setText(I18N:getGlobalText(I18N.GlobalConst.SUPPORT_DESSC))
|
||
uiMap["game_setting_ui.bg.player_id_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.COPY_ID))
|
||
uiMap["game_setting_ui.bg.exchange_btn.status"]:setText(I18N:getGlobalText(I18N.GlobalConst.SETTING_DESC_1))
|
||
|
||
local language = I18N:getCurLanguage()
|
||
uiMap["game_setting_ui.bg.language_btn.status"]:setSprite(GConst.ATLAS_PATH.UI_SETTING, "language_" .. language)
|
||
if CS.BF.BFMain.IsShenhe then
|
||
uiMap["game_setting_ui.bg.bg"]:setVisible(false)
|
||
end
|
||
|
||
uiMap["game_setting_ui.bg.tx_1"]:setText(I18N:getGlobalText(I18N.GlobalConst.SERVICE_DESC))
|
||
uiMap["game_setting_ui.bg.tx_2"]:setText(I18N:getGlobalText(I18N.GlobalConst.PRIVACY_DESC))
|
||
|
||
self.helpNode = uiMap["game_setting_ui.help_node"]
|
||
local helpTipsBG = uiMap["game_setting_ui.help_node.help_tips"]
|
||
local helpTips = uiMap["game_setting_ui.help_node.help_tips.desc"]
|
||
helpTips:setText(I18N:getGlobalText(I18N.GlobalConst.BIND_INFO_TIPS))
|
||
local h = helpTips:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredHeight
|
||
helpTips:setSizeDeltaY(h)
|
||
helpTipsBG:setSizeDeltaY(h + 39)
|
||
self.helpNode:setActive(false)
|
||
|
||
self:refreshMusic()
|
||
self:refreshVoice()
|
||
|
||
self:refreshShenhe()
|
||
self:refreshBGHeight()
|
||
end
|
||
|
||
function GameSettingUI:_addListeners()
|
||
local uiMap = self.root:genAllChildren()
|
||
uiMap["game_setting_ui.bg.close_btn"]:addClickListener(function()
|
||
self:closeUI()
|
||
end)
|
||
|
||
uiMap["game_setting_ui.bg.music_bg"]:addClickListener(function()
|
||
local status = AudioManager:isMusicEnabled()
|
||
if not status then
|
||
AudioManager:setMusicVolume(1)
|
||
else
|
||
AudioManager:setMusicVolume(0)
|
||
end
|
||
|
||
if CS.BF.BFMain.IsWhite then
|
||
self.clickMusicCount = self.clickMusicCount + 1
|
||
if self.clickMusicCount > CHECK_WHITE_LIST_COUNT then
|
||
GFunc.showToast("Please don’t frequently operate")
|
||
end
|
||
end
|
||
|
||
self:refreshMusic()
|
||
end)
|
||
|
||
uiMap["game_setting_ui.bg.voice_bg"]:addClickListener(function()
|
||
local status = AudioManager:isEffectEnabled()
|
||
if not status then
|
||
AudioManager:setEffectVolume(1)
|
||
else
|
||
AudioManager:setEffectVolume(0)
|
||
end
|
||
self:refreshVoice()
|
||
end)
|
||
|
||
uiMap["game_setting_ui.bg.language_btn"]:addClickListener(function()
|
||
ModuleManager.GameSettingManager:showLanguageUI()
|
||
end)
|
||
|
||
uiMap["game_setting_ui.bg.support_btn"]:addClickListener(function()
|
||
ModuleManager.GameSettingManager:sendSupport()
|
||
DataManager.AiHelpData:setUnreadCount()
|
||
end)
|
||
|
||
uiMap["game_setting_ui.bg.player_id_btn"]:addClickListener(function()
|
||
-- GFunc.copyStr(objectId)
|
||
end)
|
||
|
||
uiMap["game_setting_ui.bg.bg.facebook"]:addClickListener(function()
|
||
local url = GConst.GameSettingConst.SOCIAL_URL[I18N:getCurLanguage()]
|
||
if not url then
|
||
url = GConst.GameSettingConst.SOCIAL_URL.normal
|
||
end
|
||
GFunc.openUrl(url)
|
||
end)
|
||
|
||
uiMap["game_setting_ui.bg.bg.discord"]:addClickListener(function()
|
||
local url = GConst.GameSettingConst.COMMUNITY_URL[I18N:getCurLanguage()]
|
||
if not url then
|
||
url = GConst.GameSettingConst.COMMUNITY_URL.normal
|
||
end
|
||
GFunc.openUrl(url)
|
||
end)
|
||
|
||
uiMap["game_setting_ui.bg.exchange_btn"]:addClickListener(function()
|
||
ModuleManager.GameSettingManager:showCdkeyUI()
|
||
end)
|
||
|
||
uiMap["game_setting_ui.bg.tx_1"]:addClickListener(function()
|
||
GFunc.openUrl("https://cobbygame.com/tos.html")
|
||
end)
|
||
|
||
uiMap["game_setting_ui.bg.tx_2"]:addClickListener(function()
|
||
GFunc.openUrl("https://www.cobbygame.com/pp.html")
|
||
end)
|
||
|
||
uiMap["game_setting_ui.bg.point"]:addClickListener(function()
|
||
if self.helpNode then
|
||
self.helpNode:setActive(true)
|
||
end
|
||
end)
|
||
|
||
self.helpNode:addClickListener(function()
|
||
self.helpNode:setActive(false)
|
||
end)
|
||
end
|
||
|
||
function GameSettingUI:_bind()
|
||
end
|
||
|
||
function GameSettingUI:refreshMusic()
|
||
local uiMap = self.root:genAllChildren()
|
||
local offIcon = uiMap["game_setting_ui.bg.music_bg.off"]
|
||
local onIcon = uiMap["game_setting_ui.bg.music_bg.on"]
|
||
|
||
local status = AudioManager:isMusicEnabled()
|
||
offIcon:setVisible(status ~= true)
|
||
onIcon:setVisible(status == true)
|
||
end
|
||
|
||
function GameSettingUI:refreshVoice()
|
||
local uiMap = self.root:genAllChildren()
|
||
local offIcon = uiMap["game_setting_ui.bg.voice_bg.off"]
|
||
local onIcon = uiMap["game_setting_ui.bg.voice_bg.on"]
|
||
|
||
local status = AudioManager:isEffectEnabled()
|
||
offIcon:setVisible(status ~= true)
|
||
onIcon:setVisible(status == true)
|
||
end
|
||
|
||
function GameSettingUI:refreshShenhe()
|
||
local uiMap = self.root:genAllChildren()
|
||
local codeBtn = uiMap["game_setting_ui.bg.exchange_btn"]
|
||
local codeBg = uiMap["game_setting_ui.bg.exchange_bg"]
|
||
|
||
local supportBtn = uiMap["game_setting_ui.bg.support_btn"]
|
||
local supportBg = uiMap["game_setting_ui.bg.support_bg"]
|
||
|
||
codeBtn:setActive(not GFunc.isShenhe())
|
||
codeBg:setActive(not GFunc.isShenhe())
|
||
supportBtn:setActive(not GFunc.isShenhe())
|
||
supportBg:setActive(not GFunc.isShenhe())
|
||
end
|
||
|
||
function GameSettingUI:refreshBGHeight()
|
||
local uiMap = self.root:genAllChildren()
|
||
local bg = uiMap["game_setting_ui.bg"]
|
||
local communityBg = uiMap["game_setting_ui.bg.bg"]
|
||
local h = BG_HEIGHT[I18N:getCurLanguage()]
|
||
h = h or BG_HEIGHT.NORMAL
|
||
bg:setSizeDeltaY(h)
|
||
communityBg:setVisible(BG_HEIGHT[I18N:getCurLanguage()] == nil)
|
||
end
|
||
|
||
return GameSettingUI |