private bool DrawPrependField(Rect rect, int controlPrefix, bool originalPrepend)
        {
            var content = new GUIContent("Add as Prefix", "Add the count to the front of the object's name.");

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, content.text));
            return(EditorGUI.Toggle(rect, content, originalPrepend));
        }
        /// <summary>
        /// Draws the contents of the Rename Op using EditorGUILayout.
        /// </summary>
        /// <param name="controlPrefix">The prefix of the control to assign to the control names</param>
        protected override void DrawContents(int controlPrefix)
        {
            var casingLabel = new GUIContent("New Casing", "The desired casing for the new name.");

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, "To Uppercase"));
            this.Casing = (CasingChange)EditorGUILayout.EnumPopup(casingLabel, this.Casing);
        }
        /// <summary>
        /// Draws the contents of the Rename Op using EditorGUILayout.
        /// </summary>
        /// <param name="controlPrefix">The prefix of the control to assign to the control names</param>
        protected override void DrawContents(int controlPrefix)
        {
            GUIContent newNameContent = new GUIContent("New Name", "Name to replace the old one with.");

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, newNameContent.text));
            this.NewName = EditorGUILayout.TextField(newNameContent, this.NewName);
        }
        private int DrawCountFromField(Rect rect, int controlPrefix, int originalIndex)
        {
            var weights      = new float[] { 0.65f, 0.35f };
            var intFieldRect = rect.GetSplitHorizontalWeighted(1, 0.0f, weights);
            var content      = new GUIContent(
                LocalizationManager.Instance.GetTranslation("countFrom"),
                LocalizationManager.Instance.GetTranslation("theValueToStartCounting"));

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, content.text));

            // Add and subtract 1 so that it displays as 1 based.
            var countFrom = EditorGUI.IntField(intFieldRect, content, originalIndex + 1) - 1;

            var stringToCountFrom = this.RenameOperation.GetStringFromSequenceForIndex(countFrom);

            if (!string.IsNullOrEmpty(stringToCountFrom))
            {
                EditorGUI.BeginDisabledGroup(true);
                var labelStyle = new GUIStyle(EditorStyles.label);
                labelStyle.alignment = TextAnchor.MiddleLeft;
                var labelRect = rect.GetSplitHorizontalWeighted(2, 0.0f, weights);
                EditorGUI.LabelField(labelRect, new GUIContent(
                                         LocalizationManager.Instance.GetTranslation("startsWith") + ": " + stringToCountFrom),
                                     labelStyle);
                EditorGUI.EndDisabledGroup();
            }

            countFrom = Mathf.Max(countFrom, 0);
            return(countFrom);
        }
        private int DrawIncrementField(Rect rect, int controlPrefix, int originalIncrement)
        {
            var content = new GUIContent("Increment", "The value to add to the count after naming an object.");

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, content.text));
            return(EditorGUI.IntField(rect, content, originalIncrement));
        }
        /// <summary>
        /// Draws the contents of the Rename Op.
        /// </summary>
        /// <param name="controlPrefix">The prefix of the control to assign to the control names</param>
        protected override void DrawContents(Rect operationRect, int controlPrefix)
        {
            var singleLineRect = operationRect.GetSplitVertical(1, 2, LineSpacing);

            var casingLabel = new GUIContent(
                LocalizationManager.Instance.GetTranslation("newCasing"),
                LocalizationManager.Instance.GetTranslation("theDesiredCasingForName"));

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, LocalizationManager.Instance.GetTranslation("toUppercase")));
            var options = new GUIContent[] { new GUIContent(LocalizationManager.Instance.GetTranslation("Lowercase")), new GUIContent(LocalizationManager.Instance.GetTranslation("Uppercase")) };

            this.RenameOperation.Casing = (ChangeCaseOperation.CasingChange)EditorGUI.Popup(
                singleLineRect,
                casingLabel,
                (int)RenameOperation.Casing,
                options);

            var firstCharOnlyRect    = operationRect.GetSplitVertical(2, 2, LineSpacing);
            var firstCharToggleLabel = new GUIContent(
                LocalizationManager.Instance.GetTranslation("onlyFirstCharacter"),
                LocalizationManager.Instance.GetTranslation("changeOnlyTheFirstCharacterCase"));

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, LocalizationManager.Instance.GetTranslation("firstCharOnly")));
            this.RenameOperation.ChangeFirstCharacterOnly = EditorGUI.Toggle(
                firstCharOnlyRect,
                firstCharToggleLabel,
                this.RenameOperation.ChangeFirstCharacterOnly
                );
        }
        /// <summary>
        /// Draws the contents of the Rename Op.
        /// </summary>
        /// <param name="controlPrefix">The prefix of the control to assign to the control names</param>
        protected override void DrawContents(Rect operationRect, int controlPrefix)
        {
            var singleLineRect = operationRect.GetSplitVertical(1, 2, LineSpacing);

            var pascalLabel = new GUIContent(
                LocalizationManager.Instance.GetTranslation("usePascalCasing"),
                LocalizationManager.Instance.GetTranslation("flagToCapitalizeTheFirstLetterOfname"));

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, "Pascal"));
            this.RenameOperation.UsePascal = EditorGUI.Toggle(
                singleLineRect,
                pascalLabel,
                this.RenameOperation.UsePascal
                );

            var delimitersRect  = operationRect.GetSplitVertical(2, 2, LineSpacing);
            var delimitersLabel = new GUIContent(
                LocalizationManager.Instance.GetTranslation("delimiterCharacters"),
                LocalizationManager.Instance.GetTranslation("caseSensitiveCharactersIndicateStart"));

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, LocalizationManager.Instance.GetTranslation("delimiters")));
            this.RenameOperation.DelimiterCharacters = EditorGUI.TextField(
                delimitersRect,
                delimitersLabel,
                this.RenameOperation.DelimiterCharacters
                );
        }
        private int DrawCountFromField(Rect rect, int controlPrefix, int originalIndex)
        {
            var weights      = new float[] { 0.65f, 0.35f };
            var intFieldRect = rect.GetSplitHorizontalWeighted(1, 0.0f, weights);
            var content      = new GUIContent("Count From", "The value to start counting from. " +
                                              "The string from the sequence at this count will be appended to the first object.");

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, content.text));

            // Add and subtract 1 so that it displays as 1 based.
            var countFrom = EditorGUI.IntField(intFieldRect, content, originalIndex + 1) - 1;

            var stringToCountFrom = this.RenameOperation.GetStringFromSequenceForIndex(countFrom);

            if (!string.IsNullOrEmpty(stringToCountFrom))
            {
                EditorGUI.BeginDisabledGroup(true);
                var labelStyle = new GUIStyle(EditorStyles.label);
                labelStyle.alignment = TextAnchor.MiddleLeft;
                var labelRect = rect.GetSplitHorizontalWeighted(2, 0.0f, weights);
                EditorGUI.LabelField(labelRect, new GUIContent("Starts with: " + stringToCountFrom), labelStyle);
                EditorGUI.EndDisabledGroup();
            }

            countFrom = Mathf.Max(countFrom, 0);
            return(countFrom);
        }
Example #9
0
 /// <summary>
 /// Draws the contents of the Rename Op.
 /// </summary>
 /// <param name="controlPrefix">The prefix of the control to assign to the control names</param>
 protected override void DrawContents(Rect operationRect, int controlPrefix)
 {
     GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, LocalizationManager.Instance.GetTranslation("offset")));
     this.RenameOperation.Offset = EditorGUI.IntField(
         operationRect.GetSplitVertical(1, 1, LineSpacing),
         LocalizationManager.Instance.GetTranslation("offset"),
         this.RenameOperation.Offset);
 }
        /// <summary>
        /// Draws the contents of the Rename Op using EditorGUILayout.
        /// </summary>
        /// <param name="controlPrefix">The prefix of the control to assign to the control names</param>
        protected override void DrawContents(int controlPrefix)
        {
            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, "Prefix"));
            this.Prefix = EditorGUILayout.TextField("Prefix", this.Prefix);

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, "Suffix"));
            this.Suffix = EditorGUILayout.TextField("Suffix", this.Suffix);
        }
        private void DrawPlaceholderSequenceField(Rect rect, int controlPrefix, string placeholderText)
        {
            EditorGUI.BeginDisabledGroup(true);
            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, CustomSequenceContent.text));

            EditorGUI.TextField(rect, CustomSequenceContent, placeholderText);
            EditorGUI.EndDisabledGroup();
        }
        private string[] DrawCustomSequenceField(Rect rect, int controlPrefix, string[] displaySequence)
        {
            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, CustomSequenceContent.text));

            var sequenceWithCommas = StringUtilities.AddCommasBetweenStrings(displaySequence);
            var customSequence     = EditorGUI.TextField(rect, CustomSequenceContent, sequenceWithCommas);

            return(StringUtilities.StripCommasFromString(customSequence));
        }
        private int DrawIncrementField(Rect rect, int controlPrefix, int originalIncrement)
        {
            var content = new GUIContent(
                LocalizationManager.Instance.GetTranslation("increment"),
                LocalizationManager.Instance.GetTranslation("theValueToAddToTheCount"));

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, content.text));
            return(EditorGUI.IntField(rect, content, originalIncrement));
        }
        private bool DrawPrependField(Rect rect, int controlPrefix, bool originalPrepend)
        {
            var content = new GUIContent(
                LocalizationManager.Instance.GetTranslation("addAsPrefix"),
                LocalizationManager.Instance.GetTranslation("addTheCountToTheFront"));

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, content.text));
            return(EditorGUI.Toggle(rect, content, originalPrepend));
        }
Example #15
0
        /// <summary>
        /// Draws the contents of the Rename Op.
        /// </summary>
        /// <param name="controlPrefix">The prefix of the control to assign to the control names</param>
        protected override void DrawContents(Rect operationRect, int controlPrefix)
        {
            // Split even a single line GUI so that we properly subtract out spacing
            var singleLineRect = operationRect.GetSplitVertical(1, 1, LineSpacing);

            GUIContent newNameContent = new GUIContent("New Name", "Name to replace the old one with.");

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, newNameContent.text));
            this.RenameOperation.NewName = EditorGUI.TextField(singleLineRect, newNameContent, this.RenameOperation.NewName);
        }
        /// <summary>
        /// Draws the contents of the Rename Op using EditorGUILayout.
        /// </summary>
        /// <param name="controlPrefix">The prefix of the control to assign to the control names</param>
        protected override void DrawContents(int controlPrefix)
        {
            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, "Delete from Front"));
            this.NumFrontDeleteChars = EditorGUILayout.IntField("Delete from Front", this.NumFrontDeleteChars);
            this.NumFrontDeleteChars = Mathf.Max(0, this.NumFrontDeleteChars);

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, "Delete from Back"));
            this.NumBackDeleteChars = EditorGUILayout.IntField("Delete from Back", this.NumBackDeleteChars);
            this.NumBackDeleteChars = Mathf.Max(0, this.NumBackDeleteChars);
        }
Example #17
0
        /// <summary>
        /// Draws the contents of the Rename Op using EditorGUILayout.
        /// </summary>
        /// <param name="controlPrefix">The prefix of the control to assign to the control names</param>
        protected override void DrawContents(int controlPrefix)
        {
            var regexToggleContent = new GUIContent("Use Regular Expression", "Match terms using Regular Expressions, terms that allow for powerful pattern matching.");

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, regexToggleContent.text));
            this.UseRegex = EditorGUILayout.Toggle(regexToggleContent, this.UseRegex);

            GUIContent searchContent;
            GUIContent replacementContent;

            if (this.UseRegex)
            {
                searchContent      = new GUIContent("Match Regex", "Regular Expression to use to match terms.");
                replacementContent = new GUIContent("Replacement Regex", "Regular Expression to use when replacing matched patterns.");
            }
            else
            {
                searchContent = new GUIContent(
                    "Search for String",
                    "Substrings to search for in the filenames. These strings will be replaced by the Replacement String.");
                replacementContent = new GUIContent(
                    "Replace with",
                    "String to replace matching instances of the Search string.");
            }

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, "Search String"));
            this.SearchString = EditorGUILayout.TextField(searchContent, this.SearchString);

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, "Replacement String"));
            this.ReplacementString = EditorGUILayout.TextField(replacementContent, this.ReplacementString);

            var caseSensitiveContent = new GUIContent(
                "Case Sensitive",
                "Search using case sensitivity. Only strings that match the supplied casing will be replaced.");

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, caseSensitiveContent.text));
            this.SearchIsCaseSensitive = EditorGUILayout.Toggle(caseSensitiveContent, this.SearchIsCaseSensitive);

            if (this.HasErrors)
            {
                if (!IsValidRegex(this.SearchRegexPattern))
                {
                    EditorGUILayout.HelpBox(
                        "Match Expression is not a valid Regular Expression.",
                        MessageType.Error);
                }

                if (!IsValidRegex(this.ReplacementString))
                {
                    EditorGUILayout.HelpBox(
                        "Replacement Expression is not a valid Regular Expression.",
                        MessageType.Error);
                }
            }
        }
        /// <summary>
        /// Draws the contents of the Rename Op.
        /// </summary>
        /// <param name="controlPrefix">The prefix of the control to assign to the control names</param>
        protected override void DrawContents(Rect operationRect, int controlPrefix)
        {
            // Split even a single line GUI so that we properly subtract out spacing
            var singleLineRect = operationRect.GetSplitVertical(1, 1, LineSpacing);

            GUIContent newNameContent = new GUIContent(
                LocalizationManager.Instance.GetTranslation("newName"),
                LocalizationManager.Instance.GetTranslation("nameToReplaceTheOldeOne"));

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, newNameContent.text));
            this.RenameOperation.NewName = EditorGUI.TextField(singleLineRect, newNameContent, this.RenameOperation.NewName);
        }
Example #19
0
        /// <summary>
        /// Draws the contents of the Rename Op.
        /// </summary>
        /// <param name="controlPrefix">The prefix of the control to assign to the control names</param>
        protected override void DrawContents(Rect operationRect, int controlPrefix)
        {
            // Split even a single line GUI so that we properly subtract out spacing
            var singleLineRect = operationRect.GetSplitVertical(1, 1, LineSpacing);

            var casingLabel = new GUIContent("New Casing", "The desired casing for the new name.");

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, "To Uppercase"));
            this.Model.Casing = (ChangeCaseOperation.CasingChange)EditorGUI.EnumPopup(
                singleLineRect,
                casingLabel,
                this.Model.Casing);
        }
Example #20
0
        private string[] DrawStringSequenceField(Rect rect, int controlPrefix, string[] stringSequence)
        {
            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, "Sequence"));

            var sequenceContent    = new GUIContent("Sequence", "The sequence of strings to add, comma separted.");
            var oldSequence        = StringUtilities.AddCommasBetweenStrings(stringSequence);
            var sequenceStrings    = oldSequence;
            var sequenceWithCommas = EditorGUI.TextField(
                rect,
                sequenceContent,
                sequenceStrings);

            return(StringUtilities.StripCommasFromString(sequenceWithCommas));
        }
Example #21
0
        /// <summary>
        /// Draws the contents of the Rename Op.
        /// </summary>
        /// <param name="controlPrefix">The prefix of the control to assign to the control names</param>
        protected override void DrawContents(Rect operationRect, int controlPrefix)
        {
            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, "Prefix"));
            this.Model.Prefix = EditorGUI.TextField(
                operationRect.GetSplitVertical(1, 2, LineSpacing),
                "Prefix",
                this.Model.Prefix);

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, "Suffix"));
            this.Model.Suffix = EditorGUI.TextField(
                operationRect.GetSplitVertical(2, 2, LineSpacing),
                "Suffix",
                this.Model.Suffix);
        }
Example #22
0
        /// <summary>
        /// Draws the contents of the Rename Op.
        /// </summary>
        /// <param name="controlPrefix">The prefix of the control to assign to the control names</param>
        protected override void DrawContents(Rect operationRect, int controlPrefix)
        {
            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, LocalizationManager.Instance.GetTranslation("deleteFromFront")));
            this.RenameOperation.NumFrontDeleteChars = EditorGUI.IntField(
                operationRect.GetSplitVertical(1, 2, LineSpacing),
                LocalizationManager.Instance.GetTranslation("deleteFromFront"),
                this.RenameOperation.NumFrontDeleteChars);
            this.RenameOperation.NumFrontDeleteChars = Mathf.Max(0, this.RenameOperation.NumFrontDeleteChars);

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, LocalizationManager.Instance.GetTranslation("deleteFromBack")));
            this.RenameOperation.NumBackDeleteChars = EditorGUI.IntField(
                operationRect.GetSplitVertical(2, 2, LineSpacing),
                LocalizationManager.Instance.GetTranslation("deleteFromBack"),
                this.RenameOperation.NumBackDeleteChars);
            this.RenameOperation.NumBackDeleteChars = Mathf.Max(0, this.RenameOperation.NumBackDeleteChars);
        }
Example #23
0
        private string[] DrawStringSequenceField(Rect rect, int controlPrefix, string[] stringSequence)
        {
            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, LocalizationManager.Instance.GetTranslation("sequence")));

            var sequenceContent = new GUIContent(
                LocalizationManager.Instance.GetTranslation("sequence"),
                LocalizationManager.Instance.GetTranslation("theSequenceOfStringsToAddCommaSeparted"));
            var oldSequence        = StringUtilities.AddCommasBetweenStrings(stringSequence);
            var sequenceStrings    = oldSequence;
            var sequenceWithCommas = EditorGUI.TextField(
                rect,
                sequenceContent,
                sequenceStrings);

            return(StringUtilities.StripCommasFromString(sequenceWithCommas));
        }
Example #24
0
        /// <summary>
        /// Draws the contents of the Rename Op.
        /// </summary>
        /// <param name="controlPrefix">The prefix of the control to assign to the control names</param>
        protected override void DrawContents(Rect operationRect, int controlPrefix)
        {
            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, "Delete from Front"));
            this.Model.NumFrontDeleteChars = EditorGUI.IntField(
                operationRect.GetSplitVertical(1, 2, LineSpacing),
                "Delete from Front",
                this.Model.NumFrontDeleteChars);
            this.Model.NumFrontDeleteChars = Mathf.Max(0, this.Model.NumFrontDeleteChars);

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, "Delete from Back"));
            this.Model.NumBackDeleteChars = EditorGUI.IntField(
                operationRect.GetSplitVertical(2, 2, LineSpacing),
                "Delete from Back",
                this.Model.NumBackDeleteChars);
            this.Model.NumBackDeleteChars = Mathf.Max(0, this.Model.NumBackDeleteChars);
        }
        /// <summary>
        /// Draws the contents of the Rename Op using EditorGUILayout.
        /// </summary>
        /// <param name="controlPrefix">The prefix of the control to assign to the control names</param>
        protected override void DrawContents(int controlPrefix)
        {
            var presetsContent = new GUIContent("Format", "Select a preset format or specify your own format.");
            var names          = new List <GUIContent>(this.GUIPresets.Count);

            foreach (var preset in this.GUIPresets)
            {
                names.Add(new GUIContent(preset.DisplayName));
            }

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, presetsContent.text));
            this.SelectedPresetIndex = EditorGUILayout.Popup(presetsContent, this.SelectedPresetIndex, names.ToArray());
            var selectedPreset = this.GUIPresets[this.SelectedPresetIndex];

            EditorGUI.BeginDisabledGroup(selectedPreset.ReadOnly);
            var countFormatContent = new GUIContent("Count Format", "The string format to use when adding the Count to the name.");

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, countFormatContent.text));
            this.CountFormat = EditorGUILayout.TextField(countFormatContent, selectedPreset.Format);
            EditorGUI.EndDisabledGroup();

            try
            {
                this.StartingCount.ToString(this.CountFormat);
            }
            catch (System.FormatException)
            {
                var helpBoxMessage = "Invalid Count Format. Typical formats are D1 for one digit with no " +
                                     "leading zeros, D2, for two, etc." +
                                     "\nLookup the String.Format() method for more info on formatting options.";
                EditorGUILayout.HelpBox(helpBoxMessage, MessageType.Warning);
            }

            var countFromContent = new GUIContent("Count From", "The value to start counting from. The first object will have this number.");

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, countFromContent.text));
            this.StartingCount = EditorGUILayout.IntField(countFromContent, this.StartingCount);

            var incrementContent = new GUIContent("Increment", "The value to add to each object when counting.");

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, incrementContent.text));
            this.Increment = EditorGUILayout.IntField(incrementContent, this.Increment);

            selectedPreset.Format = this.CountFormat;
        }
        private CountByLetterPresetGUI DrawSequenceSelection(Rect rect, int controlPrefix)
        {
            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, "Format"));
            var modeContent    = new GUIContent("Format", "Format for the added letters.");
            var optionsContent = new GUIContent[this.GUIPresets.Count];

            for (int i = 0; i < optionsContent.Length; ++i)
            {
                optionsContent[i] = new GUIContent(this.GUIPresets[i].DisplayName);
            }

            var newlySelectedIndex = EditorGUI.Popup(
                rect,
                modeContent,
                this.SelectedModeIndex,
                optionsContent);

            return(this.GUIPresets[newlySelectedIndex]);
        }
        private void FocusForcedFocusControl()
        {
            if (this.OperationToForceFocus == null)
            {
                return;
            }

            var controlNameToForceFocus = string.Empty;

            for (int i = 0; i < this.RenameOperationsToApply.Count; ++i)
            {
                var renameOp = this.RenameOperationsToApply[i];
                if (renameOp == this.OperationToForceFocus)
                {
                    controlNameToForceFocus = GUIControlNameUtility.CreatePrefixedName(i, renameOp.ControlToFocus);
                    break;
                }
            }

            if (!string.IsNullOrEmpty(controlNameToForceFocus))
            {
                var previouslyFocusedControl = GUI.GetNameOfFocusedControl();

                // Try to focus the desired control
                GUI.FocusControl(controlNameToForceFocus);
                EditorGUI.FocusTextInControl(controlNameToForceFocus);

                // Stop focusing the desired control only once it's been focused.
                // (Workaround because for some reason this fails to focus a control when users click between breadcrumbs)
                var focusedControl = GUI.GetNameOfFocusedControl();
                if (controlNameToForceFocus.Equals(focusedControl))
                {
                    this.FocusRenameOperationDeferred(null);
                }
                else
                {
                    // If we weren't able to focus the new control, go back to whatever was focused before.
                    GUI.FocusControl(previouslyFocusedControl);
                    EditorGUI.FocusTextInControl(previouslyFocusedControl);
                }
            }
        }
Example #28
0
        /// <summary>
        /// Draws the contents of the Rename Op.
        /// </summary>
        /// <param name="controlPrefix">The prefix of the control to assign to the control names</param>
        protected override void DrawContents(Rect operationRect, int controlPrefix)
        {
            var singleLineRect = operationRect.GetSplitVertical(1, 2, LineSpacing);

            var casingLabel = new GUIContent("New Casing", "The desired casing for the new name.");

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, "To Uppercase"));
            this.RenameOperation.Casing = (ChangeCaseOperation.CasingChange)EditorGUI.EnumPopup(
                singleLineRect,
                casingLabel,
                this.RenameOperation.Casing);

            var firstCharOnlyRect    = operationRect.GetSplitVertical(2, 2, LineSpacing);
            var firstCharToggleLabel = new GUIContent("Only First Character", "Change only the first character's case.");

            this.RenameOperation.ChangeFirstCharacterOnly = EditorGUI.Toggle(
                firstCharOnlyRect,
                firstCharToggleLabel,
                this.RenameOperation.ChangeFirstCharacterOnly
                );
        }
        private CountByLetterPresetGUI DrawSequenceSelection(Rect rect, int controlPrefix)
        {
            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, "Format"));
            var modeContent = new GUIContent(
                LocalizationManager.Instance.GetTranslation("format"),
                LocalizationManager.Instance.GetTranslation("formatForTheAddedLetters"));
            var optionsContent = new GUIContent[this.GUIPresets.Count];

            for (int i = 0; i < optionsContent.Length; ++i)
            {
                optionsContent[i] = new GUIContent(this.GUIPresets[i].DisplayName);
            }

            var newlySelectedIndex = EditorGUI.Popup(
                rect,
                modeContent,
                this.SelectedModeIndex,
                optionsContent);

            return(this.GUIPresets[newlySelectedIndex]);
        }
        /// <summary>
        /// Draws the contents of the Rename Op using EditorGUILayout.
        /// </summary>
        /// <param name="controlPrefix">The prefix of the control to assign to the control names</param>
        protected override void DrawContents(int controlPrefix)
        {
            var presetsContent = new GUIContent("Preset", "Select a preset or specify your own characters.");
            var names          = new List <GUIContent>(this.GUIPresets.Count);

            foreach (var preset in this.GUIPresets)
            {
                names.Add(new GUIContent(preset.DisplayName));
            }

            GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, presetsContent.text));
            this.SelectedPresetIndex = EditorGUILayout.Popup(presetsContent, this.SelectedPresetIndex, names.ToArray());
            var selectedPreset = this.GUIPresets[this.SelectedPresetIndex];

            var workingOptions = selectedPreset.Options;

            if (selectedPreset.IsReadOnly)
            {
                // Label just looks better disabled.
                EditorGUI.BeginDisabledGroup(true);
                var readonlyLabelContent = new GUIContent(selectedPreset.ReadOnlyLabel);
                var labelStyle           = new GUIStyle(EditorStyles.label);
                labelStyle.alignment = TextAnchor.MiddleRight;
                EditorGUILayout.LabelField(readonlyLabelContent, labelStyle);
                EditorGUI.EndDisabledGroup();
            }
            else
            {
                var charactersFieldContent = new GUIContent("Characters to Remove", "All characters that will be removed from the names.");
                GUI.SetNextControlName(GUIControlNameUtility.CreatePrefixedName(controlPrefix, charactersFieldContent.text));
                workingOptions.CharactersToRemove = EditorGUILayout.TextField(charactersFieldContent, workingOptions.CharactersToRemove);

                var caseSensitiveToggleContent = new GUIContent("Case Sensitive", "Flag the search to match only the specified case");
                workingOptions.IsCaseSensitive = EditorGUILayout.Toggle(caseSensitiveToggleContent, workingOptions.IsCaseSensitive);
            }

            // Structs were copied by value, so reapply the modified structs back to their sources
            this.Options           = workingOptions;
            selectedPreset.Options = workingOptions;
        }