using System; using System.Collections.Generic; using I2.Loc; using UnityEngine; public abstract class BasePhotoWindow : MonoBehaviour { public void ResizeWindow() { int num = (int)this.WindowSize.x; int num2 = (int)this.WindowSize.y; this.WindowSize.x = (float)num; this.WindowSize.y = (float)num2; UTY.GetChildObject(base.gameObject, "Parent", false).GetComponent().size = new Vector3((float)num, (float)num2, 1f); UTY.GetChildObject(base.gameObject, "Parent", false).GetComponent().center = new Vector3((float)(num - 200) / 2f, (float)(num2 - 200) / -2f, 1f); UTY.GetChildObject(base.gameObject, "Parent/BG", false).GetComponent().width = num; UTY.GetChildObject(base.gameObject, "Parent/BG", false).GetComponent().height = num2; UTY.GetChildObject(base.gameObject, "Parent/BG2", false).GetComponent().width = num; UTY.GetChildObject(base.gameObject, "Parent/BG2", false).GetComponent().height = num2 - 20; UTY.GetChildObject(base.gameObject, "Parent/BG2", false).transform.localPosition = new Vector3(-100f, (float)((num2 - 100) * -1), 0f); UTY.GetChildObject(base.gameObject, "Parent/BG/TitleBar", false).GetComponent().width = num; UTY.GetChildObject(base.gameObject, "Parent/BG/TitleBar/Btn", false).transform.localPosition = new Vector3((float)(num - 10), -10f, 0f); this.windowTitle = UTY.GetChildObject(base.gameObject, "Parent/BG/TitleBar/Text", false).GetComponent(); if (this.windowTitle.GetComponent() == null) { this.windowTitle.text = this.InitTitle; } } public virtual void SetWindowTitle(string title) { this.windowTitle.text = title; } public virtual void SetWindowTitleFromLocalizeTerm(string termName) { Localize component = this.windowTitle.gameObject.GetComponent(); if (component != null) { component.SetTerm(termName); } } public virtual void Awake() { GameObject gameObject = GameObject.Find("/UI Root"); NDebug.Assert(gameObject != null, "BasePhotoWindow\nRootを見つけられませんでした"); this.uiCamera = gameObject.GetComponent().GetComponentInChildren(); this.ResizeWindow(); base.transform.parent.GetComponent().Reset(); this.bgWidget = UTY.GetChildObject(base.gameObject, "Parent/BG", false).GetComponent(); this.bgWidget2 = UTY.GetChildObject(base.gameObject, "Parent/BG2", false).GetComponent(); this.content_game_object_ = UTY.GetChildObject(base.gameObject, "Parent/ContentParent", false); GameObject childObject = UTY.GetChildObject(base.gameObject, "Parent/BG/TitleBar", false); if (this.panel_ == null) { this.panel_ = base.GetComponentInChildren(); } this.title_bar_label_ = UTY.GetChildObject(childObject, "Text", false).GetComponent(); Dictionary dictionary = new Dictionary(); dictionary.Add(BasePhotoWindow.BtnType.Help, "System/ヘルプ"); dictionary.Add(BasePhotoWindow.BtnType.Min, "System/最小化"); dictionary.Add(BasePhotoWindow.BtnType.Reset, "System/UI位置初期化"); dictionary.Add(BasePhotoWindow.BtnType.End, "System/閉じる"); this.btn_dic_ = new Dictionary>>(); for (int i = 0; i <= 3; i++) { BasePhotoWindow.BtnType key = (BasePhotoWindow.BtnType)i; this.btn_dic_.Add(key, new KeyValuePair>(UTY.GetChildObject(childObject, "Btn/" + key.ToString(), false).GetComponent(), new List())); EventDelegate.Add(this.btn_dic_[key].Key.onClick, new EventDelegate.Callback(this.OnButtonClickEvent)); this.mini_btn_init_pos_.Add(key, this.btn_dic_[key].Key.transform.localPosition); if (dictionary.ContainsKey(key)) { UIButton key2 = this.btn_dic_[key].Key; EventDelegate eventDelegate = new EventDelegate(this, "OnBtnMouseHoverIn"); eventDelegate.parameters[0].value = dictionary[key]; key2.gameObject.GetComponent().onHoverOver.Add(eventDelegate); EventDelegate.Add(key2.gameObject.GetComponent().onHoverOut, new EventDelegate.Callback(this.OnMouseHoverOut)); EventDelegate.Add(key2.gameObject.GetComponent().onDragStart, new EventDelegate.Callback(this.OnMouseHoverOut)); } } this.window_active_delegate_ = new EventDelegate(new EventDelegate.Callback(this.ActiveWindow)); this.init_pos_ = base.transform.localPosition; for (int j = 0; j <= 3; j++) { this.SetButtonEnabled((BasePhotoWindow.BtnType)j, false, false); } this.GetButtonOnClickEventList(BasePhotoWindow.BtnType.Reset).Add(delegate { this.ResetPosition(); }); this.SetButtonEnabled(BasePhotoWindow.BtnType.Reset, true, false); if (!this.InitVisible) { this.visible = false; } if (this.subWindows == null) { this.subWindows = new BasePhotoSubWindow[0]; } foreach (BasePhotoSubWindow basePhotoSubWindow in this.subWindows) { basePhotoSubWindow.Initizalize(this); } } public virtual void Start() { } public virtual void OnEnable() { if (this.visible && !this.IsWindowInTheScreen()) { this.ResetPosition(); this.panelDirty = 6; } } public virtual void Update() { if (0 < this.panelDirty) { this.panelDirty--; if (this.panel_ != null && this.panelDirty % 2 == 0) { UIPanel[] componentsInChildren = base.GetComponentsInChildren(); if (componentsInChildren != null) { foreach (UIPanel uipanel in componentsInChildren) { uipanel.SetDirty(); } } } } } public virtual void UpdateChildren() { UIEventTrigger[] componentsInChildren = base.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { if (componentsInChildren[i].onPress.IndexOf(this.window_active_delegate_) < 0) { componentsInChildren[i].onPress.Add(this.window_active_delegate_); } } } public virtual void ActiveWindow() { this.mgr_.ActiveWindow(this); } public void SetButtonEnabled(BasePhotoWindow.BtnType type, bool enabled, bool force_update = false) { this.btn_dic_[type].Key.gameObject.SetActive(enabled); foreach (KeyValuePair>> keyValuePair in this.btn_dic_) { keyValuePair.Value.Key.transform.localPosition = this.mini_btn_init_pos_[keyValuePair.Key]; } UIGrid component = this.btn_dic_[BasePhotoWindow.BtnType.Help].Key.transform.parent.gameObject.GetComponent(); if (component != null) { if (force_update) { component.Reposition(); } else { component.repositionNow = true; } } } public List GetButtonOnClickEventList(BasePhotoWindow.BtnType type) { return this.btn_dic_[type].Value; } public virtual void OnButtonClickEvent() { int instanceID = UIButton.current.GetInstanceID(); foreach (KeyValuePair>> keyValuePair in this.btn_dic_) { if (instanceID == keyValuePair.Value.Key.GetInstanceID()) { List value = keyValuePair.Value.Value; for (int i = 0; i < value.Count; i++) { value[i](); } } } } public virtual void ResetPosition() { base.transform.localPosition = this.init_pos_; } public virtual bool IsWindowInTheScreen() { if (this.uiCamera == null) { return true; } int margin = -30; Rect windowRectFromScreenPoint = this.GetWindowRectFromScreenPoint(margin); Rect rect = new Rect(0f, 0f, (float)Screen.width, (float)Screen.height); windowRectFromScreenPoint.position = new Vector3(windowRectFromScreenPoint.position.x, windowRectFromScreenPoint.y, 0f); bool flag = rect.Overlaps(windowRectFromScreenPoint); return rect.Overlaps(windowRectFromScreenPoint); } public virtual void OnActiveChangeWindowEvent(bool is_active) { } public virtual void SetWindowManager(BasePhotoWindowManager mgr) { this.mgr_ = mgr; } public string title { get { return this.title_bar_label_.text; } set { this.title_bar_label_.text = value; } } public string uniqueName { get { return this.uniqueWindowName; } } public int depth { get { return this.panel.GetComponentInChildren().depth / 10; } set { int num = value * 10; UIPanel[] componentsInChildren = this.panel.gameObject.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].depth = num++; } } } public virtual bool baseDraw { get { return this.bgWidget.alpha != 0f; } set { UIRect uirect = this.bgWidget; float alpha = (float)((!value) ? 0 : 1); this.bgWidget2.alpha = alpha; uirect.alpha = alpha; } } public virtual bool visible { get { return this.panel.alpha != 0f; } set { this.panel.alpha = (float)((!value) ? 0 : 1); if (value && !this.IsWindowInTheScreen()) { this.ResetPosition(); this.panelDirty = 6; } } } public UIPanel panel { get { if (this.panel_ == null) { this.panel_ = base.GetComponentInChildren(); } return this.panel_; } } public EventDelegate window_active_delegate { get { return this.window_active_delegate_; } } public virtual GameObject content_game_object { get { return this.content_game_object_; } } public Dictionary> GetWoldStoreData() { return this.mgr.GetWoldStoreData(this.windowName); } public virtual KeyValuePair> Serialize() { string key = base.gameObject.name + "title"; Dictionary dictionary = new Dictionary(); Vector3 localPosition = base.transform.localPosition; dictionary.Add("pos", string.Concat(new string[] { localPosition.x.ToString("G9"), ",", localPosition.y.ToString("G9"), ",", localPosition.z.ToString("G9") })); dictionary.Add("visible", this.visible.ToString()); for (int i = 0; i < this.subWindows.Length; i++) { dictionary.Add(i.ToString() + ":visible", this.subWindows[i].visible.ToString()); } return new KeyValuePair>(key, dictionary); } public virtual void Deserialize(Dictionary> data) { string key = base.gameObject.name + "title"; if (!data.ContainsKey(key)) { return; } Dictionary dictionary = data[key]; string[] array = dictionary["pos"].Split(new char[] { ',' }); base.transform.localPosition = new Vector3(float.Parse(array[0]), float.Parse(array[1]), float.Parse(array[2])); if (dictionary.ContainsKey("visible")) { this.visible = bool.Parse(dictionary["visible"]); } for (int i = 0; i < this.subWindows.Length; i++) { string key2 = i.ToString() + ":visible"; if (dictionary.ContainsKey(key2)) { this.subWindows[i].visible = bool.Parse(dictionary[key2]); } } } public Rect GetWindowRectFromScreenPoint() { return this.GetWindowRectFromScreenPoint(0); } public Rect GetWindowRectFromScreenPoint(int margin) { Vector3 position = this.bgWidget.transform.position; this.bgWidget.transform.localPosition = new Vector3(this.bgWidget.transform.localPosition.x - (float)margin, this.bgWidget.transform.localPosition.y + (float)margin, 0f); Vector2 vector = new Vector2(this.WindowSize.x + (float)(margin * 2), this.WindowSize.y + (float)(margin * 2)); Vector3 vector2 = this.uiCamera.WorldToScreenPoint(this.bgWidget.transform.position); Rect result = default(Rect); result.position = new Vector2(vector2.x, (float)Screen.height - vector2.y); Vector3 position2 = this.bgWidget.transform.position; Vector3 vector3 = this.uiCamera.WorldToScreenPoint(this.bgWidget.transform.position); this.bgWidget.transform.localPosition = this.bgWidget.transform.localPosition + new Vector3(vector.x, -vector.y, 0f); Vector3 vector4 = this.uiCamera.WorldToScreenPoint(this.bgWidget.transform.position); this.bgWidget.transform.position = position2; float x = vector4.x - vector3.x; float y = (float)Screen.height - vector4.y - ((float)Screen.height - vector3.y); result.size = new Vector2(x, y); this.bgWidget.transform.position = position; return result; } public BasePhotoWindowManager mgr { get { return this.mgr_; } } public abstract string windowName { get; } protected void OnBtnMouseHoverIn(string text) { MouseExposition @object = MouseExposition.GetObject(); @object.textFromLanguageTerm = text; } protected void OnMouseHoverOut() { MouseExposition @object = MouseExposition.GetObject(); @object.text = string.Empty; } public string InitTitle = "キャラクター"; [SerializeField] private string uniqueWindowName; public Vector2 WindowSize; public bool InitVisible = true; public BasePhotoSubWindow[] subWindows; private UIWidget bgWidget; private UIWidget bgWidget2; private int panelDirty; private UILabel windowTitle; protected Camera uiCamera; private UILabel title_bar_label_; protected UIPanel panel_; protected BasePhotoWindowManager mgr_; protected Dictionary>> btn_dic_; protected EventDelegate window_active_delegate_; protected GameObject content_game_object_; protected Vector3 init_pos_; private Dictionary mini_btn_init_pos_ = new Dictionary(); public enum BtnType { Help, Reset, Min, End } }