protected override void DrawWindow() { DrawHeader(); if (projectFiles.Count > 0) { DrawEditor(); DrawFooter(); } else { editorArea.Begin(); GUILayout.Label("Select a valid project workspace path"); editorArea.End(); } }
public void DrawHeader() { headerArea.Begin(); if (headerExpanded) { DrawExpandedHeader(); } else { DrawCompactHeader(); } headerArea.End(); }
private void DrawHeader() { headerArea.Begin(); GUILayout.BeginHorizontal(); GUILayout.Label("Scripts are stored in project workspace. To add a script create a new .cs file in workspace and click 'Reload'", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Project workspace:", GUILayout.ExpandWidth(false)); var newProjectWorkspacePath = GUILayout.TextField(projectWorkspacePath, GUILayout.ExpandWidth(true)); if (!newProjectWorkspacePath.Equals(projectWorkspacePath)) { projectWorkspacePath = newProjectWorkspacePath.Trim(); MainWindow.Instance.Config.ScriptWorkspacePath = projectWorkspacePath; MainWindow.Instance.SaveConfig(); } if (GUILayout.Button("Reload", GUILayout.Width(100))) { ReloadProjectWorkspace(); } GUILayout.EndHorizontal(); projectFilesScrollPosition = GUILayout.BeginScrollView(projectFilesScrollPosition); GUILayout.BeginHorizontal(); foreach (var file in projectFiles) { if (GUILayout.Button(Path.GetFileName(file.Path), GUILayout.ExpandWidth(false))) { currentFile = file; } } GUILayout.EndHorizontal(); GUILayout.EndScrollView(); headerArea.End(); }
private void DrawCommandLineArea() { commandLineArea.Begin(); GUILayout.BeginHorizontal(GUILayout.ExpandWidth(true)); GUILayout.BeginVertical(GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(false)); commandLineScrollPosition = GUILayout.BeginScrollView(commandLineScrollPosition, false, false, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(false)); GUI.SetNextControlName("ModToolsConsoleCommandLine"); commandHistory[currentCommandHistoryIndex] = GUILayout.TextArea(commandHistory[currentCommandHistoryIndex], GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); if (commandHistory[currentCommandHistoryIndex].Trim().Length == 0) { GUI.enabled = false; } GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.ExpandWidth(false)); GUILayout.BeginHorizontal(); if (GUILayout.Button("Run", GUILayout.ExpandWidth(false))) { RunCommandLine(); } GUI.enabled = true; if (currentCommandHistoryIndex == 0) { GUI.enabled = false; } if (GUILayout.Button("↑", GUILayout.ExpandWidth(false))) { currentCommandHistoryIndex--; } GUI.enabled = true; if (currentCommandHistoryIndex >= commandHistory.Count - 1) { GUI.enabled = false; } if (GUILayout.Button("↓", GUILayout.ExpandWidth(false))) { currentCommandHistoryIndex++; } GUI.enabled = true; GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); commandLineArea.End(); // refocus the command line area after enter has been pressed if (focusCommandLineArea) { GUI.FocusControl("ModToolsConsoleCommandLine"); focusCommandLineArea = false; } }
private void DrawConsole() { userNotifications = UserNotifications.GetNotifications(); consoleArea.Begin(); consoleScrollPosition = GUILayout.BeginScrollView(consoleScrollPosition); foreach (var item in userNotifications) { GUILayout.BeginHorizontal(GUI.skin.box); GUI.contentColor = Color.cyan; GUILayout.Label(item.Value); GUI.contentColor = Color.white; if (GUILayout.Button("Hide")) { UserNotifications.HideNotification(item.Key); } GUILayout.EndHorizontal(); } ConsoleMessage[] messages = null; lock (historyLock) { messages = history.ToArray(); } foreach (var item in messages) { GUILayout.BeginHorizontal(GUI.skin.box); var msg = Config.ConsoleFormatString.Replace("{{type}}", item.Type.ToString()) .Replace("{{caller}}", item.Caller) .Replace("{{message}}", item.Message); switch (item.Type) { case LogType.Log: GUI.contentColor = Config.ConsoleMessageColor; break; case LogType.Warning: GUI.contentColor = Config.ConsoleWarningColor; break; case LogType.Error: GUI.contentColor = Config.ConsoleErrorColor; break; case LogType.Assert: case LogType.Exception: GUI.contentColor = Config.ConsoleExceptionColor; break; } GUILayout.Label(msg); GUILayout.FlexibleSpace(); if (item.Count > 1) { GUI.contentColor = orangeColor; if (item.Count > 1024) { GUI.contentColor = Color.red; } GUILayout.Label(item.Count.ToString(), GUI.skin.box); } else { GUILayout.Label(string.Empty); } GUI.contentColor = Color.white; var stackTrace = item.Trace; if (stackTrace != null) { GUIStackTrace.StackTraceButton(stackTrace); } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); consoleArea.End(); }