miduo_client/Assets/ManagedResources/~Lua/Modules/Setting/SettingInfo.lua

158 lines
6.3 KiB
Lua

local SettingInfo = quick_class("SettingInfo")
local this = SettingInfo
function SettingInfo:ctor(mainPanel, gameObject)
self.mainPanel = mainPanel
self.gameObject = gameObject
self:InitComponent(gameObject)
self:BindEvent()
end
--初始化组件(用于子类重写)
function SettingInfo:InitComponent(gameObject)
this.head = Util.GetGameObject(gameObject, "playerInfo/head")
this.headpos = Util.GetGameObject(gameObject, "playerInfo/head/pos")
this.headRedpot = Util.GetGameObject(gameObject, "playerInfo/head/redpot")
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.cdKey = Util.GetGameObject(gameObject, "other/box/cdkey")
this.submit = Util.GetGameObject(gameObject, "other/box/submit")
end
--绑定事件(用于子类重写)
function SettingInfo:BindEvent()
--cdKey兑换
Util.AddClick(this.cdKey, function()
UIManager.OpenPanel(UIName.CDKeyExchangePanel)
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[11895], nil, function()
Game.Logout()
end)
end)
Util.AddClick(this.btnOneKeyCopy, function()
if not UnityEngine.Application.isMobilePlatform then
PopupTipPanel.ShowTip(Language[11896])
return
end
local str = Language[11897] .. PlayerManager.serverInfo.name .. "\n" .. Language[11898] .. PlayerManager.nickName ..
"\n" .. Language[11899] .. AppConst.OpenId .. "\n" .. Language[11900] .. PlayerManager.uid
AndroidDeviceInfo.Instance:SetCopyValue(str)
PopupTipPanel.ShowTip(Language[11901])
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.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(PlayerManager.frame)
this.playerHead:SetLevel(PlayerManager.level)
this.name:GetComponent("Text").text = PlayerManager.nickName
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[10094] or guildData.name
this.serverText.text = PlayerManager.serverInfo.name
end
function SettingInfo:OnSortingOrderChange()
end
function SettingInfo:OnShowData()
end
--界面关闭时调用(用于子类重写)
function SettingInfo:OnClose()
end
--界面销毁时调用(用于子类重写)
function SettingInfo:OnDestroy()
--SubUIManager.Close(this.UpView)
if this.playerHead then
this.playerHead:Recycle()
this.playerHead = nil
end
ClearRedPointObject(RedPointType.Setting_Head)
end
return SettingInfo