using System; using System.Collections.Generic; using System.Globalization; using UnityEngine; public class MessageClass { public MessageClass(GameObject message_window_panel, MessageWindowMgr message_mgr) { this.script_mgr_ = GameMain.Instance.ScriptMgr; this.message_mgr_ = message_mgr; this.exit_wait_count_ = -1; this.message_window_panel_ = message_window_panel; this.message_label_ = UTY.GetChildObject(this.message_window_panel_, "MessageViewer/MsgParent/Message", false).GetComponent(); this.name_label_ = UTY.GetChildObject(this.message_window_panel_, "MessageViewer/MsgParent/SpeakerName/Name", false).GetComponent(); this.hitret_sprite_ = UTY.GetChildObject(this.message_window_panel_, "MessageViewer/MsgParent/Hitret", false).GetComponent(); NDebug.AssertNull(this.message_label_ != null && this.name_label_ != null && this.hitret_sprite_ != null); this.message_label_.ProcessText(); this.hitret_sprite_.alpha = 0f; } public static KeyValuePair GetTranslationText(string baseText) { if (string.IsNullOrEmpty(baseText)) { return new KeyValuePair(string.Empty, string.Empty); } int num = baseText.IndexOf(""); if (num < 0) { num = baseText.IndexOf(""); if (num < 0) { return new KeyValuePair(baseText, string.Empty); } } return new KeyValuePair(baseText.Substring(0, num), baseText.Substring(num + 3, baseText.Length - (num + 3))); } public static string GetWrapString(UILabel draw_target, string text) { string text2 = string.Empty; draw_target.Wrap(text, out text2); if (text2.IndexOf('\n') == -1) { return text2; } string a = text2; string[] collection = text2.Split(new char[] { '\n' }); List list = new List(); list.AddRange(collection); text2 = string.Empty; for (int i = 0; i < list.Count - 1; i++) { string text3 = list[i]; string text4 = list[i + 1]; StringInfo stringInfo = new StringInfo(text3); int lengthInTextElements = stringInfo.LengthInTextElements; StringInfo stringInfo2 = new StringInfo(text4); int lengthInTextElements2 = stringInfo2.LengthInTextElements; while (0 < lengthInTextElements2 && 0 < lengthInTextElements) { string value = stringInfo2.SubstringByTextElements(0, 1); if (0 > MessageClass.kInsokuString.IndexOf(value)) { break; } text4 = stringInfo.SubstringByTextElements(lengthInTextElements - 1, 1) + text4; text3 = stringInfo.SubstringByTextElements(0, lengthInTextElements - 1); stringInfo = new StringInfo(text3); lengthInTextElements = stringInfo.LengthInTextElements; stringInfo2 = new StringInfo(text4); lengthInTextElements2 = stringInfo2.LengthInTextElements; } text2 = text2 + text3 + '\n'; list[i] = string.Empty; list[i + 1] = text4; string text5 = string.Empty; foreach (string text6 in list) { if (!(text6 == string.Empty) && !(text6 == "\n")) { text5 += text6; } } string empty = string.Empty; draw_target.Wrap(text5, out empty); text5 = empty; list.Clear(); list.AddRange(text5.Split(new char[] { '\n' })); i = -1; if (a == text5) { break; } a = text5; } if (1 <= list.Count) { text2 += list[list.Count - 1]; } return text2; } public void SetText(string name, string text, string voice_file, int voice_pitch) { this.exit_wait_count_ = -1; this.name_label_.text = name; this.ch_anime_data_.Clear(); this.ch_anime_data_.text_info = new StringInfo(MessageClass.GetWrapString(this.message_label_, text)); this.ch_anime_data_.type = MessageClass.ChAnimeData.Type.Execution; this.ch_anime_data_.start_time = GameMain.tick_count; this.ch_anime_data_.start_time = this.ch_anime_data_.start_time - this.ch_wait; this.hitret_sprite_.alpha = 0f; this.message_mgr_.AddBackLog(name, this.ch_anime_data_.text_info.String, voice_file, voice_pitch); this.Update(); } public void Clear() { this.exit_wait_count_ = -1; UILabel uilabel = this.message_label_; string empty = string.Empty; this.name_label_.text = empty; uilabel.text = empty; this.ch_anime_data_.Clear(); this.hitret_sprite_.alpha = 0f; } public void FinishChAnime() { if (this.ch_anime_data_.type == MessageClass.ChAnimeData.Type.Null) { return; } this.message_label_.text = this.ch_anime_data_.text_info.String; this.ch_anime_data_.Clear(); this.hitret_sprite_.alpha = 255f; this.exit_wait_count_ = GameMain.tick_count; } public void Update() { if (this.ch_anime_data_.type == MessageClass.ChAnimeData.Type.Null) { return; } if (this.skip_mode || this.ch_wait <= 0) { this.FinishChAnime(); return; } int num = Mathf.Max(0, Mathf.Min((GameMain.tick_count - this.ch_anime_data_.start_time) / this.ch_wait, this.ch_anime_data_.text_info.LengthInTextElements)); if (num == this.ch_anime_data_.text_info.LengthInTextElements) { this.FinishChAnime(); } else { this.message_label_.text = this.ch_anime_data_.text_info.SubstringByTextElements(0, num); } } public int GetExitWaitCount() { return (this.exit_wait_count_ >= 0) ? (GameMain.tick_count - this.exit_wait_count_) : this.exit_wait_count_; } public bool ch_anime_enabled { get { return this.ch_anime_data_.type == MessageClass.ChAnimeData.Type.Execution; } } private int ch_wait { get { return (int)((100f - (float)GameMain.Instance.CMSystem.MsgTextSpeed) * 1.5f); } } private bool skip_mode { get { return this.script_mgr_.adv_kag.skip_mode; } } public static readonly string kInsokuString = "。、・?!゛゜ヽヾゝゞ々ー)]}」』!),.:;?]}。」、・ー゚"; private GameObject message_window_panel_; private readonly MessageWindowMgr message_mgr_; private readonly ScriptManager script_mgr_; private UILabel message_label_; private UILabel name_label_; private UISprite hitret_sprite_; private MessageClass.ChAnimeData ch_anime_data_; private int exit_wait_count_; private struct ChAnimeData { public void Clear() { this.type = MessageClass.ChAnimeData.Type.Null; this.start_time = (this.cur_pos = 0); this.text_info = null; } public MessageClass.ChAnimeData.Type type; public int start_time; public StringInfo text_info; public int cur_pos; public enum Type { Null, Execution } } }