using System;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using LitJson;
|
|
|
namespace Snxxz.UI
|
{
|
public class SystemSetWin : Window
|
{
|
#region 得到组件
|
|
[SerializeField] Slider m_MusicSlider;
|
[SerializeField] Slider m_SoundEffectSlider;
|
|
[SerializeField] Toggle m_HighQuality;
|
[SerializeField] Toggle m_MediumQuality;
|
[SerializeField] Toggle m_LowQuality;
|
[SerializeField] OnOffToggle m_SixtyFrame;
|
|
[SerializeField] Toggle m_OtherPlayer;
|
[SerializeField] Toggle m_Monster;
|
|
[SerializeField] Slider m_SyncPlayerSlider;
|
[SerializeField] Text m_SyncPlayerCount;
|
|
[SerializeField] Button m_SwitchAccountBtn;
|
[SerializeField] Button m_SwitchServer;
|
[SerializeField] Text m_SwitchAccountTitle;
|
[SerializeField] Button m_LockScreenBtn;
|
[SerializeField] Button m_ServiceBulletinsBtn;
|
[SerializeField] Button m_AntiAddition;
|
|
[SerializeField] Text m_PlayerInfoText;
|
[SerializeField] Button m_CopyBtn;
|
|
#endregion
|
|
bool isInited = false;
|
|
private int playerSyncCountRef = 15;
|
private string copyContent;
|
LoginModel loginModel { get { return ModelCenter.Instance.GetModel<LoginModel>(); } }
|
|
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
isInited = false;
|
|
m_MusicSlider.onValueChanged.AddListener(OnSliderBgMusic);
|
m_SoundEffectSlider.onValueChanged.AddListener(OnSliderSoundEffect);
|
|
m_HighQuality.AddListener(OnSetQualityHigh);
|
m_MediumQuality.AddListener(OnSetQualityMedium);
|
m_LowQuality.AddListener(OnSetQualityLow);
|
m_SixtyFrame.AddListener(SwitchGameFrame);
|
|
m_OtherPlayer.AddListener(OnShowOrHideOtherPlayers);
|
m_Monster.AddListener(OnShowOrHideMonsters);
|
|
m_SyncPlayerSlider.AddListener(OnPlayerSyncCountChange);
|
|
m_SwitchAccountBtn.AddListener(ClickSwitchAccountBtn);
|
m_SwitchServer.SetListener(ClickSwitchServerButton);
|
m_LockScreenBtn.AddListener(ClickLockScreen);
|
m_CopyBtn.AddListener(ClickCopyBtn);
|
m_AntiAddition.AddListener(AntiAdditction);
|
}
|
|
protected override void OnPreOpen()
|
{
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
isInited = false;
|
loginModel.accountBindOkEvent -= UpdateAccountBindTitle;
|
SDKUtility.Instance.onFreePlatfromDoIDAuthenticationOk -= OnAuthenticationOk;
|
SystemSetting.Instance.gameFrameChangeEvent -= OnSwitchGameFrame;
|
SystemSetting.Instance.playerSyncCountChangeEvent -= OnPlayerSyncCountChange;
|
SystemSetting.Instance.SetPlayerSyncCount(playerSyncCountRef);
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
|
protected override void OnActived()
|
{
|
base.OnActived();
|
|
m_MusicSlider.value = SystemSetting.Instance.GetSoundVolume();
|
m_SoundEffectSlider.value = SystemSetting.Instance.GetSoundEffect();
|
|
m_HighQuality.isOn = SystemSetting.Instance.GetCurrentQualityLevel() == GameQuality.High;
|
m_MediumQuality.isOn = SystemSetting.Instance.GetCurrentQualityLevel() == GameQuality.Medium;
|
m_LowQuality.isOn = SystemSetting.Instance.GetCurrentQualityLevel() == GameQuality.Low;
|
m_OtherPlayer.isOn = SystemSetting.Instance.GetSystemSettingSwitch(SystemSwitch.OtherPlayer);
|
m_Monster.isOn = !SystemSetting.Instance.GetSystemSettingSwitch(SystemSwitch.HideMonster);
|
m_SyncPlayerSlider.value = playerSyncCountRef = SystemSetting.Instance.GetPlayerSyncCount();
|
m_SyncPlayerCount.text = playerSyncCountRef.ToString();
|
|
UpdateToggleSkin(m_HighQuality);
|
UpdateToggleSkin(m_MediumQuality);
|
UpdateToggleSkin(m_LowQuality);
|
UpdateToggleSkin(m_OtherPlayer);
|
UpdateToggleSkin(m_Monster);
|
|
m_SixtyFrame.isOn = SystemSetting.Instance.GetGameFps() == GameFps.Full;
|
|
var serverName = ServerListCenter.Instance.GetServerData(ServerListCenter.Instance.currentServer.region_flag).name;
|
var playerAccount = PlayerDatas.Instance.baseData.AccID.Split('@');
|
copyContent = StringUtility.Contact(serverName, "_", UIHelper.ServerStringTrim(PlayerDatas.Instance.baseData.PlayerName), "_ID:", playerAccount[0]);
|
m_PlayerInfoText.text = copyContent;
|
|
UpdateAccountBindTitle();
|
|
var sdkIDCheckIDAuthentication = ModelCenter.Instance.GetModel<LoginModel>().sdkIDCheckIDAuthentication;
|
var certificationState = sdkIDCheckIDAuthentication.type;
|
if (DTCB105_tagMCPlayerWallow.antiAddictionOpen)
|
{
|
if (certificationState == "1")
|
{
|
m_AntiAddition.gameObject.SetActive(false);
|
}
|
else if (certificationState == "2")
|
{
|
var idNumber = sdkIDCheckIDAuthentication.card_id;
|
m_AntiAddition.gameObject.SetActive(string.IsNullOrEmpty(idNumber) || !MathUtility.CheckAdult(idNumber));
|
}
|
else
|
{
|
m_AntiAddition.gameObject.SetActive(true);
|
}
|
}
|
else
|
{
|
m_AntiAddition.gameObject.SetActive(false);
|
}
|
|
var switchAccountJson = JsonMapper.ToObject(FuncSwitchConfig.Get(2).AppIdSwitch);
|
if (switchAccountJson.Keys.Contains(VersionConfig.Get().appId) && switchAccountJson[VersionConfig.Get().appId].ToString() == "0")
|
{
|
m_SwitchAccountBtn.gameObject.SetActive(false);
|
}
|
else
|
{
|
m_SwitchAccountBtn.gameObject.SetActive(true);
|
}
|
|
loginModel.accountBindOkEvent += UpdateAccountBindTitle;
|
SDKUtility.Instance.onFreePlatfromDoIDAuthenticationOk += OnAuthenticationOk;
|
SystemSetting.Instance.gameFrameChangeEvent += OnSwitchGameFrame;
|
SystemSetting.Instance.playerSyncCountChangeEvent += OnPlayerSyncCountChange;
|
|
isInited = true;
|
}
|
|
private void ClickCopyBtn()
|
{
|
SDKUtility.Instance.CopyContent(copyContent);
|
}
|
|
private void OnSliderSoundEffect(float arg0)
|
{
|
SystemSetting.Instance.SetSoundEffect(arg0);
|
}
|
|
private void OnSliderBgMusic(float arg0)
|
{
|
SystemSetting.Instance.SetSoundVolume(arg0);
|
}
|
|
private void OnSetQualityHigh(bool _value)
|
{
|
if (_value)
|
{
|
SystemSetting.Instance.SetQualityLevel(GameQuality.High);
|
if (isInited)
|
{
|
SystemSetting.Instance.SetPlayerSyncCount(10);
|
}
|
}
|
|
UpdateToggleSkin(m_HighQuality);
|
}
|
|
private void OnSetQualityMedium(bool _value)
|
{
|
if (_value)
|
{
|
SystemSetting.Instance.SetQualityLevel(GameQuality.Medium);
|
if (isInited)
|
{
|
SystemSetting.Instance.SetPlayerSyncCount(5);
|
}
|
}
|
|
UpdateToggleSkin(m_MediumQuality);
|
}
|
|
private void OnSetQualityLow(bool _value)
|
{
|
if (_value)
|
{
|
SystemSetting.Instance.SetQualityLevel(GameQuality.Low);
|
if (isInited)
|
{
|
SystemSetting.Instance.SetGameFps(GameFps.Half);
|
SystemSetting.Instance.SetPlayerSyncCount(3);
|
}
|
}
|
|
UpdateToggleSkin(m_LowQuality);
|
}
|
|
private void SwitchGameFrame()
|
{
|
var gameFrame = SystemSetting.Instance.GetGameFps();
|
|
if (gameFrame == GameFps.Half)
|
{
|
SystemSetting.Instance.SetGameFps(GameFps.Full);
|
}
|
else
|
{
|
SystemSetting.Instance.SetGameFps(GameFps.Half);
|
}
|
}
|
|
private void OnSwitchGameFrame()
|
{
|
m_SixtyFrame.isOn = SystemSetting.Instance.GetGameFps() == GameFps.Full;
|
}
|
|
private void OnShowOrHideOtherPlayers(bool _value)
|
{
|
SystemSetting.Instance.SetSystemSettingSwitch(SystemSwitch.OtherPlayer, _value);
|
UpdateToggleSkin(m_OtherPlayer);
|
}
|
|
private void OnShowOrHideMonsters(bool _value)
|
{
|
SystemSetting.Instance.SetSystemSettingSwitch(SystemSwitch.HideMonster, !_value);
|
UpdateToggleSkin(m_Monster);
|
}
|
|
private void OnPlayerSyncCountChange(float _value)
|
{
|
playerSyncCountRef = (int)_value;
|
m_SyncPlayerCount.text = playerSyncCountRef.ToString();
|
}
|
|
private void UpdateToggleSkin(Toggle _toggle)
|
{
|
var bgText = _toggle.GetComponent<Text>("Background/Background_text");
|
var checkText = _toggle.GetComponent<Text>("Background/Checkmark_text");
|
|
bgText.gameObject.SetActive(!_toggle.isOn);
|
checkText.gameObject.SetActive(_toggle.isOn);
|
}
|
|
private void ClickSwitchAccountBtn()
|
{
|
switch (VersionConfig.Get().versionAuthority)
|
{
|
case VersionAuthority.InterTest:
|
GameNetSystem.Instance.LoginOut();
|
break;
|
case VersionAuthority.Release:
|
SDKUtility.Instance.FreePlatformLoginout();
|
break;
|
}
|
}
|
|
private void ClickSwitchServerButton()
|
{
|
GameNetSystem.Instance.LoginOut();
|
}
|
|
private void ClickLockScreen()
|
{
|
if (!WindowJumpMgr.Instance.IsJumpState)
|
{
|
if (!WindowCenter.Instance.IsOpen<MainInterfaceWin>())
|
{
|
WindowCenter.Instance.Open<MainInterfaceWin>();
|
}
|
}
|
|
WindowCenter.Instance.Close<SettingUpWin>();
|
|
if (!WindowCenter.Instance.IsOpen<LockedScreenWin>())
|
{
|
WindowCenter.Instance.Open<LockedScreenWin>();
|
}
|
}
|
|
private void UpdateAccountBindTitle()
|
{
|
m_SwitchAccountTitle.text = Language.Get("SwitchAccount");
|
}
|
|
private void AntiAdditction()
|
{
|
WindowCenter.Instance.Open<AntiAddictionWin>();
|
}
|
|
private void OnAuthenticationOk(SDKUtility.FP_DoIDAuthentication _result)
|
{
|
ServerTipDetails.DisplayNormalTip(_result.errordesc);
|
m_AntiAddition.gameObject.SetActive(_result.errorcode != "1");
|
}
|
|
private void OnPlayerSyncCountChange()
|
{
|
m_SyncPlayerSlider.value = playerSyncCountRef = SystemSetting.Instance.GetPlayerSyncCount();
|
m_SyncPlayerCount.text = playerSyncCountRef.ToString();
|
}
|
|
}
|
}
|