From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Assets/Scripts/XMainClient/XOptionsDocument.cs | 1257 ++++++++++++++++++++ 1 file changed, 1257 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XOptionsDocument.cs (limited to 'Client/Assets/Scripts/XMainClient/XOptionsDocument.cs') diff --git a/Client/Assets/Scripts/XMainClient/XOptionsDocument.cs b/Client/Assets/Scripts/XMainClient/XOptionsDocument.cs new file mode 100644 index 00000000..bf1ad4d0 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XOptionsDocument.cs @@ -0,0 +1,1257 @@ +using System; +using System.Collections.Generic; +using System.IO; +using KKSG; +using MiniJSON; +using UnityEngine; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUpdater; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XOptionsDocument : XDocComponent + { + public override uint ID + { + get + { + return XOptionsDocument.uuID; + } + } + + public XOptionsView View + { + get + { + return this._view; + } + set + { + this._view = value; + } + } + + public new static readonly uint uuID = XSingleton.singleton.XHash("OptionsDocument"); + + private XOptionsView _view = null; + + public static readonly int SIGHT_NUM = 3; + + public static readonly int MAGNIFICATION_MULTIPLE = 1000; + + private readonly int[] _QualityLevel = new int[] + { + 0, + 3, + 5 + }; + + private Dictionary options = new Dictionary(default(XFastEnumIntEqualityComparer)); + + private Dictionary floatOptions = new Dictionary(default(XFastEnumIntEqualityComparer)); + + private Dictionary strOptions = new Dictionary(default(XFastEnumIntEqualityComparer)); + + public static Dictionary pushSettings = new Dictionary(); + + public static Dictionary localPushSetting = new Dictionary(); + + public static PushSetting _pushSettingTable = new PushSetting(); + + public static PushMessageTable _pushMessageTable = new PushMessageTable(); + + public static List _pushSetting1 = new List(); + + public static List _pushSetting2 = new List(); + + public static XOptions _optionsTable = new XOptions(); + + public static List>> optionsData = new List>>(); + + public static Dictionary optionsDefault = new Dictionary(default(XFastEnumIntEqualityComparer)); + + public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader(); + + public bool openVoice = true; + + public float voiceVolme = 1f; + + private float bgmVolme; + + private float mscVolme; + + public bool Flowerrain; + + private static XOptionsDocument.OptionData optionDefault = default(XOptionsDocument.OptionData); + + private float lastSameScreenValue; + + private float lastSound = -1f; + + private float lastMusic = -1f; + + private float lastVoice = -1f; + + private bool openSound; + + private bool openMusic; + + public struct OptionData + { + public string[,] val; + + public bool NeedSight; + + public bool[] NeedProfession; + + public void Init() + { + this.val = new string[XOptionsDocument.SIGHT_NUM, XGame.RoleCount]; + this.NeedProfession = new bool[XOptionsDocument.SIGHT_NUM]; + } + } + + public override void OnAttachToHost(XObject host) + { + base.OnAttachToHost(host); + this.LoadSetting(); + this.RefreshLocalSettings(); + XSingleton.singleton.XPlatform.SendGameExData("push_local_clear", ""); + } + + public static void Execute(OnLoadedCallback callback = null) + { + XOptionsDocument.AsyncLoader.AddTask("Table/PushSetting", XOptionsDocument._pushSettingTable, false); + XOptionsDocument.AsyncLoader.AddTask("Table/PushMessage", XOptionsDocument._pushMessageTable, false); + XOptionsDocument.AsyncLoader.AddTask("Table/XOptions", XOptionsDocument._optionsTable, false); + XOptionsDocument.AsyncLoader.Execute(callback); + } + + public static void OnTableLoaded() + { + XOptionsDocument.pushSettings.Clear(); + for (int i = 0; i < XOptionsDocument._pushSettingTable.Table.Length; i++) + { + bool flag = XOptionsDocument._pushSettingTable.Table[i].TimeOrSystem == 1u; + if (flag) + { + XOptionsDocument._pushSetting1.Add(XOptionsDocument._pushSettingTable.Table[i]); + } + else + { + bool flag2 = XOptionsDocument._pushSettingTable.Table[i].TimeOrSystem == 2u; + if (flag2) + { + XOptionsDocument._pushSetting2.Add(XOptionsDocument._pushSettingTable.Table[i]); + } + } + string configKey = XOptionsDocument._pushSettingTable.Table[i].ConfigKey; + XOptionsDocument.pushSettings.Add(configKey, 1); + } + XOptionsDocument.optionsData.Clear(); + for (int j = 0; j < XFastEnumIntEqualityComparer.ToInt(OptionsBattleTab.OtherTab); j++) + { + XOptionsDocument.optionsData.Add(new List>()); + XOptionsDefine option = XOptionsDefine.OD_VIEW + j; + XOptions.RowData optionData = XOptionsDocument.GetOptionData(option); + bool flag3 = optionData.OptionText != null; + if (flag3) + { + for (int k = 0; k < optionData.OptionText.Length; k++) + { + XOptionsDocument.optionsData[j].Add(new List()); + } + } + else + { + XOptionsDocument.optionsData[j].Add(new List()); + } + } + for (int l = 0; l < XOptionsDocument._optionsTable.Table.Length; l++) + { + int id = XOptionsDocument._optionsTable.Table[l].ID; + int num = XOptionsDocument._optionsTable.Table[l].Classify[0]; + int num2 = XOptionsDocument._optionsTable.Table[l].Classify[1]; + int type = XOptionsDocument._optionsTable.Table[l].Type; + int sort = XOptionsDocument._optionsTable.Table[l].Sort; + bool flag4 = id <= 0; + if (!flag4) + { + XOptions.RowData rowData = XOptionsDocument._optionsTable.Table[l]; + bool flag5 = rowData.ID != 0; + if (flag5) + { + XOptionsDocument.optionDefault.Init(); + string[] array = rowData.Default.Split(new char[] + { + '|' + }); + XOptionsDocument.optionDefault.NeedSight = (array.Length != 1); + for (int m = 0; m < XOptionsDocument.SIGHT_NUM; m++) + { + bool flag6 = array.Length == 1; + string text; + if (flag6) + { + text = array[0]; + } + else + { + text = array[m]; + } + string[] array2 = text.Split(new char[] + { + '=' + }); + XOptionsDocument.optionDefault.NeedProfession[m] = (array2.Length != 1); + for (int n = 0; n < XGame.RoleCount; n++) + { + bool flag7 = array2.Length == 1; + string text2; + if (flag7) + { + text2 = array2[0]; + } + else + { + text2 = array2[n]; + } + XOptionsDocument.optionDefault.val[m, n] = text2; + } + } + XOptionsDocument.optionsDefault.Add((XOptionsDefine)rowData.ID, XOptionsDocument.optionDefault); + } + bool flag8 = (num == 0 && num2 == 0) || type == 0; + if (!flag8) + { + bool flag9 = XOptionsDocument.optionsData.Count >= num && XOptionsDocument.optionsData[num - 1].Count >= num2; + if (flag9) + { + XOptionsDocument.optionsData[num - 1][num2 - 1].Add(rowData); + } + else + { + XSingleton.singleton.AddErrorLog("XOptions Table Error! ID:" + rowData.ID, null, null, null, null, null); + } + } + } + } + for (int num3 = 0; num3 < XOptionsDocument.optionsData.Count; num3++) + { + for (int num4 = 0; num4 < XOptionsDocument.optionsData[num3].Count; num4++) + { + XOptionsDocument.optionsData[num3][num4].Sort(new Comparison(XOptionsDocument.SortCompare)); + } + } + } + + public static XOptions.RowData GetOptionData(XOptionsDefine option) + { + return XOptionsDocument.GetOptionData(XFastEnumIntEqualityComparer.ToInt(option)); + } + + public static XOptions.RowData GetOptionData(int optionID) + { + return XOptionsDocument._optionsTable.GetByID(optionID); + } + + private static int SortCompare(XOptions.RowData item1, XOptions.RowData item2) + { + int sort = item1.Sort; + int sort2 = item2.Sort; + bool flag = sort == sort2; + int result; + if (flag) + { + result = -item1.ID.CompareTo(item2.ID); + } + else + { + result = -sort.CompareTo(sort2); + } + return result; + } + + public override void OnEnterSceneFinally() + { + SceneTable.RowData sceneData = XSingleton.singleton.GetSceneData(XSingleton.singleton.SceneID); + bool flag = sceneData != null && sceneData.ShieldSight != null; + if (flag) + { + for (int i = 0; i < sceneData.ShieldSight.Length; i++) + { + bool flag2 = (int)sceneData.ShieldSight[i] == this.GetValue(XOptionsDefine.OD_VIEW); + if (flag2) + { + this.SetDefaultSight(sceneData.ShieldSight); + break; + } + } + } + this.SetBattleOptionValue(); + bool flag3 = DlgBase.singleton.IsVisible(); + if (flag3) + { + DlgBase.singleton.SetView(XSingleton.singleton.OperationMode); + } + bool flag4 = XSingleton.singleton.SceneType == SceneType.SCENE_HORSE_RACE || XSingleton.singleton.SceneType == SceneType.SCENE_WEEKEND4V4_HORSERACING; + if (flag4) + { + } + } + + private void SetDefaultSight(byte[] shieldSight) + { + for (XOperationMode xoperationMode = XOperationMode.X25D; xoperationMode <= XOperationMode.X3D_Free; xoperationMode++) + { + bool flag = true; + for (int i = 0; i < shieldSight.Length; i++) + { + bool flag2 = (XOperationMode)shieldSight[i] == xoperationMode; + if (flag2) + { + flag = false; + break; + } + } + bool flag3 = flag; + if (flag3) + { + this.SetValue(XOptionsDefine.OD_VIEW, XFastEnumIntEqualityComparer.ToInt(xoperationMode), false); + XSingleton.singleton.AddGreenLog("Auto Change Sight:" + xoperationMode.ToString(), null, null, null, null, null); + return; + } + } + XSingleton.singleton.AddErrorLog("No Default Sight", null, null, null, null, null); + } + + public override void OnGamePause(bool pause) + { + XSingleton.singleton.AddLog("push_local_clear", null, null, null, null, null, XDebugColor.XDebug_None); + XSingleton.singleton.XPlatform.SendGameExData("push_local_clear", ""); + if (pause) + { + DateTime now = DateTime.Now; + int hour = now.Hour; + int minute = now.Minute; + int num = Convert.ToInt32(DateTime.Now.DayOfWeek.ToString("d")); + for (int i = 0; i < XOptionsDocument._pushMessageTable.Table.Length; i++) + { + PushMessageTable.RowData rowData = XOptionsDocument._pushMessageTable.Table[i]; + bool flag = rowData.IsCommonGlobal == 1u && this.IsPushOpen(rowData.Type); + if (flag) + { + bool flag2 = rowData.WeekDay == null || rowData.WeekDay.Length == 0; + if (flag2) + { + bool flag3 = (ulong)rowData.Time[0] > (ulong)((long)hour) || ((ulong)rowData.Time[0] == (ulong)((long)hour) && (ulong)rowData.Time[1] > (ulong)((long)minute)); + if (flag3) + { + XSingleton.singleton.XPlatform.SendGameExData("push_local", this.MakeJson(rowData, now)); + } + DateTime date = now.AddDays(1.0); + XSingleton.singleton.XPlatform.SendGameExData("push_local", this.MakeJson(rowData, date)); + DateTime date2 = now.AddDays(2.0); + XSingleton.singleton.XPlatform.SendGameExData("push_local", this.MakeJson(rowData, date2)); + } + else + { + for (int j = 0; j < rowData.WeekDay.Length; j++) + { + bool flag4 = rowData.WeekDay[j] == (uint)num; + if (flag4) + { + bool flag5 = (ulong)rowData.Time[0] > (ulong)((long)hour) || ((ulong)rowData.Time[0] == (ulong)((long)hour) && (ulong)rowData.Time[1] > (ulong)((long)minute)); + if (flag5) + { + XSingleton.singleton.XPlatform.SendGameExData("push_local", this.MakeJson(rowData, now)); + } + } + else + { + bool flag6 = rowData.WeekDay[j] > (uint)num; + if (flag6) + { + DateTime date3 = now.AddDays((double)((ulong)rowData.WeekDay[j] - (ulong)((long)num))); + XSingleton.singleton.XPlatform.SendGameExData("push_local", this.MakeJson(rowData, date3)); + } + } + } + } + } + } + } + base.OnGamePause(pause); + } + + private string MakeJson(PushMessageTable.RowData row, DateTime date) + { + Dictionary dictionary = new Dictionary(); + dictionary["title"] = row.Title; + dictionary["content"] = row.Content; + dictionary["type"] = 1; + bool flag = (int)Application.platform == 8; + if (flag) + { + dictionary["date"] = date.ToString("yyyy-MM-dd"); + dictionary["hour"] = ((row.Time[0] < 10u) ? ("0" + row.Time[0].ToString()) : row.Time[0].ToString()); + dictionary["min"] = ((row.Time[1] < 10u) ? ("0" + row.Time[1].ToString()) : row.Time[1].ToString()); + } + else + { + dictionary["date"] = date.ToString("yyyyMMdd"); + dictionary["hour"] = row.Time[0]; + dictionary["min"] = row.Time[1]; + } + string text = Json.Serialize(dictionary); + XSingleton.singleton.AddLog(Application.platform.ToString(), " => ", text, null, null, null, XDebugColor.XDebug_None); + return text; + } + + private bool IsPushOpen(uint type) + { + for (int i = 0; i < XOptionsDocument._pushSettingTable.Table.Length; i++) + { + bool flag = XOptionsDocument._pushSettingTable.Table[i].Type == type; + if (flag) + { + return XOptionsDocument.pushSettings[XOptionsDocument._pushSettingTable.Table[i].ConfigKey] == 1; + } + } + return true; + } + + public void OnBlockOtherPlayers() + { + this.ProccessOption(XOptionsDefine.OD_BLOCKOTHERPLAYERS, this.GetValue(XOptionsDefine.OD_BLOCKOTHERPLAYERS)); + } + + protected override void EventSubscribe() + { + base.EventSubscribe(); + base.RegisterEvent(XEventDefine.XEvent_AudioOperation, new XComponent.XEventHandler(this.OnChatVoiceHandled)); + } + + public void InitServerConfig(RoleConfig serverConfig) + { + bool flag = serverConfig != null; + if (flag) + { + bool flag2 = serverConfig.type.Count != serverConfig.value.Count; + if (flag2) + { + XSingleton.singleton.AddErrorLog("serverConfig.type.Count != serverConfig.value.Count", null, null, null, null, null); + } + else + { + Type typeFromHandle = typeof(XOptionsDefine); + for (int i = 0; i < serverConfig.type.Count; i++) + { + try + { + bool flag3 = XOptionsDocument.pushSettings.ContainsKey(serverConfig.type[i]); + if (flag3) + { + bool flag4 = !XOptionsDocument.localPushSetting.ContainsKey(serverConfig.type[i]); + if (flag4) + { + XOptionsDocument.pushSettings[serverConfig.type[i]] = int.Parse(serverConfig.value[i]); + } + } + else + { + XOptionsDefine xoptionsDefine = (XOptionsDefine)Enum.Parse(typeFromHandle, serverConfig.type[i]); + XOptionsDefine xoptionsDefine2 = xoptionsDefine; + if (xoptionsDefine2 != XOptionsDefine.OD_TEAM_PASSWORD) + { + XOptions.RowData optionData = XOptionsDocument.GetOptionData(xoptionsDefine); + bool flag5 = optionData != null && optionData.Type != 0; + if (flag5) + { + bool flag6 = optionData.Type == 2; + if (flag6) + { + float value; + bool flag7 = float.TryParse(serverConfig.value[i], out value); + if (flag7) + { + this.floatOptions[xoptionsDefine] = value; + } + this.ProccessOption(xoptionsDefine, this.GetFloatValue(xoptionsDefine)); + } + else + { + int value2; + bool flag8 = int.TryParse(serverConfig.value[i], out value2); + if (flag8) + { + this.options[xoptionsDefine] = value2; + } + this.ProccessOption(xoptionsDefine, this.GetValue(xoptionsDefine)); + } + } + } + else + { + this.strOptions.Add(xoptionsDefine, serverConfig.value[i]); + } + } + } + catch (ArgumentException) + { + XSingleton.singleton.AddGreenLog(string.Format("'{0}' is not a member of the XOptionsDefine enumeration.", serverConfig.type[i]), null, null, null, null, null); + } + } + } + } + } + + public void RefreshLocalSettings() + { + for (XOptionsDefine xoptionsDefine = XOptionsDefine.OD_START; xoptionsDefine != XOptionsDefine.OD_LOCALSETTING_END; xoptionsDefine++) + { + this.ProccessOption(xoptionsDefine, this.GetValue(xoptionsDefine)); + } + } + + public void LoadSetting() + { + string path = Application.persistentDataPath + "/options.txt"; + bool flag = (int)Application.platform == 7 || (int)Application.platform == 0 || (int)Application.platform == 2; + if (flag) + { + path = Application.dataPath + "/options.txt"; + } + this.options.Clear(); + bool flag2 = !File.Exists(path); + if (!flag2) + { + using (StreamReader streamReader = new StreamReader(path)) + { + Type typeFromHandle = typeof(XOptionsDefine); + string text; + while ((text = streamReader.ReadLine()) != null) + { + string[] array = text.Split(XGlobalConfig.SpaceSeparator); + bool flag3 = array.Length != 2; + if (flag3) + { + XSingleton.singleton.AddErrorLog("Option file format error: ", text, null, null, null, null); + } + else + { + try + { + bool flag4 = XOptionsDocument.pushSettings.ContainsKey(array[0]); + if (flag4) + { + int value = int.Parse(array[1]); + XOptionsDocument.pushSettings[array[0]] = value; + XOptionsDocument.localPushSetting[array[0]] = value; + } + else + { + XOptionsDefine key = (XOptionsDefine)Enum.Parse(typeFromHandle, array[0]); + this.options.Add(key, int.Parse(array[1])); + } + } + catch (ArgumentException) + { + XSingleton.singleton.AddErrorLog(string.Format("'{0}' is not a member of the XOptionsDefine enumeration.", array[0]), null, null, null, null, null); + } + } + } + } + } + } + + public void SaveSetting() + { + try + { + string text = Application.persistentDataPath + "/options.txt"; + bool flag = (int)Application.platform == 7 || (int)Application.platform == 0 || (int)Application.platform == 2; + if (flag) + { + text = Application.dataPath + "/options.txt"; + } + using (StreamWriter streamWriter = new StreamWriter(text)) + { + foreach (KeyValuePair keyValuePair in XOptionsDocument.localPushSetting) + { + streamWriter.Write(keyValuePair.Key); + streamWriter.Write(' '); + streamWriter.WriteLine(keyValuePair.Value); + } + foreach (KeyValuePair keyValuePair2 in this.options) + { + bool flag2 = keyValuePair2.Key >= XOptionsDefine.OD_LOCALSETTING_END; + if (!flag2) + { + streamWriter.Write(keyValuePair2.Key); + streamWriter.Write(' '); + streamWriter.WriteLine(keyValuePair2.Value); + } + } + foreach (KeyValuePair keyValuePair3 in this.floatOptions) + { + bool flag3 = keyValuePair3.Key >= XOptionsDefine.OD_LOCALSETTING_END; + if (!flag3) + { + streamWriter.Write(keyValuePair3.Key); + streamWriter.Write(' '); + streamWriter.WriteLine(keyValuePair3.Value); + } + } + XSingleton.singleton.XPlatform.SetNoBackupFlag(text); + } + } + catch (Exception) + { + XSingleton.singleton.AddErrorLog("Save Setting Error", null, null, null, null, null); + } + } + + public void ReqSwitchAccount() + { + XSingleton.singleton.Close(NetErrCode.Net_NoError); + XSingleton.singleton.AuthorizationSignOut(); + } + + public void ReqSwitchChar() + { + RpcC2M_ReturnToSelectRole rpc = new RpcC2M_ReturnToSelectRole(); + XSingleton.singleton.Send(rpc); + } + + public void ReqCustomerService() + { + XSingleton.singleton.AddLog("CS coming soon!", null, null, null, null, null, XDebugColor.XDebug_None); + } + + public void OpenCustomerService() + { + Dictionary dictionary = new Dictionary(); + RuntimePlatform platform = Application.platform; + if ((int)platform != 8) + { + if ((int)platform != 11) + { + XSingleton.singleton.AddGreenLog("CustomerService-Options", null, null, null, null, null); + } + else + { + dictionary["url"] = XSingleton.singleton.GetValue("CustomerServiceSetAndroid"); + dictionary["screendir"] = "SENSOR"; + XSingleton.singleton.XPlatform.SendExtDara("open_url", Json.Serialize(dictionary)); + } + } + else + { + dictionary["url"] = XSingleton.singleton.GetValue("CustomerServiceSetApple"); + dictionary["screendir"] = "SENSOR"; + XSingleton.singleton.XPlatform.SendExtDara("open_url", Json.Serialize(dictionary)); + } + } + + public void OpenURL(string url) + { + Application.OpenURL(url); + } + + public override void Update(float fDeltaT) + { + base.Update(fDeltaT); + bool flag = DlgBase.singleton.IsVisible() && this.View.CurrentTab == OptionsTab.OptionTab && (double)Math.Abs(this.lastSameScreenValue - this.View.uiBehaviour.m_SameScreenBar.value) > 1E-05; + if (flag) + { + this.lastSameScreenValue = this.View.uiBehaviour.m_SameScreenBar.value; + this.View.SameScreenNumChange(this.lastSameScreenValue); + } + bool flag2 = DlgBase.singleton.IsVisible() && this.View.CurrentTab == OptionsTab.OptionTab && (double)Math.Abs(this.lastSound - this.View.uiBehaviour.m_SoundBar.value) > 1E-05; + if (flag2) + { + this.lastSound = this.View.uiBehaviour.m_SoundBar.value; + this.SetValue(XOptionsDefine.BA_SOUND, (int)(this.lastSound * 100f), false); + this.ProccessOption(XOptionsDefine.BA_SOUND, (int)(this.lastSound * 100f)); + } + bool flag3 = DlgBase.singleton.IsVisible() && this.View.CurrentTab == OptionsTab.OptionTab && (double)Math.Abs(this.lastMusic - this.View.uiBehaviour.m_MusicBar.value) > 1E-05; + if (flag3) + { + this.lastMusic = this.View.uiBehaviour.m_MusicBar.value; + this.SetValue(XOptionsDefine.BA_MUSIC, (int)(this.lastMusic * 100f), false); + this.ProccessOption(XOptionsDefine.BA_MUSIC, (int)(this.lastMusic * 100f)); + } + bool flag4 = DlgBase.singleton.IsVisible() && this.View.CurrentTab == OptionsTab.OptionTab && (double)Math.Abs(this.lastVoice - this.View.uiBehaviour.m_VoiceBar.value) > 1E-05; + if (flag4) + { + this.lastVoice = this.View.uiBehaviour.m_VoiceBar.value; + this.SetValue(XOptionsDefine.BA_VOICE, (int)(this.lastVoice * 100f), false); + this.ProccessOption(XOptionsDefine.BA_VOICE, (int)(this.lastVoice * 100f)); + } + } + + private PushSetting.RowData GetPushSettingRow(string option) + { + for (int i = 0; i < XOptionsDocument._pushSettingTable.Table.Length; i++) + { + bool flag = XOptionsDocument._pushSettingTable.Table[i].ConfigKey == option; + if (flag) + { + return XOptionsDocument._pushSettingTable.Table[i]; + } + } + return null; + } + + public void SavePushValue(string option, int value) + { + bool flag = XOptionsDocument.pushSettings.ContainsKey(option); + if (flag) + { + XOptionsDocument.pushSettings[option] = value; + bool flag2 = this.GetPushSettingRow(option).TimeOrSystem == 1u; + if (flag2) + { + XOptionsDocument.localPushSetting[option] = value; + } + else + { + RpcC2G_SetRoleConfig rpcC2G_SetRoleConfig = new RpcC2G_SetRoleConfig(); + rpcC2G_SetRoleConfig.oArg.type = option; + rpcC2G_SetRoleConfig.oArg.value = value.ToString(); + XSingleton.singleton.Send(rpcC2G_SetRoleConfig); + } + } + else + { + XSingleton.singleton.AddErrorLog("not push type ", option, null, null, null, null); + } + } + + private void SaveToCloud(XOptionsDefine option, int value) + { + this.SaveToCloud(option, value.ToString()); + } + + private void SaveToCloud(XOptionsDefine option, string value) + { + bool flag = option > XOptionsDefine.OD_LOCALSETTING_END; + if (flag) + { + RpcC2G_SetRoleConfig rpcC2G_SetRoleConfig = new RpcC2G_SetRoleConfig(); + rpcC2G_SetRoleConfig.oArg.type = option.ToString(); + rpcC2G_SetRoleConfig.oArg.value = value; + XSingleton.singleton.Send(rpcC2G_SetRoleConfig); + } + } + + public bool SetValue(XOptionsDefine option, int value, bool isMustSave = false) + { + bool flag = !isMustSave && this.GetValue(option) == value; + bool result; + if (flag) + { + result = false; + } + else + { + this.options[option] = value; + this.ProccessOption(option, value); + this.SaveToCloud(option, value); + result = true; + } + return result; + } + + public bool SetSliderValue(XOptionsDefine option, float value) + { + bool flag = this.GetFloatValue(option) == value; + bool result; + if (flag) + { + result = false; + } + else + { + this.floatOptions[option] = value; + this.ProccessOption(option, value); + this.SaveToCloud(option, value.ToString()); + result = true; + } + return result; + } + + public bool SetValue(XOptionsDefine option, string value) + { + bool flag = this.GetStrValue(option) == value; + bool result; + if (flag) + { + result = false; + } + else + { + this.strOptions[option] = value; + this.SaveToCloud(option, value); + result = true; + } + return result; + } + + public int GetPushValue(string option) + { + bool flag = XOptionsDocument.pushSettings.ContainsKey(option); + int result; + if (flag) + { + result = XOptionsDocument.pushSettings[option]; + } + else + { + result = 0; + } + return result; + } + + public int GetValue(XOptionsDefine option) + { + int num; + bool flag = this.options.TryGetValue(option, out num); + int result; + if (flag) + { + result = num; + } + else + { + result = this.GetDefaultValue(option); + } + return result; + } + + public float GetFloatValue(XOptionsDefine option) + { + float num; + bool flag = this.floatOptions.TryGetValue(option, out num); + float result; + if (flag) + { + result = num; + } + else + { + result = this.GetDefaultFloatValue(option); + } + return result; + } + + public string GetStrValue(XOptionsDefine option) + { + string text; + bool flag = this.strOptions.TryGetValue(option, out text); + string result; + if (flag) + { + result = text; + } + else + { + result = this.GetDefaultStrValue(option); + } + return result; + } + + private void ProccessOption(XOptionsDefine option, int value) + { + switch (option) + { + case XOptionsDefine.OD_SOUND: + this.openSound = (value == 1); + this.SetBGMVolme(this.openSound ? ((this.lastSound == -1f) ? 1f : this.lastSound) : 0f); + break; + case XOptionsDefine.BA_SOUND: + { + bool flag = this.openSound; + if (flag) + { + this.SetBGMVolme((float)value / 100f); + } + break; + } + case XOptionsDefine.OD_MUSIC: + this.openMusic = (value == 1); + this.SetMuscVolme(this.openMusic ? ((this.lastMusic == -1f) ? 1f : this.lastMusic) : 0f); + break; + case XOptionsDefine.BA_MUSIC: + { + bool flag2 = this.openMusic; + if (flag2) + { + this.SetMuscVolme((float)value / 100f); + } + break; + } + case XOptionsDefine.OD_VOICE: + this.openVoice = (value == 1); + this.SetVoiceVolme(this.openVoice ? ((this.lastVoice == -1f) ? 1f : this.lastVoice) : 0f); + break; + case XOptionsDefine.BA_VOICE: + { + bool flag3 = this.openVoice; + if (flag3) + { + this.SetVoiceVolme((float)value / 100f); + } + break; + } + case (XOptionsDefine)7: + case (XOptionsDefine)8: + case (XOptionsDefine)9: + case (XOptionsDefine)18: + case (XOptionsDefine)19: + case XOptionsDefine.OD_TEAM_USE_PASSWORD: + case XOptionsDefine.OD_3D_TOUCH: + break; + case XOptionsDefine.OD_VOLUME: + { + bool flag4 = this.View != null; + if (flag4) + { + this.View.SetVolume(value); + } + break; + } + case XOptionsDefine.OD_RADIO_WIFI: + XSingleton.singleton.SetChannelAutoPlay(ChatChannelType.ZeroChannel, value == 1); + break; + case XOptionsDefine.OD_RADIO_TEAM: + XSingleton.singleton.SetChannelAutoPlay(ChatChannelType.Team, value == 1); + break; + case XOptionsDefine.OD_RADIO_CAMP: + XSingleton.singleton.SetChannelAutoPlay(ChatChannelType.Camp, value == 1); + break; + case XOptionsDefine.OD_RADIO_PRIVATE: + XSingleton.singleton.SetChannelAutoPlay(ChatChannelType.Friends, value == 1); + break; + case XOptionsDefine.OD_RADIO_PUBLIC: + XSingleton.singleton.SetChannelAutoPlay(ChatChannelType.Guild, value == 1); + break; + case XOptionsDefine.OD_RADIO_WORLD: + XSingleton.singleton.SetChannelAutoPlay(ChatChannelType.World, value == 1); + break; + case XOptionsDefine.OD_RADIO_AUTO_PALY: + XSingleton.singleton.SetChannelAutoPlay(ChatChannelType.Curr, value == 1); + break; + case XOptionsDefine.OD_QUALITY: + this._ProcessQuality(value); + break; + case XOptionsDefine.OD_FLOWERRAIN: + this.Flowerrain = (value == 1); + break; + case XOptionsDefine.OD_SAMESCREENNUM: + XQualitySetting.SetVisibleRoleLevel(value); + break; + case XOptionsDefine.OD_RADIO: + DlgBase.singleton.Process(value == 1); + break; + case XOptionsDefine.OD_SMOOTH: + XSingleton.singleton.SetUIOptOption(false, value == 1, false, true); + break; + case XOptionsDefine.OD_RESOLUTION: + XQualitySetting.SetResolution((XQualitySetting.EResolution)value, false); + break; + case XOptionsDefine.OD_POWERSAVE: + this._ProcessPowerSave(value); + break; + case XOptionsDefine.OD_NOTIFICATION: + this._ProcessNotification(value); + break; + case XOptionsDefine.OD_BLOCKOTHERPLAYERS: + this._ProcessBlockOtherPlayers(value); + break; + default: + switch (option) + { + case XOptionsDefine.OD_Gyro: + XSingleton.singleton.Enabled = (value == 1); + break; + case XOptionsDefine.OD_Shield_Skill_Fx: + XSingleton.singleton.UpdateShieldOperation(); + break; + case XOptionsDefine.OD_Shield_Summon: + XSingleton.singleton.UpdateShieldOperation(); + break; + case XOptionsDefine.OD_Shield_My_Skill_Fx: + XSingleton.singleton.UpdateShieldOperation(); + break; + } + break; + } + } + + private void ProccessOption(XOptionsDefine option, float value) + { + } + + private string GetDefaultStrValue(XOptionsDefine option) + { + return string.Empty; + } + + private float GetDefaultFloatValue(XOptionsDefine option) + { + string configurationDefault = this.GetConfigurationDefault(option); + bool flag = string.IsNullOrEmpty(configurationDefault); + float result; + if (flag) + { + result = 0f; + } + else + { + result = float.Parse(configurationDefault); + } + return result; + } + + private int GetDefaultValue(XOptionsDefine option) + { + int result; + switch (option) + { + case XOptionsDefine.OD_QUALITY: + result = XQualitySetting.GetDefaultQualityLevel(); + break; + case XOptionsDefine.OD_FLOWERRAIN: + result = ((XQualitySetting.GetDefaultQualityLevel() == XFastEnumIntEqualityComparer.ToInt(XQualitySetting.ESetting.ELow)) ? 0 : 1); + break; + case XOptionsDefine.OD_SAMESCREENNUM: + result = XQualitySetting.GetDefalutVisibleRoleLevel(); + break; + default: + if (option != XOptionsDefine.OD_RESOLUTION) + { + if (option != XOptionsDefine.OD_TAILCAMERA_SPEED) + { + string configurationDefault = this.GetConfigurationDefault(option); + bool flag = string.IsNullOrEmpty(configurationDefault); + if (flag) + { + result = 0; + } + else + { + result = int.Parse(configurationDefault); + } + } + else + { + bool flag2 = XSingleton.singleton.Player != null; + if (flag2) + { + result = XSingleton.singleton.TailCameraSpeed; + } + else + { + result = 50; + } + } + } + else + { + result = XQualitySetting.GetDefalutResolution(); + } + break; + } + return result; + } + + public bool IsShow3DTouch() + { + return (int)Application.platform == 8 && XSingleton.singleton.XPlatform.CheckStatus("Is_3DTouch_Supported", ""); + } + + private void _ProcessPowerSave(int value) + { + } + + private void _ProcessNotification(int value) + { + XSingleton.singleton.XPlatform.SetPushStatus(true); + } + + private void _ProcessQuality(int value) + { + XQualitySetting.SetQuality(value, false); + XQualitySetting.PostSetQuality(); + XQualitySetting.PostSetting(); + } + + private void _ProcessBlockOtherPlayers(int value) + { + bool flag = XSingleton.singleton.CurrentStage != null && XSingleton.singleton.CurrentStage.Stage == EXStage.Hall; + if (flag) + { + XSingleton.singleton.ToggleOtherPlayers(value == 1); + } + } + + protected override void OnReconnected(XReconnectedEventArgs arg) + { + this.InitServerConfig(arg.PlayerInfo.config); + } + + private bool OnChatVoiceHandled(XEventArgs e) + { + XAudioOperationArgs xaudioOperationArgs = e as XAudioOperationArgs; + bool isAudioOn = xaudioOperationArgs.IsAudioOn; + if (isAudioOn) + { + float volume = 1f; + XApolloDocument specificDocument = XDocuments.GetSpecificDocument(XApolloDocument.uuID); + bool flag = specificDocument != null; + if (flag) + { + bool isRealtimeVoiceOn = specificDocument.IsRealtimeVoiceOn; + if (isRealtimeVoiceOn) + { + volume = (float)XSingleton.singleton.GetInt("SetMusicVol") / 100f; + } + } + XSingleton.singleton.SetBusStatuMute("bus:/MainGroupControl", volume); + } + else + { + XSingleton.singleton.SetBusStatuMute("bus:/MainGroupControl", 0f); + } + return true; + } + + public void SetBGMVolme(float vol) + { + this.bgmVolme = Mathf.Clamp01(vol); + XSingleton.singleton.SetBGMVolme(this.bgmVolme); + } + + public void SetMuscVolme(float vol) + { + this.mscVolme = Mathf.Clamp01(vol); + XSingleton.singleton.SetMscVolme(this.mscVolme); + } + + public void SetVoiceVolme(float vol) + { + this.voiceVolme = vol; + } + + public string GetConfigurationDefault(XOptionsDefine option) + { + XOptionsDocument.OptionData optionData; + bool flag = XOptionsDocument.optionsDefault.TryGetValue(option, out optionData); + string result; + if (flag) + { + int num = optionData.NeedSight ? this.GetValue(XOptionsDefine.OD_VIEW) : 1; + bool flag2 = optionData.NeedProfession[num - 1]; + int num2; + if (flag2) + { + bool flag3 = XSingleton.singleton.XPlayerData == null; + if (flag3) + { + return null; + } + num2 = XFastEnumIntEqualityComparer.ToInt(XSingleton.singleton.XPlayerData.Profession) % 10; + } + else + { + num2 = 1; + } + result = optionData.val[num - 1, num2 - 1]; + } + else + { + result = null; + } + return result; + } + + public bool SetBattleOptionValue() + { + XSingleton.singleton.AddGreenLog("__RefreshBattleOptionValue", null, null, null, null, null); + XOperationMode value = (XOperationMode)this.GetValue(XOptionsDefine.OD_VIEW); + XSingleton.singleton.OperationMode = value; + XSingleton.singleton.UpdateDefaultCameraOperationByScene(); + bool flag = value == XOperationMode.X25D; + if (flag) + { + XSingleton.singleton.TailCameraSpeed = (int)this.GetFloatValue(XOptionsDefine.OD_TailCameraSpeed25D); + XSingleton.singleton.ManualCameraSpeedXInBattle = this.GetFloatValue(XOptionsDefine.OD_ManualCameraSpeedXInBattle25D); + } + else + { + bool flag2 = value == XOperationMode.X3D; + if (flag2) + { + XSingleton.singleton.TailCameraSpeed = (int)this.GetFloatValue(XOptionsDefine.OD_TailCameraSpeed3D); + XSingleton.singleton.ManualCameraSpeedXInBattle = this.GetFloatValue(XOptionsDefine.OD_ManualCameraSpeedXInBattle3D); + bool flag3 = XSingleton.singleton.CurrentStage.Stage != EXStage.Hall; + if (flag3) + { + XSingleton.singleton.AllowVertical = (this.GetValue(XOptionsDefine.OD_Vertical3D) == 1); + } + } + else + { + bool flag4 = value == XOperationMode.X3D_Free; + if (flag4) + { + XSingleton.singleton.TailCameraSpeed = (int)this.GetFloatValue(XOptionsDefine.OD_TailCameraSpeed3DFree); + XSingleton.singleton.ManualCameraSpeedXInBattle = this.GetFloatValue(XOptionsDefine.OD_ManualCameraSpeedXInBattle3DFree); + bool flag5 = XSingleton.singleton.CurrentStage.Stage != EXStage.Hall; + if (flag5) + { + XSingleton.singleton.AllowVertical = (this.GetValue(XOptionsDefine.OD_Vertical3DFree) == 1); + } + XSingleton.singleton.CameraDistance = this.GetFloatValue(XOptionsDefine.OD_Distance3DFree); + } + } + } + XOperateMode value2 = (XOperateMode)this.GetValue(XOptionsDefine.OD_OPERATE); + int num = this.GetValue(XOptionsDefine.OD_OPERATE) - 1; + XSingleton.singleton.ManualCameraSpeedXInHall = this.GetFloatValue(XOptionsDefine.ManualCameraSpeedXInHallAutoLock + num); + XSingleton.singleton.ManualCameraDampXInHall = this.GetFloatValue(XOptionsDefine.ManualCameraDampXInHallAutoLock + num); + XSingleton.singleton.ManualCameraSpeedYInHall = this.GetFloatValue(XOptionsDefine.ManualCameraSpeedYInHallAutoLock + num); + XSingleton.singleton.ManualCameraDampYInHall = this.GetFloatValue(XOptionsDefine.ManualCameraDampYInHallAutoLock + num); + XSingleton.singleton.ManualCameraDampXInBattle = this.GetFloatValue(XOptionsDefine.ManualCameraDampXInBattleAutoLock + num); + XSingleton.singleton.ManualCameraSpeedYInBattle = this.GetFloatValue(XOptionsDefine.ManualCameraSpeedYInBattleAutoLock + num); + XSingleton.singleton.ManualCameraDampYInBattle = this.GetFloatValue(XOptionsDefine.ManualCameraDampYInBattleAutoLock + num); + XSingleton.singleton.RangeWeight = (int)this.GetFloatValue(XOptionsDefine.RangeWeightAutoLock + num); + XSingleton.singleton.BossWeight = (int)this.GetFloatValue(XOptionsDefine.BossWeightAutoLock + num); + XSingleton.singleton.EliteWeight = (int)this.GetFloatValue(XOptionsDefine.EliteWeightAutoLock + num); + XSingleton.singleton.EnemyWeight = (int)this.GetFloatValue(XOptionsDefine.EnemyWeightAutoLock + num); + XSingleton.singleton.PupetWeight = (int)this.GetFloatValue(XOptionsDefine.PupetWeightAutoLock + num); + XSingleton.singleton.RoleWeight = (int)this.GetFloatValue(XOptionsDefine.RoleWeightAutoLock + num); + XSingleton.singleton.ImmortalWeight = (int)this.GetFloatValue(XOptionsDefine.ImmortalWeightAutoLock + num); + XSingleton.singleton.WithinScope = this.GetFloatValue(XOptionsDefine.WithinScopeAutoLock + num); + XSingleton.singleton.WithinRange = this.GetFloatValue(XOptionsDefine.WithinRangeAutoLock + num); + XSingleton.singleton.AssistAngle = this.GetFloatValue(XOptionsDefine.AssistAngleAutoLock + num); + XSingleton.singleton.ProfRange = this.GetFloatValue(XOptionsDefine.ProfRangeAutoLock + num); + XSingleton.singleton.ProfRangeLong = this.GetFloatValue(XOptionsDefine.ProfRangeLongAutoLock + num); + XSingleton.singleton.ProfRangeAll = this.GetFloatValue(XOptionsDefine.ProfRangeAllAutoLock + num); + XSingleton.singleton.ProfScope = (int)this.GetFloatValue(XOptionsDefine.ProfScopeAutoLock + num); + XSingleton.singleton.CameraAdjustScope = (int)this.GetFloatValue(XOptionsDefine.CameraAdjustScopeAutoLock + num); + XSingleton.singleton.UpdateOperationMode(); + XBattleSkillDocument specificDocument = XDocuments.GetSpecificDocument(XBattleSkillDocument.uuID); + bool flag6 = specificDocument.BattleView != null && specificDocument.BattleView.IsVisible(); + if (flag6) + { + specificDocument.BattleView.OnSetOptionsValue(); + } + return true; + } + } +} -- cgit v1.1-26-g67d0