123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- public class BasePhotoSubWindow : MonoBehaviour
- {
- protected 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<BoxCollider>().size = new Vector3((float)num, (float)num2, 1f);
- UTY.GetChildObject(base.gameObject, "Parent", false).GetComponent<BoxCollider>().center = new Vector3((float)(num - 200) / 2f, (float)(num2 - 200) / -2f, 1f);
- UTY.GetChildObject(base.gameObject, "Parent/BG", false).GetComponent<UIWidget>().width = num;
- UTY.GetChildObject(base.gameObject, "Parent/BG", false).GetComponent<UIWidget>().height = num2;
- UTY.GetChildObject(base.gameObject, "Parent/BG2", false).GetComponent<UIWidget>().width = num;
- UTY.GetChildObject(base.gameObject, "Parent/BG2", false).GetComponent<UIWidget>().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<UIWidget>().width = num;
- UTY.GetChildObject(base.gameObject, "Parent/BG/TitleBar/Btn", false).transform.localPosition = new Vector3((float)(num - 10), -10f, 0f);
- UTY.GetChildObject(base.gameObject, "Parent/BG/TitleBar/Text", false).GetComponent<UILabel>().text = this.InitTitle;
- }
- public virtual void Initizalize(BasePhotoWindow parentWindow)
- {
- if (this.content_game_object_ != null)
- {
- return;
- }
- this.parent_window_ = parentWindow;
- this.ResizeWindow();
- 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<UIPanel>();
- }
- this.title_bar_label_ = UTY.GetChildObject(childObject, "Text", false).GetComponent<UILabel>();
- Dictionary<BasePhotoSubWindow.BtnType, string> dictionary = new Dictionary<BasePhotoSubWindow.BtnType, string>();
- dictionary.Add(BasePhotoSubWindow.BtnType.Help, "ヘルプ");
- dictionary.Add(BasePhotoSubWindow.BtnType.Min, "最小化");
- dictionary.Add(BasePhotoSubWindow.BtnType.Reset, "UI位置初期化");
- dictionary.Add(BasePhotoSubWindow.BtnType.End, "閉じる");
- this.btn_dic_ = new Dictionary<BasePhotoSubWindow.BtnType, KeyValuePair<UIButton, List<Action>>>();
- for (int i = 0; i <= 3; i++)
- {
- BasePhotoSubWindow.BtnType key = (BasePhotoSubWindow.BtnType)i;
- this.btn_dic_.Add(key, new KeyValuePair<UIButton, List<Action>>(UTY.GetChildObject(childObject, "Btn/" + key.ToString(), false).GetComponent<UIButton>(), new List<Action>()));
- 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<UIEventTrigger>().onHoverOver.Add(eventDelegate);
- EventDelegate.Add(key2.gameObject.GetComponent<UIEventTrigger>().onHoverOut, new EventDelegate.Callback(this.OnMouseHoverOut));
- }
- }
- this.window_active_delegate_ = new EventDelegate(new EventDelegate.Callback(parentWindow.ActiveWindow));
- this.init_pos_ = base.transform.localPosition;
- for (int j = 0; j <= 3; j++)
- {
- this.SetButtonEnabled((BasePhotoSubWindow.BtnType)j, false, false);
- }
- this.GetButtonOnClickEventList(BasePhotoSubWindow.BtnType.Reset).Add(delegate
- {
- this.ResetPosition();
- });
- if (!this.InitVisible)
- {
- this.visible = false;
- }
- }
- public void SetButtonEnabled(BasePhotoSubWindow.BtnType type, bool enabled, bool force_update = false)
- {
- this.btn_dic_[type].Key.gameObject.SetActive(enabled);
- foreach (KeyValuePair<BasePhotoSubWindow.BtnType, KeyValuePair<UIButton, List<Action>>> keyValuePair in this.btn_dic_)
- {
- keyValuePair.Value.Key.transform.localPosition = this.mini_btn_init_pos_[keyValuePair.Key];
- }
- UIGrid component = this.btn_dic_[BasePhotoSubWindow.BtnType.Help].Key.transform.parent.gameObject.GetComponent<UIGrid>();
- if (component != null)
- {
- if (force_update)
- {
- component.Reposition();
- }
- else
- {
- component.repositionNow = true;
- }
- }
- }
- public List<Action> GetButtonOnClickEventList(BasePhotoSubWindow.BtnType type)
- {
- return this.btn_dic_[type].Value;
- }
- public virtual void OnButtonClickEvent()
- {
- int instanceID = UIButton.current.GetInstanceID();
- foreach (KeyValuePair<BasePhotoSubWindow.BtnType, KeyValuePair<UIButton, List<Action>>> keyValuePair in this.btn_dic_)
- {
- if (instanceID == keyValuePair.Value.Key.GetInstanceID())
- {
- List<Action> 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 void OnActiveChangeWindowEvent(bool is_active)
- {
- }
- public string title
- {
- get
- {
- return this.title_bar_label_.text;
- }
- set
- {
- this.title_bar_label_.text = value;
- }
- }
- public int depth
- {
- get
- {
- return this.panel.GetComponentInChildren<UIPanel>().depth / 10;
- }
- set
- {
- int num = value * 10;
- UIPanel[] componentsInChildren = this.panel.gameObject.GetComponentsInChildren<UIPanel>(true);
- for (int i = 0; i < componentsInChildren.Length; i++)
- {
- componentsInChildren[i].depth = num++;
- }
- }
- }
- public bool visible
- {
- get
- {
- return this.panel.alpha != 0f;
- }
- set
- {
- this.panel.alpha = (float)((!value) ? 0 : 1);
- }
- }
- public UIPanel panel
- {
- get
- {
- if (this.panel_ == null)
- {
- this.panel_ = base.GetComponentInChildren<UIPanel>();
- }
- 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 BasePhotoWindowManager mgr
- {
- get
- {
- return this.parent_window_.mgr;
- }
- }
- protected void OnBtnMouseHoverIn(string text)
- {
- MouseExposition @object = MouseExposition.GetObject();
- @object.text = text;
- }
- protected void OnMouseHoverOut()
- {
- MouseExposition @object = MouseExposition.GetObject();
- @object.text = string.Empty;
- }
- public string InitTitle = "キャラクター";
- public Vector2 WindowSize;
- public bool InitVisible = true;
- protected BasePhotoWindow parent_window_;
- protected UILabel title_bar_label_;
- protected UIPanel panel_;
- protected BasePhotoWindowManager mgr_;
- protected Dictionary<BasePhotoSubWindow.BtnType, KeyValuePair<UIButton, List<Action>>> btn_dic_;
- protected EventDelegate window_active_delegate_;
- protected GameObject content_game_object_;
- protected Vector3 init_pos_;
- private Dictionary<BasePhotoSubWindow.BtnType, Vector3> mini_btn_init_pos_ = new Dictionary<BasePhotoSubWindow.BtnType, Vector3>();
- public enum BtnType
- {
- Help,
- Reset,
- Min,
- End
- }
- }
|