private void AdjustUITransforms() { if (_TrackingStation == null) { return; } RectTransform listRect = _TrackingStation.listContainer.parent.parent as RectTransform; if (listRect != null) { listRect.anchoredPosition = new Vector2(5, -142); listRect.sizeDelta = new Vector2(280, -177); } RectTransform headerRect = _TrackingStation.listContainer.parent.parent.parent.GetChild(2) as RectTransform; if (headerRect != null) { headerRect.anchoredPosition = new Vector2(5, -108); headerRect.sizeDelta = new Vector2(266, 25); } Tracking_Utils.TrackingLog("Squishing Sidebar UI Elements"); }
private IEnumerator WaitForTrackingList() { //WaitForSeconds wait = new WaitForSeconds(0.1f); SpaceTracking _TrackingStation = null; while (_TrackingStation == null) { _TrackingStation = GameObject.FindObjectOfType <SpaceTracking>(); if (_TrackingStation == null) { yield return(null); } } processSprites(_TrackingStation); if (loadedPrefabs != null) { processUIPrefabs(); } if (UILoaded) { loaded = true; } Tracking_Utils.TrackingLog("UI Loaded"); Destroy(gameObject); }
public override void OnLoad(ConfigNode node) { if (node.HasValue("BodyPersistence")) { _bodyPersistence = Tracking_Utils.ParseDictionary(node.GetValue("BodyPersistence")); } if (node.HasValue("BodyOrderList")) { _bodyOrderList = Tracking_Utils.ParseList(node.GetValue("BodyOrderList")); } if (node.HasValue("TypePersistence")) { _typePersistence = Tracking_Utils.ParseDictionary(node.GetValue("TypePersistence")); } if (node.HasValue("TypeOrderList")) { _typeOrderList = Tracking_Utils.ParseList(node.GetValue("TypeOrderList")); } if (node.HasValue("SortMode")) { node.TryGetValue("SortMode", ref _sortMode); } if (node.HasValue("BodyOrderMode")) { node.TryGetValue("BodyOrderMode", ref _bodyOrderMode); } if (node.HasValue("TypeOrderMode")) { node.TryGetValue("TypeOrderMode", ref _typeOrderMode); } if (node.HasValue("StockOrderMode")) { node.TryGetValue("StockOrderMode", ref _stockOrderMode); } if (node.HasValue("BodyAscOrder")) { node.TryGetValue("BodyAscOrder", ref _bodyAscOrder); } if (node.HasValue("TypeAscOrder")) { node.TryGetValue("TypeAscOrder", ref _typeAscOrder); } if (node.HasValue("StockAscOrder")) { node.TryGetValue("StockAscOrder", ref _stockAscOrder); } FallbackBodyCheck(); }
private IEnumerator WaitForTrackingStation() { while (_TrackingStation == null) { var tracking = FindObjectsOfType <SpaceTracking>(); if (tracking != null) { for (int i = 0; i < tracking.Length; i++) { SpaceTracking space = tracking[i]; if (space == null) { continue; } _TrackingStation = space; } } if (_TrackingStation == null) { yield return(null); } } _ListParent = _TrackingStation.listContainer.parent; FindScrollRect(); StartCoroutine(WaitForCamera()); AdjustUITransforms(); StartCoroutine(AttachSortHeader()); _VesselToggleGroup = Instantiate(_TrackingStation.listToggleGroup); _OldTrackingList = _TrackingStation.listContainer.gameObject; _NewTrackingList = Instantiate(_OldTrackingList); _ReorderableList = _OldTrackingList.transform.parent.gameObject.AddComponent <ReorderableList>(); _ReorderableList.Init(_NewTrackingList.GetComponent <LayoutGroup>(), _NewTrackingList.GetComponent <RectTransform>()); _ReorderableList.SortType = (int)_CurrentMode; _NewTrackingList.transform.SetParent(_ListParent, false); _TrackingStation.listContainer.SetParent(null, false); _TrackingStation.tglTrackedObjects.onValueChanged.AddListener(new UnityAction <bool>(OnVesselListToggle)); _OrderedBodyList = OrderBodies(); _OrderedTypeList = OrderTypes(); Tracking_Utils.TrackingLog("Tracking Station Processed"); }
private List <Tracking_Group> SortCelestialBodies() { List <Tracking_Group> vesselGroups = new List <Tracking_Group>(); int count = _OrderedBodyList.Count; for (int i = 0; i < count; i++) { Tracking_BodyGroup body = _OrderedBodyList[i]; List <TrackingStationWidget> bodyVessels = new List <TrackingStationWidget>(); int vessels = _TrackedVesselWidgets.Count; for (int j = 0; j < vessels; j++) { if (_TrackedVesselWidgets[j].vessel.mainBody == body.Body) { bodyVessels.Add(_TrackedVesselWidgets[j]); } } List <Tracking_MoonGroup> moonGroups = new List <Tracking_MoonGroup>(); int moons = body.Moons.Count; for (int k = 0; k < moons; k++) { List <TrackingStationWidget> moonVessels = new List <TrackingStationWidget>(); for (int l = 0; l < vessels; l++) { if (_TrackedVesselWidgets[l].vessel.mainBody == body.Moons[k]) { moonVessels.Add(_TrackedVesselWidgets[l]); } } if (moonVessels.Count > 0) { moonGroups.Add(new Tracking_MoonGroup() { Moon = body.Moons[k], Vessels = SortWidgets(moonVessels) }); } } if (bodyVessels.Count > 0 || moonGroups.Count > 0) { vesselGroups.Add(new Tracking_Group(Tracking_Utils.LocalizeBodyName(body.Body.displayName), Tracking_Persistence.GetBodyPersistence(body.Body.flightGlobalsIndex), _instantStart, SortWidgets(bodyVessels), moonGroups, body.Body, VesselType.Unknown, Tracking_Mode.CelestialBody)); } } return(vesselGroups); }
private void FindScrollRect() { _ScrollView = _TrackingStation.listContainer.GetComponentInParent <ScrollRect>(); if (_ScrollView == null) { Tracking_Utils.TrackingLog("Scroll Rect Not Found"); } else { Tracking_Utils.TrackingLog("Scroll Rect Found"); } }
private IEnumerator AttachSortHeader() { Transform parent = _TrackingStation.listContainer.parent.parent.parent; while (Tracking_Loader.SortHeaderPrefab == null) { yield return(null); } SortHeader sort = Instantiate(Tracking_Loader.SortHeaderPrefab).GetComponent <SortHeader>(); sort.transform.SetParent(parent, false); sort.transform.SetSiblingIndex(2); sort.Initialize(this); Tracking_Utils.TrackingLog("Sort Header Inserted"); }
public override void OnSave(ConfigNode node) { node.AddValue("BodyPersistence", Tracking_Utils.ConcatDictionary(_bodyPersistence)); node.AddValue("BodyOrderList", Tracking_Utils.ConcatList(_bodyOrderList)); node.AddValue("TypePersistence", Tracking_Utils.ConcatDictionary(_typePersistence)); node.AddValue("TypeOrderList", Tracking_Utils.ConcatList(_typeOrderList)); node.AddValue("SortMode", _sortMode); node.AddValue("BodyOrderMode", _bodyOrderMode); node.AddValue("TypeOrderMode", _typeOrderMode); node.AddValue("StockOrderMode", _stockOrderMode); node.AddValue("BodyAscOrder", _bodyAscOrder); node.AddValue("TypeAscOrder", _typeAscOrder); node.AddValue("StockAscOrder", _stockAscOrder); }
private Tracking_Group VesselTypeGroup(VesselType type) { int vessels = _TrackedVesselWidgets.Count; List <TrackingStationWidget> typeVessels = new List <TrackingStationWidget>(); for (int i = 0; i < vessels; i++) { if (_TrackedVesselWidgets[i].vessel.vesselType == type) { typeVessels.Add(_TrackedVesselWidgets[i]); } } if (typeVessels.Count > 0) { return(new Tracking_Group(Tracking_Utils.VesselTypeString(type), Tracking_Persistence.GetTypePersistence((int)type), _instantStart, SortWidgets(typeVessels), null, null, type, Tracking_Mode.VesselType)); } return(null); }
private IEnumerator WaitForCamera() { while (_CanvasCamera == null) { _CanvasCamera = FindCamera(); if (_CanvasCamera == null) { Tracking_Utils.TrackingLog("Canvas Camera Not Found"); } else { Tracking_Utils.TrackingLog("Canvas Camera Found"); } if (_CanvasCamera == null) { yield return(null); } } FindCorners(); }
private void FindCorners() { if (_ScrollView == null || _CanvasCamera == null) { return; } Vector3[] objectCorners = new Vector3[4]; ((RectTransform)_ScrollView.transform).GetWorldCorners(objectCorners); Vector3 bl = _CanvasCamera.WorldToScreenPoint(objectCorners[0]); float x = bl.x; float y = bl.y; bl = _CanvasCamera.WorldToScreenPoint(objectCorners[2]); float width = bl.x - x; float height = bl.y - y; _ScrollViewRect = new Rect(x, y, width, height); Tracking_Utils.TrackingLog("Detected Vessel List Corners"); }
private void AddHeader() { _header = new Tracking_SubHeader(_title, _vesselCount, Tracking_Utils.GetHeaderObject(_body, VesselType.Unknown, _mode, true), (int)_mode, ToggleOrbits); }
private void AddSubGroup(Tracking_MoonGroup subGroup) { Tracking_SubGroup sub = new Tracking_SubGroup(Tracking_Utils.LocalizeBodyName(subGroup.Moon.displayName), Tracking_Persistence.GetBodyPersistence(subGroup.Moon.flightGlobalsIndex), _instant, subGroup.Vessels, subGroup.Moon, _mode); _subGroups.Add(sub); }
private void AddHeader(int vessels, int subVessels) { _header = new Tracking_Header(_title, vessels, subVessels, Tracking_Utils.GetHeaderObject(_body, _type, _mode, false), (int)_mode); }