private bool HandleCollision(HashSet <Person> collision) { TextField textField = new TextField(); foreach (Person person in collision) { foreach (Person victim in collision) { if (person.Equals(victim)) { continue; } var result = person.TakeItem(victim); switch (result.collisionEvent) { case CollisionEvent.Robbery: field.Robberies++; textField.Add(result.msg, ConsoleColor.Red); break; case CollisionEvent.Arrest: field.PutInPrison(victim, robberySentence); field.Arrests++; textField.Add(result.msg, ConsoleColor.Blue); break; case CollisionEvent.FailedRobbery: textField.Add(result.msg, ConsoleColor.White); break; } } } if (textField.Count > 0) { renderer.RenderTextField(textField, false); return(true); } return(false); }
private static void AddTextField(string name, TFieldType type) { TextField.Add(new TextFieldModel() { Label = name + ":", Hint = name + "...", Type = type, AutoCompleteIcon = AUTOCOMPLETE_ICON, DeleteTextFieldIcon = DELETE_ICON, }); }
private void InputCustomName(string name) { TextField.Add(new TextFieldModel() { Label = name + ":", Hint = name + "...", AutoCompleteIcon = AUTOCOMPLETE_ICON, DeleteTextFieldIcon = DELETE_ICON, }); _windowInputName.Close(); }
public TextFieldPlaceholder(TextField textField, string placeholderText = null) { if (textField == null) { throw new ArgumentNullException("textField"); } AddToClassList("placeholder"); text = placeholderText ?? string.Empty; textField.Add(this); pickingMode = PickingMode.Ignore; UIUtils.SetElementDisplay(this, string.IsNullOrEmpty(textField.value)); textField.RegisterCallback <ChangeEvent <string> >(OnTextFieldChange); m_ParentTextField = textField; }
public MaskedInputField() { if (monoFont == null) { monoFont = AssetFileExtensions.GetFont("SourceCodePro-Medium"); } if (monoFont == null) { Debug.Log($"Font not found"); } AddToClassList(UssClassName); editorType = GetType(); styleSheets.Add(StylesheetSetup()); style.unityFont = monoFont; var textInputBase = this.Q("unity-text-input"); VisualElementExtension.NameAsUSS(textInputBase, nameof(textInputBase)); textInputBase.style.display = DisplayStyle.Flex; textInputBase.style.color = new StyleColor(StyleKeyword.Initial); VisualElementExtension.SetBorderWidth(textInputBase, 2); maskedText = new TextField { style = { display = DisplayStyle.Flex, position = Position.Absolute, unityFont = monoFont }, value = "", pickingMode = PickingMode.Ignore, }; maskedInput = maskedText.Q("unity-text-input"); maskedInput.pickingMode = PickingMode.Ignore; VisualElementExtension.NameAsUSS(maskedInput, nameof(maskedInput)); VisualElementExtension.NameAsUSS(maskedText, nameof(maskedText)); maskedText.AddToClassList(UssClassName); Add(maskedText); this.RegisterCallback <MouseUpEvent>(evt => { VisualElementExtension.SelectRangeDelayed(this, maskedText.text.Length, maskedText.text.Length); evt.StopPropagation(); }); // Add and configure placeholder m_PlaceholderLabel = new Label { pickingMode = PickingMode.Ignore }; m_PlaceholderLabel.AddToClassList(PlaceholderUssClassName); maskedText.Add(m_PlaceholderLabel); RegisterCallback <FocusInEvent>(e => HidePlaceholder()); RegisterCallback <FocusOutEvent>(e => { if (string.IsNullOrEmpty(text)) { ShowPlaceholder(); } }); this.RegisterCallback <GeometryChangedEvent>(DeferredExecution); this.RegisterValueChangedCallback(e => OnValueChangedHandler?.Invoke(e.newValue)); }