using System; using System.Collections.Generic; using com.workman.cm3d2.scene.dailyEtc; using I2.Loc; 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(); this.PartsPopUpList.onChangePopUpListValue.Add(new Action>(this.OnChangePopUpList)); this.PartsTransForm.onChangeAxisVisibleType.Add(new Action(this.OnChangeAxisVisibleType)); this.CheckBoxVisible.onClick.Add(new Action(this.OnClickVisible)); this.CheckBoxSeasonalVisible.onClick.Add(new Action(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 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()); } 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(); if (componentInChildren != null) { componentInChildren.enabled = false; } BoxCollider[] componentsInChildren = uiobject.axis_obj.GetComponentsInChildren(); 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> 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> list = new List>(); foreach (KeyValuePair> keyValuePair2 in this.category_dic_) { list.Add(new KeyValuePair(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 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 keyValuePair in DeskManager.item_category_data_dic) { if (keyValuePair.Value == popup_val.Key) { num = keyValuePair.Key; break; } } if (num < 0) { return; } List 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(); componentInChildren.text = name; Localize component = componentInChildren.GetComponent(); if (component != null) { component.SetTerm("SceneDeskCustomize/" + 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 component2 = gameObject.GetComponent(); component2.onSelect.Clear(); EventDelegate.Add(component2.onSelect, new EventDelegate.Callback(this.OnSelectItem)); } else { transform.GetChild(i).gameObject.SetActive(false); } } UIGrid component3 = this.PartsTabPabel.GetComponent(); this.PartsTabPabel.UpdateChildren(); Utility.ResetNGUI(component3); Utility.ResetNGUI(this.PartsScrollView); this.PartsTabPabel.Select(component3.GetChild(0).GetComponentInChildren()); 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 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 keyValuePair = new KeyValuePair(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 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 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> category_dic_ = new SortedDictionary>(); private Dictionary uiobject_dic_ = new Dictionary(); 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; } }