123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- public class MessageWindowMgr : BaseMgr<MessageWindowMgr>
- {
- public void ForceDisableWindow(bool f_bDisable)
- {
- this.m_bForceDisable = f_bDisable;
- if (f_bDisable)
- {
- this.CloseMessageWindowPanel();
- }
- }
- public bool IsVisibleMessageViewer
- {
- get
- {
- return this.m_goMessageViewer.activeInHierarchy;
- }
- }
- public void Awake()
- {
- GameObject gameObject = GameObject.Find("__GameMain__/SystemUI Root");
- this.m_goMessageWindowPanel = gameObject.transform.Find("MessageWindowPanel").gameObject;
- if (this.m_goMessageWindowPanel == null)
- {
- Debug.LogError(string.Format("{0}が見つかりませんでした", "MessageWindowPanel"));
- return;
- }
- this.m_goMessageViewer = UTY.GetChildObject(this.m_goMessageWindowPanel, "MessageViewer", false);
- this.message_bg_ = UTY.GetChildObject(this.m_goMessageWindowPanel, "MessageViewer/MsgParent/MessageBox", false).GetComponent<UISprite>();
- Transform transform = gameObject.transform.Find("MessageWindowPanel/MessageViewer/MsgParent/Buttons");
- MessageWindowMgr.MessageWindowUnderButton[] array = new MessageWindowMgr.MessageWindowUnderButton[]
- {
- MessageWindowMgr.MessageWindowUnderButton.Skip,
- MessageWindowMgr.MessageWindowUnderButton.Auto,
- MessageWindowMgr.MessageWindowUnderButton.Voice,
- MessageWindowMgr.MessageWindowUnderButton.BackLog,
- MessageWindowMgr.MessageWindowUnderButton.Config
- };
- foreach (MessageWindowMgr.MessageWindowUnderButton key in array)
- {
- string text = key.ToString();
- GameObject gameObject2 = transform.Find(text).gameObject;
- if (gameObject2 == null)
- {
- NDebug.Assert(text + "が見つかりませんでした", false);
- return;
- }
- this.m_dicButtonGameObject.Add(key, new MessageWindowMgr.SystemButton(gameObject2));
- }
- this.m_messageWindowCtrl = this.m_goMessageWindowPanel.GetComponent<MessageWindowCtrl>();
- this.m_messageWindowCtrl.Init(this.m_goMessageWindowPanel);
- this.m_goMessageWindowPanel.SetActive(false);
- this.message_ = new MessageClass(this.m_goMessageWindowPanel, this);
- this.on_click_event_ = new MessageWindowMgr.OnClickEvent(GameMain.Instance.ScriptMgr.adv_kag.OnClickEvent);
- if (GameMain.Instance.VRMode)
- {
- GameObject childObject = UTY.GetChildObject(this.m_goMessageViewer, "MsgParent", false);
- this.m_vBackMsgParentPos = childObject.transform.localPosition;
- this.m_vBackMsgParentScale = childObject.transform.localScale;
- }
- }
- public bool IsClickAction()
- {
- return this.m_goMessageWindowPanel.activeSelf && !this.m_messageWindowCtrl.IsDisplayBackLog() && !BaseMgr<ConfigMgr>.Instance.IsOpenConfigPanel();
- }
- public void Update()
- {
- if (this.m_bForceDisable)
- {
- return;
- }
- if (this.m_goMessageWindowPanel.activeSelf)
- {
- float alpha = (float)(100 - GameMain.Instance.CMSystem.MsgWndAlpha) / 100f;
- this.message_bg_.alpha = alpha;
- }
- this.message_.Update();
- if (GameMain.Instance.VRMode && this.m_bVRControllerNew != GameMain.Instance.OvrMgr.OvrCamera.IsControllerModeNew)
- {
- GameObject childObject = UTY.GetChildObject(this.m_goMessageViewer, "MsgParent", false);
- if (GameMain.Instance.OvrMgr.OvrCamera.IsControllerModeNew)
- {
- childObject.transform.localPosition = new Vector3(0f, 70f, 0f);
- childObject.transform.localScale = new Vector3(2f, 2f, 1f);
- }
- else
- {
- childObject.transform.localPosition = this.m_vBackMsgParentPos;
- childObject.transform.localScale = this.m_vBackMsgParentScale;
- }
- this.m_bVRControllerNew = GameMain.Instance.OvrMgr.OvrCamera.IsControllerModeNew;
- }
- this.m_messageWindowCtrl.VRUIModeCheck();
- if (this.m_messageWindowCtrl.IsDisplayBackLog() && this.m_goMessageWindowPanel.activeSelf)
- {
- if (!BaseMgr<ConfigMgr>.Instance.IsOpenConfigPanel() && NInput.GetMouseButtonUp(1))
- {
- this.CloseBacklog();
- }
- else
- {
- Vector3 vector = Input.mouseScrollDelta;
- this.m_messageWindowCtrl.ScrollDisplayBackLog(vector.y);
- }
- }
- else
- {
- bool keyDown = Input.GetKeyDown(KeyCode.Return);
- if ((NInput.GetMouseButtonUp(0) && UICamera.isFallThrough) || keyDown)
- {
- this.ClickMessageBox(keyDown);
- }
- }
- }
- public void ClickMessageBox(bool is_leftclick_emulate)
- {
- if (this.m_bForceDisable)
- {
- return;
- }
- if (BaseMgr<ConfigMgr>.Instance.IsOpenConfigPanel())
- {
- return;
- }
- if (NInput.GetMouseButtonUp(0) || is_leftclick_emulate)
- {
- if (this.IsClickAction())
- {
- if (this.m_goMessageViewer.activeSelf)
- {
- if (this.on_click_event_ != null)
- {
- this.on_click_event_();
- }
- }
- else
- {
- this.SetMessageViewerActive(true);
- }
- }
- }
- else if (NInput.GetMouseButtonUp(1))
- {
- if (GameMain.Instance.ScriptMgr.adv_kag.GetSettingSkipMode())
- {
- this.CallEvent(MessageWindowMgr.MessageWindowUnderButton.Skip);
- }
- else if (this.m_goMessageWindowPanel.activeSelf && this.m_goMessageViewer.activeSelf)
- {
- if (this.m_messageWindowCtrl.IsDisplayBackLog())
- {
- this.CloseBacklog();
- }
- else
- {
- this.SetMessageViewerActive(false);
- }
- }
- }
- }
- public void ClickMessageWindowUnderButton()
- {
- MessageWindowMgr.MessageWindowUnderButton type = (MessageWindowMgr.MessageWindowUnderButton)Enum.Parse(typeof(MessageWindowMgr.MessageWindowUnderButton), UIButton.current.name);
- this.CallEvent(type);
- }
- public void CancelSkipAndAuto()
- {
- if (GameMain.Instance.ScriptMgr.adv_kag.GetSettingSkipMode())
- {
- this.CallEvent(MessageWindowMgr.MessageWindowUnderButton.Skip);
- }
- if (GameMain.Instance.ScriptMgr.adv_kag.auto_mode)
- {
- this.CallEvent(MessageWindowMgr.MessageWindowUnderButton.Auto);
- }
- }
- public void CallEvent(MessageWindowMgr.MessageWindowUnderButton type)
- {
- if (this.m_messageWindowCtrl.IsSelectButtonPlayingEffect() || BaseMgr<ConfigMgr>.Instance.IsOpenConfigPanel())
- {
- return;
- }
- switch (type)
- {
- case MessageWindowMgr.MessageWindowUnderButton.Skip:
- {
- bool settingSkipMode = GameMain.Instance.ScriptMgr.adv_kag.GetSettingSkipMode();
- this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Skip].select = !settingSkipMode;
- this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Auto].enabled = settingSkipMode;
- this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Voice].enabled = settingSkipMode;
- this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.BackLog].enabled = settingSkipMode;
- this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Config].enabled = settingSkipMode;
- GameMain.Instance.ScriptMgr.adv_kag.SetSettingSkipMode(!settingSkipMode);
- if (this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Voice].enabled)
- {
- this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Voice].enabled = !string.IsNullOrEmpty(this.current_voice_file_);
- }
- break;
- }
- case MessageWindowMgr.MessageWindowUnderButton.Auto:
- {
- bool auto_mode = GameMain.Instance.ScriptMgr.adv_kag.auto_mode;
- this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Auto].select = !auto_mode;
- this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Skip].enabled = auto_mode;
- this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Voice].enabled = auto_mode;
- this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.BackLog].enabled = auto_mode;
- this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Config].enabled = auto_mode;
- GameMain.Instance.ScriptMgr.adv_kag.auto_mode = !auto_mode;
- if (this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Voice].enabled)
- {
- this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Voice].enabled = !string.IsNullOrEmpty(this.current_voice_file_);
- }
- break;
- }
- case MessageWindowMgr.MessageWindowUnderButton.Voice:
- if (!string.IsNullOrEmpty(this.current_voice_file_))
- {
- GameMain.Instance.SoundMgr.VoiceStopAll();
- GameMain.Instance.SoundMgr.PlayDummyVoice(this.current_voice_file_, 0f, false, false, this.current_voice_pitch_);
- }
- break;
- case MessageWindowMgr.MessageWindowUnderButton.BackLog:
- this.OpenBacklog();
- break;
- case MessageWindowMgr.MessageWindowUnderButton.Config:
- if (!BaseMgr<ConfigMgr>.Instance.IsOpenConfigPanel())
- {
- BaseMgr<ConfigMgr>.Instance.OpenConfigPanel();
- }
- break;
- default:
- Debug.LogError("不適切なボタンがクリックされました。");
- break;
- }
- }
- public void ClickBackLogClose()
- {
- if (UICamera.currentTouchID != -2)
- {
- return;
- }
- this.CloseBacklog();
- }
- public void CreateSelectButtons(List<KeyValuePair<string, KeyValuePair<string, bool>>> dicSelectButton, Action<string, string> onClickCallBack)
- {
- this.m_messageWindowCtrl.CreateSelectButtons(dicSelectButton, onClickCallBack);
- }
- public void CreateBacklog(List<BacklogCtrl.BacklogUnit> dicBacklog)
- {
- this.m_messageWindowCtrl.CreateBacklog(dicBacklog);
- }
- public void SetMessageViewerActive(bool value)
- {
- if (this.m_bForceDisable)
- {
- value = false;
- }
- this.m_goMessageViewer.SetActive(value);
- this.m_messageWindowCtrl.GetSelectButtonCtrl().SetPanelAlpha((float)((!value) ? 0 : 1));
- }
- public void OpenMessageWindowPanel()
- {
- if (this.m_bForceDisable)
- {
- return;
- }
- if (!this.m_goMessageWindowPanel.activeSelf)
- {
- this.m_messageWindowCtrl.DisplayBacklog(false);
- this.m_goMessageWindowPanel.SetActive(true);
- }
- }
- public void CloseMessageWindowPanel()
- {
- this.message_.Clear();
- this.m_messageWindowCtrl.ClearSelectBtn();
- this.m_goMessageWindowPanel.SetActive(false);
- }
- private void OpenBacklog()
- {
- if (this.m_bForceDisable)
- {
- return;
- }
- this.backup_camera_control_ = GameMain.Instance.MainCamera.GetControl();
- GameMain.Instance.MainCamera.SetControl(false);
- this.m_messageWindowCtrl.DisplayBacklog(true);
- this.CreateBacklog(this.m_listBacklogUnit);
- this.m_goMessageWindowPanel.SetActive(true);
- }
- public void CloseBacklog()
- {
- GameMain.Instance.MainCamera.SetControl(this.backup_camera_control_);
- this.m_messageWindowCtrl.DisplayBacklog(false);
- this.m_goMessageWindowPanel.SetActive(true);
- }
- public void AddBackLog(string name, string text, string voice_file, int pitch)
- {
- BacklogCtrl.BacklogUnit backlogUnit = new BacklogCtrl.BacklogUnit();
- backlogUnit.m_speakerName = name;
- backlogUnit.m_msg = text;
- backlogUnit.m_voiceId = voice_file;
- backlogUnit.m_voicePitch = pitch;
- this.m_listBacklogUnit.Add(backlogUnit);
- if (30 < this.m_listBacklogUnit.Count)
- {
- this.m_listBacklogUnit.RemoveAt(0);
- }
- }
- public void SetText(string name, string text, string voice_file, int voice_pitch)
- {
- if (this.m_bForceDisable)
- {
- return;
- }
- this.message_.SetText(name, text, voice_file, voice_pitch);
- this.current_voice_file_ = voice_file;
- this.current_voice_pitch_ = voice_pitch;
- this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Voice].enabled = !string.IsNullOrEmpty(this.current_voice_file_);
- }
- public void ClearText()
- {
- this.current_voice_file_ = string.Empty;
- this.current_voice_pitch_ = 50;
- this.message_.Clear();
- this.m_dicButtonGameObject[MessageWindowMgr.MessageWindowUnderButton.Voice].enabled = false;
- }
- public void ClearBackLogData()
- {
- this.m_listBacklogUnit.Clear();
- }
- public void FinishChAnime()
- {
- this.message_.FinishChAnime();
- }
- public int GetExitWaitCount()
- {
- return this.message_.GetExitWaitCount();
- }
- public bool IsChAnimeEnabled()
- {
- return this.message_.ch_anime_enabled;
- }
- public const int kBackLogSaveUnit = 30;
- public MessageWindowMgr.OnClickEvent on_click_event_;
- private bool m_bForceDisable;
- private Dictionary<MessageWindowMgr.MessageWindowUnderButton, MessageWindowMgr.SystemButton> m_dicButtonGameObject = new Dictionary<MessageWindowMgr.MessageWindowUnderButton, MessageWindowMgr.SystemButton>();
- private bool m_bVRControllerNew;
- private Vector3 m_vBackMsgParentPos;
- private Vector3 m_vBackMsgParentScale;
- private GameObject m_goMessageViewer;
- private GameObject m_goMessageWindowPanel;
- private MessageWindowCtrl m_messageWindowCtrl;
- private List<BacklogCtrl.BacklogUnit> m_listBacklogUnit = new List<BacklogCtrl.BacklogUnit>();
- private UISprite message_bg_;
- private MessageClass message_;
- private string current_voice_file_ = string.Empty;
- private int current_voice_pitch_ = 50;
- private bool backup_camera_control_;
- public delegate void OnClickEvent();
- public enum MessageWindowUnderButton
- {
- None = -1,
- Skip,
- Auto,
- Voice,
- BackLog,
- Config
- }
- private class SystemButton
- {
- public SystemButton(GameObject obj)
- {
- this.game_object_ = obj;
- this.button_ = this.game_object_.GetComponent<UIButton>();
- this.select_color_ = (this.default_color_ = this.button_.defaultColor);
- this.select_color_.a = 1f;
- this.is_select_ = false;
- }
- public bool enabled
- {
- get
- {
- return this.button_.isEnabled;
- }
- set
- {
- this.button_.isEnabled = value;
- if (!value)
- {
- this.select = false;
- }
- }
- }
- public bool select
- {
- get
- {
- return this.is_select_;
- }
- set
- {
- if (this.is_select_ == value)
- {
- return;
- }
- if (value)
- {
- this.button_.isEnabled = true;
- this.button_.defaultColor = this.select_color_;
- }
- else
- {
- this.button_.defaultColor = this.default_color_;
- }
- this.button_.UpdateColor(false);
- this.is_select_ = value;
- }
- }
- private GameObject game_object_;
- private UIButton button_;
- private bool is_select_;
- private Color default_color_;
- private Color select_color_;
- }
- }
|