using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Text; using UnityEngine; public class BenchSetting : MonoBehaviour { public static BenchSetting.SettingItems Setting { get { return BenchSetting.m_UseSetting; } } private void Start() { Transform transform = GameObject.Find("SystemUI Root").transform.Find("ConfigPanel/OK"); this.m_ConfigOK = transform.GetComponent(); EventDelegate.Add(this.m_ConfigOK.onClick, new EventDelegate.Callback(this.LoadOrijinData)); GameMain.Instance.MainLight.Reset(); GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, this.m_CamControll); GameMain.Instance.CharacterMgr.DeactivateCharaAll(); for (int i = 0; i < GameMain.Instance.CharacterMgr.GetMaidCount(); i++) { if (GameMain.Instance.CharacterMgr.GetMaid(i)) { GameMain.Instance.CharacterMgr.Deactivate(i, false); } } GameMain.Instance.SoundMgr.PlayBGM(this.m_BGM, 0f, true); GameMain.Instance.BgMgr.ChangeBg(this.m_BGname); ShootCutInTex.TextureClear(DanceBattle_Mgr.CharaType.Player); ShootCutInTex.TextureClear(DanceBattle_Mgr.CharaType.Enemy); RhythmAction_Mgr.SetDanceType(RhythmAction_Mgr.DanceType.BenchMark); DanceSelect.BenchMarkInit(); this.UIInit(); this.LoadOrijinData(); Action action = delegate(string file_path) { string text3 = string.Empty; float num = -1f; FileInfo fileInfo = new FileInfo(file_path); try { using (StreamReader streamReader = new StreamReader(fileInfo.OpenRead(), Encoding.UTF8)) { text3 = streamReader.ReadLine(); if (text3 == "@Bench_Setting") { string text4 = streamReader.ReadLine(); if (text4.IndexOf(":") >= 0) { text4 = text4.Split(new char[] { ':' })[1]; } else { text4 = 1.1f.ToString(); } float.TryParse(text4, out num); string json = streamReader.ReadLine(); BenchSetting.m_UseSetting = JsonUtility.FromJson(json); } streamReader.Close(); } } catch (Exception ex) { if (string.IsNullOrEmpty(text3) || text3 != "@Bench_Setting") { Debug.Log("ヘッダー書き込み前のデータです"); } else if (num > 0f) { if (num == 1f) { Debug.Log("2017/11/22以前の設定データです"); } } else { Debug.LogError("DanceSetting.cs:ファイル読み込みエラー。エラー箇所:" + ex.StackTrace); } } this.UpdateSettingUI(BenchSetting.m_UseSetting); }; string text = UTY.gameProjectPath + "\\benchmark_setting.dat"; if (File.Exists(text)) { action(text); } else { string text2 = UTY.gameProjectPath + "\\benchmark_setting.set"; if (File.Exists(text2)) { action(text2); File.Delete(text2); } } NDebug.Assert(GameMain.Instance.ScriptMgr.adv_kag.tag_backup.ContainsKey("label"), "実行時に飛ぶラベルが未指定です"); this.m_StartLabel = GameMain.Instance.ScriptMgr.adv_kag.tag_backup["label"]; this.m_LoopCheckmark.SetActive(BenchSetting.m_UseSetting.IsLoopMode); EventDelegate.Add(this.m_LoopModeUI.onClick, new EventDelegate.Callback(this.SwitchLoopMode)); GameMain.Instance.MainCamera.FadeIn(0.5f, false, null, false, true, default(Color)); } private void OnDestroy() { EventDelegate.Remove(this.m_ConfigOK.onClick, new EventDelegate.Callback(this.LoadOrijinData)); if (this.m_JumpLabel == this.m_StartLabel) { DanceSetting.Settings.IsDepthOfFieldOn = BenchSetting.m_UseSetting.DepthFieldOn; DanceSetting.Settings.CutInGrade = BenchSetting.m_UseSetting.CutInGrade; DanceSetting.Settings.IsSEPlay = BenchSetting.m_UseSetting.NoteSePlay; Dance_Note.IsAutoPlay = true; ShootCutInTex.SetEnemyCutInTex(false); ShootCutInTex.SetPlayerCutInTex(); } else { BenchSetting.SettingRecet(); } FileInfo fileInfo = new FileInfo(UTY.gameProjectPath + "\\benchmark_setting.dat"); using (StreamWriter streamWriter = new StreamWriter(fileInfo.Create())) { streamWriter.WriteLine("@Bench_Setting"); streamWriter.WriteLine("Ver:" + 1.1f); streamWriter.WriteLine(JsonUtility.ToJson(BenchSetting.m_UseSetting)); streamWriter.Close(); } } private void SwitchLoopMode() { BenchSetting.m_UseSetting.IsLoopMode = !BenchSetting.m_UseSetting.IsLoopMode; this.m_LoopCheckmark.SetActive(BenchSetting.m_UseSetting.IsLoopMode); } private void UIInit() { EventDelegate.Add(this.m_FullScreenOn.OnButton.onClick, new EventDelegate.Callback(this.SetFullScreen)); EventDelegate.Add(this.m_FullScreenOn.OffButton.onClick, new EventDelegate.Callback(this.SetFullScreen)); foreach (Size size in this.GetResolutions()) { this.m_Resolution.items.Add(this.ToResolutionOption(size)); } EventDelegate.Add(this.m_Resolution.onChange, new EventDelegate.Callback(this.SetResolution)); this.PopupLabelLink(this.m_Resolution); IEnumerator enumerator2 = Enum.GetValues(typeof(CMSystem.AntiAliasType)).GetEnumerator(); try { while (enumerator2.MoveNext()) { object obj = enumerator2.Current; if ((CMSystem.AntiAliasType)obj != CMSystem.AntiAliasType.MAX) { this.m_Antialiasing.items.Add(obj.ToString()); } } } finally { IDisposable disposable; if ((disposable = (enumerator2 as IDisposable)) != null) { disposable.Dispose(); } } EventDelegate.Add(this.m_Antialiasing.onChange, new EventDelegate.Callback(this.SetAntialiasing)); this.PopupLabelLink(this.m_Antialiasing); IEnumerator enumerator3 = Enum.GetValues(typeof(CMSystem.ShadowQualityType)).GetEnumerator(); try { while (enumerator3.MoveNext()) { object obj2 = enumerator3.Current; this.m_ShadowQuality.items.Add(obj2.ToString()); } } finally { IDisposable disposable2; if ((disposable2 = (enumerator3 as IDisposable)) != null) { disposable2.Dispose(); } } EventDelegate.Add(this.m_ShadowQuality.onChange, new EventDelegate.Callback(this.SetShadowQuality)); this.PopupLabelLink(this.m_ShadowQuality); IEnumerator enumerator4 = Enum.GetValues(typeof(CMSystem.TextureQualityType)).GetEnumerator(); try { while (enumerator4.MoveNext()) { object obj3 = enumerator4.Current; this.m_TextureQuality.items.Add(obj3.ToString()); } } finally { IDisposable disposable3; if ((disposable3 = (enumerator4 as IDisposable)) != null) { disposable3.Dispose(); } } EventDelegate.Add(this.m_TextureQuality.onChange, new EventDelegate.Callback(this.SetTextureQuality)); this.PopupLabelLink(this.m_TextureQuality); EventDelegate.Add(this.m_BloomValue.onChange, new EventDelegate.Callback(this.SetBloomValue)); EventDelegate.Add(this.m_DepthFieldOn.OnButton.onClick, new EventDelegate.Callback(this.SetDepthField)); EventDelegate.Add(this.m_DepthFieldOn.OffButton.onClick, new EventDelegate.Callback(this.SetDepthField)); IEnumerator enumerator5 = Enum.GetValues(typeof(Appeal_Mgr.CutInGrade)).GetEnumerator(); try { while (enumerator5.MoveNext()) { object obj4 = enumerator5.Current; Appeal_Mgr.CutInGrade grade = (Appeal_Mgr.CutInGrade)obj4; this.m_CutInGrade.items.Add(Appeal_Mgr.GradeTostring(grade)); } } finally { IDisposable disposable4; if ((disposable4 = (enumerator5 as IDisposable)) != null) { disposable4.Dispose(); } } EventDelegate.Add(this.m_CutInGrade.onChange, new EventDelegate.Callback(this.SetCutInGrade)); this.PopupLabelLink(this.m_CutInGrade); EventDelegate.Add(this.m_NoteSePlay.OnButton.onClick, new EventDelegate.Callback(this.SetNoteSEPlay)); EventDelegate.Add(this.m_NoteSePlay.OffButton.onClick, new EventDelegate.Callback(this.SetNoteSEPlay)); EventDelegate.Add(this.m_StartButton.onClick, new EventDelegate.Callback(this.BenchStart)); EventDelegate.Add(this.m_BackButton.onClick, new EventDelegate.Callback(this.TitleBack)); } private void BenchStart() { this.m_JumpNextScene = true; UICamera.InputEnable = false; this.m_JumpLabel = this.m_StartLabel; GameMain.Instance.MainCamera.FadeOut(0.5f, false, delegate { UICamera.InputEnable = true; GameMain.Instance.ScriptMgr.adv_kag.JumpLabel(this.m_JumpLabel); GameMain.Instance.ScriptMgr.adv_kag.Exec(); }, true, default(Color)); } private void TitleBack() { this.m_JumpNextScene = true; UICamera.InputEnable = false; GameMain.Instance.MainCamera.FadeOut(0.5f, false, delegate { UICamera.InputEnable = true; GameMain.Instance.LoadScene("SceneToTitle"); }, true, default(Color)); } private void PopupLabelLink(UIPopupList popup) { if (!this.m_PopupLabelPair.ContainsKey(popup)) { this.m_PopupLabelPair.Add(popup, popup.transform.Find("Label").GetComponent()); } } private List> GetResolutions() { List> screenSizeList = GameMain.Instance.CMSystem.GetScreenSizeList(); Size screenSizeNow = GameMain.Instance.CMSystem.GetScreenSizeNow(); if (!screenSizeList.Contains(screenSizeNow)) { screenSizeList.Add(screenSizeNow); } return screenSizeList; } private string ToResolutionOption(Size size) { return string.Format("{0}x{1}", size.width, size.height); } private void UpdateSettingUI(BenchSetting.SettingItems setting_data) { BenchSetting.m_UseSetting.IsFullScreen = setting_data.IsFullScreen; this.SwitchUIActive(this.m_FullScreenOn, setting_data.IsFullScreen); this.m_Resolution.value = this.ToResolutionOption(new Size(setting_data.ResolutionX, setting_data.ResolutionY)); this.m_Antialiasing.value = setting_data.Antialiasing.ToString(); this.m_ShadowQuality.value = setting_data.ShadowQuality.ToString(); this.m_TextureQuality.value = setting_data.TextureQuality.ToString(); this.m_BloomValue.value = (float)setting_data.BloomValue / 100f; BenchSetting.m_UseSetting.DepthFieldOn = setting_data.DepthFieldOn; this.SwitchUIActive(this.m_DepthFieldOn, setting_data.DepthFieldOn); this.m_CutInGrade.value = Appeal_Mgr.GradeTostring(setting_data.CutInGrade); BenchSetting.m_UseSetting.NoteSePlay = setting_data.NoteSePlay; this.SwitchUIActive(this.m_NoteSePlay, setting_data.NoteSePlay); } private void LoadOrijinData() { BenchSetting.OrijinSetting.IsFullScreen = GameMain.Instance.CMSystem.FullScreen; BenchSetting.OrijinSetting.ResolutionX = GameMain.Instance.CMSystem.GetScreenSizeNow().width; BenchSetting.OrijinSetting.ResolutionY = GameMain.Instance.CMSystem.GetScreenSizeNow().height; BenchSetting.OrijinSetting.Antialiasing = GameMain.Instance.CMSystem.Antialias; BenchSetting.OrijinSetting.ShadowQuality = GameMain.Instance.CMSystem.ShadowQuality; BenchSetting.OrijinSetting.TextureQuality = GameMain.Instance.CMSystem.TextureQuality; BenchSetting.OrijinSetting.BloomValue = GameMain.Instance.CMSystem.BloomValue; BenchSetting.OrijinSetting.DepthFieldOn = DanceSetting.Settings.IsDepthOfFieldOn; BenchSetting.OrijinSetting.CutInGrade = DanceSetting.Settings.CutInGrade; BenchSetting.OrijinSetting.NoteSePlay = DanceSetting.Settings.IsSEPlay; this.UpdateSettingUI(BenchSetting.OrijinSetting); } private void SwitchUIActive(BenchSetting.Buttonpair pair) { if (UIButton.current == pair.OnButton) { this.SwitchUIActive(pair.OnButton, pair.OffButton); } else if (UIButton.current == pair.OffButton) { this.SwitchUIActive(pair.OffButton, pair.OnButton); } } private void SwitchUIActive(BenchSetting.Buttonpair pair, bool active_on) { this.SwitchUIActive(pair.OnButton, pair.OffButton, active_on); } private void SwitchUIActive(UIButton active, UIButton diactive) { active.defaultColor = this.m_ButtonActive; diactive.defaultColor = this.m_ButtonDiactive; } private void SwitchUIActive(UIButton active, UIButton diactive, bool active_on) { if (active_on) { this.SwitchUIActive(active, diactive); } else { this.SwitchUIActive(diactive, active); } } private void SetFullScreen() { if (UIButton.current != this.m_FullScreenOn.OnButton && UIButton.current != this.m_FullScreenOn.OffButton) { return; } BenchSetting.m_UseSetting.IsFullScreen = (UIButton.current == this.m_FullScreenOn.OnButton); this.SwitchUIActive(this.m_FullScreenOn); GameMain.Instance.CMSystem.FullScreen = BenchSetting.m_UseSetting.IsFullScreen; GameMain.Instance.CMSystem.ConfigScreenApply(); } private void SetResolution() { if (UIPopupList.current != this.m_Resolution) { return; } string[] array = UIPopupList.current.value.Split(new char[] { 'x' }); BenchSetting.m_UseSetting.ResolutionX = int.Parse(array[0]); BenchSetting.m_UseSetting.ResolutionY = int.Parse(array[1]); this.m_PopupLabelPair[UIPopupList.current].text = UIPopupList.current.value; GameMain.Instance.CMSystem.SetScreenSize(new Size(BenchSetting.m_UseSetting.ResolutionX, BenchSetting.m_UseSetting.ResolutionY)); GameMain.Instance.CMSystem.ConfigScreenApply(); } private void SetAntialiasing() { if (UIPopupList.current != this.m_Antialiasing) { return; } BenchSetting.m_UseSetting.Antialiasing = (CMSystem.AntiAliasType)Enum.Parse(typeof(CMSystem.AntiAliasType), UIPopupList.current.value); this.m_PopupLabelPair[UIPopupList.current].text = UIPopupList.current.value; GameMain.Instance.CMSystem.Antialias = BenchSetting.m_UseSetting.Antialiasing; GameMain.Instance.CMSystem.ConfigScreenApply(); } private void SetShadowQuality() { if (UIPopupList.current != this.m_ShadowQuality) { return; } BenchSetting.m_UseSetting.ShadowQuality = (CMSystem.ShadowQualityType)Enum.Parse(typeof(CMSystem.ShadowQualityType), UIPopupList.current.value); this.m_PopupLabelPair[UIPopupList.current].text = UIPopupList.current.value; GameMain.Instance.CMSystem.ShadowQuality = BenchSetting.m_UseSetting.ShadowQuality; GameMain.Instance.CMSystem.ConfigScreenApply(); } private void SetTextureQuality() { if (UIPopupList.current != this.m_TextureQuality) { return; } BenchSetting.m_UseSetting.TextureQuality = (CMSystem.TextureQualityType)Enum.Parse(typeof(CMSystem.TextureQualityType), UIPopupList.current.value); this.m_PopupLabelPair[UIPopupList.current].text = UIPopupList.current.value; GameMain.Instance.CMSystem.TextureQuality = BenchSetting.m_UseSetting.TextureQuality; GameMain.Instance.CMSystem.ConfigScreenApply(); } private void SetBloomValue() { if (UIProgressBar.current != this.m_BloomValue) { return; } BenchSetting.m_UseSetting.BloomValue = Mathf.FloorToInt(UIProgressBar.current.value * 100f); this.m_BloomFacter.text = BenchSetting.m_UseSetting.BloomValue.ToString(); GameMain.Instance.CMSystem.BloomValue = BenchSetting.m_UseSetting.BloomValue; GameMain.Instance.CMSystem.ConfigScreenApply(); } private void SetDepthField() { if (UIButton.current != this.m_DepthFieldOn.OnButton && UIButton.current != this.m_DepthFieldOn.OffButton) { return; } BenchSetting.m_UseSetting.DepthFieldOn = (UIButton.current == this.m_DepthFieldOn.OnButton); this.SwitchUIActive(this.m_DepthFieldOn); } private void SetCutInGrade() { if (UIPopupList.current != this.m_CutInGrade) { return; } BenchSetting.m_UseSetting.CutInGrade = Appeal_Mgr.ParseGrade(UIPopupList.current.value); this.m_PopupLabelPair[UIPopupList.current].text = UIPopupList.current.value; } private void SetNoteSEPlay() { if (UIButton.current != this.m_NoteSePlay.OnButton && UIButton.current != this.m_NoteSePlay.OffButton) { return; } BenchSetting.m_UseSetting.NoteSePlay = (UIButton.current == this.m_NoteSePlay.OnButton); this.SwitchUIActive(this.m_NoteSePlay); } public static void SettingRecet() { GameMain.Instance.CMSystem.FullScreen = BenchSetting.OrijinSetting.IsFullScreen; GameMain.Instance.CMSystem.SetScreenSize(new Size(BenchSetting.OrijinSetting.ResolutionX, BenchSetting.OrijinSetting.ResolutionY)); GameMain.Instance.CMSystem.Antialias = BenchSetting.OrijinSetting.Antialiasing; GameMain.Instance.CMSystem.ShadowQuality = BenchSetting.OrijinSetting.ShadowQuality; GameMain.Instance.CMSystem.TextureQuality = BenchSetting.OrijinSetting.TextureQuality; GameMain.Instance.CMSystem.BloomValue = BenchSetting.OrijinSetting.BloomValue; GameMain.Instance.CMSystem.ConfigScreenApply(); DanceSetting.Settings.IsDepthOfFieldOn = BenchSetting.OrijinSetting.DepthFieldOn; DanceSetting.Settings.CutInGrade = BenchSetting.OrijinSetting.CutInGrade; DanceSetting.Settings.IsSEPlay = BenchSetting.OrijinSetting.NoteSePlay; Dance_Note.IsAutoPlay = false; } public static void SettingApplay() { GameMain.Instance.CMSystem.FullScreen = BenchSetting.m_UseSetting.IsFullScreen; GameMain.Instance.CMSystem.SetScreenSize(new Size(BenchSetting.m_UseSetting.ResolutionX, BenchSetting.m_UseSetting.ResolutionY)); GameMain.Instance.CMSystem.Antialias = BenchSetting.m_UseSetting.Antialiasing; GameMain.Instance.CMSystem.ShadowQuality = BenchSetting.m_UseSetting.ShadowQuality; GameMain.Instance.CMSystem.TextureQuality = BenchSetting.m_UseSetting.TextureQuality; GameMain.Instance.CMSystem.BloomValue = BenchSetting.m_UseSetting.BloomValue; GameMain.Instance.CMSystem.ConfigScreenApply(); DanceSetting.Settings.IsDepthOfFieldOn = BenchSetting.m_UseSetting.DepthFieldOn; DanceSetting.Settings.CutInGrade = BenchSetting.m_UseSetting.CutInGrade; DanceSetting.Settings.IsSEPlay = BenchSetting.m_UseSetting.NoteSePlay; Dance_Note.IsAutoPlay = true; } private const string m_SettingHeader = "@Bench_Setting"; private const float m_SettingVer = 1.1f; [SerializeField] private bool m_CamControll = true; [SerializeField] private string m_BGM = "BGM020.ogg"; [SerializeField] private string m_BGname = "LiveStage"; [SerializeField] private Color m_ButtonActive = Color.white; [SerializeField] private Color m_ButtonDiactive = Color.white; [SerializeField] [Header("スクリーンモード")] private BenchSetting.Buttonpair m_FullScreenOn; [SerializeField] [Header("画面解像度")] private UIPopupList m_Resolution; [SerializeField] [Header("アンチエイリアス")] private UIPopupList m_Antialiasing; [SerializeField] [Header("影のクオリティ")] private UIPopupList m_ShadowQuality; [SerializeField] [Header("テクスチャクオリティ")] private UIPopupList m_TextureQuality; [SerializeField] [Header("ブルーム")] private UISlider m_BloomValue; [SerializeField] private UILabel m_BloomFacter; [SerializeField] [Header("被写界深度")] private BenchSetting.Buttonpair m_DepthFieldOn; [SerializeField] [Header("カットイン演出段階")] private UIPopupList m_CutInGrade; [SerializeField] [Header("ノートSE再生")] private BenchSetting.Buttonpair m_NoteSePlay; [SerializeField] [Header("開始ボタン")] private UIButton m_StartButton; [SerializeField] [Header("戻るボタン")] private UIButton m_BackButton; [SerializeField] [Header("ループモード用UI")] private UIButton m_LoopModeUI; [SerializeField] private GameObject m_LoopCheckmark; private static BenchSetting.SettingItems m_UseSetting = new BenchSetting.SettingItems(); private Dictionary m_PopupLabelPair = new Dictionary(); private string m_JumpLabel = string.Empty; private string m_StartLabel = string.Empty; private static BenchSetting.SettingItems OrijinSetting = new BenchSetting.SettingItems(); private UIButton m_ConfigOK; private bool m_JumpNextScene; [Serializable] private class Buttonpair { public UIButton OnButton; public UIButton OffButton; } [Serializable] public class SettingItems { public bool IsFullScreen; public int ResolutionX; public int ResolutionY; public CMSystem.AntiAliasType Antialiasing; public CMSystem.ShadowQualityType ShadowQuality; public CMSystem.TextureQualityType TextureQuality; public int BloomValue; public bool DepthFieldOn; public Appeal_Mgr.CutInGrade CutInGrade; public bool NoteSePlay; public bool IsLoopMode; } }