private void CreateSelectionSubscriptions(SelectionModes mode) { Log.DebugFormat("Creating subscription to {0} SelectionTriggerSource for selections & results.", SelectionMode); switch (mode) { case SelectionModes.Key: selectionTriggerSource = keySelectionTriggerSource; break; case SelectionModes.Point: selectionTriggerSource = pointSelectionTriggerSource; break; } if (eyeGestureTriggerSource != null) { eyeGestureTriggerSubscription = eyeGestureTriggerSource.Sequence .ObserveOnDispatcher() .Subscribe(ProcessSelectionTrigger); } if (selectionTriggerSource != null) { selectionTriggerSubscription = selectionTriggerSource.Sequence .ObserveOnDispatcher() .Subscribe(ProcessSelectionTrigger); } }
private void CreateSelectionProgressSubscription(SelectionModes mode) { Log.DebugFormat("Creating subscription to {0} SelectionTriggerSource for progress info.", SelectionMode); ITriggerSource selectionTriggerSource = null; switch (mode) { case SelectionModes.Key: selectionTriggerSource = keySelectionTriggerSource; break; case SelectionModes.Point: selectionTriggerSource = pointSelectionTriggerSource; break; } if (selectionTriggerSource != null) { selectionProgressSubscription = selectionTriggerSource.Sequence .Where(ts => ts.Progress != null) .DistinctUntilChanged() .ObserveOnDispatcher() .Subscribe(ts => { PublishSelectionProgress(new Tuple <PointAndKeyValue?, double>(ts.PointAndKeyValue, ts.Progress.Value)); }); } }
void ManualMouseClick(MouseEventArgs e, SelectionModes mode) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { SelectionPoint = PointToClient(Cursor.Position); SelectionMap = new Dictionary <int, NodeModel>(); // on double click event, mouse up will fire after so don't set selection mode back to single if (SelectionMode == SelectionModes.None) { SelectionMode = mode; } } // back button zoom out else if (e.Button == MouseButtons.XButton1) { Model.NavBack(); } // forward button zoom in else if (e.Button == MouseButtons.XButton2) { Model.NavForward(); } }
private void CreateSelectionProgressSubscription(SelectionModes mode) { Log.DebugFormat("Creating subscription to {0} SelectionTriggerSource for progress info.", SelectionMode); ITriggerSource selectionTriggerSource = null; switch (mode) { case SelectionModes.Key: selectionTriggerSource = keySelectionTriggerSource; break; case SelectionModes.Point: selectionTriggerSource = pointSelectionTriggerSource; break; } if (selectionTriggerSource != null) { selectionProgressSubscription = selectionTriggerSource.Sequence .Where(ts => ts.Progress != null) .DistinctUntilChanged() .ObserveOnDispatcher() .Subscribe(ts => { PublishSelectionProgress(new Tuple<PointAndKeyValue?, double>(ts.PointAndKeyValue, ts.Progress.Value)); }); } }
protected override void Arrange() { base.Arrange(); OriginalValue = SelectionModes.Key; NewValue = SelectionModes.Point; MainViewModel.SelectionMode = OriginalValue; InputService.ResetCalls(); }
protected override void Arrange() { base.Arrange(); OriginalValue = SelectionModes.Key; NewValue = SelectionModes.Point; MainViewModel.SelectionMode = OriginalValue; InputService.ResetCalls(); }
// Use this for initialization void Start () { ObjectTooltip.Hide (); selectionMode = SelectionModes.None; instance = this; attackButton = transform.Find ("AttackButton").GetComponent<Button> (); abilityButton = transform.Find ("AbilityButton").GetComponent<Button> (); itemButton = transform.Find ("ItemButton").GetComponent<Button> (); attackButton.gameObject.SetActive (false); abilityButton.gameObject.SetActive (false); itemButton.gameObject.SetActive (false); }
private static string BuildThemeTitle(SelectionModes selectionMode, int themeIndex) { if (selectionMode == SelectionModes.Toggle) { return("Theme " + (themeIndex % 2 == 0 ? "(Deselected)" : "(Selected)")); } else if (selectionMode == SelectionModes.MultiDimension) { return("Theme " + (themeIndex + 1)); } return("Theme"); }
internal static void GetSingleSelectionValues(int maskValue, out SelectionModes[] selectionMatch, int layerCount) { selectionMatch = new SelectionModes[layerCount]; uint[] selected; GetSelected(maskValue, out selected, layerCount); for (int i = 0; i < selectionMatch.Length; i++) { if (Array.Exists(selected, el => el == i + 1)) { selectionMatch[i] = SelectionModes.All; } } }
internal static void GetMultiSelectionValues(SerializedProperty serializedProperty, out uint[] selectionMaskValues, out SelectionModes[] selectionMatch, int layerCount) { var selectionCount = serializedProperty.serializedObject.targetObjects.Length; selectionMaskValues = new uint[selectionCount]; selectionMatch = new SelectionModes[layerCount]; for (int i = 0; i < selectionCount; i++) { var serializedObject = new SerializedObject(serializedProperty.serializedObject.targetObjects[i]); var property = serializedObject.FindProperty(serializedProperty.propertyPath); selectionMaskValues[i] = (uint)property.intValue; } if (selectionCount == 1) { GetSingleSelectionValues((int)selectionMaskValues[0], out selectionMatch, layerCount); return; } uint[] firstSelected; GetSelected((int)selectionMaskValues[0], out firstSelected, layerCount); for (int i = 1; i < selectionCount; i++) { uint[] secondSelected; GetSelected((int)selectionMaskValues[i], out secondSelected, layerCount); for (int j = 0; j < layerCount; j++) { var firstExists = Array.Exists(firstSelected, element => element == j + 1); var secondExists = Array.Exists(secondSelected, element => element == j + 1); if (firstExists && secondExists && selectionMatch[j] != SelectionModes.Mixed) { selectionMatch[j] = SelectionModes.All; } else if (!firstExists && !secondExists && selectionMatch[j] != SelectionModes.Mixed) { selectionMatch[j] = SelectionModes.None; } else { selectionMatch[j] = SelectionModes.Mixed; } } } }
protected override void OnSelectionModeChanged(SelectionModes oldValue, SelectionModes newValue) { base.OnSelectionModeChanged(oldValue, newValue); for (int i = 0; i < ItemsGenerator.TotalItemsCount; i++) { if (ItemsGenerator.HasItemViewGenerated(i)) { View item = ItemsGenerator.GetItemViewFromIndex(i); InitializeItem(item); if (_leftPadding != null) { SetLeftPadding(item, _leftPadding.Value); } } } }
private void DoSelectionPass() { // turn off lighting and draw world as flat colored objects who's color corresponds to their node id GLUtils.SafeDisable(EnableCap.Lighting, () => { // reset vbo Nodes.Reset(); // call render Model.Render(); // load vbo Nodes.Load(); // draw node vbo Nodes.Draw(BeginMode.Triangles); // read pixel at cursor byte[] rgb = new byte[3]; GL.ReadPixels(SelectionPoint.X, Height - SelectionPoint.Y, 1, 1, PixelFormat.Rgb, PixelType.UnsignedByte, rgb); // convert to color int int id = (rgb[0] << 24) | (rgb[1] << 16) | rgb[2]; // look up in map NodeModel node; SelectionMap.TryGetValue(id, out node); if (SelectionMode == SelectionModes.Single) { Model.ClickNode(node); } else { Model.SetRoot(node); } }); // clear buffer GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); // turn off selection mode SelectionMode = SelectionModes.None; }
private void Awake() { unitsRoot = FindObjectOfType <UnitsRoot>(); stateMachineLow = new StateMachine <LowStates>(); stateMachineLow.AddState(LowStates.NotSelecting); stateMachineLow.AddState(LowStates.Selecting, null, () => { ShapeSelecting(); }); stateMachineLow.AddState(LowStates.InternalConfirm, () => { ConfirmShapeSelecting(); stateMachineLow.CurrentState = LowStates.NotSelecting; }); stateMachineLow.AddState(LowStates.InternalCancel, () => { CancelShapeSelecting(); stateMachineLow.CurrentState = LowStates.NotSelecting; }); stateMachineHigh = new StateMachine <HighStates>(); stateMachineHigh.AddState(HighStates.Dead, () => { selectionMode = SelectionModes.Default; CancelSelecting(); DeselectAndDepreselectEveryone(); }); stateMachineHigh.AddState(HighStates.Inactive, () => { selectionMode = SelectionModes.Default; CancelSelecting(); }); stateMachineHigh.AddState(HighStates.Active /*, null, () => { stateMachineLow.Update(); }*/); stateMachineHigh.AddState(HighStates.Pause); stateMachineLow.CurrentState = LowStates.NotSelecting; stateMachineHigh.CurrentState = HighStates.Active; }
/// <summary> /// Initializes a new instance of the <see cref="SelectionViewModel{TEntity}"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="commonServices">The common services.</param> /// <param name="logger">The logger factory.</param> /// <param name="items">The items.</param> /// <param name="selectedItems">The selected items.</param> /// <param name="selectionMode">The selection mode.</param> /// <param name="automaticValidation"></param> public SelectionViewModel( IContext context, IBaseCommonServices commonServices, ILogger logger, IEnumerable <TEntity> items, IEnumerable <object> selectedItems, SelectionModes selectionMode = SelectionModes.Single, bool automaticValidation = false) : base(context, commonServices, logger, automaticValidation) { if (items is null) { items = items.EnsureNotNull(); } if (selectedItems is null) { selectedItems = selectedItems.EnsureNotNull(); } SelectionMode = selectionMode; Validator = new Action <IObservableClass>(arg => { if (SelectionMode == SelectionModes.Single && SelectedItem.Count != 1) { Properties[nameof(SelectedItem)].Errors.Add(commonServices.LanguageService.GetString("WarningSelectItem")); } if (SelectionMode == SelectionModes.Multiple && SelectedItem.Count < 1) { Properties[nameof(SelectedItem)].Errors.Add(commonServices.LanguageService.GetString("WarningSelectItem")); } }); Search_Command = new Command <string>(async(e) => await QueryItemsAsync(e)); RawItems = items; Items = new ObservableCollection <TEntity>(items); SelectedItem = new List <object>(selectedItems); IsInitialized = true; }
private static void RewardModules(string input, double expectedOutput) { SelectionMode = SelectionModes.Random; List <string> instructions = new List <string>(); foreach (string s in input.Split(' ')) { instructions.Add(s); } for (int i = 0; i < Constants.NumberOfSampleModules; i++) { Module module = new Module("", 0, instructions); double moduleOutput = module.Compute(new List <double>()); double relativeError = Math.Abs((moduleOutput - expectedOutput) / expectedOutput); module.SaveError(relativeError); } SelectionMode = SelectionModes.Best; }
public void ShowItems(){ ObjectTooltip.Hide (); selectionMode = SelectionModes.None; HideSubActions (); ClearButtonHighlights (); selectedItem = null; Prompt.SetText ("Select an item"); int i = 0; foreach(Item item in instance.activePartyMember.heldItems){ Vector3 newPosition = new Vector3 (130, 230 + (i * 75), 0); Item capturedItem = item; GameObject buttonObject = Instantiate (Resources.Load ("ActionButton"), newPosition, Quaternion.identity) as GameObject; buttons.Add (buttonObject); ActionButton actionButton = buttonObject.GetComponent<ActionButton> (); actionButton.sprite = capturedItem.sprite; buttonObject.transform.parent = transform; Button button = buttonObject.GetComponent<Button> (); button.transform.localScale = new Vector3 (1, 1, 1); button.onClick.RemoveAllListeners (); button.onClick.AddListener( delegate { instance.SelectItem(buttonObject, capturedItem); } ); button.onClick.AddListener( delegate { HighlightButton(actionButton); } ); i++; } ShowWeapon (); }
public void DoAttack(){ selectionMode = SelectionModes.None; HideSubActions (); SelectAbility (activePartyMember.abilities [0]); }
/// <summary> /// Adds any members found in the specified region to the selected state as long as SelectionEnabled is set to true. /// </summary> /// <param name="tolerant">The geographic region where selection occurs in cases like clicking near points where tolerance is allowed</param> /// <param name="strict">The geographic region in cases like selecting polygons where no tolerance is allowed</param> /// <param name="mode">The selection mode</param> /// <param name="affectedArea">The envelope affected area</param> /// <returns>Boolean, true if any members were added to the selection</returns> public override bool UnSelect(IEnvelope tolerant, IEnvelope strict, SelectionModes mode, out IEnvelope affectedArea) { affectedArea = new Envelope(); if (!_selectionEnabled) return false; bool somethingChanged = false; SuspendEvents(); foreach (ILayer s in GetLayers()) { IEnvelope layerArea; if (s.UnSelect(tolerant, strict, mode, out layerArea)) somethingChanged = true; affectedArea.ExpandToInclude(layerArea); } ResumeEvents(); OnSelectionChanged(); // fires only AFTER the individual layers have fired their events. return somethingChanged; }
public void ShowAbilities(){ ObjectTooltip.Hide (); selectionMode = SelectionModes.None; HideSubActions (); ClearButtonHighlights (); selectedItem = null; Prompt.SetText ("Select an ability"); int i = 0; int xIncrement = 0; foreach(Ability ability in activePartyMember.abilities){ if (i != 0) { if (xIncrement > 3) xIncrement = 0; float x = 55 + ((xIncrement) * 75); float y = 225 + (Mathf.Floor((i-1)/4) * 75); Vector3 newPosition = new Vector3(x, y, 0); GameObject buttonObject = Instantiate (Resources.Load ("ActionButton"), newPosition, Quaternion.identity) as GameObject; Sprite sprite = Resources.Load<Sprite>("Sprites/" + ability.SpriteName ()); buttonObject.GetComponent<ActionButton> ().sprite = sprite; buttonObject.transform.parent = transform; Button button = buttonObject.GetComponent<Button> (); button.transform.localScale = new Vector3 (1, 1, 1); Ability capturedAbility = ability; button.onClick.AddListener (delegate { SelectAbility (capturedAbility); }); buttons.Add (buttonObject); xIncrement++; } i++; } }
protected void RenderGeneralSettings() { Rect position; bool isPlayMode = EditorApplication.isPlaying || EditorApplication.isPaused; using (new EditorGUILayout.HorizontalScope()) { InspectorUIUtility.DrawTitle("General"); if (target != null) { var helpURL = target.GetType().GetCustomAttribute <HelpURLAttribute>(); if (helpURL != null) { InspectorUIUtility.RenderDocumentationButton(helpURL.URL); } } } EditorGUILayout.BeginVertical(EditorStyles.helpBox); // States // If states value is not provided, try to use Default states type if (statesProperty.objectReferenceValue == null) { statesProperty.objectReferenceValue = ThemeInspector.GetDefaultInteractableStates(); } GUI.enabled = !isPlayMode; EditorGUILayout.PropertyField(statesProperty, new GUIContent("States", "The States this Interactable is based on")); GUI.enabled = true; if (statesProperty.objectReferenceValue == null) { InspectorUIUtility.DrawError("Please assign a States object!"); serializedObject.ApplyModifiedProperties(); return; } EditorGUILayout.PropertyField(enabledProperty, new GUIContent("Enabled", "Is this Interactable Enabled?")); // Input Actions bool validActionOptions = inputActionOptions != null; GUI.enabled = validActionOptions && !isPlayMode; var actionOptions = validActionOptions ? inputActionOptions : new string[] { "Missing Mixed Reality Toolkit" }; DrawDropDownProperty(EditorGUILayout.GetControlRect(), actionId, actionOptions, InputActionsLabel); GUI.enabled = true; using (new EditorGUI.IndentLevelScope()) { EditorGUILayout.PropertyField(isGlobal, new GUIContent("Is Global", "Like a modal, does not require focus")); } // Speech keywords bool validSpeechKeywords = speechKeywordOptions != null; GUI.enabled = validSpeechKeywords && !isPlayMode; string[] keywordOptions = validSpeechKeywords ? speechKeywordOptions : new string[] { "Missing Speech Commands" }; int currentIndex = validSpeechKeywords ? SpeechKeywordLookup(voiceCommands.stringValue, speechKeywordOptions) : 0; position = EditorGUILayout.GetControlRect(); //BeginProperty allows tracking of serialized properties for bolding prefab changes etc EditorGUI.BeginProperty(position, SpeechComamndsLabel, voiceCommands); { currentIndex = EditorGUI.Popup(position, SpeechComamndsLabel.text, currentIndex, keywordOptions); if (validSpeechKeywords) { voiceCommands.stringValue = currentIndex > 0 ? speechKeywordOptions[currentIndex] : string.Empty; } } EditorGUI.EndProperty(); GUI.enabled = true; // show requires gaze because voice command has a value if (!string.IsNullOrEmpty(voiceCommands.stringValue)) { using (new EditorGUI.IndentLevelScope()) { SerializedProperty requireGaze = serializedObject.FindProperty("RequiresFocus"); EditorGUILayout.PropertyField(requireGaze, new GUIContent("Requires Focus", "Does the voice command require gazing at this interactable?")); } } // should be 1 or more dimensions.intValue = Mathf.Clamp(dimensions.intValue, 1, 9); string[] selectionModeNames = Enum.GetNames(typeof(SelectionModes)); // clamp to values in the enum int selectionModeIndex = Mathf.Clamp(dimensions.intValue, 1, selectionModeNames.Length) - 1; // user-friendly dimension settings SelectionModes selectionMode = SelectionModes.Button; position = EditorGUILayout.GetControlRect(); GUI.enabled = !isPlayMode; EditorGUI.BeginProperty(position, selectionModeLabel, dimensions); { selectionMode = (SelectionModes)EditorGUI.EnumPopup(position, selectionModeLabel, (SelectionModes)(selectionModeIndex)); switch (selectionMode) { case SelectionModes.Button: dimensions.intValue = 1; break; case SelectionModes.Toggle: dimensions.intValue = 2; break; case SelectionModes.MultiDimension: // multi dimension mode - set min value to 3 dimensions.intValue = Mathf.Max(3, dimensions.intValue); position = EditorGUILayout.GetControlRect(); dimensions.intValue = EditorGUI.IntField(position, dimensionsLabel, dimensions.intValue); break; default: break; } } EditorGUI.EndProperty(); if (dimensions.intValue > 1) { // toggle or multi dimensional button using (new EditorGUI.IndentLevelScope()) { EditorGUILayout.PropertyField(canSelect, new GUIContent("Can Select", "The user can toggle this button")); EditorGUILayout.PropertyField(canDeselect, new GUIContent("Can Deselect", "The user can untoggle this button, set false for a radial interaction.")); position = EditorGUILayout.GetControlRect(); EditorGUI.BeginProperty(position, startDimensionLabel, startDimensionIndex); { if (dimensions.intValue >= selectionModeNames.Length) { // multi dimensions if (!isPlayMode) { startDimensionIndex.intValue = EditorGUI.IntField(position, startDimensionLabel, startDimensionIndex.intValue); } else { EditorGUI.IntField(position, CurrentDimensionLabel, dimensionIndex.intValue); } } else if (dimensions.intValue == (int)SelectionModes.Toggle + 1) { if (!isPlayMode) { bool isToggled = EditorGUI.Toggle(position, isToggledLabel, startDimensionIndex.intValue > 0); startDimensionIndex.intValue = isToggled ? 1 : 0; } else { bool isToggled = EditorGUI.Toggle(position, isToggledLabel, dimensionIndex.intValue > 0); } } startDimensionIndex.intValue = Mathf.Clamp(startDimensionIndex.intValue, 0, dimensions.intValue - 1); } EditorGUI.EndProperty(); } } GUI.enabled = true; EditorGUILayout.EndVertical(); }
public override bool Select(IEnvelope tolerant, IEnvelope strict, SelectionModes mode, out IEnvelope affectedArea) { affectedArea = new Envelope(); if (!_selectionEnabled) return false; bool somethingChanged = false; MapFrame.SuspendEvents(); foreach (ILayer s in GetLayers()) { if (s.SelectionEnabled == false) continue; IEnvelope layerArea; if(s.Select(tolerant, strict, mode, out layerArea)) somethingChanged = true; affectedArea.ExpandToInclude(layerArea); } Stopwatch sw = new Stopwatch(); sw.Start(); MapFrame.ResumeEvents(); sw.Stop(); Debug.WriteLine("ResumeEvents: " + sw.ElapsedMilliseconds); OnSelectionChanged(); // fires only AFTER the individual layers have fired their events. return somethingChanged; }
private void CreateSelectionSubscriptions(SelectionModes mode) { Log.DebugFormat("Creating subscription to {0} SelectionTriggerSource for selections & results.", SelectionMode); switch (mode) { case SelectionModes.Key: selectionTriggerSource = keySelectionTriggerSource; break; case SelectionModes.Point: selectionTriggerSource = pointSelectionTriggerSource; break; } if (selectionTriggerSource != null) { selectionTriggerSubscription = selectionTriggerSource.Sequence .ObserveOnDispatcher() .Subscribe(ProcessSelectionTrigger); } }
/// <summary> /// Adds any members found in the specified region to the selected state as long as SelectionEnabled is set to true. /// </summary> /// <param name="strict">The tight envelope to use for polygons</param> /// <param name="tolerant">The geographic region where selection occurs that is tolerant for point or linestrings</param> /// <param name="mode">The selection mode</param> /// <param name="affectedArea">The envelope affected area</param> /// <returns>Boolean, true if any members were added to the selection</returns> public bool UnSelect(IEnvelope tolerant, IEnvelope strict, SelectionModes mode, out IEnvelope affectedArea) { affectedArea = new Envelope(); if (MapFrame == null) return false; return MapFrame.UnSelect(tolerant, strict, mode, out affectedArea); }
/// <summary> /// This method inverts the selection for the specified region. Members already a part of the selection /// will be removed from the selection, while members that are not a part of the selection will be added /// to the selection. /// </summary> /// <param name="tolerant">The region specifying where featuers should be added or removed from the selection</param> /// <param name="strict">With polygon selection it is better not to allow any tolerance since the polygons already contain it</param> /// <param name="affectedArea">The geographic region that will be impacted by the changes</param> /// <param name="selectionMode">The SelectionModes enumeration that clarifies how the features should interact with the region</param> public override bool InvertSelection(IEnvelope tolerant, IEnvelope strict, SelectionModes selectionMode, out IEnvelope affectedArea) { if (!_drawnStatesNeeded && !_editMode) AssignFastDrawnStates(); IEnvelope region = tolerant; bool changed = false; affectedArea = new Envelope(); if (DataSet.FeatureType == FeatureTypes.Polygon) { region = strict; } _selection.SelectionMode = selectionMode; if (IsWithinLegendSelection() || _scheme.IsWithinLegendSelection()) { changed = _selection.InvertSelection(region, out affectedArea); } else { List<IFeatureCategory> categories = _scheme.GetCategories().ToList(); foreach (IFeatureCategory category in categories) { if (!category.IsWithinLegendSelection()) continue; _selection.RegionCategory = category; if (_selection.AddRegion(region, out affectedArea)) changed = true; _selection.RegionCategory = null; } } return changed; }
public void SelectItem(GameObject buttonObject, Item item){ selectionMode = SelectionModes.ItemTarget; selectedItem = item; foreach (GameObject enemy in RoomController.instance.enemies) { enemy.GetComponent<Baddie> ().EnableClick (); } foreach(GameObject button in instance.buttons){ if (button != null) { Destroy (button); } } ObjectTooltip.Show (selectedItem); instance.buttons.Clear (); Prompt.SetText ("Select a target"); }
protected void RenderGeneralSettings() { Rect position; using (new EditorGUILayout.HorizontalScope()) { InspectorUIUtility.DrawLabel("General", InspectorUIUtility.TitleFontSize, InspectorUIUtility.ColorTint10); if (target != null) { var helpURL = target.GetType().GetCustomAttribute <HelpURLAttribute>(); if (helpURL != null) { InspectorUIUtility.RenderDocumentationButton(helpURL.URL); } } } using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { // If states value is not provided, try to use Default states type if (statesProperty.objectReferenceValue == null) { statesProperty.objectReferenceValue = GetDefaultInteractableStatesFile(); } EditorGUILayout.PropertyField(statesProperty, new GUIContent("States")); if (statesProperty.objectReferenceValue == null) { InspectorUIUtility.DrawError("Please assign a States object!"); serializedObject.ApplyModifiedProperties(); return; } EditorGUILayout.PropertyField(enabledProperty, new GUIContent("Enabled")); // Input Actions bool validActionOptions = inputActionOptions != null; using (new EditorGUI.DisabledScope(!validActionOptions)) { var actionOptions = validActionOptions ? inputActionOptions : new string[] { "Missing Mixed Reality Toolkit" }; DrawDropDownProperty(EditorGUILayout.GetControlRect(), actionId, actionOptions, InputActionsLabel); } using (new EditorGUI.IndentLevelScope()) { EditorGUILayout.PropertyField(isGlobal, new GUIContent("Is Global")); } // Speech keywords bool validSpeechKeywords = speechKeywordOptions != null; using (new EditorGUI.DisabledScope(!validSpeechKeywords)) { string[] keywordOptions = validSpeechKeywords ? speechKeywordOptions : new string[] { "Missing Speech Commands" }; int currentIndex = validSpeechKeywords ? SpeechKeywordLookup(voiceCommands.stringValue, speechKeywordOptions) : 0; position = EditorGUILayout.GetControlRect(); // BeginProperty allows tracking of serialized properties for bolding prefab changes etc using (new EditorGUI.PropertyScope(position, SpeechComamndsLabel, voiceCommands)) { currentIndex = EditorGUI.Popup(position, SpeechComamndsLabel.text, currentIndex, keywordOptions); if (validSpeechKeywords) { voiceCommands.stringValue = currentIndex > 0 ? speechKeywordOptions[currentIndex] : string.Empty; } } } // show requires gaze because voice command has a value if (!string.IsNullOrEmpty(voiceCommands.stringValue)) { using (new EditorGUI.IndentLevelScope()) { SerializedProperty requireGaze = serializedObject.FindProperty("voiceRequiresFocus"); EditorGUILayout.PropertyField(requireGaze, VoiceRequiresFocusLabel); } } // should be 1 or more dimensions.intValue = Mathf.Clamp(dimensions.intValue, 1, 9); // user-friendly dimension settings SelectionModes selectionMode = SelectionModes.Button; position = EditorGUILayout.GetControlRect(); using (new EditorGUI.PropertyScope(position, selectionModeLabel, dimensions)) { // Show enum popup for selection mode, hide option to select SelectionModes.Invalid selectionMode = (SelectionModes)EditorGUI.EnumPopup(position, selectionModeLabel, Interactable.ConvertToSelectionMode(dimensions.intValue), (value) => { return((SelectionModes)value != SelectionModes.Invalid); }); switch (selectionMode) { case SelectionModes.Button: dimensions.intValue = 1; break; case SelectionModes.Toggle: dimensions.intValue = 2; break; case SelectionModes.MultiDimension: // multi dimension mode - set min value to 3 dimensions.intValue = Mathf.Max(3, dimensions.intValue); position = EditorGUILayout.GetControlRect(); dimensions.intValue = EditorGUI.IntField(position, dimensionsLabel, dimensions.intValue); break; default: break; } } if (dimensions.intValue > 1) { // toggle or multi dimensional button using (new EditorGUI.IndentLevelScope()) { EditorGUILayout.PropertyField(canSelect, new GUIContent("Can Select", "The user can toggle this button")); EditorGUILayout.PropertyField(canDeselect, new GUIContent("Can Deselect", "The user can untoggle this button, set false for a radial interaction.")); position = EditorGUILayout.GetControlRect(); using (new EditorGUI.PropertyScope(position, startDimensionLabel, startDimensionIndex)) { var mode = Interactable.ConvertToSelectionMode(dimensions.intValue); if (mode == SelectionModes.Toggle) { bool isToggled = EditorGUI.Toggle(position, isToggledLabel, startDimensionIndex.intValue > 0); startDimensionIndex.intValue = isToggled ? 1 : 0; } else if (mode == SelectionModes.MultiDimension) { startDimensionIndex.intValue = EditorGUI.IntField(position, startDimensionLabel, startDimensionIndex.intValue); } startDimensionIndex.intValue = Mathf.Clamp(startDimensionIndex.intValue, 0, dimensions.intValue - 1); } } } } }
private void DoSelectionPass() { // turn off lighting and draw world as flat colored objects who's color corresponds to their node id GLUtils.SafeDisable(EnableCap.Lighting, () => { // reset vbo Nodes.Reset(); // call render Model.Render(); // load vbo Nodes.Load(); // draw node vbo Nodes.Draw(BeginMode.Triangles); // read pixel at cursor byte[] rgb = new byte[3]; GL.ReadPixels(SelectionPoint.X, Height - SelectionPoint.Y, 1, 1, PixelFormat.Rgb, PixelType.UnsignedByte, rgb); // convert to color int int id = (rgb[0] << 24) | (rgb[1] << 16) | rgb[2]; // look up in map NodeModel node; SelectionMap.TryGetValue(id, out node); if (SelectionMode == SelectionModes.Single) Model.ClickNode(node); else Model.SetRoot(node); }); // clear buffer GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); // turn off selection mode SelectionMode = SelectionModes.None; }
/// <summary /> public HierarchyFieldMetadata() { this.selectionModeField = SelectionModes.Multiple; }
/// <summary /> public EnumerationFieldMetadata() { this.selectionModeField = SelectionModes.Multiple; }
void ManualMouseClick(MouseEventArgs e, SelectionModes mode) { if (e.Button == System.Windows.Forms.MouseButtons.Left) { SelectionPoint = PointToClient(Cursor.Position); SelectionMap = new Dictionary<int, NodeModel>(); // on double click event, mouse up will fire after so don't set selection mode back to single if (SelectionMode == SelectionModes.None) SelectionMode = mode; } // back button zoom out else if (e.Button == MouseButtons.XButton1) Model.NavBack(); // forward button zoom in else if (e.Button == MouseButtons.XButton2) Model.NavForward(); }
public void ShowActions(){ ObjectTooltip.Hide (); selectionMode = SelectionModes.None; itemButton.gameObject.SetActive (true); attackButton.gameObject.SetActive (true); abilityButton.gameObject.SetActive (true); ClearActionButtonHighlights(); foreach(PartyMember partyMember in PartyMember.members){ partyMember.HideOverlay (); } activePartyMember.ShowOverlay (); attackButton.onClick.RemoveAllListeners (); abilityButton.onClick.RemoveAllListeners (); itemButton.onClick.RemoveAllListeners (); itemButton.onClick.AddListener (delegate { ClearActionButtonHighlights(); }); attackButton.onClick.AddListener (delegate { ClearActionButtonHighlights(); }); abilityButton.onClick.AddListener (delegate { ClearActionButtonHighlights(); }); attackButton.onClick.AddListener (delegate { HighlightButton (attackButton.GetComponent<ActionButton>()); }); abilityButton.onClick.AddListener (delegate { HighlightButton (abilityButton.GetComponent<ActionButton>()); }); itemButton.onClick.AddListener (delegate { HighlightButton (itemButton.GetComponent<ActionButton>()); }); attackButton.onClick.AddListener (delegate { SelectAbility (activePartyMember.abilities[0]); }); abilityButton.onClick.AddListener (delegate { this.ShowAbilities(); }); itemButton.onClick.AddListener (delegate { this.ShowItems(); }); }
/// <summary> /// This is overriden in sub-classes /// </summary> /// <param name="tolerant">The geographic envelope in cases like cliking near points where tolerance is allowed</param> /// <param name="strict">The geographic region when working with absolutes, without a tolerance</param> /// <param name="mode"></param> /// <param name="affectedArea"></param> /// <returns></returns> public virtual bool UnSelect(IEnvelope tolerant, IEnvelope strict, SelectionModes mode, out IEnvelope affectedArea) { affectedArea = null; return false; }
public virtual void RenderCustomInspector() { serializedObject.Update(); Rect position; bool isPlayMode = EditorApplication.isPlaying || EditorApplication.isPaused; #region General Settings EditorGUILayout.BeginHorizontal(); InspectorUIUtility.DrawTitle("General"); InspectorUIUtility.RenderDocLinkButton(Interactable_URL); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginVertical(EditorStyles.helpBox); // States SerializedProperty states = serializedObject.FindProperty("States"); // If states value is not provided, try to use Default states type if (states.objectReferenceValue == null) { states.objectReferenceValue = ThemeInspector.GetDefaultInteractableStates(); } GUI.enabled = !isPlayMode; EditorGUILayout.PropertyField(states, new GUIContent("States", "The States this Interactable is based on")); GUI.enabled = true; if (states.objectReferenceValue == null) { InspectorUIUtility.DrawError("Please assign a States object!"); EditorGUILayout.EndVertical(); serializedObject.ApplyModifiedProperties(); return; } //standard Interactable Object UI SerializedProperty enabled = serializedObject.FindProperty("Enabled"); EditorGUILayout.PropertyField(enabled, new GUIContent("Enabled", "Is this Interactable Enabled?")); SerializedProperty actionId = serializedObject.FindProperty("InputActionId"); if (actionOptions == null) { GUI.enabled = false; EditorGUILayout.Popup("Input Actions", 0, new string[] { "Missing Mixed Reality Toolkit" }); GUI.enabled = true; } else { position = EditorGUILayout.GetControlRect(); DrawDropDownProperty(position, actionId, actionOptions, new GUIContent("Input Actions", "The input action filter")); } using (new EditorGUI.IndentLevelScope()) { SerializedProperty isGlobal = serializedObject.FindProperty("IsGlobal"); EditorGUILayout.PropertyField(isGlobal, new GUIContent("Is Global", "Like a modal, does not require focus")); } SerializedProperty voiceCommands = serializedObject.FindProperty("VoiceCommand"); // check speech commands profile for a list of commands if (speechKeywords == null) { GUI.enabled = false; EditorGUILayout.Popup("Speech Command", 0, new string[] { "Missing Speech Commands" }); InspectorUIUtility.DrawNotice("Create speech commands in the MRTK/Input/Speech Commands Profile"); GUI.enabled = true; } else { //look for items in the sppech commands list that match the voiceCommands string // this string should be empty if we are not listening to speech commands // will return zero if empty, to match the inserted off value. int currentIndex = SpeechKeywordLookup(voiceCommands.stringValue, speechKeywords); GUI.enabled = !isPlayMode; position = EditorGUILayout.GetControlRect(); GUIContent label = new GUIContent("Speech Command", "Speech Commands to use with Interactable, pulled from MRTK/Input/Speech Commands Profile"); EditorGUI.BeginProperty(position, label, voiceCommands); { currentIndex = EditorGUI.Popup(position, label, currentIndex, speechKeywords); if (currentIndex > 0) { voiceCommands.stringValue = speechKeywords[currentIndex].text; } else { voiceCommands.stringValue = ""; } } EditorGUI.EndProperty(); GUI.enabled = true; } // show requires gaze because voice command has a value if (!string.IsNullOrEmpty(voiceCommands.stringValue)) { using (new EditorGUI.IndentLevelScope()) { SerializedProperty requireGaze = serializedObject.FindProperty("RequiresFocus"); EditorGUILayout.PropertyField(requireGaze, new GUIContent("Requires Focus", "Does the voice command require gazing at this interactable?")); } } SerializedProperty dimensions = serializedObject.FindProperty("Dimensions"); // should be 1 or more dimensions.intValue = Mathf.Clamp(dimensions.intValue, 1, 9); string[] selectionModeNames = Enum.GetNames(typeof(SelectionModes)); // clamp to values in the enum int selectionModeIndex = Mathf.Clamp(dimensions.intValue, 1, selectionModeNames.Length) - 1; // user-friendly dimension settings SelectionModes selectionMode = SelectionModes.Button; position = EditorGUILayout.GetControlRect(); GUI.enabled = !isPlayMode; EditorGUI.BeginProperty(position, selectionModeLabel, dimensions); { selectionMode = (SelectionModes)EditorGUI.EnumPopup(position, selectionModeLabel, (SelectionModes)(selectionModeIndex)); switch (selectionMode) { case SelectionModes.Button: dimensions.intValue = 1; break; case SelectionModes.Toggle: dimensions.intValue = 2; break; case SelectionModes.MultiDimension: // multi dimension mode - set min value to 3 dimensions.intValue = Mathf.Max(3, dimensions.intValue); position = EditorGUILayout.GetControlRect(); dimensions.intValue = EditorGUI.IntField(position, dimensionsLabel, dimensions.intValue); break; default: break; } } EditorGUI.EndProperty(); if (dimensions.intValue > 1) { // toggle or multi dimensional button using (new EditorGUI.IndentLevelScope()) { SerializedProperty canSelect = serializedObject.FindProperty("CanSelect"); SerializedProperty canDeselect = serializedObject.FindProperty("CanDeselect"); SerializedProperty startDimensionIndex = serializedObject.FindProperty("StartDimensionIndex"); EditorGUILayout.PropertyField(canSelect, new GUIContent("Can Select", "The user can toggle this button")); EditorGUILayout.PropertyField(canDeselect, new GUIContent("Can Deselect", "The user can untoggle this button, set false for a radial interaction.")); position = EditorGUILayout.GetControlRect(); EditorGUI.BeginProperty(position, startDimensionLabel, startDimensionIndex); { if (dimensions.intValue >= selectionModeNames.Length) { // multi dimensions if (!isPlayMode) { startDimensionIndex.intValue = EditorGUI.IntField(position, startDimensionLabel, startDimensionIndex.intValue); } else { SerializedProperty dimensionIndex = serializedObject.FindProperty("dimensionIndex"); EditorGUI.IntField(position, CurrentDimensionLabel, dimensionIndex.intValue); } } else if (dimensions.intValue == (int)SelectionModes.Toggle + 1) { // toggle if (!isPlayMode) { bool isToggled = EditorGUI.Toggle(position, isToggledLabel, startDimensionIndex.intValue > 0); startDimensionIndex.intValue = isToggled ? 1 : 0; } else { SerializedProperty dimensionIndex = serializedObject.FindProperty("dimensionIndex"); bool isToggled = EditorGUI.Toggle(position, isToggledLabel, dimensionIndex.intValue > 0); } } startDimensionIndex.intValue = Mathf.Clamp(startDimensionIndex.intValue, 0, dimensions.intValue - 1); } EditorGUI.EndProperty(); } GUI.enabled = true; } EditorGUILayout.EndVertical(); #endregion EditorGUILayout.Space(); if (!ProfilesSetup && !showProfiles) { InspectorUIUtility.DrawWarning("Profiles (Optional) have not been set up or has errors."); } #region Profiles bool isProfilesOpen = InspectorUIUtility.DrawSectionFoldout("Profiles", showProfiles, FontStyle.Bold, InspectorUIUtility.TitleFontSize); if (showProfiles != isProfilesOpen) { showProfiles = isProfilesOpen; EditorPrefs.SetBool(ShowProfilesPrefKey, showProfiles); } if (profileList.arraySize < 1) { AddProfile(0); } int validProfileCnt = 0; int themeCnt = 0; if (showProfiles) { for (int i = 0; i < profileList.arraySize; i++) { EditorGUILayout.BeginVertical(EditorStyles.helpBox); // get profiles SerializedProperty sItem = profileList.GetArrayElementAtIndex(i); SerializedProperty gameObject = sItem.FindPropertyRelative("Target"); string targetName = "Profile " + (i + 1); if (gameObject.objectReferenceValue != null) { targetName = gameObject.objectReferenceValue.name; validProfileCnt++; } EditorGUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(gameObject, new GUIContent("Target", "Target gameObject for this theme properties to manipulate")); bool triggered = InspectorUIUtility.SmallButton(new GUIContent(InspectorUIUtility.Minus, "Remove Profile"), i, RemoveProfile); if (triggered) { continue; } EditorGUILayout.EndHorizontal(); // get themes SerializedProperty themes = sItem.FindPropertyRelative("Themes"); // make sure there are enough themes as dimensions if (themes.arraySize > dimensions.intValue) { // make sure there are not more themes than dimensions int cnt = themes.arraySize - 1; for (int j = cnt; j > dimensions.intValue - 1; j--) { themes.DeleteArrayElementAtIndex(j); } } // add themes when increasing dimensions if (themes.arraySize < dimensions.intValue) { int cnt = themes.arraySize; for (int j = cnt; j < dimensions.intValue; j++) { themes.InsertArrayElementAtIndex(themes.arraySize); SerializedProperty theme = themes.GetArrayElementAtIndex(themes.arraySize - 1); string[] themeLocations = AssetDatabase.FindAssets("DefaultTheme"); if (themeLocations.Length > 0) { for (int k = 0; k < themeLocations.Length; k++) { string path = AssetDatabase.GUIDToAssetPath(themeLocations[k]); Theme defaultTheme = (Theme)AssetDatabase.LoadAssetAtPath(path, typeof(Theme)); if (defaultTheme != null) { theme.objectReferenceValue = defaultTheme; break; } } } } } // Render all themes for current target for (int t = 0; t < themes.arraySize; t++) { SerializedProperty themeItem = themes.GetArrayElementAtIndex(t); string themeLabel = BuildThemeTitle(selectionMode, t); EditorGUILayout.PropertyField(themeItem, new GUIContent(themeLabel, "Theme properties for interaction feedback")); if (themeItem.objectReferenceValue != null && gameObject.objectReferenceValue) { if (themeItem.objectReferenceValue.name == "DefaultTheme") { EditorGUILayout.BeginHorizontal(); InspectorUIUtility.DrawWarning("DefaultTheme should not be edited. "); bool newTheme = InspectorUIUtility.FlexButton(new GUIContent("Create Theme", "Create a new theme"), new int[] { i, t, 0 }, CreateTheme); if (newTheme) { continue; } EditorGUILayout.EndHorizontal(); } SerializedProperty hadDefault = sItem.FindPropertyRelative("HadDefaultTheme"); hadDefault.boolValue = true; string prefKey = themeItem.objectReferenceValue.name + "Profiles" + i + "_Theme" + t + "_Edit"; bool hasPref = EditorPrefs.HasKey(prefKey); bool showSettings = EditorPrefs.GetBool(prefKey); if (!hasPref) { showSettings = true; } InspectorUIUtility.ListSettings settings = listSettings[i]; bool show = InspectorUIUtility.DrawSectionFoldout(themeItem.objectReferenceValue.name + " (Click to edit)", showSettings, FontStyle.Normal); if (show != showSettings) { EditorPrefs.SetBool(prefKey, show); settings.Show = show; } if (show) { SerializedObject themeObj = new SerializedObject(themeItem.objectReferenceValue); SerializedProperty themeObjSettings = themeObj.FindProperty("Settings"); themeObj.Update(); GUILayout.Space(5); if (themeObjSettings.arraySize < 1) { AddThemeProperty(new int[] { i, t, 0 }); } int[] location = new int[] { i, t, 0 }; State[] iStates = GetStates(); ThemeInspector.RenderThemeSettings(themeObjSettings, themeObj, themeOptions, gameObject, location, iStates, ThemePropertiesBoxMargin); InspectorUIUtility.FlexButton(new GUIContent("+", "Add Theme Property"), location, AddThemeProperty); ThemeInspector.RenderThemeStates(themeObjSettings, iStates, ThemePropertiesBoxMargin); themeObj.ApplyModifiedProperties(); } listSettings[i] = settings; validProfileCnt++; } else { // show message about profile setup string themeMsg = "Assign a "; if (gameObject.objectReferenceValue == null) { themeMsg += "Target "; } if (themeItem.objectReferenceValue == null) { if (gameObject.objectReferenceValue == null) { themeMsg += "and "; } themeMsg += "Theme "; } themeMsg += "above to add visual effects"; SerializedProperty hadDefault = sItem.FindPropertyRelative("HadDefaultTheme"); if (!hadDefault.boolValue && t == 0) { string[] themeLocations = AssetDatabase.FindAssets("DefaultTheme"); if (themeLocations.Length > 0) { for (int j = 0; j < themeLocations.Length; j++) { string path = AssetDatabase.GUIDToAssetPath(themeLocations[0]); Theme defaultTheme = (Theme)AssetDatabase.LoadAssetAtPath(path, typeof(Theme)); if (defaultTheme != null) { themeItem.objectReferenceValue = defaultTheme; break; } } if (themeItem.objectReferenceValue != null) { hadDefault.boolValue = true; } } else { InspectorUIUtility.DrawError("DefaultTheme missing from project!"); } } InspectorUIUtility.DrawError(themeMsg); } themeCnt += themes.arraySize; } EditorGUILayout.EndVertical(); }// profile for loop if (GUILayout.Button(new GUIContent("Add Profile"))) { AddProfile(profileList.arraySize); } } else { // make sure profiles are setup if closed by default for (int i = 0; i < profileList.arraySize; i++) { SerializedProperty sItem = profileList.GetArrayElementAtIndex(i); SerializedProperty gameObject = sItem.FindPropertyRelative("Target"); SerializedProperty themes = sItem.FindPropertyRelative("Themes"); if (gameObject.objectReferenceValue != null) { validProfileCnt++; } for (int t = 0; t < themes.arraySize; t++) { SerializedProperty themeItem = themes.GetArrayElementAtIndex(themes.arraySize - 1); if (themeItem.objectReferenceValue != null && gameObject.objectReferenceValue) { validProfileCnt++; SerializedProperty hadDefault = sItem.FindPropertyRelative("HadDefaultTheme"); hadDefault.boolValue = true; } } themeCnt += themes.arraySize; } } ProfilesSetup = validProfileCnt == profileList.arraySize + themeCnt; #endregion EditorGUILayout.Space(); #region Events settings bool isEventsOpen = InspectorUIUtility.DrawSectionFoldout("Events", showEvents, FontStyle.Bold, InspectorUIUtility.TitleFontSize); if (showEvents != isEventsOpen) { showEvents = isEventsOpen; EditorPrefs.SetBool(ShowEventsPrefKey, showEvents); } EditorGUILayout.Space(); if (showEvents) { SerializedProperty onClick = serializedObject.FindProperty("OnClick"); EditorGUILayout.PropertyField(onClick, new GUIContent("OnClick")); SerializedProperty events = serializedObject.FindProperty("Events"); GUI.enabled = !isPlayMode; for (int i = 0; i < events.arraySize; i++) { SerializedProperty eventItem = events.GetArrayElementAtIndex(i); InteractableReceiverListInspector.RenderEventSettings(eventItem, i, eventOptions, ChangeEvent, RemoveEvent); } GUI.enabled = true; if (eventOptions.ClassNames.Length > 1) { if (GUILayout.Button(new GUIContent("Add Event"))) { AddEvent(events.arraySize); } } } #endregion serializedObject.ApplyModifiedProperties(); }
/// <summary> /// Un-highlights or returns the features from the specified region. The specified selectionMode /// will be used to determine how to choose features. /// </summary> /// <param name="tolerant">The geographic envelope in cases like cliking near points where tolerance is allowed</param> /// <param name="strict">The geographic region when working with absolutes, without a tolerance</param> /// <param name="affectedArea">The geographic envelope that will be visibly impacted by the change</param> /// <param name="selectionMode">The selection mode that controls how to choose members relative to the region </param> /// <returns>Boolean, true if members were removed from the selection.</returns> public override bool UnSelect(IEnvelope tolerant, IEnvelope strict, SelectionModes selectionMode, out IEnvelope affectedArea) { if (!_drawnStatesNeeded && !_editMode) AssignFastDrawnStates(); IEnvelope region = tolerant; if (DataSet.FeatureType == FeatureTypes.Polygon) region = strict; affectedArea = new Envelope(); bool changed = false; if (IsWithinLegendSelection() || _scheme.IsWithinLegendSelection()) { if (_editMode) { _selection.SelectionMode = selectionMode; changed = _selection.RemoveRegion(region, out affectedArea); } else { _selection.SelectionMode = selectionMode; changed = _selection.RemoveRegion(region, out affectedArea); } } else { SuspendChangeEvent(); _selection.SuspendChanges(); List<IFeatureCategory> categories = _scheme.GetCategories().ToList(); foreach (IFeatureCategory category in categories) { if (!category.IsSelected) continue; _selection.RegionCategory = category; _selection.RemoveRegion(region, out affectedArea); _selection.RegionCategory = null; } _selection.ResumeChanges(); ResumeChangeEvent(); } return changed; }