public void Register(EInputType inputType, EVirtualKeyType keyType, Action <InputInfo> callback) { switch (inputType) { case EInputType.Action: if (actionInputEventDic.ContainsKey(keyType)) { actionInputEventDic[keyType] += callback; } else { actionInputEventDic.Add(keyType, callback); } break; case EInputType.State: if (stateInputEventDic.ContainsKey(keyType)) { stateInputEventDic[keyType] += callback; } else { stateInputEventDic.Add(keyType, callback); } break; } }
public string GetBindingNameOfInputType(EInputType inputType) { switch (inputType) { case EInputType.Cancel: return(GetNameOfBinding(_controls.Player.Cancel.bindings)); case EInputType.Confirm: return(GetNameOfBinding(_controls.Player.Confirm.bindings)); case EInputType.Inventory: return(GetNameOfBinding(_controls.Player.Inventory.bindings)); case EInputType.Movement: return(GetNameOfBindingForComposedInput(_controls.Player.Movement.bindings)); case EInputType.Next: return(GetNameOfBinding(_controls.Player.Next.bindings)); case EInputType.Previous: return(GetNameOfBinding(_controls.Player.Previous.bindings)); case EInputType.Use: return(GetNameOfBinding(_controls.Player.Use.bindings)); default: Management.Log.Instance.WriteException(new ArgumentException()); return(string.Empty); } }
public void BroadcastInputEvent(EInputType newInput) { if (OnInputEvent != null) { OnInputEvent(newInput); } }
public PageFactory WithInput(string id, string name, string value, EInputType type = EInputType.Text) { var iv = new InputView(id, name, value, type); Page.AddView(iv); return(this); }
public static bool IsWithStyleItems(EInputType type) { if (type == EInputType.CheckBox || type == EInputType.Radio || type == EInputType.SelectMultiple || type == EInputType.SelectOne || type == EInputType.RelatedField) { return(true); } return(false); }
public static bool IsPureString(EInputType type) { if (type == EInputType.Date || type == EInputType.DateTime || type == EInputType.CheckBox || type == EInputType.Radio || type == EInputType.SelectMultiple || type == EInputType.SelectOne || type == EInputType.Image || type == EInputType.Video || type == EInputType.File || type == EInputType.RelatedField) { return(false); } return(true); }
public static ListItem GetListItem(EInputType type, bool selected) { var item = new ListItem(GetText(type), GetValue(type)); if (selected) { item.Selected = true; } return(item); }
/// <inheritdoc cref="AbstractView"/> /// <summary> /// Create a new instance of an InputView with an ID, a Name, a Value, and the specified style. /// </summary> /// <param name="id">The unique ID for the View</param> /// <param name="name">The name of the View</param> /// <param name="value">The value inputted into the field</param> /// <param name="type">The style of the input. DEFAULT: <see cref="EInputType.Text"/></param> /// <exception cref="InvalidValueForTypeException">Thrown when the value is invalid for the input type</exception> public InputView(string id, string name, string value, EInputType type = EInputType.Text) : base(id, name) { Type = EViewType.Input; InputType = type; if (!IsValueValidForType(value)) { throw new InvalidValueForTypeException("The new value is invalid for the input type"); } Value = value; }
public InputView(string id, string name, EInputType type = EInputType.Text) : base(id, name) { if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException(nameof(name)); } Type = EViewType.Input; InputType = type; }
public void GetHashCode_ReturnsNamePlusType() { var comparer = new RawInputEqualityComparer(); const string inputName = "TestName"; const EInputType inputType = EInputType.Analog; var firstInput = new RawInput(inputName, inputType); Assert.AreEqual(inputName.GetHashCode() + inputType.GetHashCode(), comparer.GetHashCode(firstInput)); }
public static string ParseString(EInputType inputType, string content, string replace, string to, int startIndex, int length, int wordNum, string ellipsis, bool isClearTags, bool isReturnToBr, bool isLower, bool isUpper, string formatString) { if (EInputTypeUtils.IsPureString(inputType)) { return(ParseString(content, replace, to, startIndex, length, wordNum, ellipsis, isClearTags, isReturnToBr, isLower, isUpper, formatString)); } else { return(content); } }
public void DifferentObject_MatchingTypeAndName_True() { var comparer = new RawInputEqualityComparer(); const string inputName = "TestName"; const EInputType inputType = EInputType.Analog; var firstInput = new RawInput(inputName, inputType); var secondInput = new RawInput(inputName, inputType); Assert.IsTrue(comparer.Equals(firstInput, secondInput)); }
public static bool Equals(EInputType type, string typeStr) { if (string.IsNullOrEmpty(typeStr)) { return(false); } if (string.Equals(GetValue(type).ToLower(), typeStr.ToLower())) { return(true); } return(false); }
private void StartListening(EInputType _inputType, EInputTarget _inputTarget) { inputType = _inputType; inputTarget = _inputTarget; lastConfirmedMidiKey = 0; lastUsedKnobValue = 0; lastUsedKnob = 0; processedMessages = MidiDriver.Instance.TotalMessageCount; InEditorUpdateMode = true; EditorApplication.update += EditorUpdate; }
public void DifferentObject_MatchingNameButDifferentType_False() { var comparer = new RawInputEqualityComparer(); const string inputName = "TestName"; const EInputType inputType = EInputType.Analog; const EInputType otherType = EInputType.Button; var firstInput = new RawInput(inputName, inputType); var secondInput = new RawInput(inputName, otherType); Assert.IsFalse(comparer.Equals(firstInput, secondInput)); }
public static bool IsGamePadConnected(EInputType aType) { if (aType >= EInputType.Length) { return(false); } if (aType == EInputType.Keyboard) { return(true); } return(myControllerStates[(int)aType].myCurrentState.IsConnected); }
public static PlayerInput GetInput(EInputType inputType, Player player) { switch (inputType) { case EInputType.GAMECONTROLLER: return(new PlayerGameControllerInput(player)); case EInputType.NETWORK: return(new PlayerNetworkInput(player)); default: return(new PlayerGameControllerInput(player)); } }
public void EnableInputType(EInputType type, bool e) { InputModule module = inputModules[type]; module.Enable(e); if (e) { activeModules.Add(module); } else { activeModules.Remove(module); } }
protected virtual string GetFormatString(EInputType inputType) { string formatString; if (inputType == EInputType.TextEditor) { formatString = FormatTextEditor; } else if (inputType == EInputType.Image) { formatString = FormatImage; } else { formatString = FormatDefault; } return(formatString); }
public PlayerInfo(int aPlayerIndex, EInputType aInputType, string aPlayerName = null) { myPlayerIndex = aPlayerIndex; myInputType = aInputType; myMappedActions = new ActionMapper(); if (aPlayerName == null) { GenerateName(); GenerateDefaultActions(); } else { myName = aPlayerName; GenerateDefaultActions(); // json read mapped actions, if new player, generate default anyways } }
public void GiveInput(EInputType newInput) { switch (newInput) { case EInputType.MOVEUP_KEYDOWN: movingUp = true; break; case EInputType.MOVEDOWN_KEYDOWN: movingDown = true; break; case EInputType.MOVERIGHT_KEYDOWN: movingRight = true; break; case EInputType.MOVELEFT_KEYDOWN: movingLeft = true; break; case EInputType.MOVEUP_KEYUP: movingUp = false; break; case EInputType.MOVEDOWN_KEYUP: movingDown = false; break; case EInputType.MOVERIGHT_KEYUP: movingRight = false; break; case EInputType.MOVELEFT_KEYUP: movingLeft = false; break; default: break; } }
//public void AutoAttack() //{ // GameObject enemyClosest = FindClosestEnemy(GameObject.FindGameObjectsWithTag("enemy")); // if (enemyClosest != null) // { // IHavePlayerStats playerStats = GetComponent<IHavePlayerStats>(); // IHaveEnemyStats enemyStats = enemyClosest.GetComponent<IHaveEnemyStats>(); // if (playerStats != null && enemyStats != null) // { // if (isAutoAttack) // { // DamageCalculation dc = new DamageCalculation(); // autoAttackCounter += Time.deltaTime; // if (autoAttackCounter > dc.AttackSpeedCalculation(AttackSpeed)) // { // GetComponent<Player>().LaunchAttack(playerStats, enemyStats, "player_attack"); // autoAttackCounter = 0; // } // } // } // } //} //private GameObject FindClosestEnemy(GameObject[] _enemyObjects) //{ // if (_enemyObjects != null) // { // GameObject finalClosestEnemy = null; // float distance = Mathf.Infinity; // Vector3 position = transform.position; // foreach (GameObject obj in _enemyObjects) // { // Vector3 diff = obj.transform.position - position; // float curDistance = diff.sqrMagnitude; // if (curDistance < distance) // { // finalClosestEnemy = obj; // distance = curDistance; // } // } // if (Vector2.Distance(transform.position, finalClosestEnemy.transform.position) < trackEnemyLenght) // { // return finalClosestEnemy; // } // else // { // return null; // } // } // else // { // return null; // } //} #endregion void OnInputController(EInputType type, KeyCode code) { Debug.Log(type + " " + code); switch (type) { case EInputType.GETKEY_DOWN: KeyDownAction(code); break; case EInputType.GETKEY_HOLD: KeyHoldAction(code); break; case EInputType.GETKEY_UP: KeyUpAction(code); break; case EInputType.MOUSE_DOWN: MouseDownAction(); break; } }
public InputContext(InputContextConfig config) { _currentFrameInputList = new List <InputInfo>(); keycodeSetToCheck = new HashSet <KeyCode>(); _actionInputMappingDic = new Dictionary <KeyCode, InputMapRule>(); _stateInputMappingDic = new Dictionary <KeyCode, InputMapRule>(); _rangeInputMappingDic = new Dictionary <KeyCode, InputMapRule>(); for (int i = 0; i < config.inputMapRuleList.Count; i++) { EInputType inputType = config.inputMapRuleList[i].inputType; KeyCode keyCode = config.inputMapRuleList[i].realKeyCode; switch (inputType) { case EInputType.Action: if (_actionInputMappingDic.ContainsKey(keyCode) == false) { _actionInputMappingDic.Add(keyCode, config.inputMapRuleList[i]); } break; case EInputType.State: if (_stateInputMappingDic.ContainsKey(keyCode) == false) { _stateInputMappingDic.Add(keyCode, config.inputMapRuleList[i]); } break; case EInputType.Range: if (_rangeInputMappingDic.ContainsKey(keyCode) == false) { _rangeInputMappingDic.Add(keyCode, config.inputMapRuleList[i]); } break; } keycodeSetToCheck.Add(keyCode); } }
private void OnInputEvent(EInputType newInput) { if (newInput == EInputType.POSSESS_KEYDOWN) { PossessClosestPossessable(); } else if (primaryPossession != null) { primaryPossession.GiveInput(newInput); } //if (currentSecondaryPossessions.Count > 0) //{ // for (int i = 0; i < currentSecondaryPossessions.Count; i++) // { // currentSecondaryPossessions[i].GiveInput(newInput); // } //} //TODO: Handle player only inputs //(the ones not specific to bot, like opening menu etc.) }
public GameObject InstantiatePlayer(int id, EInputType inputType) { if (PlayerList == null) { PlayerList = new List <Player>(); } GameObject PlayerGameObject = Instantiate(PlayerPrefab, spawnZone.transform.position, Quaternion.identity) as GameObject; PlayerGameObject.transform.SetRandomSpherePosition(EDomeLayer.LAYER0_CLOSE); Player newPlayer = PlayerGameObject.GetComponent <Player>(); newPlayer.Init(id, "Player " + PlayerCount.ToString()); PlayerInput pInput = PlayerInputFactory.GetInput(inputType, newPlayer); newPlayer.SetPlayerInput(pInput); PlayerList.Add(newPlayer); OnInstantiatePlayer.Invoke(newPlayer); return(PlayerGameObject); }
public static string GetAdditionalAttributes(string whereUsed, EInputType inputType) { var additionalAttributes = string.Empty; if (string.IsNullOrEmpty(whereUsed)) { //if (inputType == EInputType.Text || inputType == EInputType.Image || inputType == EInputType.File) //{ // additionalAttributes = @"class=""colorblur"" onfocus=""this.className='colorfocus';"" onblur=""this.className='colorblur';"" size=""60"""; //} //else if (inputType == EInputType.TextArea) //{ // additionalAttributes = @"class=""colorblur"" onfocus=""this.className='colorfocus';"" onblur=""this.className='colorblur';"" cols=""60"" rows=""5"""; //} //else if (inputType == EInputType.Date || inputType == EInputType.DateTime) //{ // additionalAttributes = @"class=""colorblur Wdate"" size=""25"""; //} } else if (whereUsed == "usercenter") { if (inputType == EInputType.Text || inputType == EInputType.Image || inputType == EInputType.Video || inputType == EInputType.File) { additionalAttributes = @"class=""input-txt"" style=""width:320px"""; } else if (inputType == EInputType.TextArea) { additionalAttributes = @"class=""input-area area-s5"" cols=""60"" rows=""5"""; } else if (inputType == EInputType.Date || inputType == EInputType.DateTime) { additionalAttributes = @"class=""input-txt Wdate"" style=""width:120px"""; } } return(additionalAttributes); }
//-------------------------------------------------------------------------------------- bool checkInputType(EKeyList inpuKey, EInputType inputType, float deltaTime) { int pressed = KeyStates[(int)inpuKey].Pressed; float pressedTime = KeyStates[(int)inpuKey].PressedTime; float releasedTime = KeyStates[(int)inpuKey].ReleasedTime; bool ret = false; switch (inputType) { case EInputType.EIT_Click: ret = (pressedTime == 0); break; case EInputType.EIT_DoubleClick: ret = (pressed == 2 && pressedTime == 0); break; case EInputType.EIT_Press: ret = (pressed != 0 && (pressedTime < LongPressedTime && pressedTime + deltaTime >= LongPressedTime)); break; case EInputType.EIT_Release: ret = (pressed == 0 && releasedTime == 0); break; case EInputType.EIT_Pressing: ret = (pressed != 0); break; case EInputType.EIT_Releasing: ret = (pressed == 0); break; } return(ret); }
public TextBox(EInputType inputType = DEFAULT_INPUT_TYPE) : base() { InputType = inputType; Background = new PictureBox(Create.Texture("TextBoxBg")); Label = new Label(null, BlazeraLib.Label.ESize.VSmall); AddWidget(Label); BackHappened = false; IsActive = false; Dimension *= DEFAULT_BACKGROUND_SCALE_FACTOR; Label.Changed += new ChangeEventHandler(Label_Changed); }
private bool InsertTableStyleInfo(EInputType inputType) { var isChanged = false; var attributeNameArray = AttributeNames.Text.Split('\n'); var relatedIdentity = (int)_relatedIdentities[0]; var styleInfoArrayList = new ArrayList(); foreach (var itemString in attributeNameArray) { if (!string.IsNullOrEmpty(itemString)) { var attributeName = itemString; var displayName = string.Empty; if (StringUtils.Contains(itemString, "(") && StringUtils.Contains(itemString, ")")) { var length = itemString.IndexOf(')') - itemString.IndexOf('('); if (length > 0) { displayName = itemString.Substring(itemString.IndexOf('(') + 1, length); attributeName = itemString.Substring(0, itemString.IndexOf('(')); } } attributeName = attributeName.Trim(); displayName = displayName.Trim(' ', '(', ')'); if (string.IsNullOrEmpty(displayName)) { displayName = attributeName; } if (TableStyleManager.IsExists(relatedIdentity, _tableName, attributeName) || TableStyleManager.IsExistsInParents(_relatedIdentities, _tableName, attributeName)) { FailMessage($@"显示样式添加失败:字段名""{attributeName}""已存在"); return(false); } var styleInfo = new TableStyleInfo(0, relatedIdentity, _tableName, attributeName, 0, displayName, string.Empty, TranslateUtils.ToBool(IsVisible.SelectedValue), false, TranslateUtils.ToBool(IsSingleLine.SelectedValue), EInputTypeUtils.GetValue(inputType), DefaultValue.Text, TranslateUtils.ToBool(IsHorizontal.SelectedValue), string.Empty); styleInfo.Additional.Columns = TranslateUtils.ToInt(Columns.Text); styleInfo.Additional.Height = TranslateUtils.ToInt(Height.Text); styleInfo.Additional.Width = Width.Text; if (inputType == EInputType.CheckBox || inputType == EInputType.Radio || inputType == EInputType.SelectMultiple || inputType == EInputType.SelectOne) { styleInfo.StyleItems = new List <TableStyleItemInfo>(); var isHasSelected = false; foreach (RepeaterItem item in MyRepeater.Items) { var ItemTitle = (TextBox)item.FindControl("ItemTitle"); var ItemValue = (TextBox)item.FindControl("ItemValue"); var IsSelected = (CheckBox)item.FindControl("IsSelected"); if ((inputType != EInputType.SelectMultiple && inputType != EInputType.CheckBox) && isHasSelected && IsSelected.Checked) { FailMessage("操作失败,只能有一个初始化时选定项!"); return(false); } if (IsSelected.Checked) { isHasSelected = true; } var itemInfo = new TableStyleItemInfo(0, 0, ItemTitle.Text, ItemValue.Text, IsSelected.Checked); styleInfo.StyleItems.Add(itemInfo); } } styleInfoArrayList.Add(styleInfo); } } try { var attributeNames = new ArrayList(); foreach (TableStyleInfo styleInfo in styleInfoArrayList) { attributeNames.Add(styleInfo.AttributeName); TableStyleManager.Insert(styleInfo, _tableStyle); } Body.AddSiteLog(PublishmentSystemId, "批量添加表单显示样式", $"类型:{ETableStyleUtils.GetText(_tableStyle)},字段名: {TranslateUtils.ObjectCollectionToString(attributeNames)}"); isChanged = true; } catch (Exception ex) { FailMessage(ex, "显示样式添加失败:" + ex.Message); } return(isChanged); }
private bool InsertTableStyleInfo(EInputType inputType) { var isChanged = false; var relatedIdentity = _relatedIdentities[0]; if (TableStyleManager.IsExists(relatedIdentity, _tableName, TbAttributeName.Text)) //|| TableStyleManager.IsExistsInParents(this.relatedIdentities, this.tableName, this.tbAttributeName.Text) { FailMessage($@"显示样式添加失败:字段名""{TbAttributeName.Text}""已存在"); return(false); } _styleInfo = TableStyleManager.IsMetadata(_tableStyle, TbAttributeName.Text) ? TableStyleManager.GetTableStyleInfo(_tableStyle, _tableName, TbAttributeName.Text, _relatedIdentities) : new TableStyleInfo(); _styleInfo.RelatedIdentity = relatedIdentity; _styleInfo.TableName = _tableName; _styleInfo.AttributeName = TbAttributeName.Text; _styleInfo.DisplayName = PageUtils.FilterXss(TbDisplayName.Text); _styleInfo.HelpText = TbHelpText.Text; _styleInfo.IsVisible = TranslateUtils.ToBool(RblIsVisible.SelectedValue); _styleInfo.IsSingleLine = TranslateUtils.ToBool(RblIsSingleLine.SelectedValue); _styleInfo.InputType = EInputTypeUtils.GetValue(inputType); _styleInfo.DefaultValue = TbDefaultValue.Text; _styleInfo.IsHorizontal = TranslateUtils.ToBool(DdlIsHorizontal.SelectedValue); _styleInfo.Additional.Columns = TranslateUtils.ToInt(TbColumns.Text); _styleInfo.Additional.Height = TranslateUtils.ToInt(TbHeight.Text); _styleInfo.Additional.Width = TbWidth.Text; _styleInfo.Additional.IsFormatString = TranslateUtils.ToBool(RblIsFormatString.SelectedValue); _styleInfo.Additional.RelatedFieldId = TranslateUtils.ToInt(DdlRelatedFieldId.SelectedValue); _styleInfo.Additional.RelatedFieldStyle = DdlRelatedFieldStyle.SelectedValue; if (inputType == EInputType.CheckBox || inputType == EInputType.Radio || inputType == EInputType.SelectMultiple || inputType == EInputType.SelectOne) { _styleInfo.StyleItems = new List <TableStyleItemInfo>(); var isRapid = TranslateUtils.ToBool(DdlItemType.SelectedValue); if (isRapid) { var itemArrayList = TranslateUtils.StringCollectionToStringList(TbItemValues.Text); foreach (string itemValue in itemArrayList) { var itemInfo = new TableStyleItemInfo(0, _styleInfo.TableStyleId, itemValue, itemValue, false); _styleInfo.StyleItems.Add(itemInfo); } } else { var isHasSelected = false; foreach (RepeaterItem item in RptItems.Items) { var itemTitle = (TextBox)item.FindControl("ItemTitle"); var itemValue = (TextBox)item.FindControl("ItemValue"); var isSelected = (CheckBox)item.FindControl("IsSelected"); if (inputType != EInputType.SelectMultiple && inputType != EInputType.CheckBox && isHasSelected && isSelected.Checked) { FailMessage("操作失败,只能有一个初始化时选定项!"); return(false); } if (isSelected.Checked) { isHasSelected = true; } var itemInfo = new TableStyleItemInfo(0, 0, itemTitle.Text, itemValue.Text, isSelected.Checked); _styleInfo.StyleItems.Add(itemInfo); } } } try { TableStyleManager.Insert(_styleInfo, _tableStyle); Body.AddSiteLog(PublishmentSystemId, "添加表单显示样式", $"类型:{ETableStyleUtils.GetText(_tableStyle)},字段名:{_styleInfo.AttributeName}"); isChanged = true; } catch (Exception ex) { FailMessage(ex, "显示样式添加失败:" + ex.Message); } return(isChanged); }
private bool UpdateTableStyleInfo(EInputType inputType) { var isChanged = false; _styleInfo.AttributeName = TbAttributeName.Text; _styleInfo.DisplayName = PageUtils.FilterXss(TbDisplayName.Text); _styleInfo.HelpText = TbHelpText.Text; _styleInfo.IsVisible = TranslateUtils.ToBool(RblIsVisible.SelectedValue); _styleInfo.IsSingleLine = TranslateUtils.ToBool(RblIsSingleLine.SelectedValue); _styleInfo.InputType = EInputTypeUtils.GetValue(inputType); _styleInfo.DefaultValue = TbDefaultValue.Text; _styleInfo.IsHorizontal = TranslateUtils.ToBool(DdlIsHorizontal.SelectedValue); _styleInfo.Additional.Columns = TranslateUtils.ToInt(TbColumns.Text); _styleInfo.Additional.Height = TranslateUtils.ToInt(TbHeight.Text); _styleInfo.Additional.Width = TbWidth.Text; _styleInfo.Additional.IsFormatString = TranslateUtils.ToBool(RblIsFormatString.SelectedValue); _styleInfo.Additional.RelatedFieldId = TranslateUtils.ToInt(DdlRelatedFieldId.SelectedValue); _styleInfo.Additional.RelatedFieldStyle = DdlRelatedFieldStyle.SelectedValue; ArrayList styleItems = null; if (inputType == EInputType.CheckBox || inputType == EInputType.Radio || inputType == EInputType.SelectMultiple || inputType == EInputType.SelectOne) { styleItems = new ArrayList(); var isRapid = TranslateUtils.ToBool(DdlItemType.SelectedValue); if (isRapid) { var itemArrayList = TranslateUtils.StringCollectionToStringList(TbItemValues.Text); foreach (string itemValue in itemArrayList) { var itemInfo = new TableStyleItemInfo(0, _styleInfo.TableStyleId, itemValue, itemValue, false); styleItems.Add(itemInfo); } } else { var isHasSelected = false; foreach (RepeaterItem item in RptItems.Items) { var itemTitle = (TextBox)item.FindControl("ItemTitle"); var itemValue = (TextBox)item.FindControl("ItemValue"); var isSelected = (CheckBox)item.FindControl("IsSelected"); if ((inputType != EInputType.SelectMultiple && inputType != EInputType.CheckBox) && isHasSelected && isSelected.Checked) { FailMessage("操作失败,只能有一个初始化时选定项!"); return(false); } if (isSelected.Checked) { isHasSelected = true; } var itemInfo = new TableStyleItemInfo(0, _styleInfo.TableStyleId, itemTitle.Text, itemValue.Text, isSelected.Checked); styleItems.Add(itemInfo); } } } try { TableStyleManager.Update(_styleInfo); TableStyleManager.DeleteAndInsertStyleItems(_styleInfo.TableStyleId, styleItems); Body.AddSiteLog(PublishmentSystemId, "修改表单显示样式", $"类型:{ETableStyleUtils.GetText(_tableStyle)},字段名:{_styleInfo.AttributeName}"); isChanged = true; } catch (Exception ex) { FailMessage(ex, "显示样式修改失败:" + ex.Message); } return(isChanged); }