123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Runtime.Serialization.Formatters.Binary;
- using System.Text;
- using Dance;
- using I2.Loc;
- using UnityEngine;
- public class DanceSetting : MonoBehaviour
- {
- private void Awake()
- {
- this.m_OrijinBgheight = this.m_SettingUIBg.height;
- if (!DanceSetting.m_IsFileCheck)
- {
- Action<string, bool> action = delegate(string file_path, bool binary_ver)
- {
- float num = -1f;
- FileInfo fileInfo = new FileInfo(file_path);
- try
- {
- if (binary_ver)
- {
- using (FileStream fileStream = new FileStream(file_path, FileMode.Open, FileAccess.Read))
- {
- BinaryFormatter binaryFormatter = new BinaryFormatter();
- string text = (string)binaryFormatter.Deserialize(fileStream);
- string text2 = (string)binaryFormatter.Deserialize(fileStream);
- float.TryParse(text2.Split(new char[]
- {
- ':'
- })[1], out num);
- DanceSetting.Settings = (SettingData)binaryFormatter.Deserialize(fileStream);
- fileStream.Close();
- }
- }
- else
- {
- using (StreamReader streamReader = new StreamReader(fileInfo.OpenRead(), Encoding.UTF8))
- {
- string text3 = streamReader.ReadLine();
- if (text3 == "@Dance_Setting")
- {
- string s = streamReader.ReadLine().Split(new char[]
- {
- ':'
- })[1];
- float.TryParse(s, out num);
- text3 = streamReader.ReadLine();
- }
- DanceSetting.Settings = JsonUtility.FromJson<SettingData>(text3);
- streamReader.Close();
- }
- }
- }
- catch (Exception ex)
- {
- if (num > 0f)
- {
- if (num == 1f)
- {
- Debug.Log("2017/11/22以前の設定データです");
- }
- }
- else
- {
- DanceSetting.Settings = new SettingData();
- File.Delete(file_path);
- Debug.LogWarning("ダンス設定読み込みに失敗したので初期化します。エラー箇所:" + ex.StackTrace);
- }
- }
- };
- string fullPath = Path.GetFullPath(".\\dance_setting_br.dat");
- DanceSetting.m_IsFileExist = File.Exists(fullPath);
- if (DanceSetting.m_IsFileExist)
- {
- action(fullPath, true);
- }
- else
- {
- string fullPath2 = Path.GetFullPath(".\\dance_setting.set");
- string fullPath3 = Path.GetFullPath(".\\dance_setting.dat");
- if (File.Exists(fullPath2))
- {
- action(fullPath2, false);
- File.Delete(fullPath2);
- }
- else if (File.Exists(fullPath3))
- {
- action(fullPath3, false);
- File.Delete(fullPath3);
- }
- }
- DanceSetting.m_IsFileCheck = true;
- }
- }
- private void Start()
- {
- EventDelegate.Callback callback = delegate()
- {
- GameObject gameObject = GameObject.Find("Drop-down List");
- if (gameObject)
- {
- int width = gameObject.GetComponentInChildren<UISprite>().width;
- gameObject.transform.position = UIButton.current.transform.TransformPoint(Vector3.down * this.m_PopUpOffset + Vector3.left * (float)width / 2f);
- }
- };
- IEnumerator enumerator = this.m_ButtonGroup.GetEnumerator();
- try
- {
- while (enumerator.MoveNext())
- {
- object obj = enumerator.Current;
- Transform transform = (Transform)obj;
- UIPopupList componentInChildren = transform.GetComponentInChildren<UIPopupList>();
- if (componentInChildren)
- {
- DanceSetting.NeedData needData = new DanceSetting.NeedData();
- if (transform.Find("Label"))
- {
- needData.Label = transform.Find("Label").GetComponent<UILabel>();
- needData.localize = needData.Label.GetComponent<Localize>();
- }
- needData.Button = transform.GetComponentInChildren<UIButton>();
- EventDelegate.Add(needData.Button.onClick, callback);
- needData.Collider = transform.GetComponentInChildren<BoxCollider>();
- this.m_SettingUIList.Add(componentInChildren, needData);
- EventDelegate.Add(componentInChildren.onChange, new EventDelegate.Callback(this.ValueSetting));
- this.SetUIValue(componentInChildren);
- }
- }
- }
- finally
- {
- IDisposable disposable;
- if ((disposable = (enumerator as IDisposable)) != null)
- {
- disposable.Dispose();
- }
- }
- }
- private void SetUIValue(UIPopupList list)
- {
- DanceSetting.UIInspectorSetting uiinspectorSetting = this.m_SettingList.SingleOrDefault((DanceSetting.UIInspectorSetting e) => e.PopUpUI == list);
- if (uiinspectorSetting == null)
- {
- return;
- }
- foreach (string text in list.items)
- {
- bool flag = false;
- bool flag2 = false;
- string text2 = text.Replace("\r", string.Empty);
- string text3 = text2;
- string[] array = text2.Split(new char[]
- {
- '/'
- });
- if (array != null && 1 < array.Length)
- {
- text3 = array[array.Length - 1];
- flag2 = true;
- }
- switch (uiinspectorSetting.MyType)
- {
- case DanceSetting.SettingType.Product:
- flag = this.IsProductMatch(text3);
- break;
- case DanceSetting.SettingType.Audience:
- flag = this.IsAudienceMatch(text3);
- break;
- case DanceSetting.SettingType.DepthofField:
- flag = this.IsSettingOn(text3, DanceSetting.Settings.IsDepthOfFieldOn);
- break;
- case DanceSetting.SettingType.SePlay:
- flag = this.IsSettingOn(text3, DanceSetting.Settings.IsSEPlay);
- break;
- case DanceSetting.SettingType.Voltage:
- flag = this.IsVoltageMatch(text3);
- break;
- case DanceSetting.SettingType.BlackBg:
- flag = this.IsSettingOn(text3, DanceSetting.Settings.IsblackBGon);
- break;
- case DanceSetting.SettingType.NoteEffect:
- flag = this.IsEffectLigthtMatch(text3);
- break;
- case DanceSetting.SettingType.NoteTiming:
- flag = this.IsTimingMatch(text3);
- break;
- case DanceSetting.SettingType.JudgeTiming:
- flag = this.IsJudgeTimingMatch(text3);
- break;
- case DanceSetting.SettingType.FpsCam:
- flag = this.IsSettingOn(text3, DanceSetting.Settings.FPSCamMode);
- break;
- case DanceSetting.SettingType.Cutin:
- flag = this.IsCutinMatch(text3);
- break;
- case DanceSetting.SettingType.Undress:
- flag = this.IsUndressFaceMatch(text3);
- break;
- case DanceSetting.SettingType.SubtitleOn:
- flag = this.IsSettingOn(text3, DanceSetting.Settings.IsSubtitleOn);
- break;
- case DanceSetting.SettingType.SubtitleType:
- flag = this.IsSubtitleTypeMatch(text3);
- break;
- }
- IL_1F2:
- if (flag)
- {
- list.value = ((!flag2) ? text3 : text2);
- break;
- }
- continue;
- goto IL_1F2;
- }
- }
- private bool IsProductMatch(string text)
- {
- bool result = false;
- switch (DanceSetting.Settings.Product)
- {
- case Product_Mgr.ProductRank.Low:
- result = (text == "下位");
- break;
- case Product_Mgr.ProductRank.Special:
- result = (text == "上位");
- break;
- case Product_Mgr.ProductRank.Normal:
- result = (text == "通常");
- break;
- }
- return result;
- }
- private bool IsAudienceMatch(string text)
- {
- bool result = false;
- switch (DanceSetting.Settings.Audience)
- {
- case Product_Mgr.AudienceState.Few:
- result = (text == "小");
- break;
- case Product_Mgr.AudienceState.Normal:
- result = (text == "中");
- break;
- case Product_Mgr.AudienceState.Many:
- result = (text == "大");
- break;
- }
- return result;
- }
- private bool IsSettingOn(string text, bool condition)
- {
- if (condition)
- {
- return text == "ON";
- }
- return text == "OFF";
- }
- private bool IsVoltageMatch(string text)
- {
- int num = 0;
- if (int.TryParse(text, out num))
- {
- return DanceSetting.Settings.Voltage == num;
- }
- if (text == "普通")
- {
- return DanceSetting.Settings.Voltage == 3;
- }
- return text == "難しい" && DanceSetting.Settings.Voltage == 4;
- }
- private bool IsCutinMatch(string text)
- {
- return DanceSetting.Settings.CutInGrade == Appeal_Mgr.ParseGrade(text);
- }
- private bool IsTimingMatch(string text)
- {
- return DanceSetting.Settings.NoteOccurTiming.ToString() == text.Replace("+", string.Empty).Replace("秒", string.Empty);
- }
- private bool IsEffectLigthtMatch(string text)
- {
- if (text == "軽量")
- {
- return DanceSetting.Settings.IsNoteEffectLight;
- }
- return !DanceSetting.Settings.IsNoteEffectLight;
- }
- private bool IsUndressFaceMatch(string text)
- {
- if (text == "通常")
- {
- return DanceSetting.Settings.UndressFaceOn;
- }
- return !DanceSetting.Settings.UndressFaceOn;
- }
- private bool IsJudgeTimingMatch(string text)
- {
- return DanceSetting.Settings.NoteJudgeTiming == float.Parse(text.Replace("秒", string.Empty));
- }
- private bool IsSubtitleTypeMatch(string text)
- {
- string @string = SubtitleDisplayManager.EnumConvert.GetString(DanceSetting.Settings.SubtitleType);
- return text == @string;
- }
- private void OnDestroy()
- {
- using (FileStream fileStream = new FileStream(Path.GetFullPath(".\\dance_setting_br.dat"), FileMode.Create, FileAccess.Write))
- {
- BinaryFormatter binaryFormatter = new BinaryFormatter();
- binaryFormatter.Serialize(fileStream, "@Dance_Setting");
- binaryFormatter.Serialize(fileStream, string.Format("Ver:{0}", 1.7f));
- binaryFormatter.Serialize(fileStream, DanceSetting.Settings);
- fileStream.Close();
- }
- DanceSetting.m_IsFileExist = true;
- }
- private void SwitchFlag(string value_text, ref bool swtch_flag)
- {
- if (value_text != null)
- {
- if (!(value_text == "ON"))
- {
- if (value_text == "OFF")
- {
- swtch_flag = false;
- }
- }
- else
- {
- swtch_flag = true;
- }
- }
- }
- private void SetProduct(string value_text)
- {
- Product_Mgr.ProductRank product = Product_Mgr.ProductRank.Low;
- if (value_text != null)
- {
- if (!(value_text == "下位"))
- {
- if (!(value_text == "通常"))
- {
- if (value_text == "上位")
- {
- product = Product_Mgr.ProductRank.Special;
- }
- }
- else
- {
- product = Product_Mgr.ProductRank.Normal;
- }
- }
- else
- {
- product = Product_Mgr.ProductRank.Low;
- }
- }
- DanceSetting.Settings.Product = product;
- }
- private void SetAudience(string value_text)
- {
- Product_Mgr.AudienceState audience = Product_Mgr.AudienceState.Normal;
- if (value_text != null)
- {
- if (!(value_text == "小"))
- {
- if (!(value_text == "中"))
- {
- if (value_text == "大")
- {
- audience = Product_Mgr.AudienceState.Many;
- }
- }
- else
- {
- audience = Product_Mgr.AudienceState.Normal;
- }
- }
- else
- {
- audience = Product_Mgr.AudienceState.Few;
- }
- }
- DanceSetting.Settings.Audience = audience;
- }
- private void SetVoltage(string value_text)
- {
- int voltage = 0;
- if (int.TryParse(value_text, out voltage))
- {
- DanceSetting.Settings.Voltage = voltage;
- }
- else if (value_text != null)
- {
- if (!(value_text == "普通"))
- {
- if (value_text == "難しい")
- {
- DanceSetting.Settings.Voltage = 4;
- }
- }
- else
- {
- DanceSetting.Settings.Voltage = 3;
- }
- }
- }
- private void SetCutInGrade(string value_text)
- {
- DanceSetting.Settings.CutInGrade = Appeal_Mgr.ParseGrade(value_text);
- }
- private void SetNoteTiming(string value_text)
- {
- DanceSetting.Settings.NoteOccurTiming = int.Parse(value_text.Replace("+", string.Empty));
- }
- private void SetEffectLight(string value_text)
- {
- if (value_text != null)
- {
- if (!(value_text == "通常"))
- {
- if (value_text == "軽量")
- {
- DanceSetting.Settings.IsNoteEffectLight = true;
- }
- }
- else
- {
- DanceSetting.Settings.IsNoteEffectLight = false;
- }
- }
- }
- private void SetUndressFace(string value_text)
- {
- if (value_text != null)
- {
- if (!(value_text == "通常"))
- {
- if (value_text == "我慢")
- {
- DanceSetting.Settings.UndressFaceOn = false;
- }
- }
- else
- {
- DanceSetting.Settings.UndressFaceOn = true;
- }
- }
- }
- private void SetJudgeTiming(string value_text)
- {
- DanceSetting.Settings.NoteJudgeTiming = float.Parse(value_text);
- }
- private void SetSubtitleType(string value_text)
- {
- foreach (SubtitleDisplayManager.DisplayType displayType in (SubtitleDisplayManager.DisplayType[])Enum.GetValues(typeof(SubtitleDisplayManager.DisplayType)))
- {
- string @string = SubtitleDisplayManager.EnumConvert.GetString(displayType);
- if (value_text == @string)
- {
- DanceSetting.Settings.SubtitleType = displayType;
- break;
- }
- }
- }
- private void ValueSetting()
- {
- string text = UIPopupList.current.value.Replace("\r", string.Empty);
- string text2 = text;
- bool isLocalized = UIPopupList.current.isLocalized;
- if (isLocalized)
- {
- string[] array = text2.Split(new char[]
- {
- '/'
- });
- if (array != null && 1 < array.Length)
- {
- text2 = array[array.Length - 1];
- }
- }
- DanceSetting.UIInspectorSetting uiinspectorSetting = this.m_SettingList.SingleOrDefault((DanceSetting.UIInspectorSetting e) => e.PopUpUI == UIPopupList.current);
- if (uiinspectorSetting == null)
- {
- return;
- }
- switch (uiinspectorSetting.MyType)
- {
- case DanceSetting.SettingType.Product:
- this.SetProduct(text2);
- break;
- case DanceSetting.SettingType.Audience:
- this.SetAudience(text2);
- break;
- case DanceSetting.SettingType.DepthofField:
- this.SwitchFlag(text2, ref DanceSetting.Settings.IsDepthOfFieldOn);
- break;
- case DanceSetting.SettingType.SePlay:
- this.SwitchFlag(text2, ref DanceSetting.Settings.IsSEPlay);
- break;
- case DanceSetting.SettingType.Voltage:
- this.SetVoltage(text2);
- break;
- case DanceSetting.SettingType.BlackBg:
- this.SwitchFlag(text2, ref DanceSetting.Settings.IsblackBGon);
- break;
- case DanceSetting.SettingType.NoteEffect:
- this.SetEffectLight(text2);
- break;
- case DanceSetting.SettingType.NoteTiming:
- this.SetNoteTiming(text2);
- break;
- case DanceSetting.SettingType.JudgeTiming:
- this.SetJudgeTiming(text2);
- break;
- case DanceSetting.SettingType.FpsCam:
- this.SwitchFlag(text2, ref DanceSetting.Settings.FPSCamMode);
- break;
- case DanceSetting.SettingType.Cutin:
- this.SetCutInGrade(text2);
- break;
- case DanceSetting.SettingType.Undress:
- this.SetUndressFace(text2);
- break;
- case DanceSetting.SettingType.SubtitleOn:
- this.SwitchFlag(text2, ref DanceSetting.Settings.IsSubtitleOn);
- break;
- case DanceSetting.SettingType.SubtitleType:
- this.SetSubtitleType(text2);
- break;
- }
- if (this.m_SettingUIList[UIPopupList.current].Label)
- {
- if (isLocalized && this.m_SettingUIList[UIPopupList.current].localize != null)
- {
- this.m_IsSettingChange = (this.m_SettingUIList[UIPopupList.current].localize.Term != text);
- this.m_SettingUIList[UIPopupList.current].localize.SetTerm(text);
- }
- else
- {
- this.m_IsSettingChange = (this.m_SettingUIList[UIPopupList.current].Label.text != text);
- this.m_SettingUIList[UIPopupList.current].Label.text = text;
- }
- }
- }
- public void DisSelectable()
- {
- foreach (KeyValuePair<UIPopupList, DanceSetting.NeedData> keyValuePair in this.m_SettingUIList)
- {
- if (keyValuePair.Value.Collider)
- {
- keyValuePair.Value.Collider.enabled = false;
- }
- }
- }
- public void SetUIMode(string mode = "")
- {
- RhythmAction_Mgr.DanceType nowDance = RhythmAction_Mgr.NowDance;
- if (nowDance != RhythmAction_Mgr.DanceType.Challenge)
- {
- if (nowDance != RhythmAction_Mgr.DanceType.VS)
- {
- if (mode.IndexOf("モード") >= 0)
- {
- this.m_ModeLabel.text = mode + "設定";
- }
- else
- {
- this.m_ModeLabel.text = mode + "モード設定";
- }
- }
- else
- {
- this.m_ModeLabel.text = "VSダンス設定";
- }
- }
- else
- {
- this.m_ModeLabel.text = "ダンスショー設定";
- }
- Localize component = this.m_ModeLabel.GetComponent<Localize>();
- if (component != null)
- {
- component.SetTerm("SceneDanceSelect/" + this.m_ModeLabel.text);
- }
- int num = 0;
- foreach (DanceSetting.UIInspectorSetting uiinspectorSetting in this.m_SettingList)
- {
- GameObject gameObject = uiinspectorSetting.PopUpUI.transform.parent.gameObject;
- bool flag = uiinspectorSetting.OnDanceList.Contains(RhythmAction_Mgr.NowDance);
- if (GameMain.Instance.VRMode)
- {
- flag &= uiinspectorSetting.UseVR;
- }
- if (uiinspectorSetting.MyType == DanceSetting.SettingType.SubtitleOn)
- {
- flag = false;
- }
- else if (uiinspectorSetting.MyType == DanceSetting.SettingType.SubtitleType)
- {
- flag &= Product.SPP;
- }
- gameObject.SetActive(flag);
- if (flag)
- {
- gameObject.transform.localPosition = Vector3.up * (this.m_FirstUIposY - this.m_UISetInterval * (float)num);
- num++;
- }
- }
- this.m_SettingUIBg.height = this.m_OrijinBgheight + num * Mathf.FloorToInt(this.m_UISetInterval);
- }
- private const string m_SettingHeader = "@Dance_Setting";
- private const float m_SettingVer = 1.7f;
- [SerializeField]
- [Header("設定項目設置間隔")]
- private float m_UISetInterval;
- [SerializeField]
- private float m_FirstUIposY;
- [SerializeField]
- [Header("ポップアップ表示オフセット")]
- private float m_PopUpOffset = 27.47f;
- [SerializeField]
- [Header("ボタンUIグループ")]
- private Transform m_ButtonGroup;
- [SerializeField]
- private UILabel m_ModeLabel;
- private Dictionary<UIPopupList, DanceSetting.NeedData> m_SettingUIList = new Dictionary<UIPopupList, DanceSetting.NeedData>();
- [SerializeField]
- [Header("各UI設定")]
- private List<DanceSetting.UIInspectorSetting> m_SettingList = new List<DanceSetting.UIInspectorSetting>
- {
- new DanceSetting.UIInspectorSetting(DanceSetting.SettingType.Product),
- new DanceSetting.UIInspectorSetting(DanceSetting.SettingType.Audience),
- new DanceSetting.UIInspectorSetting(DanceSetting.SettingType.DepthofField),
- new DanceSetting.UIInspectorSetting(DanceSetting.SettingType.SePlay),
- new DanceSetting.UIInspectorSetting(DanceSetting.SettingType.Voltage),
- new DanceSetting.UIInspectorSetting(DanceSetting.SettingType.BlackBg),
- new DanceSetting.UIInspectorSetting(DanceSetting.SettingType.NoteEffect),
- new DanceSetting.UIInspectorSetting(DanceSetting.SettingType.NoteTiming),
- new DanceSetting.UIInspectorSetting(DanceSetting.SettingType.JudgeTiming),
- new DanceSetting.UIInspectorSetting(DanceSetting.SettingType.FpsCam),
- new DanceSetting.UIInspectorSetting(DanceSetting.SettingType.Cutin),
- new DanceSetting.UIInspectorSetting(DanceSetting.SettingType.Undress),
- new DanceSetting.UIInspectorSetting(DanceSetting.SettingType.SubtitleOn),
- new DanceSetting.UIInspectorSetting(DanceSetting.SettingType.SubtitleType)
- };
- private bool m_IsSettingChange;
- [SerializeField]
- [Header("設定UI背景")]
- private UISprite m_SettingUIBg;
- private int m_OrijinBgheight;
- public static SettingData Settings = new SettingData();
- private static bool m_IsFileExist = false;
- private static bool m_IsFileCheck = false;
- private class NeedData
- {
- public UILabel Label;
- public Localize localize;
- public UIButton Button;
- public BoxCollider Collider;
- public string DefoValue;
- }
- public enum SettingType
- {
- Product,
- Audience,
- DepthofField,
- SePlay,
- Voltage,
- BlackBg,
- NoteEffect,
- NoteTiming,
- JudgeTiming,
- FpsCam,
- Cutin,
- Undress,
- AllRelease,
- SubtitleOn,
- SubtitleType
- }
- [Serializable]
- private class UIInspectorSetting
- {
- public UIInspectorSetting(DanceSetting.SettingType type)
- {
- this.MyType = type;
- }
- public DanceSetting.SettingType MyType;
- public UIPopupList PopUpUI;
- public List<RhythmAction_Mgr.DanceType> OnDanceList = new List<RhythmAction_Mgr.DanceType>();
- public bool UsePublic = true;
- public bool UseVR = true;
- }
- }
|