internal static int DoMaskField(Rect position, int controlID, int mask, string[] flagNames, GUIStyle style) { int changedFlags; bool changedToValue; return(MaskFieldGUI.DoMaskField(position, controlID, mask, flagNames, style, out changedFlags, out changedToValue)); }
internal static int DoMaskField(Rect position, int controlID, int mask, string[] flagNames, int[] flagValues, GUIStyle style) { int num; bool flag; return(MaskFieldGUI.DoMaskField(position, controlID, mask, flagNames, flagValues, style, out num, out flag)); }
public override void OnClose() { Undo.undoRedoEvent -= OnUndoRedoPerformed; Event.current?.Use(); MaskFieldGUI.DestroyMaskCallBackInfo(); base.OnClose(); }
internal static int DoMaskField(Rect position, int controlID, int mask, string[] flagNames, int[] flagValues, GUIStyle style, out int changedFlags, out bool changedToValue) { mask = MaskFieldGUI.MaskCallbackInfo.GetSelectedValueForControl(controlID, mask, out changedFlags, out changedToValue); string t; string[] options; int[] array; int[] array2; MaskFieldGUI.GetMenuOptions(mask, flagNames, flagValues, out t, out options, out array, out array2); Event current = Event.current; if (current.type == EventType.Repaint) { GUIContent content = (!EditorGUI.showMixedValue) ? EditorGUIUtility.TempContent(t) : EditorGUI.mixedValueContent; style.Draw(position, content, controlID, false); } else if ((current.type == EventType.MouseDown && position.Contains(current.mousePosition)) || current.MainActionKeyForControl(controlID)) { MaskFieldGUI.MaskCallbackInfo.m_Instance = new MaskFieldGUI.MaskCallbackInfo(controlID); current.Use(); EditorUtility.DisplayCustomMenu(position, options, (!EditorGUI.showMixedValue) ? array2 : new int[0], new EditorUtility.SelectMenuItemFunction(MaskFieldGUI.MaskCallbackInfo.m_Instance.SetMaskValueDelegate), array.Clone()); GUIUtility.keyboardControl = controlID; } return(mask); }
internal static int DoMaskField(Rect position, int controlID, int mask, string[] flagNames, GUIStyle style, out int changedFlags, out bool changedToValue) { int[] array = new int[flagNames.Length]; for (int i = 0; i < array.Length; i++) { array[i] = 1 << i; } return(MaskFieldGUI.DoMaskField(position, controlID, mask, flagNames, array, style, out changedFlags, out changedToValue)); }
static int DoMaskField(Rect rect, int mask, string[] displayedOptions, GUIStyle popup) { var flagValues = new int[displayedOptions.Length]; for (int i = 0; i < flagValues.Length; ++i) { flagValues[i] = (1 << i); } string buttonText; string[] optionNames; int[] optionMaskValues; int[] selectedOptions; MaskFieldGUI.GetMenuOptions(mask, displayedOptions, flagValues, out buttonText, out optionNames, out optionMaskValues, out selectedOptions); var id = EditorGUIUtility.GetControlID("AdvancedDropdown".GetHashCode(), FocusType.Keyboard, rect); if (EditorGUI.DropdownButton(id, rect, GUIContent.Temp(buttonText), EditorStyles.popup)) { s_CurrentControl = id; ResetAndCreateWindow(); var dataSource = new MultiselectDataSource(mask, displayedOptions, flagValues); InitMultiselectPopupWindow(rect, dataSource); s_Instance.selectionChanged += dataSource.UpdateSelectedId; s_Instance.selectionChanged += i => { m_ShouldReturnValue = true; }; s_Instance.windowClosed += w => { m_WindowClosed = true; }; } if (m_ShouldReturnValue && s_CurrentControl == id) { m_ShouldReturnValue = false; return(s_DataSource.mask); } if (m_WindowClosed && s_CurrentControl == id) { s_CurrentControl = 0; m_WindowClosed = false; var result = s_DataSource.mask; s_DataSource = null; return(result); } return(mask); }
public static Enum DoEnumMaskPopup(Rect rect, Enum options, GUIStyle style) { var enumData = EnumDataUtility.GetCachedEnumData(options.GetType()); var optionValue = EnumDataUtility.EnumFlagsToInt(enumData, options); string buttonText; string[] optionNames; int[] optionMaskValues; int[] selectedOptions; MaskFieldGUI.GetMenuOptions(optionValue, enumData.displayNames, enumData.flagValues, out buttonText, out optionNames, out optionMaskValues, out selectedOptions); var id = EditorGUIUtility.GetControlID("AdvancedDropdown".GetHashCode(), FocusType.Keyboard, rect); if (EditorGUI.DropdownButton(id, rect, GUIContent.Temp(buttonText), EditorStyles.popup)) { s_CurrentControl = id; ResetAndCreateWindow(); var dataSource = new MultiselectDataSource(options); InitMultiselectPopupWindow(rect, dataSource); s_Instance.selectionChanged += dataSource.UpdateSelectedId; s_Instance.selectionChanged += i => { m_ShouldReturnValue = true; }; s_Instance.windowClosed += w => { m_WindowClosed = true; }; } if (m_ShouldReturnValue && s_CurrentControl == id) { m_ShouldReturnValue = false; return(s_DataSource.enumFlags); } if (m_WindowClosed && s_CurrentControl == id) { s_CurrentControl = 0; m_WindowClosed = false; var result = s_DataSource.enumFlags; s_DataSource = null; return(result); } return(options); }
internal static void GetMenuOptions(int mask, string[] flagNames, int[] flagValues, out string buttonText, out string[] optionNames, out int[] optionMaskValues, out int[] selectedOptions) { bool flag = flagValues[0] == 0; bool flag2 = flagValues[flagValues.Length - 1] == -1; string text = (!flag) ? "Nothing" : flagNames[0]; string text2 = (!flag2) ? "Everything" : flagNames[flagValues.Length - 1]; int bufferLength = flagNames.Length + ((!flag) ? 1 : 0) + ((!flag2) ? 1 : 0); int num = flagNames.Length - ((!flag) ? 0 : 1) - ((!flag2) ? 0 : 1); int num2 = (!flag) ? 0 : 1; int num3 = num2 + num; buttonText = "Mixed ..."; if (mask == 0) { buttonText = text; } else if (mask == -1) { buttonText = text2; } else { for (int i = num2; i < num3; i++) { if (mask == flagValues[i]) { buttonText = flagNames[i]; } } } optionNames = MaskFieldGUI.GetBuffer <string>(MaskFieldGUI.s_OptionNames, bufferLength); optionNames[0] = text; optionNames[1] = text2; for (int j = num2; j < num3; j++) { int num4 = j - num2 + 2; optionNames[num4] = flagNames[j]; } int num5 = 0; int num6 = 0; MaskFieldGUI.s_SelectedOptionsSet.Clear(); if (mask == 0) { MaskFieldGUI.s_SelectedOptionsSet.Add(0); } if (mask == -1) { MaskFieldGUI.s_SelectedOptionsSet.Add(1); } for (int k = num2; k < num3; k++) { int num7 = flagValues[k]; num5 |= num7; if ((mask & num7) == num7) { int item = k - num2 + 2; MaskFieldGUI.s_SelectedOptionsSet.Add(item); num6 |= num7; } } selectedOptions = MaskFieldGUI.GetBuffer <int>(MaskFieldGUI.s_SelectedOptions, MaskFieldGUI.s_SelectedOptionsSet.Count); int num8 = 0; foreach (int current in MaskFieldGUI.s_SelectedOptionsSet) { selectedOptions[num8] = current; num8++; } optionMaskValues = MaskFieldGUI.GetBuffer <int>(MaskFieldGUI.s_OptionValues, bufferLength); optionMaskValues[0] = 0; optionMaskValues[1] = -1; for (int l = num2; l < num3; l++) { int num9 = l - num2 + 2; int num10 = flagValues[l]; bool flag3 = (num6 & num10) == num10; int num11 = (!flag3) ? (num6 | num10) : (num6 & ~num10); if (num11 == num5) { num11 = -1; } optionMaskValues[num9] = num11; } }