299 lines
12 KiB
Lua
299 lines
12 KiB
Lua
local SettingInfo = quick_class("SettingInfo")
|
|
local this = SettingInfo
|
|
|
|
local languageGroup = { Language[12810], Language[12811] }
|
|
|
|
function SettingInfo:ctor(gameObject, rootPanel)
|
|
self.gameObject = gameObject
|
|
self:InitComponent(gameObject, rootPanel)
|
|
end
|
|
|
|
--初始化组件(用于子类重写)
|
|
function SettingInfo:InitComponent(gameObject, rootPanel)
|
|
this.spLoader = SpriteLoader.New()
|
|
this.rootPanel = rootPanel
|
|
this.head = Util.GetGameObject(gameObject, "playerInfo/head")
|
|
this.headpos = Util.GetGameObject(gameObject, "playerInfo/head/pos")
|
|
this.headRedpot = Util.GetGameObject(gameObject, "playerInfo/head/redpot")
|
|
--反馈邮箱
|
|
this.fankui = Util.GetGameObject(gameObject, "other/fankui")
|
|
if this.fankui then
|
|
local fankuiText = this.fankui:GetComponent("Text")
|
|
fankuiText.text = ServerConfigManager.GetSettingValue(ServerConfigManager.SettingConfig.SHOW_EMAIL_SETTING) or ""
|
|
end
|
|
this.instructionsBtn = Util.GetGameObject(gameObject, "other/protos/instructionsBtn")
|
|
this.privacyBtn = Util.GetGameObject(gameObject, "other/protos/privacyBtn")
|
|
this.name = Util.GetGameObject(gameObject, "playerInfo/name/Text")
|
|
this.btnChangeName = Util.GetGameObject(gameObject, "playerInfo/name/Image/btn")
|
|
|
|
this.exp = Util.GetGameObject(gameObject, "playerInfo/exp"):GetComponent("Slider")
|
|
this.expText = Util.GetGameObject(gameObject, "playerInfo/exp/ExpText"):GetComponent("Text")
|
|
|
|
this.uidText = Util.GetGameObject(gameObject, "playerInfo/uid/Text"):GetComponent("Text")
|
|
this.idText = Util.GetGameObject(gameObject, "playerInfo/id/Text"):GetComponent("Text")
|
|
this.guildText = Util.GetGameObject(gameObject, "playerInfo/guild/Text"):GetComponent("Text")
|
|
this.serverText = Util.GetGameObject(gameObject, "playerInfo/server/Text"):GetComponent("Text")
|
|
|
|
this.BGMSlider = Util.GetGameObject(gameObject, "setting/BGMSlider"):GetComponent("Slider")
|
|
this.BGMSliderValue = Util.GetGameObject(gameObject, "setting/BGMSlider/count"):GetComponent("Text")
|
|
this.SoundSlider = Util.GetGameObject(gameObject, "setting/SoundSlider"):GetComponent("Slider")
|
|
this.SoundSliderValue = Util.GetGameObject(gameObject, "setting/SoundSlider/count"):GetComponent("Text")
|
|
|
|
this.btnChangeLogin = Util.GetGameObject(gameObject, "setting/changelogin")
|
|
this.btnOneKeyCopy = Util.GetGameObject(gameObject, "setting/oneKeyCopy")
|
|
this.btnBind = Util.GetGameObject(gameObject, "other/box/BindAccount")
|
|
this.btnCancel = Util.GetGameObject(gameObject, "other/box/CancelAccount")
|
|
--兑换码
|
|
this.cdKey = Util.GetGameObject(gameObject, "other/box/cdkey")
|
|
this.submit = Util.GetGameObject(gameObject, "other/box/submit")
|
|
|
|
-- --游戏语言切换按钮
|
|
-- this.languageBtn = Util.GetGameObject(gameObject, "other/box/languageBtn")
|
|
-- this.languageText= Util.GetGameObject(this.languageBtn,"Text"):GetComponent("Text")
|
|
-- this.languageText.text=GetCurLanguage()==0 and "中文" or "英文"
|
|
|
|
if IsLanguagePack then
|
|
this.dropDown = Util.GetGameObject(gameObject, "other/box/Dropdown"):GetComponent("Dropdown")
|
|
this.dropDownText = Util.GetGameObject(gameObject, "other/box/Dropdown/Label"):GetComponent("Text")
|
|
this.dropDownTip = Util.GetGameObject(gameObject, "other/box/Dropdown/tip")
|
|
else
|
|
this.dropDown = Util.GetGameObject(gameObject, "other/box/Dropdown")
|
|
this.dropDown:SetActive(false)
|
|
end
|
|
|
|
if ServerConfigManager.IsSettingActive(ServerConfigManager.SettingConfig.IS_SELECT_RESLUTION) then
|
|
this.selectResolution = Util.GetGameObject(gameObject, "other/box/selectResolution"):GetComponent("Dropdown")
|
|
this.selectResolutionText = Util.GetGameObject(gameObject, "other/box/selectResolution/Label"):GetComponent(
|
|
"Text")
|
|
this.selectResolutionTip = Util.GetGameObject(gameObject, "other/box/selectResolution/tip")
|
|
else
|
|
this.selectResolution = Util.GetGameObject(gameObject, "other/box/selectResolution")
|
|
this.selectResolution:SetActive(false)
|
|
end
|
|
|
|
if AppConst.isSDKLogin and SDKMgr:GetSubChannel() and SDKMgr:GetSubChannel() == "Yes" then
|
|
this.btnBind:SetActive(true)
|
|
else
|
|
this.btnBind:SetActive(false)
|
|
end
|
|
end
|
|
|
|
function SettingInfo:SetTipShow()
|
|
if IsLanguagePack then
|
|
local flag = PlayerPrefs.GetInt("language_flag")
|
|
--LogGreen("PlayerPrefs:"..flag)
|
|
if flag == 0 then
|
|
--this.dropDownText.text = Language[12810]
|
|
--elseif flag == 2 then
|
|
this.dropDownText.text = "Tiếng Việt"
|
|
elseif flag == 1 then
|
|
this.dropDownText.text = "English"
|
|
elseif flag == 2 then
|
|
this.dropDownText.text = "ภาษาไทย"
|
|
end
|
|
this.dropDown.value = flag
|
|
if GetCurLanguage() ~= flag then
|
|
this.dropDownTip.gameObject:SetActive(true)
|
|
else
|
|
this.dropDownTip.gameObject:SetActive(false)
|
|
end
|
|
end
|
|
end
|
|
|
|
function SettingInfo:SetReslutionTipShow()
|
|
if ServerConfigManager.IsSettingActive(ServerConfigManager.SettingConfig.IS_SELECT_RESLUTION) then
|
|
local value = PlayerPrefs.GetInt("ResLution")
|
|
this.selectResolution.value = value
|
|
if value == 0 then
|
|
UnityEngine.Application.targetFrameRate = 60;
|
|
this.selectResolutionText.text = Language[12812]
|
|
this.selectResolutionTip.gameObject:SetActive(false)
|
|
else
|
|
UnityEngine.Application.targetFrameRate = 60;
|
|
this.selectResolutionText.text = Language[12813]
|
|
this.selectResolutionTip.gameObject:SetActive(true)
|
|
end
|
|
end
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function SettingInfo:BindEvent()
|
|
if IsLanguagePack then
|
|
this.dropDown.onValueChanged:AddListener(
|
|
function(value)
|
|
PlayerPrefs.SetInt("language_flag", value)
|
|
this:SetTipShow()
|
|
if value == GetCurLanguage() then
|
|
return
|
|
end
|
|
MsgPanel.ShowTwo(Language[12814], function() end, function()
|
|
--Game.Logout()
|
|
PlayerPrefs.SetInt("language", PlayerPrefs.GetInt("language_flag", GetCurLanguage()))
|
|
Game.Restart()
|
|
end, Language[10685], Language[10686], "", false, "")
|
|
end
|
|
)
|
|
end
|
|
--用户隐私协议
|
|
Util.AddClick(this.instructionsBtn, function()
|
|
OpenWeb("https://yhxy.tiandiyouxi.com")
|
|
end)
|
|
Util.AddClick(this.privacyBtn, function()
|
|
OpenWeb("https://yszx.tiandiyouxi.com")
|
|
end)
|
|
if ServerConfigManager.IsSettingActive(ServerConfigManager.SettingConfig.IS_SELECT_RESLUTION) then
|
|
this.selectResolution.onValueChanged:AddListener(
|
|
function(value)
|
|
PlayerPrefs.SetInt("ResLution", value)
|
|
this:SetReslutionTipShow()
|
|
end
|
|
)
|
|
end
|
|
--cdKey兑换
|
|
Util.AddClick(this.cdKey, function()
|
|
UIManager.OpenPanel(UIName.CDKeyExchangePanel)
|
|
end)
|
|
--游客绑定
|
|
Util.AddClick(this.btnBind, function()
|
|
if AppConst.isSDKLogin and SDKMgr:GetSubChannel() and SDKMgr:GetSubChannel() == "Yes" then
|
|
SubmitExtraData({ type = SDKSubMitType.TYPE_FENGTI_BIND_ACCOUNT })
|
|
end
|
|
end)
|
|
--账号注销
|
|
Util.AddClick(this.btnCancel, function()
|
|
|
|
end)
|
|
-- --语言切换
|
|
-- Util.AddClick(this.languageBtn, function()
|
|
-- local setId=GetCurLanguage()==0 and 1 or 0
|
|
-- Log("中英切换"..setId)
|
|
-- PlayerPrefs.SetInt("language",setId)
|
|
-- this.languageText.text=GetCurLanguage()==0 and "中文" or "英文"
|
|
-- end)
|
|
--上报战斗日志
|
|
Util.AddOnceClick(this.submit, function()
|
|
BattleRecordManager.SubmitBattleRecord()
|
|
end)
|
|
|
|
Util.AddClick(this.head, function()
|
|
UIManager.OpenPanel(UIName.HeadChangePopup)
|
|
end)
|
|
|
|
Util.AddClick(this.btnChangeName, function()
|
|
--PopupTipPanel.ShowTip("功能尚未开放,敬请期待")
|
|
UIManager.OpenPanel(UIName.CreateNamePopup)
|
|
end)
|
|
|
|
Util.AddSlider(this.BGMSlider.gameObject, function(go, value)
|
|
SettingManager.SetSettingData(SETTING_TYPE.BGM_RATIO, value)
|
|
this.BGMSliderValue.text = math.floor(value * 100)
|
|
end)
|
|
|
|
Util.AddSlider(this.SoundSlider.gameObject, function(go, value)
|
|
SettingManager.SetSettingData(SETTING_TYPE.SOUND_RATIO, value)
|
|
this.SoundSliderValue.text = math.floor(value * 100)
|
|
end)
|
|
|
|
Util.AddClick(this.btnChangeLogin, function()
|
|
MsgPanel.ShowTwo(Language[12815], nil, function()
|
|
Game.Logout()
|
|
end)
|
|
end)
|
|
|
|
Util.AddClick(this.btnOneKeyCopy, function()
|
|
if not UnityEngine.Application.isMobilePlatform then
|
|
PopupTipPanel.ShowTip(Language[12816])
|
|
return
|
|
end
|
|
local str = Language[12817] ..
|
|
PlayerManager.serverInfo.name .. "\n" .. Language[12818] .. PlayerManager.nickName ..
|
|
"\n" .. Language[12819] .. AppConst.OpenId .. "\n" .. Language[12820] .. PlayerManager.uid
|
|
AndroidDeviceInfo.Instance:SetCopyValue(str)
|
|
PopupTipPanel.ShowTip(Language[12821])
|
|
end)
|
|
|
|
BindRedPointObject(RedPointType.Setting_Head, this.headRedpot)
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function SettingInfo:AddListener()
|
|
Game.GlobalEvent:AddEvent(GameEvent.Player.OnHeadFrameChange, this.RefreshPlayerInfoShow)
|
|
Game.GlobalEvent:AddEvent(GameEvent.Player.OnHeadChange, this.RefreshPlayerInfoShow)
|
|
Game.GlobalEvent:AddEvent(GameEvent.Player.OnChangeName, this.RefreshPlayerInfoShow)
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function SettingInfo:RemoveListener()
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Player.OnHeadFrameChange, this.RefreshPlayerInfoShow)
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Player.OnHeadChange, this.RefreshPlayerInfoShow)
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Player.OnChangeName, this.RefreshPlayerInfoShow)
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function SettingInfo:OnOpen()
|
|
end
|
|
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
function SettingInfo:OnShow()
|
|
this:SetTipShow()
|
|
this:SetReslutionTipShow()
|
|
this.cdKey:SetActive(true)
|
|
this.RefreshPlayerInfoShow()
|
|
this.BGMSlider.value = SettingManager.GetSettingData(SETTING_TYPE.BGM_RATIO)
|
|
this.SoundSlider.value = SettingManager.GetSettingData(SETTING_TYPE.SOUND_RATIO)
|
|
this:OnShowData()
|
|
end
|
|
|
|
function this.RefreshPlayerInfoShow()
|
|
if not this.playerHead then
|
|
--this.playerHead = CommonPool.CreateNode(POOL_ITEM_TYPE.PLAYER_HEAD, this.headpos)
|
|
this.playerHead = SubUIManager.Open(SubUIConfig.PlayerHeadView, this.headpos.transform)
|
|
end
|
|
this.playerHead:Reset()
|
|
this.playerHead:SetHead(PlayerManager.head)
|
|
this.playerHead:SetFrame(HeadManager.GetCurFrameId())
|
|
this.playerHead:SetLevel(PlayerManager.level)
|
|
this.playerHead:SetLayer(this.rootPanel.sortingOrder)
|
|
this.playerHead:SetEffectScale(1.1)
|
|
|
|
this.name:GetComponent("Text").text = PracticeManager.SetNameColor(PlayerManager.nickName,
|
|
PracticeManager.PracticeLevel)
|
|
this.exp.value = PlayerManager.exp / PlayerManager.userLevelData[PlayerManager.level].Exp
|
|
this.expText.text = PlayerManager.exp .. "/" .. PlayerManager.userLevelData[PlayerManager.level].Exp
|
|
this.uidText.text = PlayerManager.uid
|
|
this.idText.text = AppConst.OpenId or LoginManager.openId
|
|
local guildData = MyGuildManager.GetMyGuildInfo()
|
|
this.guildText.text = guildData == nil and Language[10179] or guildData.name
|
|
this.serverText.text = PlayerManager.serverInfo.name
|
|
end
|
|
|
|
function SettingInfo:OnSortingOrderChange()
|
|
-- 头像层级
|
|
if this.playerHead then
|
|
this.playerHead:SetLayer(this.rootPanel.sortingOrder)
|
|
end
|
|
end
|
|
|
|
function SettingInfo:OnShowData()
|
|
|
|
end
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
function SettingInfo:OnClose()
|
|
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function SettingInfo:OnDestroy()
|
|
this.spLoader:Destroy()
|
|
|
|
--SubUIManager.Close(this.UpView)
|
|
if this.playerHead then
|
|
this.playerHead:Recycle()
|
|
this.playerHead = nil
|
|
end
|
|
ClearRedPointObject(RedPointType.Setting_Head)
|
|
end
|
|
|
|
return SettingInfo
|