using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using LitJson;
|
|
|
namespace vnxbqy.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] ToggleButton m_IsNotShowBroadEffect; //隐藏广播特效
|
|
[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] Button m_UpdateNotice;
|
[SerializeField] Button m_CleanCache;
|
|
[SerializeField] Text m_PlayerInfoText;
|
[SerializeField] Button m_CopyBtn;
|
[SerializeField] Button m_LanguageDropdown;
|
[SerializeField] Text m_LDLabel;
|
[SerializeField] Button m_LDTemplate;
|
[SerializeField] GameObject m_LDListView;
|
[SerializeField] GameObject m_LanguageMenu;
|
|
|
#endregion
|
bool bShowAccount = true;
|
bool isInited = false;
|
|
private int playerSyncCountRef = 15;
|
private string copyContent;
|
string accountStr;
|
string sid;
|
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_IsNotShowBroadEffect.AddListener(OnShowOrHideEffect);
|
|
m_SyncPlayerSlider.AddListener(OnPlayerSyncCountChange);
|
|
m_SwitchAccountBtn.AddListener(ClickSwitchAccountBtn);
|
m_SwitchServer.SetListener(ClickSwitchServerButton);
|
m_LockScreenBtn.AddListener(ClickLockScreen);
|
m_CopyBtn.AddListener(ClickCopyBtn);
|
m_AntiAddition.AddListener(AntiAdditction);
|
m_UpdateNotice.SetListener(() => {
|
GameNotice.OpenGameNoticeForce();
|
});
|
|
m_LanguageDropdown.onClick.AddListener(() =>
|
{
|
m_LDListView.SetActive(!m_LDListView.activeInHierarchy);
|
});
|
|
m_CleanCache.SetListener(ResourcesPath.Instance.CleanCache);
|
}
|
|
protected override void OnPreOpen()
|
{
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
isInited = false;
|
loginModel.accountBindOkEvent -= UpdateAccountBindTitle;
|
SystemSetting.Instance.gameFrameChangeEvent -= OnSwitchGameFrame;
|
SystemSetting.Instance.playerSyncCountChangeEvent -= OnPlayerSyncCountChange;
|
SystemSetting.Instance.SetPlayerSyncCount(playerSyncCountRef);
|
}
|
protected override void OnAfterClose()
|
{
|
m_LDListView.SetActive(true);
|
}
|
|
protected override void OnActived()
|
{
|
base.OnActived();
|
|
for (int i = 0; i < GeneralDefine.checkShowSwitchAccount.Count; i++)
|
{
|
if (GeneralDefine.checkShowSwitchAccount[i] == VersionConfig.Get().appId)
|
bShowAccount = false;
|
}
|
m_SwitchAccountBtn.SetActive(bShowAccount);
|
m_SwitchServer.SetActive(bShowAccount);
|
|
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();
|
m_IsNotShowBroadEffect.isOn = LocalSave.GetBool("IsNotShowBroadEffect", false);
|
|
UpdateToggleSkin(m_HighQuality);
|
UpdateToggleSkin(m_MediumQuality);
|
UpdateToggleSkin(m_LowQuality);
|
UpdateToggleSkin(m_OtherPlayer);
|
UpdateToggleSkin(m_Monster);
|
|
InitLanguageOptions();
|
|
m_SixtyFrame.isOn = SystemSetting.Instance.GetGameFps() == GameFps.Full;
|
|
var serverName = ServerListCenter.Instance.GetServerData(ServerListCenter.Instance.currentServer.region_flag).name;
|
if (!string.IsNullOrEmpty(serverName))
|
serverName = serverName.Replace("@gm", "");
|
var playerAccount = PlayerDatas.Instance.baseData.AccID.Split('@');
|
var accountArr = new string[playerAccount.Length - 3];
|
Array.Copy(playerAccount, accountArr, playerAccount.Length - 3);
|
accountStr = string.Join("@", accountArr);
|
copyContent = StringUtility.Contact(serverName, "_", UIHelper.ServerStringTrim(PlayerDatas.Instance.baseData.PlayerName), "_ID:", accountStr);
|
m_PlayerInfoText.text = copyContent;
|
sid = UIHelper.ServerStringTrim(playerAccount[playerAccount.Length - 1]).Substring(1);
|
|
|
UpdateAccountBindTitle();
|
|
var sdkIDCheckIDAuthentication = ModelCenter.Instance.GetModel<LoginModel>().sdkIDCheckIDAuthentication;
|
var certificationState = sdkIDCheckIDAuthentication.type;
|
if (DTCB105_tagMCPlayerWallow.antiAddictionOpen)
|
{
|
if (certificationState == "1")
|
{
|
m_AntiAddition.SetActive(false);
|
}
|
else if (certificationState == "2")
|
{
|
var idNumber = sdkIDCheckIDAuthentication.card_id;
|
m_AntiAddition.SetActive(string.IsNullOrEmpty(idNumber) || !MathUtility.CheckAdult(idNumber));
|
}
|
else
|
{
|
m_AntiAddition.SetActive(true);
|
}
|
}
|
else
|
{
|
m_AntiAddition.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.SetActive(false);
|
}
|
else
|
{
|
if (bShowAccount)
|
m_SwitchAccountBtn.SetActive(true);
|
}
|
|
loginModel.accountBindOkEvent += UpdateAccountBindTitle;
|
SystemSetting.Instance.gameFrameChangeEvent += OnSwitchGameFrame;
|
SystemSetting.Instance.playerSyncCountChangeEvent += OnPlayerSyncCountChange;
|
|
isInited = true;
|
}
|
|
|
|
/// <summary>
|
/// 初始化语言选项
|
/// /// </summary>
|
private void InitLanguageOptions()
|
{
|
m_LDListView.SetActive(false);
|
if (string.IsNullOrEmpty(InitialFunctionConfig.Get("Language").Numerical1))
|
{
|
this.m_LanguageMenu.SetActive(false);
|
return;
|
}
|
var json = LitJson.JsonMapper.ToObject(InitialFunctionConfig.Get("Language").Numerical1);
|
m_LDListView.transform.ClearAllChilds();
|
m_LDLabel.text = "unknow";
|
foreach (var key in json.Keys)
|
{
|
var label = (string)json[key];
|
if (key == Language.Id)
|
m_LDLabel.text = label;
|
var item = GameObject.Instantiate(m_LDTemplate, m_LDListView.transform);
|
item.SetActive(true);
|
(item.FindComponent("Text", "Text") as Text).text = label;
|
var lgId = key;
|
item.onClick.AddListener(() =>
|
{
|
OnDropdownChanged(lgId, label);
|
});
|
}
|
}
|
|
public void OnDropdownChanged(string lgId, string label)
|
{
|
m_LDListView.SetActive(false);
|
Language.Id = lgId;
|
m_LDLabel.text = label;
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("language_tip_info"), Language.Get("language_tip_btn2"), Language.Get("language_tip_btn1"), (yes) =>
|
{
|
Debug.LogFormat("退出!:{0}", yes);
|
if (yes)
|
{
|
|
#if UNITY_EDITOR
|
UnityEditor.EditorApplication.isPlaying = false;
|
#else
|
Application.Quit();
|
#endif
|
}
|
});
|
}
|
|
private void ClickCopyBtn()
|
{
|
string copyFomat = "Server:{0}\r\nName:{1}\r\nID:{2}";
|
if (sid == "17")
|
sid = "18";
|
else if (sid == "18")
|
sid = "17";
|
ynmbxxjUtil.Instance.CopyContent(string.Format(copyFomat, sid, UIHelper.ServerStringTrim(PlayerDatas.Instance.baseData.PlayerName), accountStr));
|
}
|
|
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.SetGameFps(GameFps.Full);
|
SystemSetting.Instance.SetPlayerSyncCount(20);
|
m_Monster.isOn = true;
|
OnShowOrHideMonsters(true);
|
}
|
}
|
|
UpdateToggleSkin(m_HighQuality);
|
}
|
|
private void OnSetQualityMedium(bool _value)
|
{
|
if (_value)
|
{
|
SystemSetting.Instance.SetQualityLevel(GameQuality.Medium);
|
if (isInited)
|
{
|
SystemSetting.Instance.SetGameFps(GameFps.Half);
|
SystemSetting.Instance.SetPlayerSyncCount(8);
|
m_Monster.isOn = true;
|
OnShowOrHideMonsters(true);
|
}
|
}
|
|
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);
|
m_Monster.isOn = false;
|
OnShowOrHideMonsters(false);
|
}
|
}
|
|
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);
|
}
|
|
void OnShowOrHideEffect()
|
{
|
m_IsNotShowBroadEffect.isOn = !m_IsNotShowBroadEffect.isOn;
|
LocalSave.SetBool("IsNotShowBroadEffect", m_IsNotShowBroadEffect.isOn); //隐藏广播特效
|
}
|
|
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.SetActive(!_toggle.isOn);
|
checkText.SetActive(_toggle.isOn);
|
}
|
|
private void ClickSwitchAccountBtn()
|
{
|
DeleteUIRoot();
|
switch (VersionConfig.Get().versionAuthority)
|
{
|
case VersionAuthority.InterTest:
|
GameNetSystem.Instance.LoginOut();
|
break;
|
case VersionAuthority.Release:
|
GameNetSystem.Instance.LoginOut(); //咪噜不会回调,所以直接登出
|
ynmbxxjUtil.Instance.FreePlatformLoginout();
|
loginModel.sdkLogined = false;
|
break;
|
}
|
}
|
|
void DeleteUIRoot()
|
{
|
CameraManager.uiCamera.clearFlags = CameraClearFlags.SolidColor;
|
}
|
private void ClickSwitchServerButton()
|
{
|
DeleteUIRoot();
|
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(ynmbxxjUtil.FP_DoIDAuthentication _result)
|
{
|
ServerTipDetails.DisplayNormalTip(_result.errordesc);
|
m_AntiAddition.SetActive(_result.errorcode != "1");
|
}
|
|
private void OnPlayerSyncCountChange()
|
{
|
m_SyncPlayerSlider.value = playerSyncCountRef = SystemSetting.Instance.GetPlayerSyncCount();
|
m_SyncPlayerCount.text = playerSyncCountRef.ToString();
|
}
|
|
|
}
|
}
|