123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369 |
- using System;
- using System.Collections.Generic;
- using com.workman.cm3d2.scene.dailyEtc;
- using UnityEngine;
- using wf;
- public class DeskItemWindow : BasePhotoWindow
- {
- public override string windowName
- {
- get
- {
- return this.InitTitle;
- }
- }
- public override void Awake()
- {
- base.Awake();
- this.camera_move_support_ = base.gameObject.AddComponent<WfCameraMoveSupport>();
- this.PartsPopUpList.onChangePopUpListValue.Add(new Action<KeyValuePair<string, UnityEngine.Object>>(this.OnChangePopUpList));
- this.PartsTransForm.onChangeAxisVisibleType.Add(new Action(this.OnChangeAxisVisibleType));
- this.CheckBoxVisible.onClick.Add(new Action<WFCheckBox>(this.OnClickVisible));
- this.CheckBoxSeasonalVisible.onClick.Add(new Action<WFCheckBox>(this.OnClickSeasonalVisible));
- }
- public override void Start()
- {
- base.Start();
- base.SetButtonEnabled(BasePhotoWindow.BtnType.Help, true, false);
- base.GetButtonOnClickEventList(BasePhotoWindow.BtnType.Help).Add(new Action(this.OnClickHelp));
- if (string.IsNullOrEmpty(GameMain.Instance.BgMgr.GetBGName()))
- {
- GameMain.Instance.BgMgr.ChangeBg(DailyAPI.dayBg);
- }
- List<DeskManager.InstansData> item_inst_data = DeskManager.item_inst_data;
- int num = 0;
- foreach (DeskManager.InstansData instansData in item_inst_data)
- {
- if (instansData.item_data != null && instansData.IsPossessing() && !(instansData.item_object == null))
- {
- int category_id = instansData.item_data.category_id;
- if (!this.category_dic_.ContainsKey(category_id))
- {
- this.category_dic_.Add(category_id, new List<DeskManager.InstansData>());
- }
- this.category_dic_[category_id].Add(instansData);
- num = System.Math.Max(num, this.category_dic_[category_id].Count);
- DeskItemWindow.UIObject uiobject = DeskItemWindow.UIObject.Create(instansData.item_object);
- uiobject.axis_obj.offsetScale = instansData.item_data.init_ui_position_scale;
- uiobject.axis_obj.ScaleMinMax = new Vector2(this.PartsTransForm.ScaleInput.SliderMin, this.PartsTransForm.ScaleInput.SliderMax);
- if (GameMain.Instance.VRMode)
- {
- MeshRenderer componentInChildren = uiobject.axis_obj.GetComponentInChildren<MeshRenderer>();
- if (componentInChildren != null)
- {
- componentInChildren.enabled = false;
- }
- BoxCollider[] componentsInChildren = uiobject.axis_obj.GetComponentsInChildren<BoxCollider>();
- foreach (BoxCollider boxCollider in componentsInChildren)
- {
- boxCollider.enabled = false;
- }
- }
- uiobject.rotate_obj.offsetScale = instansData.item_data.init_ui_position_scale;
- this.uiobject_dic_.Add(instansData.item_object, uiobject);
- }
- }
- foreach (KeyValuePair<int, List<DeskManager.InstansData>> keyValuePair in this.category_dic_)
- {
- keyValuePair.Value.Sort((DeskManager.InstansData a, DeskManager.InstansData b) => a.id - b.id);
- }
- for (int j = 0; j < num; j++)
- {
- GameObject gameObject = Utility.CreatePrefab(this.PartsTabPabel.gameObject, "ScenePhotoMode/WindowListItemBig", true);
- }
- List<KeyValuePair<string, UnityEngine.Object>> list = new List<KeyValuePair<string, UnityEngine.Object>>();
- foreach (KeyValuePair<int, List<DeskManager.InstansData>> keyValuePair2 in this.category_dic_)
- {
- list.Add(new KeyValuePair<string, UnityEngine.Object>(DeskManager.item_category_data_dic[keyValuePair2.Key], null));
- }
- this.PartsPopUpList.popup_value_list = list;
- if (0 < this.PartsPopUpList.popup_value_list.Count)
- {
- this.PartsPopUpList.SetPopupValue(this.PartsPopUpList.popup_value_list[0].Key);
- }
- if (2 <= list.Count)
- {
- this.WindowSize.y = this.WindowSize.y + 30f;
- base.ResizeWindow();
- Transform transform = UTY.GetChildObject(base.gameObject, "Parent/ContentParent", false).transform;
- Vector3 localPosition = transform.localPosition;
- localPosition.y -= 30f;
- transform.localPosition = localPosition;
- transform = UTY.GetChildObject(base.gameObject, "Parent/ListParent", false).transform;
- localPosition = transform.localPosition;
- localPosition.y -= 30f;
- transform.localPosition = localPosition;
- }
- }
- protected void OnChangePopUpList(KeyValuePair<string, UnityEngine.Object> popup_val)
- {
- if (this.select_pop_up_value_name_ == popup_val.Key)
- {
- return;
- }
- this.select_pop_up_value_name_ = popup_val.Key;
- int num = -1;
- foreach (KeyValuePair<int, string> keyValuePair in DeskManager.item_category_data_dic)
- {
- if (keyValuePair.Value == popup_val.Key)
- {
- num = keyValuePair.Key;
- break;
- }
- }
- if (num < 0)
- {
- return;
- }
- List<DeskManager.InstansData> list = null;
- if (this.category_dic_.ContainsKey(num))
- {
- list = this.category_dic_[num];
- }
- if (list == null)
- {
- return;
- }
- Transform transform = this.PartsTabPabel.gameObject.transform;
- for (int i = 0; i < transform.childCount; i++)
- {
- if (i < list.Count)
- {
- DeskManager.InstansData instansData = list[i];
- GameObject gameObject = transform.GetChild(i).gameObject;
- gameObject.SetActive(true);
- string name = instansData.item_data.name;
- gameObject.name = instansData.id.ToString();
- UILabel componentInChildren = gameObject.GetComponentInChildren<UILabel>();
- componentInChildren.text = name;
- int j = componentInChildren.width;
- componentInChildren.width = 0;
- componentInChildren.MakePixelPerfect();
- while (j < componentInChildren.width)
- {
- componentInChildren.fontSize--;
- componentInChildren.width = 0;
- componentInChildren.MakePixelPerfect();
- }
- componentInChildren.width = j;
- UIWFTabButton component = gameObject.GetComponent<UIWFTabButton>();
- component.onSelect.Clear();
- EventDelegate.Add(component.onSelect, new EventDelegate.Callback(this.OnSelectItem));
- }
- else
- {
- transform.GetChild(i).gameObject.SetActive(false);
- }
- }
- UIGrid component2 = this.PartsTabPabel.GetComponent<UIGrid>();
- this.PartsTabPabel.UpdateChildren();
- Utility.ResetNGUI(component2);
- Utility.ResetNGUI(this.PartsScrollView);
- this.PartsTabPabel.Select(component2.GetChild(0).GetComponentInChildren<UIWFTabButton>());
- if (this.category_dic_.Count <= 1)
- {
- this.PartsPopUpList.gameObject.SetActive(false);
- }
- }
- protected void OnSelectItem()
- {
- if (!UIWFSelectButton.current.isSelected)
- {
- return;
- }
- int num = int.Parse(UIWFSelectButton.current.name);
- GameObject gameObject = null;
- DeskManager.InstansData instansData = null;
- List<DeskManager.InstansData> item_inst_data = DeskManager.item_inst_data;
- int num2 = 0;
- while (num2 < item_inst_data.Count && gameObject == null)
- {
- if (item_inst_data[num2].id == num)
- {
- gameObject = item_inst_data[num2].item_object;
- instansData = item_inst_data[num2];
- }
- num2++;
- }
- KeyValuePair<string, UnityEngine.Object> keyValuePair = new KeyValuePair<string, UnityEngine.Object>(string.Empty, gameObject);
- this.select_item_ = null;
- GameObject target_object = (!(keyValuePair.Value == null)) ? (keyValuePair.Value as GameObject) : null;
- this.CheckBoxVisible.enabled = false;
- this.CheckBoxSeasonalVisible.visible = false;
- if (keyValuePair.Value == null)
- {
- this.PartsTransForm.SetObject(null);
- return;
- }
- if (instansData == null)
- {
- return;
- }
- this.PartsTransForm.SetObject(target_object, instansData.item_data.init_position, instansData.item_data.init_rotation, instansData.item_data.init_scale);
- this.select_item_ = instansData;
- if (this.select_item_.item_data.seasonal)
- {
- this.CheckBoxSeasonalVisible.text = "特定期間のみ表示する(" + this.select_item_.item_data.seasonal_month[0].ToString() + "月)";
- }
- this.UpdateUI();
- }
- public void UpdateVisible()
- {
- if (this.select_item_ == null)
- {
- this.CheckBoxVisible.enabled = false;
- this.CheckBoxSeasonalVisible.visible = false;
- return;
- }
- this.CheckBoxVisible.enabled = true;
- this.CheckBoxVisible.check = this.select_item_.visible;
- if (this.select_item_.item_data.seasonal)
- {
- this.CheckBoxSeasonalVisible.visible = true;
- this.CheckBoxSeasonalVisible.check = this.select_item_.only_season_visible;
- }
- else
- {
- this.CheckBoxSeasonalVisible.visible = false;
- }
- List<DeskManager.InstansData> item_inst_data = DeskManager.item_inst_data;
- for (int i = 0; i < item_inst_data.Count; i++)
- {
- if (!(item_inst_data[i].item_object == null))
- {
- if (!item_inst_data[i].item_data.seasonal || !item_inst_data[i].visible || item_inst_data[i] == this.select_item_)
- {
- item_inst_data[i].item_object.SetActive(item_inst_data[i].visible);
- }
- else if (item_inst_data[i].only_season_visible)
- {
- item_inst_data[i].item_object.SetActive(item_inst_data[i].IsNowMonthSeason());
- }
- }
- }
- }
- public void UpdateUI()
- {
- this.UpdateVisible();
- this.OnChangeAxisVisibleType();
- }
- protected void OnChangeAxisVisibleType()
- {
- if (this.select_item_ == null)
- {
- return;
- }
- GameObject item_object = this.select_item_.item_object;
- WindowPartsTransform.AxisVisibleType axis_visible_type = this.PartsTransForm.axis_visible_type;
- foreach (KeyValuePair<GameObject, DeskItemWindow.UIObject> keyValuePair in this.uiobject_dic_)
- {
- DeskItemWindow.UIObject value = keyValuePair.Value;
- if (axis_visible_type == WindowPartsTransform.AxisVisibleType.UnVisible || item_object != keyValuePair.Key || !item_object.activeSelf)
- {
- value.axis_obj.Visible = false;
- value.rotate_obj.Visible = false;
- }
- else if (axis_visible_type == WindowPartsTransform.AxisVisibleType.Position)
- {
- value.axis_obj.Visible = true;
- value.rotate_obj.Visible = false;
- }
- else if (axis_visible_type == WindowPartsTransform.AxisVisibleType.Rotate)
- {
- value.axis_obj.Visible = false;
- value.rotate_obj.Visible = true;
- }
- }
- }
- public void OnClickCameraFocus()
- {
- if (this.select_item_ == null || this.select_item_.item_object == null)
- {
- return;
- }
- Transform transform = this.select_item_.item_object.transform;
- Vector3 position = transform.position;
- float distance = 1.6f;
- Vector2 aroundAngle = new Vector2(-90f, 4.7f);
- this.camera_move_support_.StartCameraPosition(position, distance, aroundAngle);
- }
- protected void OnClickVisible(WFCheckBox checkbox)
- {
- if (this.select_item_ == null)
- {
- return;
- }
- this.select_item_.visible = checkbox.check;
- this.UpdateUI();
- }
- protected void OnClickSeasonalVisible(WFCheckBox checkbox)
- {
- if (this.select_item_ == null || !this.select_item_.item_data.seasonal)
- {
- return;
- }
- this.select_item_.only_season_visible = checkbox.check;
- this.UpdateUI();
- }
- protected void OnClickHelp()
- {
- uGUITutorialPanel.OpenTutorial("SceneDeskCustomize", null, true);
- }
- public WFCheckBox CheckBoxVisible;
- public WFCheckBox CheckBoxSeasonalVisible;
- public WindowPartsPopUpList PartsPopUpList;
- public WindowPartsTransform PartsTransForm;
- public UIWFTabPanel PartsTabPabel;
- public UIScrollView PartsScrollView;
- private SortedDictionary<int, List<DeskManager.InstansData>> category_dic_ = new SortedDictionary<int, List<DeskManager.InstansData>>();
- private Dictionary<GameObject, DeskItemWindow.UIObject> uiobject_dic_ = new Dictionary<GameObject, DeskItemWindow.UIObject>();
- private DeskManager.InstansData select_item_;
- private string select_pop_up_value_name_ = string.Empty;
- private WfCameraMoveSupport camera_move_support_;
- public class UIObject
- {
- private UIObject()
- {
- }
- public static DeskItemWindow.UIObject Create(GameObject target_obj)
- {
- return new DeskItemWindow.UIObject
- {
- target_obj = target_obj,
- rotate_obj = PhotoWindowManager.CreateWorldTransformRotate(target_obj, false),
- axis_obj = PhotoWindowManager.CreateWorldTransformAxis(target_obj, false, false)
- };
- }
- public WorldTransformAxis axis_obj;
- public GizmoRender rotate_obj;
- public GameObject target_obj;
- }
- }
|