123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582 |
- using System;
- using System.Collections.Generic;
- using I2.Loc;
- using UnityEngine;
- using wf;
- public class ObjectManagerWindow : BaseMaidPhotoWindow
- {
- public override void Awake()
- {
- base.Awake();
- this.camera_move_support_ = base.gameObject.AddComponent<WfCameraMoveSupport>();
- this.scroll_view_ = NGUITools.FindInParents<UIScrollView>(this.Grid.transform);
- EventDelegate.Add(this.CameraFocusButton.onClick, new EventDelegate.Callback(this.OnClickCameraFocus));
- this.VisibleCheckButton.onClick.Add(delegate(WFCheckBox check_box)
- {
- if (this.select_trans_target_ != null && this.select_trans_target_.obj != null)
- {
- this.select_trans_target_.obj.SetActive(check_box.check);
- }
- });
- EventDelegate.Add(this.RemoveButton.onClick, delegate()
- {
- if (this.select_trans_target_.obj == null || this.select_trans_target_.type == PhotoTransTargetObject.Type.BG)
- {
- return;
- }
- this.createBgObjectWindow.RemoveObject(this.select_trans_target_.obj);
- });
- this.CheckCreateWindowVisible.onClick.Add(delegate(WFCheckBox check_box)
- {
- this.createBgObjectWindow.visible = check_box.check;
- if (check_box.check)
- {
- this.CheckAttacWindowVisible.check = false;
- this.AttachPointWindow.visible = false;
- }
- });
- this.createBgObjectWindow.GetButtonOnClickEventList(BasePhotoSubWindow.BtnType.End).Add(delegate
- {
- this.CheckCreateWindowVisible.check = false;
- foreach (Action<WFCheckBox> action in this.CheckCreateWindowVisible.onClick)
- {
- action(this.CheckCreateWindowVisible);
- }
- });
- this.createBgObjectWindow.SetButtonEnabled(BasePhotoSubWindow.BtnType.End, true, false);
- this.AttachPointWindow.onStateTextChangeEvent = delegate(string text)
- {
- this.AttachPointStateLabel.text = text;
- if (Product.supportMultiLanguage)
- {
- string termPrefix = string.Empty;
- string term;
- if (text.LastIndexOf(" : ") != -1)
- {
- int num = text.LastIndexOf(" : ") + 3;
- termPrefix = text.Substring(0, num);
- term = "ScenePhotoMode/アタッチポイント/" + text.Substring(num);
- }
- else
- {
- term = "ScenePhotoMode/アタッチポイント/" + text;
- }
- Localize component = this.AttachPointStateLabel.GetComponent<Localize>();
- if (component != null)
- {
- component.TermPrefix = termPrefix;
- component.SetTerm(term);
- }
- }
- };
- this.AttachPointWindow.gameObject.SetActive(true);
- WFCheckBox checkAttacWindowVisible = this.CheckAttacWindowVisible;
- bool flag = false;
- this.CheckAttacWindowVisible.enabled = flag;
- checkAttacWindowVisible.check = flag;
- this.AttachPointWindow.SetButtonEnabled(BasePhotoSubWindow.BtnType.End, true, false);
- this.AttachPointWindow.GetButtonOnClickEventList(BasePhotoSubWindow.BtnType.End).Add(delegate
- {
- this.CheckAttacWindowVisible.check = false;
- foreach (Action<WFCheckBox> action in this.CheckAttacWindowVisible.onClick)
- {
- action(this.CheckAttacWindowVisible);
- }
- });
- this.CheckAttacWindowVisible.onClick.Add(delegate(WFCheckBox check_box)
- {
- this.AttachPointWindow.visible = check_box.check;
- if (check_box.check)
- {
- this.CheckCreateWindowVisible.check = false;
- this.createBgObjectWindow.visible = false;
- }
- });
- this.PartsTransForm.onChangeAxisVisibleType.Add(new Action(this.OnChangeAxisVisibleType));
- this.target_list_.Add(new PhotoTransTargetObject(null, "選択なし", "ScenePhotoMode/選択なし", PhotoTransTargetObject.Type.Maid, Vector2.zero));
- this.CreateTabButton(this.Grid.gameObject, this.target_list_[0]);
- this.TabPanel.UpdateChildren();
- this.TabPanel.Select(this.Grid.GetChild(0).gameObject.GetComponent<UIWFTabButton>());
- this.Grid.sorting = UIGrid.Sorting.Vertical;
- Utility.ResetNGUI(this.Grid);
- Utility.ResetNGUI(this.scroll_view_);
- this.UpdateChildren();
- }
- public override void Start()
- {
- base.Start();
- this.AttachPointWindow.gameObject.SetActive(false);
- }
- public new void Update()
- {
- if (Input.GetKeyDown(KeyCode.F3))
- {
- this.PartsTransForm.NextAxis();
- }
- if (Input.GetKeyDown(KeyCode.F4) && this.CameraFocusButton.isEnabled)
- {
- this.OnClickCameraFocus();
- }
- }
- public void OnSelectItem(PhotoTransTargetObject select)
- {
- this.select_trans_target_ = select;
- if (select == null)
- {
- return;
- }
- if (select.obj == null || select.type == PhotoTransTargetObject.Type.BG)
- {
- this.RemoveButton.gameObject.SetActive(false);
- this.AttachPointWindow.gameObject.SetActive(false);
- WFCheckBox checkAttacWindowVisible = this.CheckAttacWindowVisible;
- bool flag = false;
- this.CheckAttacWindowVisible.visible = flag;
- flag = flag;
- this.CheckAttacWindowVisible.check = flag;
- checkAttacWindowVisible.enabled = flag;
- this.AttachPointWindow.onStateTextChangeEvent("設定不可");
- }
- else
- {
- this.RemoveButton.gameObject.SetActive(true);
- this.AttachPointWindow.gameObject.SetActive(true);
- this.CheckAttacWindowVisible.enabled = (this.AttachPointWindow.activeMaidListCount != 0);
- this.CheckAttacWindowVisible.visible = true;
- this.CheckAttacWindowVisible.check = this.AttachPointWindow.visible;
- foreach (Action<WFCheckBox> action in this.CheckAttacWindowVisible.onClick)
- {
- action(this.CheckAttacWindowVisible);
- }
- }
- if (select != null && select.obj != null && select.axis_obj != null && select.rotate_obj != null)
- {
- select.axis_obj.Visible = (select.rotate_obj.Visible = false);
- }
- if (select.obj != null)
- {
- UIButtonColor cameraFocusButton = this.CameraFocusButton;
- bool flag = true;
- this.VisibleCheckButton.enabled = flag;
- cameraFocusButton.isEnabled = flag;
- this.VisibleCheckButton.check = select.obj.activeSelf;
- if (select.type == PhotoTransTargetObject.Type.BG)
- {
- this.VisibleCheckButton.visible = false;
- }
- else
- {
- this.VisibleCheckButton.visible = true;
- }
- }
- else
- {
- this.VisibleCheckButton.visible = false;
- UIButtonColor cameraFocusButton2 = this.CameraFocusButton;
- bool flag = false;
- this.VisibleCheckButton.check = flag;
- flag = flag;
- this.VisibleCheckButton.enabled = flag;
- cameraFocusButton2.isEnabled = flag;
- }
- this.PartsTransForm.SetObject(select.obj, Vector3.zero, Vector3.zero, Vector3.one);
- this.OnChangeAxisVisibleType();
- this.AttachPointWindow.OnSelectItem(select);
- }
- public override void OnMaidAddEvent(Maid maid, bool is_deserialize_load)
- {
- if (is_deserialize_load)
- {
- foreach (PhotoTransTargetObject photoTransTargetObject in this.target_list_)
- {
- if (!string.IsNullOrEmpty(photoTransTargetObject.attach_maid_guid) && !(photoTransTargetObject.attach_maid_guid != maid.status.guid))
- {
- Transform transform = photoTransTargetObject.obj.transform;
- Vector3 position = transform.position;
- Quaternion rotation = transform.rotation;
- photoTransTargetObject.Attach(photoTransTargetObject.attachi_point, false, maid);
- transform.localPosition = photoTransTargetObject.attachi_local_pos;
- transform.localRotation = photoTransTargetObject.attachi_local_rotate;
- }
- }
- }
- this.AttachPointWindow.OnMaidAddEvent(maid, is_deserialize_load);
- if (this.CheckAttacWindowVisible.visible)
- {
- this.CheckAttacWindowVisible.enabled = (this.AttachPointWindow.activeMaidListCount != 0);
- }
- }
- public override void OnMaidRemoveEventPrev(Maid maid)
- {
- List<GameObject> list = new List<GameObject>();
- foreach (PhotoTransTargetObject photoTransTargetObject in this.target_list_)
- {
- if (photoTransTargetObject.attachi_point != PhotoTransTargetObject.AttachPoint.Null && photoTransTargetObject.attach_maid_guid == maid.status.guid)
- {
- list.Add(photoTransTargetObject.obj);
- }
- }
- for (int i = 0; i < list.Count; i++)
- {
- this.createBgObjectWindow.RemoveObject(list[i]);
- }
- this.AttachPointWindow.OnMaidRemoveEventPrev(maid);
- if (this.AttachPointWindow.activeMaidList.Count <= 0)
- {
- this.CheckAttacWindowVisible.check = false;
- foreach (Action<WFCheckBox> action in this.CheckAttacWindowVisible.onClick)
- {
- action(this.CheckAttacWindowVisible);
- }
- }
- if (this.CheckAttacWindowVisible.visible)
- {
- this.CheckAttacWindowVisible.enabled = (this.AttachPointWindow.activeMaidListCount != 0);
- }
- }
- public PhotoTransTargetObject AddTransTargetObject(GameObject target_obj, string draw_name, string nameTerm, PhotoTransTargetObject.Type type)
- {
- if (target_obj == null)
- {
- return null;
- }
- PhotoTransTargetObject photoTransTargetObject = new PhotoTransTargetObject(target_obj, draw_name, nameTerm, type, new Vector2(this.PartsTransForm.ScaleInput.SliderMin, this.PartsTransForm.ScaleInput.SliderMax));
- if (GameMain.Instance.VRMode && type != PhotoTransTargetObject.Type.BG)
- {
- MeshRenderer componentInChildren = photoTransTargetObject.axis_obj.GetComponentInChildren<MeshRenderer>();
- if (componentInChildren != null)
- {
- componentInChildren.enabled = false;
- }
- BoxCollider[] componentsInChildren = photoTransTargetObject.axis_obj.GetComponentsInChildren<BoxCollider>();
- foreach (BoxCollider boxCollider in componentsInChildren)
- {
- boxCollider.enabled = false;
- }
- }
- this.target_list_.Add(photoTransTargetObject);
- this.target_list_.Sort();
- UIWFTabButton uiwftabButton = this.CreateTabButton(this.Grid.gameObject, photoTransTargetObject);
- UIEventTrigger[] componentsInChildren2 = uiwftabButton.gameObject.GetComponentsInChildren<UIEventTrigger>();
- List<EventDelegate> onPress = this.Grid.GetChild(0).GetComponent<UIEventTrigger>().onPress;
- for (int j = 0; j < componentsInChildren2.Length; j++)
- {
- componentsInChildren2[j].onPress = onPress;
- }
- Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>();
- List<Transform> childList = this.Grid.GetChildList();
- for (int k = 0; k < childList.Count; k++)
- {
- dictionary.Add(childList[k].name, childList[k].transform);
- }
- for (int l = 0; l < this.target_list_.Count; l++)
- {
- if (dictionary.ContainsKey(this.target_list_[l].guid))
- {
- dictionary[this.target_list_[l].guid].localPosition = new Vector3(0f, (float)(l * 10), 0f);
- }
- }
- this.TabPanel.UpdateChildren();
- this.Grid.Reposition();
- this.scroll_view_.UpdatePosition();
- if (this.change_bg_ && type == PhotoTransTargetObject.Type.BG)
- {
- this.TabPanel.Select(uiwftabButton);
- this.change_bg_ = false;
- }
- return photoTransTargetObject;
- }
- public void RemoveTransTargetObject(GameObject target_obj)
- {
- if (target_obj == null)
- {
- return;
- }
- bool flag = false;
- this.change_bg_ = false;
- UIWFTabButton selectButtonObject = this.TabPanel.GetSelectButtonObject();
- string text = string.Empty;
- for (int i = 0; i < this.target_list_.Count; i++)
- {
- if (this.target_list_[i].obj == target_obj)
- {
- flag = (this.target_list_[i].type == PhotoTransTargetObject.Type.BG);
- if (flag && selectButtonObject != null && this.target_list_[i].guid == selectButtonObject.name)
- {
- this.change_bg_ = true;
- }
- text = this.target_list_[i].guid;
- this.target_list_[i].Delete();
- this.target_list_.RemoveAt(i);
- break;
- }
- }
- if (!string.IsNullOrEmpty(text))
- {
- if (selectButtonObject != null && selectButtonObject.name == text)
- {
- List<Transform> childList = this.Grid.GetChildList();
- for (int j = 0; j < childList.Count; j++)
- {
- if (childList[j].name == text)
- {
- if (j + 1 < childList.Count)
- {
- this.TabPanel.Select(this.Grid.GetChild(j + 1).gameObject.GetComponent<UIWFTabButton>());
- }
- else
- {
- this.TabPanel.Select(this.Grid.GetChild(j - 1).gameObject.GetComponent<UIWFTabButton>());
- }
- break;
- }
- }
- }
- List<Transform> childList2 = this.Grid.GetChildList();
- for (int k = 0; k < childList2.Count; k++)
- {
- if (childList2[k].gameObject.name == text)
- {
- childList2[k].gameObject.transform.SetParent(null, false);
- UnityEngine.Object.Destroy(childList2[k].gameObject);
- }
- }
- int num = 12;
- if (flag)
- {
- num--;
- }
- Utility.ResetNGUI(this.Grid);
- if (this.Grid.GetChildList().Count <= num)
- {
- Utility.ResetNGUI(this.scroll_view_);
- }
- else
- {
- this.scroll_view_.UpdatePosition();
- this.scroll_view_.UpdateScrollbars();
- }
- this.TabPanel.UpdateChildren();
- }
- }
- protected void OnChangeAxisVisibleType()
- {
- WindowPartsTransform.AxisVisibleType axis_visible_type = this.PartsTransForm.axis_visible_type;
- for (int i = 0; i < this.target_list_.Count; i++)
- {
- PhotoTransTargetObject photoTransTargetObject = this.target_list_[i];
- if (photoTransTargetObject != null && !(photoTransTargetObject.obj == null))
- {
- if (axis_visible_type == WindowPartsTransform.AxisVisibleType.UnVisible || photoTransTargetObject == null || photoTransTargetObject.obj == null || photoTransTargetObject != this.select_trans_target_)
- {
- if (photoTransTargetObject.axis_obj != null)
- {
- photoTransTargetObject.axis_obj.Visible = false;
- }
- if (photoTransTargetObject.rotate_obj != null)
- {
- photoTransTargetObject.rotate_obj.Visible = false;
- }
- }
- else if (axis_visible_type == WindowPartsTransform.AxisVisibleType.Position)
- {
- if (photoTransTargetObject.axis_obj != null)
- {
- photoTransTargetObject.axis_obj.Visible = true;
- }
- if (photoTransTargetObject.rotate_obj != null)
- {
- photoTransTargetObject.rotate_obj.Visible = false;
- }
- }
- else if (axis_visible_type == WindowPartsTransform.AxisVisibleType.Rotate)
- {
- if (photoTransTargetObject.axis_obj != null)
- {
- photoTransTargetObject.axis_obj.Visible = false;
- }
- if (photoTransTargetObject.rotate_obj != null)
- {
- photoTransTargetObject.rotate_obj.Visible = true;
- }
- }
- }
- }
- }
- public void OnClickCameraFocus()
- {
- if (this.select_trans_target_ == null || this.select_trans_target_.obj == null)
- {
- return;
- }
- Vector3 position = this.select_trans_target_.obj.transform.position;
- float distance = 4f;
- Vector2 aroundAngle = new Vector2(-180f, 4.7f);
- this.camera_move_support_.StartCameraPosition(position, distance, aroundAngle);
- }
- private UIWFTabButton CreateTabButton(GameObject parent_obj, PhotoTransTargetObject target)
- {
- GameObject gameObject = Utility.CreatePrefab(parent_obj, "ScenePhotoMode/WindowListItem", true);
- gameObject.name = target.guid.ToString();
- gameObject.GetComponentInChildren<UILabel>().text = target.draw_name;
- Utility.SetLocalizeTerm(gameObject.GetComponentInChildren<Localize>(), target.nameTerm, false);
- UIWFTabButton component = gameObject.GetComponent<UIWFTabButton>();
- EventDelegate.Add(component.onSelect, delegate()
- {
- if (!UIWFSelectButton.current.isSelected)
- {
- return;
- }
- for (int i = 0; i < this.target_list_.Count; i++)
- {
- if (this.target_list_[i].guid == UIWFSelectButton.current.name)
- {
- this.OnSelectItem(this.target_list_[i]);
- break;
- }
- }
- });
- return component;
- }
- public override void OnSerializeEvent()
- {
- Dictionary<string, Dictionary<string, string>> woldStoreData = base.GetWoldStoreData();
- woldStoreData.Clear();
- this.createBgObjectWindow.OnSerializeEvent(ref woldStoreData);
- foreach (PhotoTransTargetObject photoTransTargetObject in this.target_list_)
- {
- if (!(photoTransTargetObject.obj == null) && photoTransTargetObject.type != PhotoTransTargetObject.Type.BG)
- {
- Dictionary<string, string> dictionary = woldStoreData[photoTransTargetObject.obj.name];
- dictionary["attachi_point"] = photoTransTargetObject.attachi_point.ToString();
- dictionary["attachi_maid_guid"] = photoTransTargetObject.attach_maid_guid.ToString();
- dictionary["attachi_local_pos"] = photoTransTargetObject.obj.transform.localPosition.ToString("G9");
- dictionary["attachi_local_rotation"] = photoTransTargetObject.obj.transform.localRotation.ToString("G9");
- }
- }
- }
- public override void OnDeserializeEvent()
- {
- Dictionary<string, Dictionary<string, string>> woldStoreData = base.GetWoldStoreData();
- List<string> list = new List<string>();
- foreach (KeyValuePair<string, Dictionary<string, string>> keyValuePair in woldStoreData)
- {
- string key = keyValuePair.Key;
- Dictionary<string, string> value = keyValuePair.Value;
- string text = value["attachi_maid_guid"];
- if (!string.IsNullOrEmpty(text))
- {
- if (!PhotoWindowManager.maidGuidReplaceDic.ContainsKey(text))
- {
- value["attachi_maid_guid"] = text;
- }
- else if (string.IsNullOrEmpty(PhotoWindowManager.maidGuidReplaceDic[text]))
- {
- list.Add(key);
- }
- else
- {
- value["attachi_maid_guid"] = PhotoWindowManager.maidGuidReplaceDic[text];
- }
- }
- }
- foreach (string key2 in list)
- {
- woldStoreData.Remove(key2);
- }
- this.createBgObjectWindow.OnDeserializeEvent(ref woldStoreData);
- foreach (KeyValuePair<string, Dictionary<string, string>> keyValuePair2 in woldStoreData)
- {
- string key3 = keyValuePair2.Key;
- Dictionary<string, string> value2 = keyValuePair2.Value;
- string text2 = value2["attachi_maid_guid"];
- PhotoTransTargetObject.AttachPoint attachi_point = (PhotoTransTargetObject.AttachPoint)Enum.Parse(typeof(PhotoTransTargetObject.AttachPoint), value2["attachi_point"]);
- Vector3 attachi_local_pos = Parse.Vector3(value2["attachi_local_pos"]);
- Quaternion attachi_local_rotate = Parse.Quaternion(value2["attachi_local_rotation"]);
- if (!string.IsNullOrEmpty(text2))
- {
- for (int i = 0; i < this.target_list_.Count; i++)
- {
- if (this.target_list_[i].obj != null && this.target_list_[i].obj.name == key3)
- {
- this.target_list_[i].attach_maid_guid = text2;
- this.target_list_[i].attachi_point = attachi_point;
- this.target_list_[i].attachi_local_pos = attachi_local_pos;
- this.target_list_[i].attachi_local_rotate = attachi_local_rotate;
- break;
- }
- }
- }
- }
- this.TabPanel.Select(this.Grid.GetChild(0).gameObject.GetComponent<UIWFTabButton>());
- this.Grid.Reposition();
- this.scroll_view_.ResetPosition();
- }
- public override KeyValuePair<string, Dictionary<string, string>> Serialize()
- {
- KeyValuePair<string, Dictionary<string, string>> result = base.Serialize();
- Dictionary<string, string> value = result.Value;
- this.AttachPointWindow.Serialize(ref value);
- result = new KeyValuePair<string, Dictionary<string, string>>(result.Key, value);
- return result;
- }
- public override void Deserialize(Dictionary<string, Dictionary<string, string>> data)
- {
- base.Deserialize(data);
- string key = base.gameObject.name + "title";
- if (!data.ContainsKey(key))
- {
- return;
- }
- Dictionary<string, string> deserializeData = data[key];
- this.AttachPointWindow.Deserialize(deserializeData);
- this.CheckCreateWindowVisible.check = this.createBgObjectWindow.visible;
- }
- public WFCheckBox CheckCreateWindowVisible;
- public CreateBGObjectSubWindow createBgObjectWindow;
- public WFCheckBox CheckAttacWindowVisible;
- public AttachPointSubWindow AttachPointWindow;
- public UILabel AttachPointStateLabel;
- public UIButton RemoveButton;
- public UIGrid Grid;
- public UIWFTabPanel TabPanel;
- public WindowPartsTransform PartsTransForm;
- public UIButton CameraFocusButton;
- public WFCheckBox VisibleCheckButton;
- private List<PhotoTransTargetObject> target_list_ = new List<PhotoTransTargetObject>();
- private bool change_bg_;
- private PhotoTransTargetObject select_trans_target_;
- private WfCameraMoveSupport camera_move_support_;
- private UIScrollView scroll_view_;
- }
|