private void DrawReviewDistantsElements() { EditorGUILayout.LabelField("Distant Devices", EditorStyles.boldLabel); GUILayout.Label($"<b>{Tab.DistantSlaves.Count}</b> slave {(Tab.DistantSlaves.Count == 1 ? "device was" : "devices were")} " + "too far from a master device for connection.", EditorUIUtils.LabelStyle); GUILayout.BeginHorizontal(); bool btnPrevious = GUILayout.Button("Previous"); bool btnNext = GUILayout.Button("Next"); GUILayout.EndHorizontal(); if (btnPrevious) { Tab.ReviewDistantSlaveIndex--; } if (btnNext) { Tab.ReviewDistantSlaveIndex++; } if (btnPrevious || btnNext) { Tab.ReviewDistantSlaveNewDistance = -1; Tab.ReviewDistantSlaveIndex = Mathf.Clamp(Tab.ReviewDistantSlaveIndex, 0, Tab.DistantSlaves.Count - 1); Selection.activeGameObject = Tab.DistantSlaves[Tab.ReviewDistantSlaveIndex].gameObject; SceneView.FrameLastActiveSceneView(); } if (Tab.ReviewDistantSlaveIndex > -1) { var slaveUnderReview = Tab.DistantSlaves[Tab.ReviewDistantSlaveIndex]; if (EditorUIUtils.BigAssButton("Retry")) { Tab.ReviewDistantSlaveNewDistance = DeviceLinker.TryLinkSlaveToClosestMaster(slaveUnderReview); EditorUtility.SetDirty((Component)slaveUnderReview); } if (Tab.ReviewDistantSlaveNewDistance > DeviceLinker.Masters[0].MaxDistance) { GUILayout.Label($"<b>{slaveUnderReview.gameObject.name}</b>: maximum distance of <b>{DeviceLinker.Masters[0].MaxDistance}</b> " + $"tiles exceeded; distance to nearest master found to be <b>{Tab.ReviewDistantSlaveNewDistance, 0:N}</b> tiles.", EditorUIUtils.LabelStyle); } else if (slaveUnderReview.Master != null) { GUILayout.Label($"<b>{slaveUnderReview.gameObject.name}</b> has been relinked.", EditorUIUtils.LabelStyle); } else { GUILayout.Label($"<b>{slaveUnderReview.gameObject.name}</b>'s link status is uncertain.", EditorUIUtils.LabelStyle); } } }
private void SectionReviewNames() { EditorGUILayout.LabelField("Review Failed Names", EditorStyles.boldLabel); GUILayout.BeginHorizontal(); bool btnPrevious = GUILayout.Button("Previous"); bool btnNext = GUILayout.Button("Next"); GUILayout.EndHorizontal(); if (btnPrevious) { reviewedObjectIndex--; } if (btnNext) { reviewedObjectIndex++; } if (btnPrevious || btnNext) { reviewedObjectIndex = Mathf.Clamp(reviewedObjectIndex, 0, badObjects.Count - 1); Selection.activeGameObject = badObjects[reviewedObjectIndex].gameObject; SceneView.FrameLastActiveSceneView(); enteredName = string.Empty; randomIdentifier = GenerateRandomIdentifier(); } if (reviewedObjectIndex > -1) { var reviewedObject = badObjects[reviewedObjectIndex]; EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Current name:"); GUI.enabled = false; GUILayout.TextField(reviewedObject.name); GUI.enabled = true; GUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Object's location:"); enteredName = EditorGUILayout.TextField(enteredName); EditorGUILayout.EndHorizontal(); EditorGUILayout.HelpBox("Expecting a room name, e.g. 'Engineering Lobby' or 'Central Primary Hallway'.", MessageType.Info); if (string.IsNullOrWhiteSpace(enteredName) == false) { string devicePrefix = regexes[activeWindowTab].Split(' ')[0].Substring(1); string proposedName = $"{devicePrefix} - {enteredName} - {randomIdentifier}"; EditorGUILayout.BeginHorizontal(); GUI.enabled = false; EditorGUILayout.TextField(proposedName); GUI.enabled = true; if (Regex.Match(proposedName, regexes[activeWindowTab]).Success) { GUILayout.Label("Proposed name is valid"); reviewedObject.name = proposedName; modifiedObjects.Add(reviewedObject); } else { GUILayout.Label("Proposed name is invalid"); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(10); if (modifiedObjects.Count > 0 && EditorUIUtils.BigAssButton("Save All")) { foreach (var gameObject in modifiedObjects) { EditorUtility.SetDirty(gameObject); } EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene()); reviewedObjectIndex = -1; modifiedObjects.Clear(); PopulateList(); ScanList(); } } }