Ejemplo n.º 1
0
    /// <summary>
    ///   Sets up the inputs and adds them as children.
    /// </summary>
    public override void _Ready()
    {
        if (string.IsNullOrEmpty(InputName))
        {
            throw new InvalidOperationException($"{nameof(InputName)} can't be empty");
        }

        if (DisplayName == null)
        {
            throw new InvalidOperationException($"{nameof(DisplayName)} can't be null");
        }

        if (Inputs == null)
        {
            throw new InvalidOperationException($"{nameof(Inputs)} can't be null");
        }

        inputActionHeader    = GetNode <Label>(InputActionHeaderPath);
        inputEventsContainer = GetNode <HBoxContainer>(InputEventsContainerPath);
        addInputEvent        = GetNode <Button>(AddInputEventPath);

        addInputEvent.RegisterToolTipForControl("addInputButton", "options");

        inputActionHeader.Text = DisplayName;

        foreach (var input in Inputs)
        {
            input.AssociatedAction = new WeakReference <InputActionItem>(this);
            inputEventsContainer.AddChild(input);
        }

        inputEventsContainer.MoveChild(addInputEvent, Inputs.Count);

        Inputs.CollectionChanged += OnInputsChanged;
    }
Ejemplo n.º 2
0
    private void OnInputsChanged(object sender, NotifyCollectionChangedEventArgs e)
    {
        switch (e.Action)
        {
        case NotifyCollectionChangedAction.Add:
            foreach (InputEventItem newItem in e.NewItems)
            {
                inputEventsContainer.AddChild(newItem);
            }

            inputEventsContainer.MoveChild(addInputEvent, Inputs.Count);

            break;

        case NotifyCollectionChangedAction.Remove:
            foreach (InputEventItem oldItem in e.OldItems)
            {
                inputEventsContainer.RemoveChild(oldItem);
            }

            break;

        default:
            throw new NotSupportedException($"{e.Action} is not supported on {nameof(Inputs)}");
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    ///   Sets up the inputs and adds them as children.
    /// </summary>
    public override void _Ready()
    {
        inputActionHeader    = GetNode <Label>(InputActionHeaderPath);
        inputEventsContainer = GetNode <HBoxContainer>(InputEventsContainerPath);
        addInputEvent        = GetNode <Button>(AddInputEventPath);

        inputActionHeader.Text = DisplayName;

        foreach (var input in Inputs)
        {
            input.AssociatedAction = new WeakReference <InputActionItem>(this);
            inputEventsContainer.AddChild(input);
        }

        inputEventsContainer.MoveChild(addInputEvent, Inputs.Count);

        Inputs.CollectionChanged += OnInputsChanged;
    }
Ejemplo n.º 4
0
    /// <summary>
    ///   Sets up the inputs and adds them as children.
    /// </summary>
    public override void _Ready()
    {
        inputActionHeader    = GetNode <Label>(InputActionHeaderPath);
        inputEventsContainer = GetNode <HBoxContainer>(InputEventsContainerPath);
        addInputEvent        = GetNode <Button>(AddInputEventPath);

        ToolTipHelper.RegisterToolTipForControl(
            addInputEvent, tooltipCallbacks, ToolTipManager.Instance.GetToolTip("addInputButton", "options"));

        inputActionHeader.Text = DisplayName;

        foreach (var input in Inputs)
        {
            input.AssociatedAction = new WeakReference <InputActionItem>(this);
            inputEventsContainer.AddChild(input);
        }

        inputEventsContainer.MoveChild(addInputEvent, Inputs.Count);

        Inputs.CollectionChanged += OnInputsChanged;
    }