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

155 lines
6.1 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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")
end
--绑定事件(用于子类重写)
function SettingInfo:BindEvent()
--cdKey兑换
Util.AddClick(this.cdKey, function()
UIManager.OpenPanel(UIName.CDKeyExchangePanel)
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("您确定要重新登录?", nil, function()
Framework.Dispose()
App.Instance:ReStart()
end)
end)
Util.AddClick(this.btnOneKeyCopy, function()
if not UnityEngine.Application.isMobilePlatform then
PopupTipPanel.ShowTip("不支持当前平台")
return
end
local str = "服务器名:" .. PlayerManager.serverInfo.name .. "\n" .. "角色名:" .. PlayerManager.nickName ..
"\n" .. "账号ID" .. AppConst.OpenId .. "\n" .. "角色ID" .. PlayerManager.uid
AndroidDeviceInfo.Instance:SetCopyValue(str)
PopupTipPanel.ShowTip("复制成功")
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
local guildData = MyGuildManager.GetMyGuildInfo()
this.guildText.text = guildData == nil and "" 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