예제 #1
0
        // Start is called before the first frame update
        void Start()
        {
            Assert.IsNotNull(Pointer);
            Assert.IsNotNull(Camera);
            Assert.IsNotNull(Raycaster);
            Assert.IsNotNull(EventSystem);

            HoveredObjects   = new List <GameObject>();
            HoveredUiObjects = new List <GameObject>();

            PrimaryMouseClicked += () => {
                RaycastHit hit;
                Ray        ray = Camera.main.ScreenPointToRay(Pointer.Position);

                if (Physics.Raycast(ray, out hit, 100))
                {
                    var objectHit = hit.transform;

                    ObjectPrimaryClicked?.Invoke(new ObjectPrimaryClicked()
                    {
                        Object = objectHit.gameObject
                    });
                }
                ;
            };
        }
예제 #2
0
        public bool HandlePointerAction(int x, int y, int width, int height, PointerAction action)
        {
            if (!this.Enabled)
            {
                return(false);
            }

            if (action == Rendering.PointerAction.Move)
            {
                return(false);
            }

            x -= width - _pixelMapper.Columns - 50;
            y -= height - _pixelMapper.Rows - 50;

            if (x <= 0 || x >= _pixelMapper.Columns ||
                y <= 0 || y >= _pixelMapper.Rows)
            {
                return(false);
            }

            // we're inside the minimap
            (x, y) = _pixelMapper.CoordsToWorldPixels(x, y);

            x -= _pixelMapper.ViewPortWidth / 2;
            y -= _pixelMapper.ViewPortHeight / 2;

            _pixelMapper.SetViewPort(x, y);

            return(true);
        }
예제 #3
0
 /// <summary>
 /// </summary>
 /// <param name="keyType"></param>
 /// <param name="pointerAction"></param>
 /// <returns></returns>
 public void kirk_4_7_get_key(int keyType, PointerAction pointerAction)
 {
     fixed(byte *key = _kirk_4_7_get_key(keyType))
     {
         pointerAction(key);
     }
 }
예제 #4
0
        private void OnEnable()
        {
            Application.onBeforeRender += BeforeRender;
            if (targetIdentifier)
            {
                targetIdentifier.gameObject.SetActive(true);
            }

            if (segments == null)
            {
                segments = new List <GameObject>();
            }

            if (prevType != shapeType || numSegments != segments.Count)
            {
                ResetSegments();
            }

            getLineAction = GetLineActionType;

            if (action != null)
            {
                action.Disable();
                action = null;
            }
            action      = getLineAction(this);
            prevPointer = pointerType;
        }
예제 #5
0
        public void FixedUpdate()
        {
            if (prevType != shapeType || numSegments != segments.Count)
            {
                ResetSegments();
                prevType = shapeType;
            }

            if (prevPointer != pointerType)
            {
                action.Disable();
                action      = getLineAction(this);
                prevPointer = pointerType;
                return;
            }

            action.DrawSegments(ref segments);
            //targetIdentifier.position = action.GetTargetPos();
            //if (segments != null && segments.Count > 0)
            //{
            //Vector3 forward = PhysicsProject(transform.position, transform.forward);
            //GeneratePoints(forward, PhysicsProject(forward, Vector3.down));
            //}

            //if (segments != null && segments.Count > 0)
            //for (int i = 0; i < segments.Count; i++)
            //UpdateElement(linePoints, i, true, segments[i]);
        }
예제 #6
0
        private bool HandleInteraction(int x, int y, PointerAction action)
        {
            (int width, int height) = _game.GetScreenSize();

            if (_capturedHandler != null)
            {
                _capturedHandler.HandlePointerAction(x, y, width, height, action);
                return(true);
            }
            else if (_capturedTool != null)
            {
                ExecuteTool(_capturedTool, x, y, action);
                return(true);
            }

            if (action is PointerAction.Click)
            {
                bool preHandled = false;
                foreach (IInteractionHandler handler in _handler)
                {
                    if (handler.PreHandleNextClick && action is PointerAction.Click)
                    {
                        _capturedHandler = handler;
                        preHandled      |= handler.HandlePointerAction(x, y, width, height, action);
                    }
                }
                if (preHandled)
                {
                    return(true);
                }
            }

            foreach (IInteractionHandler handler in _handler)
            {
                if (handler.HandlePointerAction(x, y, width, height, action))
                {
                    if (action is PointerAction.Click or PointerAction.Drag)
                    {
                        _capturedHandler = handler;
                    }
                    return(true);
                }
            }

            if (_gameManager.CurrentTool is not null)
            {
                if (ExecuteTool(_gameManager.CurrentTool, x, y, action))
                {
                    if (action is PointerAction.Click or PointerAction.Drag)
                    {
                        _capturedTool = _gameManager.CurrentTool;
                    }
                }
            }

            return(false);
        }
예제 #7
0
        void OnMouseButtonHeld(object sender, MouseEventArgs e)
        {
            PointerAction action = null;

            Point pointerPosition = e.currentState.Position;

            if (mouseBindings.TryGetValue(new MouseBinding(e.button, InputState.held), out action))
            {
                action?.Invoke(pointerPosition);
            }
        }
예제 #8
0
        public override bool HandleMouseAction(int x, int y, PointerAction action)
        {
            if (action is Rendering.PointerAction.Click or Rendering.PointerAction.Move)
            {
                foreach (var button in _buttons)
                {
                    if (button.HandleMouseAction(x, y, action))
                    {
                        return(true);
                    }

                    x -= button.Width;
                }
            }
            return(false);
        }
예제 #9
0
 public virtual bool HandleMouseAction(int x, int y, PointerAction action)
 {
     if (x is >= 0 && x <= this.Width && y >= 0 && y <= this.Height)
     {
         if (action == PointerAction.Click)
         {
             _onClick?.Invoke();
         }
         else
         {
             _isHovered = true;
         }
         return(true);
     }
     _isHovered = false;
     return(false);
 }
예제 #10
0
        private bool ExecuteTool(ITool tool, int x, int y, PointerAction action)
        {
            (int column, int row) = _pixelMapper.ViewPortPixelsToCoords(x, y);

            var inSameCell = (column == _lastToolColumn && row == _lastToolRow);

            if (action is PointerAction.Click or PointerAction.Drag)
            {
                _lastToolColumn = column;
                _lastToolRow    = row;
            }

            if (!inSameCell && tool.IsValid(column, row) && action is PointerAction.Click or PointerAction.Drag)
            {
                tool.Execute(column, row);
                return(true);
            }
예제 #11
0
        protected override bool HandlePointerAction(int x, int y, PointerAction action)
        {
            if (action is Rendering.PointerAction.Click or Rendering.PointerAction.Move)
            {
                x -= ButtonLeft;
                foreach (var button in GetButtons())
                {
                    if (button.HandleMouseAction(x, y, action))
                    {
                        OnChanged();
                        return(true);
                    }

                    y -= button.Height + ButtonGap;
                }
            }
            return(true);
        }
예제 #12
0
        public bool HandlePointerAction(int x, int y, int width, int height, PointerAction action)
        {
            bool didAdjust = false;

            if (action == PointerAction.ZoomIn)
            {
                didAdjust = _pixelMapper.AdjustGameScale(ZoomInDelta);
            }
            else if (action == PointerAction.ZoomOut)
            {
                didAdjust = _pixelMapper.AdjustGameScale(ZoomOutDelta);
            }

            if (didAdjust == false)
            {
                return(false);
            }

            // TODO: Move the viewport so its centered on where the mouse pointer is

            return(true);
        }
예제 #13
0
        private bool ExecuteTool(ITool tool, int x, int y, PointerAction action)
        {
            (int column, int row) = _pixelMapper.ViewPortPixelsToCoords(x, y);

            var inSameCell = (column == _lastToolColumn && row == _lastToolRow);

            if (action is PointerAction.Click)
            {
                _hasDragged = false;
            }
            if (action is PointerAction.Drag)
            {
                _hasDragged     = true;
                _lastToolColumn = column;
                _lastToolRow    = row;
            }

            if (!inSameCell && action is PointerAction.Drag && tool.IsValid(column, row))
            {
                tool.Execute(column, row, true);
                return(true);
            }
            else if (tool is IDraggableTool draggableTool)
            {
                if (action == PointerAction.Click)
                {
                    draggableTool.StartDrag(x, y);
                    return(true);
                }
                else if (action == PointerAction.Drag)
                {
                    draggableTool.ContinueDrag(x, y);
                    return(true);
                }
            }

            return(false);
        }
예제 #14
0
 public void BindPointerEvent(MouseButton button, InputState inputState, PointerAction action)
 {
     mouseBindings.Add(new MouseBinding(button, inputState), action);
     inputManager.ListenFor(button);
 }
예제 #15
0
        public bool HandlePointerAction(int x, int y, int width, int height, PointerAction action)
        {
            if (!this.Visible)
            {
                return(false);
            }

            if (action is not(PointerAction.Move or PointerAction.Click))
            {
                return(false);
            }

            var panelHeight = GetPanelHeight();
            var panelWidth  = GetPanelWidth();

            y -= this.Top;

            if (this.Position == PanelPosition.Right)
            {
                if (IsCollapsed())
                {
                    x -= width;
                }
                else
                {
                    x -= (width - panelWidth);
                }
            }
            else if (this.Position == PanelPosition.Left)
            {
                if (IsCollapsed())
                {
                    x -= TitleAreaWidth;
                }
            }
            else
            {
                x -= GetLeft(width);
            }

            if (x >= -TitleAreaWidth && x <= 0 && y >= 10 && y <= 10 + _titleWidth)
            {
                if (IsCollapsed())
                {
                    _collapsed = !_collapsed;
                    OnChanged();
                }
                else if (action == PointerAction.Click && y <= 10 + CloseButtonWidth && this.CanClose)
                {
                    this.Visible = false;
                    Close();
                }
                return(true);
            }
            else if (!IsCollapsed() && x is >= 0 && x <= panelWidth && y >= 0 && y <= panelHeight)
            {
                if (this.Position == PanelPosition.Left)
                {
                    x -= 5;
                }
                else
                {
                    x -= 10;
                }
                y -= this.TopPadding;

                return(HandlePointerAction(x, y, action));
            }
            else if (this.IsCollapsable && !_collapsed)
            {
                _collapsed = true;
                OnChanged();
            }

            return(false);
        }
예제 #16
0
파일: Kirk.cs 프로젝트: shin527/cspspemu
		/// <summary>
		/// 
		/// </summary>
		/// <param name="key_type"></param>
		/// <returns></returns>
		public void kirk_4_7_get_key(int key_type, PointerAction PointerAction)
		{
			fixed (byte* key = _kirk_4_7_get_key(key_type))
			{
				PointerAction(key);
			}
		}
예제 #17
0
 public GestureToPointerAction(string in_gesture, PointerAction in_pointerAction)
 {
     m_gesture       = in_gesture;
     m_pointerAction = in_pointerAction;
 }
예제 #18
0
    // Use this for initialization
    void Start()
    {
        for (int i = 0, j = transform.childCount; i < j; i++)
        {
            Transform childTransform = transform.GetChild(i);

            if (childTransform.name == "Picker")
            {
                if (picker == null)
                {
                    picker = childTransform.gameObject;
                }
            }

            if (childTransform.name == "LuminositeSlider")
            {
                if (luminositeSlider == null)
                {
                    luminositeSlider = childTransform.gameObject;
                }
            }
        }

        if (pointerAction == null)
        {
            PointerAction colorPickerPointerAction = picker.GetComponent <PointerAction>();

            if (colorPickerPointerAction == null)
            {
                colorPickerPointerAction = picker.AddComponent <PointerAction>();
            }

            pointerAction = colorPickerPointerAction;

            if (pointerAction == null)
            {
                Debug.LogError("Aucun PointerAction spécifié !");
            }

            pointerAction.setLimitValues(minPointerPos, maxPointerPos);
        }

        if (luminoSlider == null)
        {
            LuminoSlider luminoiteSliderLuminoSlider = luminositeSlider.GetComponent <LuminoSlider>();

            if (luminoiteSliderLuminoSlider == null)
            {
                luminoiteSliderLuminoSlider = luminositeSlider.AddComponent <LuminoSlider>();
            }

            luminoSlider = luminoiteSliderLuminoSlider;

            if (luminoSlider == null)
            {
                Debug.LogError("Aucun PointerAction spécifié !");
            }

            luminoSlider.setLuminosite(1.0f);
        }
    }