Beispiel #1
0
        void OnInput(InputEvent e)
        {
            var hits = Resolve <ISelectionManager>()?.CastRayFromScreenSpace(e.Snapshot.MousePosition, true);

            if (hits != null && e.Snapshot.MouseEvents.Any(x => x.MouseButton == MouseButton.Left && x.Down))
            {
                var clickEvent = new UiLeftClickEvent();
                foreach (var hit in hits)
                {
                    if (!clickEvent.Propagating)
                    {
                        break;
                    }
                    var component = hit.Target as IComponent;
                    component?.Receive(clickEvent, this);
                }
            }

            if (e.Snapshot.MouseEvents.Any(x => x.MouseButton == MouseButton.Left && !x.Down))
            {
                Raise(new UiLeftReleaseEvent());
            }

            if (e.Snapshot.MouseEvents.Any(x => x.MouseButton == MouseButton.Right && x.Down))
            {
                Raise(new CloseWindowEvent());
            }
        }
Beispiel #2
0
        void OnInput(InputEvent e)
        {
            IList <(float, Selection)> hits = new List <(float, Selection)>();

            Raise(new ScreenCoordinateSelectEvent(e.Snapshot.MousePosition, (t, selection) => hits.Add((t, selection))));
            var orderedHits = hits.OrderBy(x => x.Item1).Select(x => x.Item2).ToList();

            // Clicks are targeted, releases are broadcast. e.g. if you click and drag a slider and move outside
            // its hover area, then it should switch to "ClickedBlurred". If you then release the button while
            // still outside its hover area and releases were broadcast, it would never receive the release and
            // it wouldn't be able to transition back to Normal
            if (e.Snapshot.MouseEvents.Any(x => x.MouseButton == MouseButton.Left && x.Down))
            {
                var clickEvent = new UiLeftClickEvent();
                foreach (var hit in orderedHits)
                {
                    if (!clickEvent.Propagating)
                    {
                        break;
                    }
                    var component = hit.Target as IComponent;
                    component?.Receive(clickEvent, this);
                }
            }

            if (e.Snapshot.MouseEvents.Any(x => x.MouseButton == MouseButton.Right && x.Down))
            {
                var clickEvent = new UiRightClickEvent();
                foreach (var hit in orderedHits)
                {
                    if (!clickEvent.Propagating)
                    {
                        break;
                    }
                    var component = hit.Target as IComponent;
                    component?.Receive(clickEvent, this);
                }
            }

            if (e.Snapshot.MouseEvents.Any(x => x.MouseButton == MouseButton.Left && !x.Down))
            {
                Raise(new UiLeftReleaseEvent());
            }

            if (e.Snapshot.MouseEvents.Any(x => x.MouseButton == MouseButton.Right && !x.Down))
            {
                Raise(new UiRightReleaseEvent());
            }
        }
Beispiel #3
0
        void OnClick(UiLeftClickEvent e)
        {
            e.Propagating = false;

            if (_isClickTimerPending) // If they double-clicked...
            {
                var memberId = PartyMember?.Id;
                if (memberId.HasValue)
                {
                    Raise(new InventoryOpenEvent(memberId.Value));
                }
                _isClickTimerPending = false; // Ensure the single-click behaviour doesn't happen.
            }
            else // For the first click, just start the double-click timer.
            {
                var config = Resolve <GameConfig>();
                Raise(new StartTimerEvent(TimerName, config.UI.ButtonDoubleClickIntervalSeconds, this));
                _isClickTimerPending = true;
            }
        }