public void ContextMenu(GenericMenu menu, Row row, int i) { if (row.log.instanceID != 0) { menu.AddItem(new GUIContent("#" + i + " " + LC.G("FilterByThisObjectName")), false, this.ActiveFilter, row); } }
private static void Clone(MenuCommand menuCommand) { Component component = menuCommand.context as Component; if (ComponentUtility.CopyComponent(component) == true) { if (ComponentUtility.PasteComponentAsNew(component.gameObject) == true) { Component[] c = component.gameObject.GetComponents <Component>(); for (int i = 0; i < c.Length; i++) { if (c[i] == component) { while (i++ < c.Length - 2 && ComponentUtility.MoveComponentUp(c[c.Length - 1]) == true) { ; } break; } } } else { EditorUtility.DisplayDialog(LC.G("CloneComponent_Error_Title"), LC.G("CloneComponent_Error_Message"), LC.G("Yes")); } } }
protected virtual void OnGUI() { if (HQ.Settings == null) { GUILayout.Label(string.Format(LC.G("RequiringConfigurationFile"), NGNavSelectionWindow.Title)); if (GUILayout.Button(LC.G("ShowPreferencesWindow")) == true) { Utility.ShowPreferencesWindowAt(Constants.PreferenceTitle); } return; } Rect r = this.position; r.x = 0F; r.y = 0F; if (this.errorPopup.exception != null) { r.height = this.errorPopup.boxHeight; this.errorPopup.OnGUIRect(r); r.y += r.height; r.height = this.position.height - r.height; } try { this.listDrawer.OnGUI(r); } catch (Exception ex) { this.errorPopup.exception = ex; } }
private Rect GUIExport(Rect r) { Vars vars = this.perWindowVars.Get(RowUtility.drawingWindow); EditorGUI.BeginDisabledGroup(this.streams[vars.workingStream].rowsDrawer.Count == 0); { Utility.content.text = LC.G("RecorderModule_ExportSamples"); float x = r.x; float width = HQ.Settings.Get <GeneralSettings>().MenuButtonStyle.CalcSize(Utility.content).x; r.x = r.x + r.width - width; r.width = width; if (GUI.Button(r, Utility.content, HQ.Settings.Get <GeneralSettings>().MenuButtonStyle) == true) { List <Row> rows = new List <Row>(); for (int i = 0; i < this.streams[vars.workingStream].rowsDrawer.Count; i++) { rows.Add(this.console.rows[this.streams[vars.workingStream].rowsDrawer[i]]); } ExportLogsWindow.Export(rows); } r.width = r.x - x; r.x = x; } EditorGUI.EndDisabledGroup(); return(r); }
private void DebugDrawResent(Packet packet) { if (GUILayout.Button(LC.G("NGInspector_Resend"), GUILayoutOptionPool.Width(60F)) == true) { this.Hierarchy.Client.AddPacket(packet); } }
public void Update() { // Some deeper code can close the client connection, we need to maintain a reference. Client c = this.client; if (this.isPinging == false) { if (Conf.DebugMode != Conf.DebugState.Verbose && this.nextPingTime < EditorApplication.timeSinceStartup) { c.AddPacket(new ClientSendPingPacket(), this.OnPingReceived); this.isPinging = true; this.nextPingTime = EditorApplication.timeSinceStartup; } } else if (Conf.DebugMode != Conf.DebugState.Verbose && EditorApplication.timeSinceStartup - this.nextPingTime > NGServerInstance.MaxPingTimeBeforeShutdown) { InternalNGDebug.Log(LC.G("NGHierarchy_ClientDisconnected") + " Due to expired ping. (" + c.tcpClient.Client.LocalEndPoint + ") " /* + EditorApplication.timeSinceStartup + " - " + this.nextPingTime*/); ConnectionsManager.Close(c); return; } if (this.DetectClientDisced(c) == true) { InternalNGDebug.LogError(LC.G("RemoteModule_ClientDisconnected")); ConnectionsManager.Close(c); return; } c.ExecuteReceivedCommands(ConnectionsManager.Executer); c.Write(ConnectionsManager.Executer); }
public Rect OnGUI(Rect r, bool compact) { GUI.Box(r, string.Empty, GeneralStyles.Toolbar); r.xMax -= 16F; r.y += 2F; this.name = EditorGUI.TextField(r, compact == false ? LC.G("GameObjectWithName") : string.Empty, this.name, GeneralStyles.ToolbarSearchTextField); if (compact == true && string.IsNullOrEmpty(this.name) == true) { r.x += 15F; EditorGUI.LabelField(r, LC.G("GameObjectWithName"), GeneralStyles.TextFieldPlaceHolder); r.x -= 15F; } r.x += r.width; r.width = 16F; if (GUI.Button(r, GUIContent.none, GeneralStyles.ToolbarSearchCancelButton) == true) { this.name = string.Empty; GUI.FocusControl(null); } r.y += r.height; return(r); }
public void ContextMenu(GenericMenu menu, Row row, int i) { if (row is ILogContentGetter) { menu.AddItem(new GUIContent("#" + i + " " + LC.G("FilterByThisContent")), false, this.ActiveFilter, row); } }
public void OnGUI(Rect r) { GUILayout.BeginArea(r); { EditorGUILayout.BeginHorizontal(); { using (LabelWidthRestorer.Get(92F)) { this.dataSeparator = EditorGUILayout.TextField(LC.G("DataSeparator"), this.dataSeparator); } if (GUILayout.Button("Tab", GeneralStyles.ToolbarButton) == true) { GUI.FocusControl(null); this.dataSeparator += "\\t"; } if (GUILayout.Button("CR", GeneralStyles.ToolbarButton) == true) { GUI.FocusControl(null); this.dataSeparator += "\\r"; } if (GUILayout.Button("LF", GeneralStyles.ToolbarButton) == true) { GUI.FocusControl(null); this.dataSeparator += "\\n"; } //GUILayout.Space(10F); GUILayout.FlexibleSpace(); using (LabelWidthRestorer.Get(85F)) { this.logSeparator = EditorGUILayout.TextField(LC.G("LogSeparator"), this.logSeparator); } if (GUILayout.Button("Tab", GeneralStyles.ToolbarButton) == true) { GUI.FocusControl(null); this.logSeparator += "\\t"; } if (GUILayout.Button("CR", GeneralStyles.ToolbarButton) == true) { GUI.FocusControl(null); this.logSeparator += "\\r"; } if (GUILayout.Button("LF", GeneralStyles.ToolbarButton) == true) { GUI.FocusControl(null); this.logSeparator += "\\n"; } } EditorGUILayout.EndHorizontal(); } GUILayout.EndArea(); }
public void ContextMenu(GenericMenu menu, Row row, int i) { if (row.log.instanceID != 0 && this.GetTransformFromObject(EditorUtility.InstanceIDToObject(row.log.instanceID)) != null) { menu.AddItem(new GUIContent("#" + i + " " + LC.G("FilterByThisObject")), false, this.ActiveFilter, row); } }
public override void OnGUI() { this.endMaxLog = EditorGUILayout.IntField(LC.G("MaxSamples"), this.endMaxLog); if (this.endMaxLog < 1) { this.endMaxLog = 1; } }
public override void OnGUI() { this.time = EditorGUILayout.FloatField(LC.G("TimeStartMode_Time"), this.time); if (this.time < 0F) { this.time = 0F; } }
private static void OnGUI() { if (HQ.Settings == null) { GUILayout.Label(LC.G("ConsoleSettings_NullTarget")); return; } if (ConsoleSettingsEditor.menuButtonStyle == null) { ConsoleSettingsEditor.menuButtonStyle = new GUIStyle("ToolbarButton"); } GUILayout.BeginHorizontal(); { if (GUILayout.Toggle(ConsoleSettingsEditor.currentTab == MainTab.General, LC.G("ConsoleSettings_General"), ConsoleSettingsEditor.menuButtonStyle) == true) { ConsoleSettingsEditor.currentTab = MainTab.General; } if (GUILayout.Toggle(ConsoleSettingsEditor.currentTab == MainTab.Inputs, LC.G("ConsoleSettings_Inputs"), ConsoleSettingsEditor.menuButtonStyle) == true) { ConsoleSettingsEditor.currentTab = MainTab.Inputs; } if (GUILayout.Toggle(ConsoleSettingsEditor.currentTab == MainTab.Themes, LC.G("ConsoleSettings_Themes"), ConsoleSettingsEditor.menuButtonStyle) == true) { ConsoleSettingsEditor.currentTab = MainTab.Themes; } if (GUILayout.Toggle(ConsoleSettingsEditor.currentTab == MainTab.Presets, LC.G("ConsoleSettings_Presets"), ConsoleSettingsEditor.menuButtonStyle) == true) { ConsoleSettingsEditor.currentTab = MainTab.Presets; } } GUILayout.EndHorizontal(); EditorGUI.BeginChangeCheck(); { if (ConsoleSettingsEditor.currentTab == MainTab.General) { ConsoleSettingsEditor.OnGUIGeneral(); } else if (ConsoleSettingsEditor.currentTab == MainTab.Inputs) { ConsoleSettingsEditor.OnGUIInputs(); } else if (ConsoleSettingsEditor.currentTab == MainTab.Themes) { ConsoleSettingsEditor.OnGUIThemes(); } else if (ConsoleSettingsEditor.currentTab == MainTab.Presets) { ConsoleSettingsEditor.OnGUIPresets(); } } if (EditorGUI.EndChangeCheck() == true) { HQ.InvalidateSettings(); } }
protected virtual void OnDisable() { Utility.UnregisterWindow(this); if (this.initialized == false) { return; } this.initialized = false; NGConsoleWindow.nativeConsoleWindowField.SetValue(null, null); if (this.syncLogs != null) { this.syncLogs.EndNewLog -= this.RepaintWithModules; this.syncLogs.UpdateLog -= this.UpdateLog; this.syncLogs.NewLog -= this.ConvertNewLog; this.syncLogs.ResetLog -= this.LocalResetLogs; this.syncLogs.ClearLog -= this.Clear; this.syncLogs.OptionAltered -= this.UpdateConsoleFlags; } if (this.modules != null) { try { Module module = this.GetModule(this.workingModuleId); if (module != null) { module.OnLeave(); } for (int i = 0; i < this.modules.Length; i++) { this.modules[i].OnDisable(); } } catch (Exception ex) { InternalNGDebug.LogException(LC.G("Console_IssueEncountered"), ex); if (Conf.DebugMode == Conf.DebugState.None) { InternalNGDebug.LogError("NG Console has aborted its uninitialization and has closed for safety. Relaunch NG Console and contact the author using the Contact form through Preferences."); this.Close(); } } this.modules = null; } HQ.SettingsChanged -= this.OnSettingsChanged; Undo.undoRedoPerformed -= this.Repaint; this.settings = null; }
public virtual Rect OnTabGUI(Rect r, int i) { if (this.lastTotalCount != this.totalCount) { this.lastTotalCount = this.totalCount; this.tabLabel.text = (this.onlyCategory == true ? "[" : string.Empty) + this.name + (this.onlyCategory == true ? "]" : string.Empty) + " (" + this.totalCount + ")"; } GeneralSettings settings = HQ.Settings.Get <GeneralSettings>(); float xMax = r.xMax; r.width = settings.MenuButtonStyle.CalcSize(this.tabLabel).x; EditorGUI.BeginChangeCheck(); GUI.Toggle(r, i == this.container.WorkingStream, this.tabLabel, settings.MenuButtonStyle); if (EditorGUI.EndChangeCheck() == true) { if (Event.current.button == 0) { this.container.FocusStream(i); } else { // Show context menu on right click. if (Event.current.button == 1) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent(LC.G("MainModule_ChangeName")), false, this.ChangeStreamName); menu.AddItem(new GUIContent(LC.G("MainModule_ToggleCategory")), this.onlyCategory, this.ToggleCategory); menu.AddItem(new GUIContent(LC.G("MainModule_PauseOnLog")), this.pauseOnLog, this.TogglePauseOnLog); menu.AddItem(new GUIContent(LC.G("Delete")), false, this.DeleteStream, i); if (this.rowsDrawer.Count > 0) { menu.AddItem(new GUIContent(LC.G("Clear")), false, this.ClearStream); } else { menu.AddDisabledItem(new GUIContent(LC.G("Clear"))); } menu.DropDown(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 0, 0)); } else if (Event.current.button == 2) { this.container.DeleteStream(i); } } } r.x += r.width; r.xMax = xMax; return(r); }
public override void OnGUI(Rect r) { Utility.content.text = LC.G("NGProject_AutoLoad"); EditorGUI.BeginChangeCheck(); this.window.autoLoad = EditorGUILayout.Toggle(Utility.content, this.window.autoLoad); if (EditorGUI.EndChangeCheck() == true) { this.window.Repaint(); } }
private void ExportLogs() { try { File.WriteAllText(this.exportFile, this.drawer.Export()); InternalNGDebug.Log(LC.G("LogsExportedTo") + "\"" + this.exportFile + "\"."); } catch (Exception ex) { InternalNGDebug.LogException(ex); } }
public void ContextMenu(GenericMenu menu, Row row, int i) { if (row is ILogContentGetter) { GameObject gameObject = EditorUtility.InstanceIDToObject(row.log.instanceID) as GameObject; if (gameObject != null) { menu.AddItem(new GUIContent("#" + i + " " + LC.G("FilterByTag")), false, this.ActiveFilter, gameObject); } } }
protected virtual void OnGUIDisconnected() { GUILayout.FlexibleSpace(); if (GUILayout.Button(LC.G("NGRemote_NotConnected") + Environment.NewLine + LC.G("NGRemote_NotConnectedTooltip"), GeneralStyles.BigCenterText, GUILayoutOptionPool.ExpandHeightTrue)) { XGUIHighlightManager.Highlight(NGRemoteHierarchyWindow.NormalTitle + ".Connect"); NGRemoteHierarchyWindow.Open(); } EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link); GUILayout.FlexibleSpace(); }
protected override void OnGUIHeader() { EditorGUILayout.BeginHorizontal(GeneralStyles.Toolbar); { if (GUILayout.Button("☰", "GV Gizmo DropDown", GUILayoutOptionPool.Width(30F)) == true) { PopupWindow.Show(new Rect(0F, 16F, 0F, 0F), new OptionPopup(this)); } this.showTypes = GUILayout.Toggle(this.showTypes, "", GeneralStyles.ToolbarDropDown, GUILayoutOptionPool.Width(20F)); EditorGUI.BeginChangeCheck(); this.searchKeywords = EditorGUILayout.TextField(this.searchKeywords, GeneralStyles.ToolbarSearchTextField, GUILayoutOptionPool.ExpandWidthTrue); if (EditorGUI.EndChangeCheck() == true) { this.showTypes = true; this.searchPatterns = Utility.SplitKeywords(this.searchKeywords, ' '); this.RefreshFilter(); } if (GUILayout.Button("", GeneralStyles.ToolbarSearchCancelButton) == true) { this.searchKeywords = string.Empty; this.searchPatterns = Utility.SplitKeywords(this.searchKeywords, ' '); GUI.FocusControl(null); this.RefreshFilter(); } if (this.autoLoad == false) { if (this.Hierarchy.inspectableTypes == null) { bool isConnected = this.Hierarchy.IsClientConnected(); EditorGUI.BeginDisabledGroup(!isConnected); if (GUILayout.Button(LC.G("NGProject_Load"), GeneralStyles.ToolbarButton, GUILayoutOptionPool.Width(40F)) == true) { this.Hierarchy.LoadInspectableTypes(this.OnStaticTypesReceived); } XGUIHighlightManager.DrawHighlightLayout(NGRemoteStaticInspectorWindow.Title + ".Load", this); EditorGUI.EndDisabledGroup(); } } } EditorGUILayout.EndHorizontal(); if (this.errorPopup.exception != null) { this.errorPopup.OnGUILayout(); } }
private static void OnGUIInputs() { ConsoleSettings settings = HQ.Settings.Get <ConsoleSettings>(); for (int n = 0, i = 0; i < settings.inputsManager.groups.Count; ++i, ++n) { if (GUILayout.Toggle(i == ConsoleSettingsEditor.selectedInputsGroup, LC.G("InputGroup_" + settings.inputsManager.groups[i].name), ConsoleSettingsEditor.menuButtonStyle) == true) { ConsoleSettingsEditor.selectedInputsGroup = i; } } if (ConsoleSettingsEditor.selectedInputsGroup < settings.inputsManager.groups.Count) { ConsoleSettingsEditor.inputScrollPosition = EditorGUILayout.BeginScrollView(ConsoleSettingsEditor.inputScrollPosition); { for (int n = 0, j = 0; j < settings.inputsManager.groups[ConsoleSettingsEditor.selectedInputsGroup].commands.Count; ++j, ++n) { while (n >= ConsoleSettingsEditor.testInputAnimationFeedback.Count) { var af = new AnimFloat(0F, EditorWindow.focusedWindow.Repaint); af.speed = 1F; af.target = 0F; ConsoleSettingsEditor.testInputAnimationFeedback.Add(new GUITimer(EditorWindow.focusedWindow.Repaint, Constants.CheckFadeoutCooldown, 0F)); } if (settings.inputsManager.groups[ConsoleSettingsEditor.selectedInputsGroup].commands[j].Check() == true) { ConsoleSettingsEditor.testInputAnimationFeedback[n].Start(); ConsoleSettingsEditor.testInputAnimationFeedback[n].af.valueChanged.RemoveAllListeners(); ConsoleSettingsEditor.testInputAnimationFeedback[n].af.valueChanged.AddListener(EditorWindow.focusedWindow.Repaint); } if (ConsoleSettingsEditor.testInputAnimationFeedback[n].Value > 0F) { using (ColorContentRestorer.Get(Color.Lerp(GUI.contentColor, ConsoleSettingsEditor.HighlightInput, ConsoleSettingsEditor.testInputAnimationFeedback[n].Value))) ConsoleSettingsEditor.DrawInputCommand(settings.inputsManager.groups[ConsoleSettingsEditor.selectedInputsGroup].commands[j]); } else { ConsoleSettingsEditor.DrawInputCommand(settings.inputsManager.groups[ConsoleSettingsEditor.selectedInputsGroup].commands[j]); } } GUILayout.Space(10F); } EditorGUILayout.EndScrollView(); } }
private Rect GUIExport(Rect r) { Vars vars = this.perWindowVars.Get(RowUtility.drawingWindow); EditorGUI.BeginDisabledGroup(this.folders.Count == 0 || this.folders[vars.workingFolder].rowsDrawer.Count == 0); { Utility.content.text = LC.G("ArchiveModule_ExportArchives"); GeneralSettings settings = HQ.Settings.Get <GeneralSettings>(); float x = r.x; float width = settings.MenuButtonStyle.CalcSize(Utility.content).x; r.x = r.x + r.width - width; r.width = width; if (GUI.Button(r, Utility.content, settings.MenuButtonStyle) == true) { List <Row> rows = new List <Row>(); Vars closedVars = vars; for (int i = 0; i < this.folders[vars.workingFolder].rowsDrawer.Count; i++) { rows.Add(this.console.rows[this.folders[vars.workingFolder].rowsDrawer[i]]); } Action <ILogExporter, Row> ExportLogNote = delegate(ILogExporter exporter, Row row) { foreach (LogNote n in this.folders[closedVars.workingFolder].notes) { if (n.row == row) { exporter.AddColumn("note", n.note, null); break; } } }; ExportLogsWindow.Export(rows, ExportLogNote); } r.width = r.x - x; r.x = x; } EditorGUI.EndDisabledGroup(); return(r); }
private Rect HeaderButton(Rect r) { Utility.content.text = LC.G("ColorMarkers"); GeneralSettings settings = HQ.Settings.Get <GeneralSettings>(); float x = r.x; float width = settings.MenuButtonStyle.CalcSize(Utility.content).x; r.x = r.x + r.width - width; r.width = width; if (GUI.Button(r, Utility.content.text, settings.MenuButtonStyle) == true) { Utility.OpenWindow <ColorMarkersWizard>(true, ColorMarkersWizard.Title, true); } r.width = r.x - x; r.x = x; return(r); }
protected virtual void OnGUI() { Rect r = this.position; r.x = 0F; r.y = 0F; r.yMax -= 32F; this.drawer.OnGUI(r); r.y += r.height; r.height = 32F; GUILayout.BeginArea(r); { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.BeginVertical(); { GUILayout.Space(10F); using (LabelWidthRestorer.Get(95F)) { this.exportFile = NGEditorGUILayout.SaveFileField(LC.G("ExportFilePath"), this.exportFile, string.Empty, string.Empty); } } EditorGUILayout.EndVertical(); GUILayout.Space(10F); EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(this.exportFile)); { using (BgColorContentRestorer.Get(GeneralStyles.HighlightActionButton)) { if (GUILayout.Button(LC.G("Export"), GUILayoutOptionPool.Height(30F)) == true) { this.ExportLogs(); } } } EditorGUI.EndDisabledGroup(); } EditorGUILayout.EndHorizontal(); } GUILayout.EndArea(); }
public Rect OnGUI(Rect r, bool compact) { float xMax = r.xMax; if (compact == false) { GUI.Box(r, string.Empty, GeneralStyles.Toolbar); Utility.content.text = LC.G("AcceptedTags"); r.width = GUI.skin.label.CalcSize(Utility.content).x + 10F; // Add a small margin for clarity. GUI.Label(r, Utility.content); r.x += r.width; } for (int i = 0; i < this.acceptedTags.Count; i++) { Utility.content.text = this.acceptedTags[i]; r.width = GeneralStyles.ToolbarButton.CalcSize(Utility.content).x; if (GUI.Button(r, Utility.content, GeneralStyles.ToolbarButton) == true) { this.acceptedTags.RemoveAt(i); break; } r.x += r.width; } r.width = xMax - r.x - 16F; this.newTag = EditorGUI.TextField(r, this.newTag); r.x += r.width; r.width = 16F; if (GUI.Button(r, "+", GeneralStyles.ToolbarButton) == true && string.IsNullOrEmpty(this.newTag) == false) { this.acceptedTags.Add(this.newTag); this.newTag = string.Empty; } r.y += r.height + 2F; return(r); }
public virtual float GetOptionWidth() { GeneralSettings settings = HQ.Settings.Get <GeneralSettings>(); float width = 0F; if (HQ.Settings.Get <MainModuleSettings>().displayClearStreamButton == true) { Utility.content.text = LC.G("Clear"); width += settings.MenuButtonStyle.CalcSize(Utility.content).x; } width += settings.MenuButtonStyle.CalcSize(this.logContent).x; width += settings.MenuButtonStyle.CalcSize(this.warningContent).x; width += settings.MenuButtonStyle.CalcSize(this.errorContent).x; if (HQ.Settings.Get <GeneralSettings>().differentiateException == true) { width += settings.MenuButtonStyle.CalcSize(this.exceptionContent).x; } width += 30F; return(width); }
public override void OnGUI(Rect r) { this.currentVars = this.perWindowVars.Get(RowUtility.drawingWindow); float yOrigin = r.y; float maxHeight = r.height; if (EditorApplication.isPlaying == false && this.streams.Count > 0) { if (this.requirePlayModeStyle == null) { this.requirePlayModeStyle = new GUIStyle(GUI.skin.label); this.requirePlayModeStyle.alignment = TextAnchor.MiddleRight; this.requirePlayModeStyle.normal.textColor = Color.green; } r.height = Constants.SingleLineHeight; GUI.Label(r, LC.G("SampleStream_RequirePlayMode"), this.requirePlayModeStyle); } r.x = 0F; r.width = this.console.position.width; r = this.DrawSampleTabs(r); r.x = 0F; r.width = this.console.position.width; r.height = maxHeight - (r.y - yOrigin); this.currentVars.workingStream = Mathf.Clamp(this.currentVars.workingStream, 0, this.streams.Count - 1); if (0 <= this.currentVars.workingStream && this.currentVars.workingStream < this.streams.Count) { this.streams[this.currentVars.workingStream].OnGUI(r); } else { GUI.Label(r, LC.G("RecorderModule_NoSampleCreated"), GeneralStyles.CenterText); } }
protected virtual void OnEnable() { Utility.RestoreIcon(this, NGPrefsWindow.TitleColor); Metrics.UseTool(6); // NGPrefs NGChangeLogWindow.CheckLatestVersion(NGAssemblyInfo.Name); this.filteredIndexes = new List <int>(); this.prefManagers = Utility.CreateNGTInstancesOf <PrefsManager>(); this.prefManagerNames = new string[this.prefManagers.Length]; for (int i = 0; i < this.prefManagers.Length; i++) { this.prefManagerNames[i] = Utility.NicifyVariableName(this.prefManagers[i].GetType().Name); } if (this.searchKeywords != null) { this.searchPatterns = Utility.SplitKeywords(this.searchKeywords, ' '); } if (this.currentManager >= this.prefManagers.Length) { this.currentManager = this.prefManagers.Length - 1; } if (this.currentManager >= 0) { this.LoadCurrentPreferences(); } this.minSize = new Vector2(this.minSize.x, 100F); this.resetContent = new GUIContent("↺", LC.G("NGPrefs_Reset")); this.applyContent = new GUIContent("↣", LC.G("NGPrefs_Apply")); }
public override void DrawRow(RowsDrawer rowsDrawer, Rect r, int streamIndex, bool?collapse) { if (this.isParsed == false) { this.ParseLog(); } float originWidth = RowUtility.drawingWindow.position.width - rowsDrawer.verticalScrollbarWidth; LogSettings settings = HQ.Settings.Get <LogSettings>(); // Draw highlight. r.x = 0F; r.width = originWidth; r.height = settings.height; this.DrawBackground(rowsDrawer, r, streamIndex); r.width = 16F; EditorGUI.DrawRect(r, JSONRow.FoldColor); bool isOpened = rowsDrawer.rowsData.ContainsKey(this); EditorGUI.BeginChangeCheck(); EditorGUI.Foldout(r, isOpened, ""); if (EditorGUI.EndChangeCheck() == true) { if (isOpened == false) { rowsDrawer.rowsData.Add(this, true); } else { rowsDrawer.rowsData.Remove(this); } isOpened = !isOpened; rowsDrawer.InvalidateViewHeight(); } r.x = r.width; r.width = originWidth - r.x; // Handle mouse inputs. if (r.Contains(Event.current.mousePosition) == true) { // Toggle on middle click. if (Event.current.type == EventType.MouseDown && Event.current.button == 2) { if (rowsDrawer.currentVars.IsSelected(streamIndex) == false) { if (Event.current.control == false) { rowsDrawer.currentVars.ClearSelection(); } rowsDrawer.currentVars.AddSelection(streamIndex); if (Event.current.control == false) { rowsDrawer.FitFocusedLogInScreen(streamIndex); } } if (isOpened == false) { rowsDrawer.rowsData.Add(this, true); } else { rowsDrawer.rowsData.Remove(this); } isOpened = !isOpened; rowsDrawer.InvalidateViewHeight(); Event.current.Use(); } // Show menu on right click up. else if (Event.current.type == EventType.MouseUp && Event.current.button == 1 && rowsDrawer.currentVars.IsSelected(streamIndex) == true) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent(LC.G("CopyLine")), false, rowsDrawer.MenuCopyLine, this); menu.AddItem(new GUIContent(LC.G("CopyActualExplodedJSON")), false, this.CopyAllActualExplodedJSON, rowsDrawer); menu.AddItem(new GUIContent(LC.G("CopyFullExplodedJSON")), false, this.CopyAllFullExplodedJSON, rowsDrawer); menu.AddItem(new GUIContent(LC.G("ViewJSON")), false, this.ViewJSON); if (string.IsNullOrEmpty(this.StackTrace) == false) { menu.AddItem(new GUIContent(LC.G("CopyStackTrace")), false, rowsDrawer.MenuCopyStackTrace, this); } menu.AddItem(new GUIContent("Advance Copy Shift+C"), false, rowsDrawer.OpenAdvanceCopy); if (rowsDrawer.currentVars.CountSelection >= 2) { menu.AddItem(new GUIContent(LC.G("ExportSelection")), false, rowsDrawer.MenuExportSelection, this); } if (RowsDrawer.GlobalLogContextMenu != null) { RowsDrawer.GlobalLogContextMenu(menu, rowsDrawer, streamIndex, this); } if (rowsDrawer.LogContextMenu != null) { rowsDrawer.LogContextMenu(menu, this); } menu.ShowAsContext(); Event.current.Use(); } // Focus on right click down. else if (Event.current.type == EventType.MouseDown && Event.current.button == 1) { // Handle multi-selection. if (Event.current.control == true) { if (rowsDrawer.currentVars.IsSelected(streamIndex) == false) { rowsDrawer.currentVars.AddSelection(streamIndex); } } else { if (rowsDrawer.currentVars.IsSelected(streamIndex) == false) { rowsDrawer.currentVars.ClearSelection(); rowsDrawer.currentVars.AddSelection(streamIndex); } rowsDrawer.FitFocusedLogInScreen(streamIndex); } Event.current.Use(); } // Focus on left click. else if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { // Set the selection to the log's object if available. if (this.log.instanceID != 0 && (Event.current.modifiers & settings.selectObjectOnModifier) != 0) { Selection.activeInstanceID = this.log.instanceID; } // Go to line if force focus is available. else if ((Event.current.modifiers & settings.forceFocusOnModifier) != 0) { RowUtility.GoToLine(this, this.log, true); } // Handle multi-selection. if (Event.current.control == true && rowsDrawer.currentVars.IsSelected(streamIndex) == true) { rowsDrawer.currentVars.RemoveSelection(streamIndex); } else { if (Event.current.shift == true) { rowsDrawer.currentVars.WrapSelection(streamIndex); } else if (Event.current.control == false) { if (settings.alwaysDisplayLogContent == false && rowsDrawer.currentVars.CountSelection != 1) { rowsDrawer.bodyRect.height -= rowsDrawer.currentVars.rowContentHeight + ConsoleConstants.RowContentSplitterHeight; } else { // Reset last click when selection changes. if (rowsDrawer.currentVars.IsSelected(streamIndex) == false) { RowUtility.LastClickTime = 0; } } rowsDrawer.currentVars.ClearSelection(); } if (Event.current.shift == false) { rowsDrawer.currentVars.AddSelection(streamIndex); } if (Event.current.control == false) { rowsDrawer.FitFocusedLogInScreen(streamIndex); } GUI.FocusControl(null); Event.current.Use(); } } // Handle normal behaviour on left click up. else if (Event.current.type == EventType.MouseUp && Event.current.button == 0) { // Go to line on double click. if (RowUtility.LastClickTime + Constants.DoubleClickTime > EditorApplication.timeSinceStartup && RowUtility.LastClickIndex == streamIndex && rowsDrawer.currentVars.IsSelected(streamIndex) == true) { bool focus = false; if ((Event.current.modifiers & settings.forceFocusOnModifier) != 0) { focus = true; } RowUtility.GoToLine(this, this.log, focus); } // Ping on simple click. else if (this.log.instanceID != 0) { EditorGUIUtility.PingObject(this.log.instanceID); } RowUtility.LastClickTime = EditorApplication.timeSinceStartup; RowUtility.LastClickIndex = streamIndex; RowUtility.drawingWindow.Repaint(); Event.current.Use(); } } r = this.DrawPreLogData(rowsDrawer, r); r.width = originWidth - r.x; GUI.Label(r, this.firstLine, settings.Style); if (isOpened == true) { if (this.root == null) { this.ParseJSON(); } r.y += r.height; r.x = 16F; r.width = originWidth - 16F; r.height = this.root.GetHeight(); EditorGUI.BeginChangeCheck(); this.root.Draw(r); if (EditorGUI.EndChangeCheck() == true) { rowsDrawer.InvalidateViewHeight(); } if (Event.current.type == EventType.MouseMove) { this.editor.Repaint(); } } }
public override Rect OnGUI(Rect r) { if (SampleStream.startModeTypes == null) { Type type = typeof(StartMode); List <Type> listTypes = new List <Type>(2); List <string> listNames = new List <string>(2); foreach (Type c in Utility.EachNGTSubClassesOf(type)) { listTypes.Add(c); if (c.Name.EndsWith(type.Name) == true) { listNames.Add(Utility.NicifyVariableName(c.Name.Remove(c.Name.Length - type.Name.Length, type.Name.Length))); } else { listNames.Add(Utility.NicifyVariableName(c.Name)); } } SampleStream.startModeTypes = listTypes.ToArray(); SampleStream.startModeNames = listNames.ToArray(); type = typeof(EndMode); listTypes.Clear(); listNames.Clear(); foreach (Type c in Utility.EachNGTSubClassesOf(type)) { listTypes.Add(c); if (c.Name.EndsWith(type.Name) == true) { listNames.Add(Utility.NicifyVariableName(c.Name.Remove(c.Name.Length - type.Name.Length, type.Name.Length))); } else { listNames.Add(Utility.NicifyVariableName(c.Name)); } } SampleStream.endModeTypes = listTypes.ToArray(); SampleStream.endModeNames = listNames.ToArray(); listTypes.Clear(); listNames.Clear(); this.startModes = new StartMode[SampleStream.startModeTypes.Length]; for (int i = 0; i < this.startModes.Length; i++) { this.startModes[i] = (StartMode)Activator.CreateInstance(SampleStream.startModeTypes[i]); this.startModes[i].Init(this); } this.endModes = new EndMode[SampleStream.endModeTypes.Length]; for (int i = 0; i < this.endModes.Length; i++) { this.endModes[i] = (EndMode)Activator.CreateInstance(SampleStream.endModeTypes[i]); this.endModes[i].Init(this); } } Rect rectModes = r; r.width = rectModes.width - SampleStream.ResetButtonWidth - SampleStream.ConditionSpacing - SampleStream.ConditionSpacing; r.width *= .5F; r.height = Constants.SingleLineHeight; using (BgColorContentRestorer.Get(this.hasStarted, Color.green)) this.currentStartMode = EditorGUI.Popup(r, LC.G("SampleStream_StartMode"), this.currentStartMode, SampleStream.startModeNames); r.y += r.height; GUILayout.BeginArea(r); { this.startModes[this.currentStartMode].OnGUI(); } GUILayout.EndArea(); r.y -= r.height; r.x += r.width + SampleStream.ConditionSpacing; using (BgColorContentRestorer.Get(this.hasEnded, Color.green)) this.currentEndMode = EditorGUI.Popup(r, LC.G("SampleStream_EndMode"), this.currentEndMode, SampleStream.endModeNames); r.y += r.height; GUILayout.BeginArea(r); { this.endModes[this.currentEndMode].OnGUI(); } GUILayout.EndArea(); r.x += r.width + SampleStream.ConditionSpacing; r.y -= r.height; r.width = SampleStream.ResetButtonWidth; r.height = Constants.SingleLineHeight + Constants.SingleLineHeight; if (GUI.Button(r, LC.G("Reset")) == true) { this.Clear(); } r.y += r.height; r.x = rectModes.x; r.height = rectModes.height - (r.y - rectModes.y); r.width = rectModes.width; return(base.OnGUI(r)); }