예제 #1
0
        private void CheckInput()
        {
            while (BLT.HasInput() && !isClosed)
            {
                var input = BLT.Read();

                if (input == BLT.TK_CLOSE)
                {
                    isClosed = true;
                }

                if (IsMouseMove(input))
                {
                    _mouseActive = true;
                    _mouseX      = BLT.State(BLT.TK_MOUSE_X);
                    _mouseY      = BLT.State(BLT.TK_MOUSE_Y);
                }
                if (IsClickEvent(input))
                {
                    _mouseActive = true;
                }
                else
                {
                    ResolveKeyboardInput(input);
                }

                SetMouseButtons(input);
            }
        }
        public MapCoordinate GetMapEditorMapCoordinateFromMousePosition(MapCoordinate cameraPosition, int x, int y)
        {
            var lookupX = cameraPosition.X - BLT.State(BLT.TK_WIDTH) / (2 * BLTTilesIOSystem.TILE_SPACING) + x / BLTTilesIOSystem.TILE_SPACING;
            var lookupY = cameraPosition.Y - BLT.State(BLT.TK_HEIGHT) / (2 * BLTTilesIOSystem.TILE_SPACING) + y / BLTTilesIOSystem.TILE_SPACING;

            return(new MapCoordinate(cameraPosition.Key, lookupX, lookupY));
        }
예제 #3
0
        private void SetMouseButtons(int input)
        {
            var leftMouseCurrentlyDown  = BLT.State(BLT.TK_MOUSE_LEFT) == 1;
            var rightMouseCurrentlyDown = BLT.State(BLT.TK_MOUSE_RIGHT) == 1;

            _leftClick  = _leftMouseDown && !leftMouseCurrentlyDown;
            _rightClick = _rightMouseDown && !rightMouseCurrentlyDown;

            _leftMouseDown  = leftMouseCurrentlyDown;
            _rightMouseDown = rightMouseCurrentlyDown;
        }
예제 #4
0
        private void ResolveKeyboardInput(int input)
        {
            var key = BLTKeyConverter.FromBLTInput(input);

            _keyCombination = new KeyCombination
            {
                Key   = key,
                Ctrl  = BLT.State(BLT.TK_CONTROL) != 0,
                Shift = BLT.State(BLT.TK_SHIFT) != 0,
                Alt   = BLT.State(BLT.TK_ALT) != 0,
            };
        }