private static void PopulateProperties(FieldUI ui, Field field) { ui.Description = field.Description; ui.Name = field.Name; ui.Type = field.Readonly ? EditorType.Readonly : field.DataType; ui.IsVisible = field.IsVisible; }
internal static FieldUI ToUI(this Field field) { var ui = new FieldUI(); PopulateBaseProperties(ui, field); return(ui); }
private static void PopulateProperties(FieldUI ui, Field field) { ui.Description = field.Description; ui.Name = field.Name; ui.Type = field.DataType; ui.IsVisible = field.IsVisible; ui.IsDisabled = field.IsDisabled; }
private static void PopulateBaseProperties(FieldUI ui, Field field) { ui.Description = field.Description; ui.Name = field.Name; ui.IsVisible = field.IsVisible; ui.IsDisabled = field.IsDisabled; ui.OrderByExpression = field.OrderByExpression; ui.SortDescending = field.DefaultOrder; }
private void Start() { fieldGUI = transform.GetComponent <FieldGUI>(); fieldUI = transform.GetComponent <FieldUI>(); fieldContainer = transform.GetComponent <FieldContainer>(); fieldContainerUI = transform.GetComponent <FieldContainerUI>(); settingsGUI = transform.GetComponent <SettingsGUI>(); panel = transform.GetComponent <Panel>(); isingAlgorithm = transform.GetComponent <IsingAlgorithm>(); }
Color[] colors = new Color[2]; // field fill [0] and border [1] colors void Start() { // // // // // // // Private components assignment // // // // // // // manager = transform.parent.GetComponent <FieldManager>(); fill = transform.Find("Fill").GetComponent <SpriteRenderer>(); fillCopy = transform.Find("Fill copy").GetComponent <SpriteRenderer>(); border = transform.Find("Border").GetComponent <SpriteRenderer>(); // // // // // // // Properties assignment // // // // // // // ctStrength = strength; startPos = transform.position; // // // // // // // Field color assignment according its ownership // // // // // // // SetColors(ownership); fill.color = fillCopy.color = colors[0]; border.color = colors[1]; // // // // // // // Field UI creation // // // // // // // Color c = colors[0]; c.a = 0; Vector3 pos = Camera.main.WorldToScreenPoint(transform.position); fieldUI = Instantiate(manager.strengthTextPrefab, manager.fieldUI).GetComponent <FieldUI>(); fieldUI.fieldTransform = transform; fieldUI.rt.position = pos; fieldUI.defenseBackground.color = c; fieldUI.unitText.text = strength.ToString(); fieldUI.defenseText.text = defense.ToString(); // // // // // // // Repeatedly random move // // // // // // // RandomMove(); }
public static RenderFragment?ToRenderFragment(this FieldUI field, EditContext editContext) { if (field is ExpressionFieldUI expressionField) { return(builder => { builder.AddContent(0, expressionField.Expression.StringGetter(editContext.Entity)); }); } else if (field is CustomPropertyFieldUI customField) { return(builder => { var editorType = customField.CustomType; builder.OpenComponent(0, editorType); builder.AddAttribute(1, nameof(BaseEditor.Entity), editContext.Entity); builder.AddAttribute(2, nameof(BaseEditor.EntityState), editContext.EntityState); builder.AddAttribute(3, nameof(BaseEditor.Property), customField.Property); builder.AddAttribute(4, nameof(BaseEditor.IsDisabledFunc), customField.IsDisabled); if (editorType.IsSubclassOf(typeof(BaseDataEditor))) { builder.AddAttribute(5, nameof(BaseDataEditor.DataCollection), customField.DataCollection); } builder.CloseComponent(); }); } else { var editorType = field.Type switch { EditorType.Readonly => typeof(ReadonlyEditor), EditorType.Numeric => typeof(NumericEditor), EditorType.Checkbox => typeof(CheckboxEditor), EditorType.Date => typeof(DateEditor), EditorType.TextArea => typeof(TextAreaEditor), EditorType.TextBox => typeof(TextBoxEditor), EditorType.Select => typeof(SelectEditor), EditorType.MultiSelect => typeof(MultiSelectEditor), EditorType.Dropdown => typeof(DropdownEditor), _ => null }; if (editorType == null) { return(null); } return(builder => { builder.OpenComponent(0, editorType); builder.AddAttribute(1, nameof(BaseEditor.Entity), editContext.Entity); builder.AddAttribute(2, nameof(BaseEditor.EntityState), editContext.EntityState); if (field is PropertyFieldUI propertyField) { builder.AddAttribute(3, nameof(BaseEditor.Property), propertyField.Property); builder.AddAttribute(4, nameof(BaseEditor.IsDisabledFunc), propertyField.IsDisabled); if (editorType.IsSubclassOf(typeof(BaseDataEditor))) { builder.AddAttribute(5, nameof(BaseDataEditor.DataCollection), propertyField.DataCollection); } if (editorType.IsSubclassOf(typeof(BaseRelationEditor))) { builder.AddAttribute(6, nameof(BaseRelationEditor.DataCollection), propertyField.DataCollection); } } builder.CloseComponent(); }); } } }
public static RenderFragment?ToRenderFragment(this FieldUI field, FormEditContext editContext, ListType usedInDisplayType) { if (field is CustomExpressionFieldUI customExpressionField) { return(builder => { var editorType = customExpressionField.CustomType; builder.OpenComponent(0, editorType); builder.AddAttributes(editContext, customExpressionField, usedInDisplayType); builder.CloseComponent(); }); } else if (field is ExpressionFieldUI expressionField) { var displayType = expressionField.Type switch { DisplayType.Label => typeof(LabelDisplay), DisplayType.Pre => typeof(PreDisplay), _ => null }; if (displayType == null) { return(null); } return(builder => { builder.OpenComponent(0, displayType); builder.AddAttributes(editContext, expressionField, usedInDisplayType); builder.CloseComponent(); }); } else if (field is CustomPropertyFieldUI customPropertyField) { return(builder => { var editorType = customPropertyField.CustomType; builder.OpenComponent(0, editorType); builder.AddAttributes(editContext, customPropertyField, usedInDisplayType); if (editorType.IsSubclassOf(typeof(BaseDataEditor))) { builder.AddAttribute(7, nameof(BaseDataEditor.DataCollection), customPropertyField.DataCollection); } builder.CloseComponent(); }); } else if (field is PropertyFieldUI propertyField) { var editorType = propertyField.Type switch { EditorType.Readonly => typeof(ReadonlyEditor), EditorType.Numeric => typeof(NumericEditor), EditorType.Checkbox => typeof(CheckboxEditor), EditorType.Date => typeof(DateEditor), EditorType.TextArea => typeof(TextAreaEditor), EditorType.TextBox => typeof(TextBoxEditor), EditorType.Select => typeof(SelectEditor), EditorType.MultiSelect => typeof(MultiSelectEditor), EditorType.Dropdown => typeof(DropdownEditor), _ => null }; if (editorType == null) { return(null); } return(builder => { builder.OpenComponent(0, editorType); builder.AddAttributes(editContext, propertyField, usedInDisplayType); if (editorType.IsSubclassOf(typeof(BaseDataEditor))) { builder.AddAttribute(7, nameof(BaseDataEditor.DataCollection), propertyField.DataCollection); } if (editorType.IsSubclassOf(typeof(BaseRelationEditor))) { builder.AddAttribute(8, nameof(BaseRelationEditor.DataCollection), propertyField.DataCollection); } builder.CloseComponent(); }); } else { throw new InvalidOperationException(); } }
public static RenderFragment?ToRenderFragment(this FieldUI field, FormEditContext editContext, ListType usedInDisplayType) { if (field is CustomExpressionFieldUI customExpressionField) { return(builder => { var editorType = customExpressionField.CustomType; builder.OpenComponent(0, editorType); builder.AddAttributes(editContext, customExpressionField, usedInDisplayType); builder.CloseComponent(); }); } else if (field is ExpressionFieldUI expressionField) { var displayType = expressionField.Type switch { DisplayType.Label => typeof(LabelDisplay), DisplayType.Pre => typeof(PreDisplay), _ => null }; if (displayType == null) { return(null); } return(builder => { builder.OpenComponent(0, displayType); builder.AddAttributes(editContext, expressionField, usedInDisplayType); builder.CloseComponent(); }); } else if (field is CustomPropertyFieldUI customPropertyField) { return(builder => { var editorType = customPropertyField.CustomType; builder.OpenComponent(0, editorType); builder.AddAttributes(editContext, customPropertyField, usedInDisplayType); if (editorType.IsSubclassOf(typeof(BaseDataEditor))) { builder.AddAttribute(9, nameof(BaseDataEditor.DataCollection), customPropertyField.DataCollection); } builder.CloseComponent(); }); } else if (field is PropertyFieldUI propertyField) { var editorType = propertyField.Type.GetEditor(); if (editorType == null) { return(null); } return(builder => { builder.OpenComponent(0, editorType); builder.AddAttributes(editContext, propertyField, usedInDisplayType); if (editorType.IsSubclassOf(typeof(BaseDataEditor))) { builder.AddAttribute(9, nameof(BaseDataEditor.DataCollection), propertyField.DataCollection); } if (editorType.IsSubclassOf(typeof(BaseRelationEditor))) { builder.AddAttribute(10, nameof(BaseRelationEditor.DataCollection), propertyField.DataCollection); } builder.CloseComponent(); }); } else { throw new InvalidOperationException(); } }
public void CloseFieldUI() { FieldUI.DOAnchorPos(new Vector2(0, -1400), 0.4f); }
public void OpenFieldUI() { FieldUI.DOAnchorPos(new Vector2(0, 0), 0.4f); }