using UnityEditor; using UnityEngine; using System; using System.Collections.Generic; using System.IO; using Perforce.P4; using log4net; namespace P4Connect { // Use the ConfigWindow Class to display an EditorWindow for editing values // This Editor window allows the user to set and store // Perforce connection settings that will be used to // Check out files on Save / Move / Delete / etc... // The connection parameters are saved as Editor Preferences // which means they go the registry. [Serializable] public class ConfigWindow : EditorWindow { public static bool ConnectionWizardShowing = false; public const int MaxPendingItems = 200; static bool _stylesInitialized = false; private static ConfigWindow _pInstance = null; public static ConfigWindow Instance { get { if (_pInstance == null) { ShowWindow(); } return _pInstance; } } private static string WindowName = "P4 Settings"; // Add menu item to show the configuration panel [MenuItem("Edit/Perforce Settings", false, 300)] public static void ShowWindow() { // Show existing window instance. If one doesn't exist, make one. _pInstance = EditorWindow.GetWindow<ConfigWindow>(WindowName); _pInstance.titleContent = new GUIContent(WindowName); _pInstance.name = WindowName; _pInstance.minSize = new UnityEngine.Vector2(350.0f, 130.0f); } public void OnEnable() { // Debug.Log("ConfigWindow OnEnable"); //Debug.Log("URI: " + Config.ServerURI.ToStringNullSafe()); //this should be defined in UnityEditor 5.1.1 and later //Config.titleContent.title = "foo"; // = ContentWindowTitle; } public void OnDisable() { //Debug.Log("ConfigWindow OnDisable"); // Debug.Log("URI: " + Config.ServerURI.ToStringNullSafe()); } void OnSelectionChange() { Repaint(); } public static void OnDestroy() { //Debug.Log("ConfigWindow OnDestroy"); if (ConnectionWizardShowing) { ConnectionWizard.Window.Close(); ConnectionWizardShowing = false; } } public static void Refresh() { if (Instance != null) Instance.Repaint(); } private static int _blinkCount = 0; private static int _blinkMax = 6; private static bool _blinkOn = true; private void OnInspectorUpdate() { Repaint(); // 10 x a second _blinkCount++; if (_blinkCount >= _blinkMax) // approx every second { if (_blinkOn) { _blinkButtonStyle = _gButtonStyle; } else { _blinkButtonStyle = _yButtonStyle; } _blinkOn = !_blinkOn; _blinkCount = 0; } } private static GUIStyle _fatButtonStyle; private static GUIStyle _rButtonStyle; private static GUIStyle _gButtonStyle; private static GUIStyle _yButtonStyle; private static GUIStyle _blinkButtonStyle; private static GUIStyle _bigButtonStyle; private static GUIStyle _bigRadioStyle; //private static string SkinPath = "Assets/P4Connect/Editor/P4Connect.guiskin"; private static GUISkin _p4Skin = null; // Access the P4Skin, if the asset can't be found, construct it. // Only called once when initializing styles. public static GUISkin GetP4Skin() { if (_p4Skin != null) return _p4Skin; #if Unity_4_0 // GUISkin p4Skin = Resources.LoadAssetAtPath(SkinPath, typeof(GUISkin)) as GUISkin; #else // GUISkin p4Skin = AssetDatabase.LoadAssetAtPath(SkinPath, typeof (GUISkin)) as GUISkin; #endif // if (p4Skin != null) // { // Comment out the following line if you are developing a new skin // return (p4Skin); // } // We couldn't find one, so we construct it ourselves // Debug.Log("Creating GUISkin"); _p4Skin = GUISkin.Instantiate(GUI.skin) as GUISkin; if (_p4Skin == null) { Debug.Log("Could not instantiate p4Skin"); _p4Skin = GUI.skin; return _p4Skin; } var bigButtonStyle = new GUIStyle(GUI.skin.button) { name = "bigButton", alignment = TextAnchor.MiddleCenter, fontSize = 18, fixedHeight = 100, fixedWidth = 100, }; var bigRadioStyle = new GUIStyle(GUI.skin.button) { name = "bigRadio", alignment = TextAnchor.MiddleCenter, fontSize = 14, fixedHeight = 100, fixedWidth = 100, }; var fatButtonStyle = new GUIStyle(GUI.skin.button) { name = "fatButton", alignment = TextAnchor.MiddleCenter, fontSize = 16, fixedHeight = 50, }; var gButtonStyle = new GUIStyle(fatButtonStyle) { name = "greenFatButton", normal = new GUIStyleState() { background = Icons.GetIcon("button-green.png") as Texture2D, textColor = Color.black }, }; var rButtonStyle = new GUIStyle(fatButtonStyle) { name = "redFatButton", normal = new GUIStyleState() { background = Icons.GetIcon("button-red.png") as Texture2D, textColor = Color.white }, }; var yButtonStyle = new GUIStyle(fatButtonStyle) { name = "yellowFatButton", normal = new GUIStyleState() { background = Icons.GetIcon("button-yellow.png") as Texture2D, textColor = Color.black }, }; // Add some custom types to the default set. List<GUIStyle> myCustomStyles = new List<GUIStyle>(_p4Skin.customStyles) { bigButtonStyle, bigRadioStyle, fatButtonStyle, gButtonStyle, rButtonStyle, yButtonStyle, }; _p4Skin.customStyles = myCustomStyles.ToArray(); _blinkButtonStyle = fatButtonStyle; // Write this skin out to P4Skin for future use. //Debug.Log("Writing Skin"); // try // { // AssetDatabase.StartAssetEditing(); // AssetDatabase.CreateAsset(p4Skin, SkinPath); // AssetDatabase.StopAssetEditing(); // EditorUtility.SetDirty(p4Skin); // } // catch (Exception ex) // { // Debug.Log("GetP4Skin Exception: " + ex.Message); // } return _p4Skin; } // Static initializer called ONCE from OnGUI() after initialization private static void InitializeStyles() { //Debug.Log("ConfigWindow InitializeStyles()"); GUI.skin = GetP4Skin(); _bigButtonStyle = GUI.skin.GetStyle("bigButton"); _bigRadioStyle = GUI.skin.GetStyle("bigRadio"); _fatButtonStyle = GUI.skin.GetStyle("fatButton"); _gButtonStyle = GUI.skin.GetStyle("greenFatButton"); _rButtonStyle = GUI.skin.GetStyle("redFatButton"); _yButtonStyle = GUI.skin.GetStyle("yellowFatButton"); } /// <summary> /// Static Constructor, reads connection settings from Prefs at least once /// </summary> public static void Initialize() { Refresh(); } /// <summary> /// Figure out if the Current Settings need to be saved. /// This is used to draw attention to saving settings after a successful connection. /// </summary> /// <returns></returns> private bool SaveNeeded() { if (!Config.PerforceEnabled || !Config.Valid) return false; if (Config.LastSavedConnection == null) { // We are connected, so save this configuration as LastSavedConnection Config.LastSavedConnection = new ConnectionConfig(true); } if (Config.LastSavedConnection.MatchesConfig()) { return false; } else { //Debug.Log("LastSaved: " + Config.LastSavedConnection.ToString()); //Debug.Log("Default: " + Config.DefaultConnection.ToString()); } return true; } static Color _saveColor; private static readonly Color DisabledColor = Color.red; private static readonly Color ConnectedColor = Color.white; private static readonly Color DisconnectedColor = Color.yellow; private static Color StatusColor() { var c = Color.white; if (Config.PerforceEnabled) { c = Config.Valid ? ConnectedColor : DisconnectedColor; } else { c = DisabledColor; } return c; } // static objects frequently used to create controls static readonly GUILayoutOption BoxWidth = GUILayout.MaxWidth(200.0f); static readonly GUILayoutOption EnumWidth = GUILayout.Width(75.0f); static readonly GUILayoutOption WideEnumWidth = GUILayout.Width(100.0f); static readonly GUILayoutOption CheckWidth = GUILayout.Width(16.0f); static readonly GUILayoutOption TextWidth = GUILayout.Width(250.0f); static readonly GUILayoutOption ButtonWidth = GUILayout.Width(80.0f); static readonly GUILayoutOption IntWidth = GUILayout.Width(30.0f); static readonly GUILayoutOption LabelWidth = GUILayout.Width(84.0f); static readonly GUILayoutOption IndentWidth = GUILayout.Width(10.0f); static readonly GUILayoutOption BigIconHeight = GUILayout.Height(100.0f); static float _VerticalSkip = 8.0f; // ToolTips need GUIContent entries private static GUIContent _contentIcon = new GUIContent("Icon", "View P4Connect documentation on the web"); private static readonly GUIContent ContentConnectPane = new GUIContent("Connection", "Edit P4Connect Connection Settings"); private static readonly GUIContent ContentOptionsPane = new GUIContent("Options", "Edit P4Connect general options"); private static readonly GUIContent ContentDiagnosticsPane = new GUIContent("Diagnostics\n+\nUtilities", "Edit P4Connect Diagnostic options"); private static readonly GUIContent ContentDisable = new GUIContent("Disable", "Disable p4connect for this project"); private static readonly GUIContent ContentEnable = new GUIContent("Enable", "Enable p4connect for this project"); private static readonly GUIContent ContentConnect = new GUIContent("Connect", "Create Connection to Server using current settings"); private static readonly GUIContent ContentDisconnect = new GUIContent("Disconnect", "Break Connection with Server"); private static readonly GUIContent ContentSaveSettings = new GUIContent("Save Settings", "Save the current settings"); private static readonly GUIContent ContentDocLink = new GUIContent("View Web Documentation", "Click to view P4Connect documentation"); private static readonly GUIContent ContentSaveTypeEnum = new GUIContent("Settings storage type:", "Change the current save mode\nEditor Preferences (registry) or \n Config Asset stores config in an asset"); private static readonly GUIContent ContentConsoleLogEnum = new GUIContent("Console Log Reporting Level: ", "Select how much of the P4Connect log gets echoed to the Unity Console"); private static GUIContent _wizardIconContent = new GUIContent("Icon", "Configuration Wizard"); static Texture2D _bigIcon = null; static Texture2D _wizardIcon = null; private void OnGuiStatusBar() { _saveColor = GUI.color; GUI.color = StatusColor(); EditorGUILayout.BeginHorizontal("HelpBox", BigIconHeight); if (_bigIcon == null) { _bigIcon = Icons.GetIcon("p4connect-icon.png") as Texture2D; _contentIcon = new GUIContent(_bigIcon, "Click to view documentation on the web"); } if (GUILayout.Button(_contentIcon, _bigButtonStyle)) { System.Diagnostics.Process.Start("http://www.perforce.com/perforce/doc.current/manuals/p4connectguide/index.html"); } GUI.color = _saveColor; EditorGUILayout.BeginVertical(); // Status Pane GUI.color = StatusColor(); if (Config.PerforceEnabled) { EditorGUILayout.BeginHorizontal(); if (!Config.Valid) { EditorGUILayout.HelpBox("Perforce Integration is INACTIVE. Please Verify your Settings!", MessageType.Warning, true); } else { EditorGUILayout.HelpBox("Perforce Integration is ACTIVE.", MessageType.Info, true); } GUILayout.FlexibleSpace(); GUI.color = _saveColor; if (GUILayout.Button(ContentDisable, _rButtonStyle, GUILayout.Width(120.0f))) { Config.PerforceEnabled = false; } EditorGUILayout.EndHorizontal(); } else { EditorGUILayout.BeginHorizontal(); EditorGUILayout.HelpBox("Perforce Integration is DISABLED.", MessageType.Info, true); GUILayout.FlexibleSpace(); GUI.color = _saveColor; if (GUILayout.Button(ContentEnable, _gButtonStyle, GUILayout.Width(120.0f))) { Config.PerforceEnabled = true; Config.Valid = Config.CheckSettings(Config.DefaultConnection); // Go ahead and try to connect also } EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginVertical("Box"); GUILayout.Label("Version: " + Version.PerforceReleaseString + "-" + Version.Build, "BoldLabel"); GUILayout.Label("Project: " + Main.RootPath.ToStringNullSafe(), EditorStyles.miniLabel); EditorGUILayout.BeginHorizontal(); GUILayout.Label("Save Mode: " + Config.SaveMode.ToString(), EditorStyles.miniLabel); GUILayout.FlexibleSpace(); GUIStyle buttonStyle = SaveNeeded() ? _blinkButtonStyle : _fatButtonStyle; if (GUILayout.Button(ContentSaveSettings, buttonStyle, GUILayout.Width(150.0f))) { if (Config.SaveMode == Config.SaveSettingsMode.EditorPrefs) { Debug.Log("Saving configuration as Editor Preferences"); Config.WritePrefs(); } else { Debug.Log("Saving configuration as Configuration Asset"); Config.WriteConfigAsset(); } Config.LastSavedConnection = new ConnectionConfig(true); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); // Box EditorGUILayout.EndVertical(); // Status Pane EditorGUILayout.EndHorizontal(); // End of Toolbar GUI.color = _saveColor; } private enum GuiSettingsMode { Connection, Options, Diagnostics } [SerializeField] private static GuiSettingsMode _currentMode = GuiSettingsMode.Connection; [SerializeField] private static bool _bConnection = true; [SerializeField] private static bool _bOptions = false; [SerializeField] private static bool _bDiagnostics = false; private void OnGuiSettings() { EditorGUILayout.BeginHorizontal("Box"); EditorGUILayout.BeginVertical(); // ReSharper disable once AssignmentInConditionalExpression if (_bConnection = GUILayout.Toggle(_bConnection, ContentConnectPane, _bigRadioStyle)) { _bOptions = _bDiagnostics = false; _currentMode = GuiSettingsMode.Connection; } // ReSharper disable once AssignmentInConditionalExpression if (_bOptions = GUILayout.Toggle(_bOptions, ContentOptionsPane, _bigRadioStyle)) { _bConnection = _bDiagnostics = false; _currentMode = GuiSettingsMode.Options; } // ReSharper disable once AssignmentInConditionalExpression if (_bDiagnostics = GUILayout.Toggle(_bDiagnostics, ContentDiagnosticsPane, _bigRadioStyle)) { _bConnection = _bOptions = false; _currentMode = GuiSettingsMode.Diagnostics; } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("box"); switch (_currentMode) { case GuiSettingsMode.Connection: OnGuiConnectionPanel(); break; case GuiSettingsMode.Options: OnGUIOptionsPanel(); break; case GuiSettingsMode.Diagnostics: OnGUIDiagnosticsPanel(); break; } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } #region ConnectionPanel /// <summary> /// Draw the Panel with Connection information /// </summary> private void OnGuiConnectionPanel() { bool errorFound = false; if (_wizardIcon == null) { _wizardIcon = Icons.GetIcon("wizard-bee.png") as Texture2D; _wizardIconContent = new GUIContent(_wizardIcon, "Click to activate Wizard"); } GUILayout.BeginVertical(); // Panel GUILayout.Label("Connection Settings", EditorStyles.boldLabel); GUILayout.Space(_VerticalSkip); GUILayout.BeginVertical("Box"); // connection box // Disable connection settings if already connected EditorGUI.BeginDisabledGroup(Config.Valid); { EditorGUILayout.BeginHorizontal(); { GUILayout.Label("*Server URI:", LabelWidth); Config.ServerUri = EditorGUILayout.TextField(Config.ServerUri); } EditorGUILayout.EndHorizontal(); if (Config.DefaultConnection.Tested && !Config.DefaultConnection.ServerValid) { EditorGUILayout.HelpBox("Invalid Server URI", MessageType.Error); errorFound = true; } EditorGUILayout.BeginHorizontal(); { GUILayout.Label("*Username:", LabelWidth); Config.Username = EditorGUILayout.TextField(Config.Username); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Password:", LabelWidth); Config.Password = EditorGUILayout.PasswordField(Config.Password); } EditorGUILayout.EndHorizontal(); if (!errorFound && Config.DefaultConnection.Tested && !(Config.DefaultConnection.PasswordValid && Config.DefaultConnection.UserValid)) { EditorGUILayout.HelpBox("Invalid Username / Password", MessageType.Error); errorFound = true; } EditorGUILayout.BeginHorizontal(); { GUILayout.Label("*Workspace:", LabelWidth); Config.Workspace = EditorGUILayout.TextField(Config.Workspace); } EditorGUILayout.EndHorizontal(); if (!errorFound && Config.DefaultConnection.Tested && Config.DefaultConnection.PasswordValid && (!Config.DefaultConnection.WorkspaceValid)) { EditorGUILayout.HelpBox("Invalid Workspace", MessageType.Error); errorFound = true; } if (!errorFound && Config.DefaultConnection.Tested && Config.DefaultConnection.WorkspaceValid && !Config.DefaultConnection.ProjectRootValid) { // The project isn't under the workspace root string perforcePath = "//" + Config.Workspace + "/..."; string rootPath = P4Connect.Main.RootPath; EditorGUILayout.HelpBox("Invalid Workspace. The client path:\n" + "\t" + perforcePath + "\n" + "maps to this folder:\n" + "\t" + VerifySettings.LastWorkspaceMapping + "\n" + "which is not a parent directory of the project's root:\n" + "\t" + rootPath, MessageType.Error); } EditorGUILayout.BeginHorizontal(); { GUILayout.Label("P4HOST:", LabelWidth); Config.Hostname = EditorGUILayout.TextField(Config.Hostname); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("P4CHARSET:", LabelWidth); Config.Charset = EditorGUILayout.TextField(Config.Charset); } EditorGUILayout.EndHorizontal(); } EditorGUI.EndDisabledGroup(); // Connection Valid EditorGUILayout.BeginHorizontal(); EditorGUI.BeginDisabledGroup(!Config.PerforceEnabled); GUI.SetNextControlName("connect"); if (GUILayout.Button(Config.Valid ? ContentDisconnect : ContentConnect, Config.Valid ? _rButtonStyle : _gButtonStyle, GUILayout.Width(120.0f))) { if (Config.Valid) { Config.DefaultConnection.Reset(); // disconnect Config.Valid = false; } else { EditorGUILayout.HelpBox("Please Wait! Checking Perforce Settings. This can take a while ...", MessageType.Info); Config.DefaultConnection.FromConfig(); Config.Valid = Config.CheckSettings(Config.DefaultConnection); } } EditorGUI.EndDisabledGroup(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); // Connection Box EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); // New Settings Assistance { GUILayout.Label("Load Settings", EditorStyles.boldLabel); GUILayout.Space(_VerticalSkip); EditorGUILayout.BeginVertical("box"); EditorGUI.BeginDisabledGroup(Config.Valid); { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.BeginVertical("box"); if (GUILayout.Button(_wizardIconContent, _bigButtonStyle)) { GUI.FocusControl(""); if (!ConnectionWizardShowing) { ConnectionWizard.ShowWindow(); ConnectionWizardShowing = true; } } EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical(); if (GUILayout.Button("Load Defaults", EditorStyles.miniButton, BoxWidth)) { GUI.FocusControl(""); Config.ResetValues(); Config.DefaultConnection.FromConfig(); Repaint(); } if (GUILayout.Button("Load P4 Environment", EditorStyles.miniButton, BoxWidth)) { GUI.FocusControl(""); if (!Config.ReadEnvironment()) { EditorUtility.DisplayDialog("Read Perforce Environment", "No Perforce Environment variables found!", "OK"); } Config.DefaultConnection.FromConfig(); Repaint(); } if (GUILayout.Button("Load P4Config", BoxWidth)) { GUI.FocusControl(""); string configName = Environment.GetEnvironmentVariable("P4CONFIG"); if (string.IsNullOrEmpty(configName)) { configName = Config.P4ConfigDefault; // If not in environment, use the default. } string p4ConfigFile = Config.FindP4ConfigFile(configName); if (string.IsNullOrEmpty(p4ConfigFile)) { Debug.Log("P4Config file " + configName + " Not Found"); } else { Config.LoadP4ConfigFile(p4ConfigFile); Debug.Log("P4Config Found at: " + Path.GetFullPath(p4ConfigFile)); } Config.DefaultConnection.FromConfig(); Repaint(); } if (GUILayout.Button("Load Editor Prefs", BoxWidth)) { GUI.FocusControl(""); Config.ReadPrefs(); Config.DefaultConnection.FromConfig(); Repaint(); } if (GUILayout.Button("Load Config Asset", BoxWidth)) { GUI.FocusControl(""); if (!Config.ReadConfigAsset()) { EditorUtility.DisplayDialog("Read Configuration Asset", "No Configuration Asset found!", "OK"); } Config.DefaultConnection.FromConfig(); Repaint(); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndHorizontal(); } EditorGUI.EndDisabledGroup(); // Settings Valid EditorGUILayout.EndHorizontal(); GUILayout.EndVertical(); } // new settings EditorGUILayout.EndVertical(); GUILayout.EndVertical(); // Panel } #endregion #region OptionsPanel private void OnGUIOptionsPanel() { GUILayout.Label("Options", EditorStyles.boldLabel); GUILayout.Space(_VerticalSkip); EditorGUILayout.BeginVertical("box"); EditorGUILayout.BeginHorizontal(); { Config.DisplayStatusIcons = EditorGUILayout.Toggle(Config.DisplayStatusIcons, CheckWidth); GUILayout.Label("Display Status Icons"); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { Config.CheckStatusForMenus = EditorGUILayout.Toggle(Config.CheckStatusForMenus, CheckWidth); GUILayout.Label("Gray out invalid menu options", TextWidth); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Don't check if more than"); Config.CheckStatusForMenusMaxItems = EditorGUILayout.IntField(Config.CheckStatusForMenusMaxItems, IntWidth); GUILayout.Label("files selected"); GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Diff Tool Executable "); if (GUILayout.Button("Browse...", EditorStyles.miniButton, ButtonWidth)) { string dir; string path; GUI.FocusControl(""); if (Config.DiffToolPathname.Length > 0) { dir = System.IO.Directory.GetParent(Config.DiffToolPathname).FullName; } else { dir = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFiles); } path = EditorUtility.OpenFilePanel("Choose Diff Tool Executable", dir, ""); if (path.Length > 0) { Config.DiffToolPathname = path; } } GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label(" ", IndentWidth); Config.DiffToolPathname = GUILayout.TextField(Config.DiffToolPathname, GUILayout.MinWidth(80.0f), GUILayout.ExpandWidth(true)); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { Config.AskBeforeCheckout = EditorGUILayout.Toggle(Config.AskBeforeCheckout, CheckWidth); GUILayout.Label("Ask before checkout on edit"); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { Config.WarnOnSpecialCharacters = EditorGUILayout.Toggle(Config.WarnOnSpecialCharacters, CheckWidth); GUILayout.Label("Reserved character warning (@#*%)"); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); Config.IncludeSolutionFiles = EditorGUILayout.Toggle(Config.IncludeSolutionFiles, CheckWidth); GUILayout.Label("Include Solution Files"); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); Config.IncludeProjectFiles = EditorGUILayout.Toggle(Config.IncludeProjectFiles, CheckWidth); GUILayout.Label("Include Project Files"); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); Config.UnityVsSupport = EditorGUILayout.Toggle(Config.UnityVsSupport, CheckWidth); GUILayout.Label("Integrate with UnityVS", TextWidth); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); Config.UseTypemap = EditorGUILayout.Toggle(Config.UseTypemap, CheckWidth); GUILayout.Label("Use Perforce server typemap", TextWidth); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Close Perforce connection after"); Config.ConnectionTimeOut = EditorGUILayout.IntField(Config.ConnectionTimeOut, IntWidth); GUILayout.Label("seconds"); GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("p4ignore: "); if (GUILayout.Button("Browse...", EditorStyles.miniButton, ButtonWidth)) { string dir; string path; GUI.FocusControl(""); if (Config.IgnoreName.Length > 0) { dir = System.IO.Directory.GetParent(Config.IgnoreName).FullName; } else { dir = Main.RootPath; } path = EditorUtility.OpenFilePanel("Choose P4Ignore File", dir, ""); if (path.Length > 0) { Config.IgnoreName = path; } } GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label(" ", IndentWidth); Config.IgnoreName = GUILayout.TextField(Config.IgnoreName, GUILayout.MinWidth(80.0f), GUILayout.ExpandWidth(true)); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Additional Ignore Lines:"); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label(" ", IndentWidth); Config.IgnoreLines = EditorGUILayout.TextArea(Config.IgnoreLines, GUILayout.MinHeight(16.0f), GUILayout.MinWidth(200.0f), GUILayout.ExpandWidth(true)); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label(ContentSaveTypeEnum); Config.SaveMode = (Config.SaveSettingsMode)EditorGUILayout.EnumPopup(Config.SaveMode, WideEnumWidth); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); GUILayout.EndVertical(); // BOX } #endregion #region DiagnosticsPanel private void OnGUIDiagnosticsPanel() { GUILayout.Label("Diagnostics", EditorStyles.boldLabel); GUILayout.Space(_VerticalSkip); EditorGUILayout.BeginVertical("box"); EditorGUILayout.BeginHorizontal(); Config.DisplayP4Timings = EditorGUILayout.Toggle(Config.DisplayP4Timings, CheckWidth); GUILayout.Label("Display P4 Timings"); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); Config.EchoP4Commands = EditorGUILayout.Toggle(Config.EchoP4Commands, CheckWidth); GUILayout.Label("Echo P4 Commands to log"); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); Config.ShowPaths = EditorGUILayout.Toggle(Config.ShowPaths, CheckWidth); GUILayout.Label("Show File Paths in Console"); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { EditorGUI.BeginDisabledGroup(Config.LogPath.Length == 0); { bool newEnableLog = EditorGUILayout.Toggle(Config.EnableLog, CheckWidth); if (newEnableLog != Config.EnableLog) { Config.EnableLog = newEnableLog; Logger.Initialize(); } } EditorGUI.EndDisabledGroup(); GUILayout.Label("Enable Logging"); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label("Log File: "); if (GUILayout.Button("Browse...", EditorStyles.miniButton, ButtonWidth)) { GUI.FocusControl(""); if (Config.LogPath.Length == 0) { Config.LogPath = Config.DefaultLogFile(); } string dir = System.IO.Directory.GetParent(Config.LogPath).FullName; string path = EditorUtility.SaveFilePanel("Set P4Connect Log File", dir, "p4connect", "log"); if (path.Length > 0) { Config.LogPath = path; Config.EnableLog = true; } } if (Config.LogPath.Length == 0) { Config.EnableLog = false; } GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); { GUILayout.Label(" ", IndentWidth); Config.LogPath = GUILayout.TextField(Config.LogPath, GUILayout.MinWidth(80.0f), GUILayout.ExpandWidth(true)); GUILayout.FlexibleSpace(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Label(ContentConsoleLogEnum); Config.ConsoleLogLevel = (Logger.LogLevel)EditorGUILayout.EnumPopup(Config.ConsoleLogLevel, EnumWidth); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.Label("Utilities", EditorStyles.boldLabel); GUILayout.Space(_VerticalSkip); EditorGUILayout.BeginVertical("Box"); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Delete Configuration Asset", EditorStyles.miniButton, BoxWidth)) { if (EditorUtility.DisplayDialog("Delete Configuration Asset", "Are you sure you want to delete this asset?", "OK", "Cancel")) { Config.DeleteConfigAsset(); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Clear Editor Prefs", EditorStyles.miniButton, BoxWidth)) { if (EditorUtility.DisplayDialog("Remove All EditorPrefs", "Are you sure you want to remove ALL Unity EditorPreferences?", "OK", "Cancel")) { EditorPrefs.DeleteAll(); } } EditorGUILayout.EndHorizontal(); GUILayout.Space(_VerticalSkip); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button(ContentDocLink, EditorStyles.miniButton, BoxWidth)) { System.Diagnostics.Process.Start("http://www.perforce.com/perforce/doc.current/manuals/p4connectguide/index.html"); } EditorGUILayout.EndHorizontal(); GUILayout.EndVertical(); } #endregion [SerializeField] Vector2 vScroll = Vector2.zero; /// <summary> /// Called by Unity when the windows needs to be updated /// </summary> void OnGUI() { if (Event.current == null || Application.isPlaying) { GUIUtility.ExitGUI(); } if (PasswordPrompt.Active) { return; } if (!_stylesInitialized) { InitializeStyles(); _stylesInitialized = true; } vScroll = EditorGUILayout.BeginScrollView(vScroll, false, false); // Show the status bar OnGuiStatusBar(); OnGuiSettings(); EditorGUILayout.EndScrollView(); // Scroll View Wrapper for dialog } // public static SerializationMode CachedSerializationMode // { // get; // private set; // } // public static bool SettingsSaved // { // get; set; // } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 25222 | seandanger | "Forking branch Main of perforce-software-p4connect to seandanger-p4connect." | ||
//guest/perforce_software/p4connect/main/src/P4Connect/P4Connect/P4Connect.ConfigWindow.cs | |||||
#2 | 20275 | Norman Morse |
Update source to match 2016.2 patch 2 release Much thrashing of source during refactor. Proper caching of asset statuses, reducing fstats issued. Some bug fixes by Liz Lam Cleanup of Pending changes, rework of initialization and play/stop play transitions |
||
#1 | 19279 | Norman Morse |
Update workshop from internal changes. These Changes are the basis of the 2016.2 release - Dropped support for Unity 4 - Built in Unity 5 - Fixed assembly misidentifications. - Fixed problem where configuration dialog would pop up between runs |