public int GetGesturePriorityAtKey(BKI_UIType hand, string key) { int returnVal = 0; switch (hand) { case BKI_UIType.combi: if (combiDictionary.ContainsKey(key)) { returnVal = combiDictionary[key].GetGesturePriority(); } break; case BKI_UIType.left: if (lhDictionary.ContainsKey(key)) { returnVal = lhDictionary[key].GetGesturePriority(); } break; case BKI_UIType.right: if (rhDictionary.ContainsKey(key)) { returnVal = rhDictionary[key].GetGesturePriority(); } break; } return(returnVal); }
// Opens the object selection window when the "Load existing Gesture" is pressed. private void ShowPicker(BKI_UIType uiType) { lastSelected = uiType; pickerWindow = EditorGUIUtility.GetControlID(FocusType.Passive) + 100; string buttonText = ""; if (uiType == BKI_UIType.right) { buttonText = "rhGes_"; } if (uiType == BKI_UIType.left) { buttonText = "lhGes_"; } if (uiType == BKI_UIType.combi) { buttonText = "combiGes_"; EditorGUIUtility.ShowObjectPicker <BKI_CombiGestureClass>(null, false, buttonText, pickerWindow); } else { EditorGUIUtility.ShowObjectPicker <BKI_SingleGestureClass>(null, false, buttonText, pickerWindow); } }
private void DrawButtonsSingle(BKI_Hand hand) { string handString = (hand == BKI_Hand.right) ? "right" : "left"; string handStringShorthand = (hand == BKI_Hand.right) ? "rh" : "lh"; lhGesture = SerializeGesture(BKI_Hand.left, leftHandValues); rhGesture = SerializeGesture(BKI_Hand.right, rightHandValues); float buttonWidth = WINDOW_MAX_SIZE_X * 0.25f - (DEFAULT_AREA_PADDING * 2.5f); int xPos = DEFAULT_AREA_PADDING; BKI_UIType t = (hand == BKI_Hand.right) ? BKI_UIType.right : BKI_UIType.left; GUILayout.BeginArea(buttonStackRect); { GUILayout.BeginArea(new Rect(xPos, 0, WINDOW_MAX_SIZE_X * 0.45f - DEFAULT_AREA_PADDING, TITLE_FIELD_SIZE * 3)); { EditorGUILayout.BeginHorizontal(); DrawSubmitButtonSingle(hand, buttonWidth); EditorGUILayout.EndHorizontal(); } GUILayout.EndArea(); GUILayout.Space(DEFAULT_AREA_PADDING); } GUILayout.EndArea(); }
public override bool IsGestureValid(BKI_UIType t) { if (leftHandGesture == null || rightHandGesture == null) { return(false); } return(leftHandGesture.IsGestureValid(BKI_UIType.left) && rightHandGesture.IsGestureValid(BKI_UIType.right)); }
// Display the "Load existing gesture" button and handles the input event coupled to it. private void DrawOpenGestureButton(BKI_UIType uiType, float width = 0) { int buttonHeight = 40; string buttonText = ""; if (uiType == BKI_UIType.right) { buttonText = "rh"; } if (uiType == BKI_UIType.left) { buttonText = "lh"; } if (uiType == BKI_UIType.combi) { buttonText = "combi"; } if (width > 0) { if (GUILayout.Button("Load existing \n gesture " + buttonText, GUILayout.Height(buttonHeight), GUILayout.Width(width))) { ShowPicker(uiType); } } else { if (GUILayout.Button("Load existing \n gesture " + buttonText, GUILayout.Height(buttonHeight))) { ShowPicker(uiType); } } if (Event.current.commandName == "ObjectSelectorUpdated" && EditorGUIUtility.GetObjectPickerControlID() == pickerWindow) { CatchPickerObject(EditorGUIUtility.GetObjectPickerObject(), lastSelected); pickerWindow = -1; this.Focus(); } }
public override bool IsGestureValid(BKI_UIType t) { if (BKI_FingerCurler.BKI_Curler_Instance == null) { return(false); } FingerValues values; switch (t) { case BKI_UIType.left: values = GetFingerValues(BKI_Hand.left); break; case BKI_UIType.right: values = GetFingerValues(BKI_Hand.right); break; default: return(false); } if (requiresClench && !values.isGripping) { return(false); } if (IsValueInAllowedRange(BKI_Finger.thumb, values.thumb) && IsValueInAllowedRange(BKI_Finger.index, values.index) && IsValueInAllowedRange(BKI_Finger.middle, values.middle) && IsValueInAllowedRange(BKI_Finger.ring, values.ring) && IsValueInAllowedRange(BKI_Finger.pinky, values.pinky)) { return(true); } return(false); }
public bool IsGestureAtKeyValid(BKI_UIType hand, string key) { switch (hand) { case BKI_UIType.combi: if (combiDictionary.ContainsKey(key)) { return(combiDictionary[key].IsGestureValid(hand)); } else { return(false); } case BKI_UIType.left: if (lhDictionary.ContainsKey(key)) { return(lhDictionary[key].IsGestureValid(hand)); } else { return(false); } case BKI_UIType.right: if (rhDictionary.ContainsKey(key)) { return(rhDictionary[key].IsGestureValid(hand)); } else { return(false); } } return(false); }
private void CatchPickerObject(object o, BKI_UIType ls) { if (o == null) { return; } switch (ls) { case BKI_UIType.left: BKI_SingleGestureClass t = o as BKI_SingleGestureClass; if (t == null) { Debug.LogError("Object invalid. Stopping opening."); break; } if (t.hand != BKI_Hand.left) { Debug.LogError("You tried to open a right handed gesture into the left hand editor. Stopping opening."); break; } lhGesture = ScriptableObject.Instantiate(t); leftHandValues = DeserializeGesture(lhGesture); lhMirror = DeserializeGesture(lhGesture); isOpenedFromResourcesLh = true; currentGestureSavedLh = true; pickerWindowGNameLh = t.gestureIdentifier; break; case BKI_UIType.right: BKI_SingleGestureClass u = o as BKI_SingleGestureClass; if (u == null) { Debug.LogError("Object invalid. Stopping opening."); break; } if (u.hand != BKI_Hand.right) { Debug.LogError("You tried to open a left handed gesture into the left hand editor. Stopping opening."); break; } rhGesture = ScriptableObject.Instantiate(u); rightHandValues = DeserializeGesture(rhGesture); rhMirror = DeserializeGesture(rhGesture); isOpenedFromResourcesRh = true; currentGestureSavedRh = true; pickerWindowGNameRh = u.gestureIdentifier; break; case BKI_UIType.combi: BKI_CombiGestureClass ges = o as BKI_CombiGestureClass; if (ges == null) { Debug.LogError("Object invalid. Stopping opening."); break; } if (!ges.name.Contains("combi")) { Debug.LogError("You tried to open a gesture other than a combination gesture. Terminating."); break; } combiGesture = ScriptableObject.Instantiate(ges); CatchPickerObject(combiGesture.leftHandGesture, BKI_UIType.left); CatchPickerObject(combiGesture.rightHandGesture, BKI_UIType.right); pickerWindowGNameCombi = ges.gestureIdentifier; currentGestureSavedCombi = true; isOpenedFromResourcesCombi = true; break; } }
public bool IsGestureValid(BKI_UIType hand, string id) { return(id == null || gestureStorage.IsGestureAtKeyValid(hand, id)); }
// Validation function that compares values from the controllers to the preset values. public virtual bool IsGestureValid(BKI_UIType t) { return(false); }