Ejemplo n.º 1
0
        public virtual void SetDataToCell(CacheObjectCell cell)
        {
            cell.NameLabel.text = NameLabelText;
            if (cell.HiddenNameLabel != null)
            {
                cell.HiddenNameLabel.Text = NameLabelTextRaw ?? string.Empty;
            }
            cell.ValueLabel.gameObject.SetActive(true);

            cell.SubContentHolder.gameObject.SetActive(SubContentShowWanted);
            if (IValue != null)
            {
                IValue.UIRoot.transform.SetParent(cell.SubContentHolder.transform, false);
                IValue.SetLayout();
            }

            bool evaluated = TryAutoEvaluateIfUnitialized(cell);

            if (cell.CopyButton != null)
            {
                bool hasEvaluated = State != ValueState.NotEvaluated && State != ValueState.Exception;
                cell.CopyButton.Component.gameObject.SetActive(hasEvaluated);
                cell.PasteButton.Component.gameObject.SetActive(hasEvaluated && this.CanWrite);
            }

            if (!evaluated)
            {
                return;
            }

            // The following only executes if the object has evaluated.
            // For members and properties with args, they will return by default now.

            switch (State)
            {
            case ValueState.Exception:
                SetValueState(cell, ValueStateArgs.Default);
                break;

            case ValueState.Boolean:
                SetValueState(cell, new ValueStateArgs(false, toggleActive: true, applyActive: CanWrite));
                break;

            case ValueState.Number:
                SetValueState(cell, new ValueStateArgs(false, typeLabelActive: true, inputActive: true, applyActive: CanWrite));
                break;

            case ValueState.String:
                if (LastValueWasNull)
                {
                    SetValueState(cell, new ValueStateArgs(true, subContentButtonActive: true));
                }
                else
                {
                    SetValueState(cell, new ValueStateArgs(true, false, SignatureHighlighter.StringOrange, subContentButtonActive: true));
                }
                break;

            case ValueState.Enum:
                SetValueState(cell, new ValueStateArgs(true, subContentButtonActive: CanWrite));
                break;

            case ValueState.Color:
            case ValueState.ValueStruct:
                if (ParseUtility.CanParse(LastValueType))
                {
                    SetValueState(cell, new ValueStateArgs(false, false, null, true, false, true, CanWrite, true, true));
                }
                else
                {
                    SetValueState(cell, new ValueStateArgs(true, inspectActive: true, subContentButtonActive: true));
                }
                break;

            case ValueState.Collection:
            case ValueState.Dictionary:
                SetValueState(cell, new ValueStateArgs(true, inspectActive: !LastValueWasNull, subContentButtonActive: !LastValueWasNull));
                break;

            case ValueState.Unsupported:
                SetValueState(cell, new ValueStateArgs(true, inspectActive: !LastValueWasNull));
                break;
            }

            cell.RefreshSubcontentButton();
        }
Ejemplo n.º 2
0
        public virtual void SetDataToCell(CacheObjectCell cell)
        {
            cell.NameLabel.text = NameLabelText;
            cell.ValueLabel.gameObject.SetActive(true);

            cell.SubContentHolder.gameObject.SetActive(SubContentShowWanted);
            if (IValue != null)
            {
                IValue.UIRoot.transform.SetParent(cell.SubContentHolder.transform, false);
                IValue.SetLayout();
            }

            if (SetCellEvaluateState(cell))
            {
                return;
            }

            switch (State)
            {
            case ValueState.Exception:
                SetValueState(cell, ValueStateArgs.Default);
                break;

            case ValueState.Boolean:
                SetValueState(cell, new ValueStateArgs(false, toggleActive: true, applyActive: CanWrite));
                break;

            case ValueState.Number:
                SetValueState(cell, new ValueStateArgs(false, typeLabelActive: true, inputActive: true, applyActive: CanWrite));
                break;

            case ValueState.String:
                if (LastValueWasNull)
                {
                    SetValueState(cell, new ValueStateArgs(true, subContentButtonActive: true));
                }
                else
                {
                    SetValueState(cell, new ValueStateArgs(true, false, SignatureHighlighter.StringOrange, subContentButtonActive: true));
                }
                break;

            case ValueState.Enum:
                SetValueState(cell, new ValueStateArgs(true, subContentButtonActive: CanWrite));
                break;

            case ValueState.Color:
            case ValueState.ValueStruct:
                if (ParseUtility.CanParse(LastValueType))
                {
                    SetValueState(cell, new ValueStateArgs(false, false, null, true, false, true, CanWrite, true, true));
                }
                else
                {
                    SetValueState(cell, new ValueStateArgs(true, inspectActive: true, subContentButtonActive: true));
                }
                break;

            case ValueState.Collection:
            case ValueState.Dictionary:
                SetValueState(cell, new ValueStateArgs(true, inspectActive: !LastValueWasNull, subContentButtonActive: !LastValueWasNull));
                break;

            case ValueState.Unsupported:
                SetValueState(cell, new ValueStateArgs(true, inspectActive: !LastValueWasNull));
                break;
            }

            cell.RefreshSubcontentButton();
        }