Ejemplo n.º 1
0
 protected AbstractInputHandler(IAutoBot bot, IKeyboardHandler keyboard, IMouseHandler mouse, ICollection <IDevice> devices) :
     base(bot)
 {
     this.Keyboard = keyboard;
     this.Mouse    = mouse;
     this.Devices  = devices;
 }
 public void SetUp()
 {
     _keyboardHandler = Substitute.For<IKeyboardHandler>();
     _controllerFactory = new ControllerFactory(_keyboardHandler);
     _controller1 = _controllerFactory.Controller1;
     _controller2 = _controllerFactory.Controller2;
 }
 public void SetUp()
 {
     _keyboardHandler = Substitute.For<IKeyboardHandler>();
     _keyboardHandler.IsPressed(Arg.Any<Keys>()).Returns(false);
     _keyboardController = new KeyboardController(_keyboardHandler);
     _keyboardController.SetMapping(Keys.A, ShipActions.Thrust);
     _keyboardController.SetMapping(Keys.B, ShipActions.FireProjectile);
     _keyboardController.SetMapping(Keys.C, ShipActions.Thrust | ShipActions.FireProjectile);
 }
Ejemplo n.º 4
0
 public BMBApplication(
     IProcessListener processListener,
     IProcessHandler processHandler,
     IKeyboardListener keyboardListener,
     IKeyboardHandler keyboardHandler)
 {
     this.processListener  = processListener;
     this.processHandler   = processHandler;
     this.keyboardListener = keyboardListener;
     this.keyboardHandler  = keyboardHandler;
 }
Ejemplo n.º 5
0
        public void SetUp()
        {
            _universe = Substitute.For<IUniverse>();
            _gravitySimulator = Substitute.For<IGravitySimulator>();
            _gameObjectFactory = Substitute.For<IGameObjectFactory>();
            _keyboardHandler = Substitute.For<IKeyboardHandler>();
            _actionHandler = Substitute.For<IActionHandler>();
            _drawingManager = Substitute.For<IDrawingManager>();

            _gameEngine = new GameEngine(_universe, _gravitySimulator, _gameObjectFactory, _keyboardHandler, _actionHandler, _drawingManager);
        }
Ejemplo n.º 6
0
        internal GameEngine(IUniverse universe, IGravitySimulator gravitySimulator, IGameObjectFactory gameObjectFactory, IKeyboardHandler keyboardHandler, IActionHandler actionHandler, IDrawingManager drawingManager)
        {
            _universe = universe;
            _drawingManager = drawingManager;
            _gravitySimulator = gravitySimulator;

            _gameObjectFactory = gameObjectFactory;

            _keyboardHandler = keyboardHandler;
            _actionHandler = actionHandler;
            _controllerFactory = new ControllerFactory(_keyboardHandler);
            actionHandler.RegisterTriggerAction(Keys.Space, () => _paused = !_paused);
        }
 public BrowserControl(
     IContextMenuHandler contextMenuHandler,
     IDisplayHandler displayHandler,
     IDownloadHandler downloadHandler,
     IKeyboardHandler keyboardHandler,
     ILifeSpanHandler lifeSpanHandler,
     IRequestHandler requestHandler,
     string url) : base(url)
 {
     this.contextMenuHandler = contextMenuHandler;
     this.displayHandler     = displayHandler;
     this.downloadHandler    = downloadHandler;
     this.keyboardHandler    = keyboardHandler;
     this.lifeSpanHandler    = lifeSpanHandler;
     this.requestHandler     = requestHandler;
 }
Ejemplo n.º 8
0
        public GameBoyViewModel(IGameBoy gameBoy, IDispatcher dispatcher, IWindow window,
                                IOpenFileDialogFactory fileDialogFactory,
                                IKeyboardHandler keyboardHandler)
        {
            _gameBoy                  = gameBoy;
            _dispatcher               = dispatcher;
            _window                   = window;
            _keyboardHandler          = keyboardHandler;
            _keyboardHandler.KeyDown += OnKeyDown;
            _keyboardHandler.KeyUp   += OnKeyUp;
            _window.OnClosing        += HandleClosing;

            _buttonMapping = new ButtonMapping();

            _memory = new MemoryViewModel(_gameBoy.Memory, "Memory View");
            _cpu    = new CPUViewModel(_gameBoy, _dispatcher);

            // TODO(aaecheve): Should this be another function handling this?
            _gameBoy.CPU.BreakpointFound   += BreakpointHandler;
            _gameBoy.CPU.InterruptHappened += InterruptHandler;
            _gameBoy.ErrorEvent            += _gameBoy_ErrorEvent;

            _interrupt             = new InterruptManagerViewModel(_gameBoy, _dispatcher);
            _ioRegisters           = new IORegistersManagerViewModel(_gameBoy, _dispatcher);
            _soundChannelInternals = new SoundChannelInternalsViewModel(_gameBoy);
            _display              = new DisplayViewModel(_gameBoy, _gameBoy.Display, _gameBoy.Memory, _dispatcher);
            _gameBoyGamePad       = new GameBoyGamePadViewModel(_gameBoy, _dispatcher);
            _breakpoints          = new BreakpointsViewModel(_gameBoy);
            _dissasemble          = new DissasembleViewModel(_breakpoints, _gameBoy);
            _instructionHistogram = new InstructionHistogramViewModel(_gameBoy, _dispatcher);
            _apu            = new APUViewModel(_gameBoy, _dispatcher);
            _memoryImage    = new MemoryImageViewModel(_gameBoy, _dispatcher);
            _soundRecording = new SoundRecordingViewModel(_gameBoy);
            _controls       = new ControlsViewModel(this, _buttonMapping);

            // Gameboy Controller events
            _gameBoyController = new GameBoyContollerViewModel(_gameBoy, fileDialogFactory, _breakpoints);
            _gameBoyController.OnFileLoaded += FileLoadedHandler;
            _gameBoyController.OnStep       += StepHandler;
            _gameBoyController.OnRun        += RunHandler;
            _gameBoyController.OnPause      += PauseHandler;
        }
Ejemplo n.º 9
0
        public GameBoyViewModel(IGameBoy gameBoy, IDispatcher dispatcher, IWindow window, 
                                IOpenFileDialogFactory fileDialogFactory, 
                                IKeyboardHandler keyboardHandler)
        {
            _gameBoy = gameBoy;
            _dispatcher = dispatcher;
            _window = window;
            _keyboardHandler = keyboardHandler;
            _keyboardHandler.KeyDown += OnKeyDown;
            _keyboardHandler.KeyUp += OnKeyUp;
            _window.OnClosing += HandleClosing;

            _buttonMapping = new ButtonMapping();

            _memory = new MemoryViewModel(_gameBoy.Memory, "Memory View");
            _cpu = new CPUViewModel(_gameBoy, _dispatcher);

            // TODO(aaecheve): Should this be another function handling this?
            _gameBoy.CPU.BreakpointFound += BreakpointHandler;
            _gameBoy.CPU.InterruptHappened += InterruptHandler;
            _gameBoy.ErrorEvent += _gameBoy_ErrorEvent;

            _interrupt = new InterruptManagerViewModel(_gameBoy, _dispatcher);
            _ioRegisters = new IORegistersManagerViewModel(_gameBoy, _dispatcher);
            _soundChannelInternals = new SoundChannelInternalsViewModel(_gameBoy);
            _display = new DisplayViewModel(_gameBoy, _gameBoy.Display, _gameBoy.Memory, _dispatcher);
            _gameBoyGamePad = new GameBoyGamePadViewModel(_gameBoy, _dispatcher);
            _breakpoints = new BreakpointsViewModel(_gameBoy);
            _dissasemble = new DissasembleViewModel(_breakpoints, _gameBoy);
            _instructionHistogram = new InstructionHistogramViewModel(_gameBoy, _dispatcher);
            _apu = new APUViewModel(_gameBoy, _dispatcher);
            _memoryImage = new MemoryImageViewModel(_gameBoy, _dispatcher);
            _soundRecording = new SoundRecordingViewModel(_gameBoy);
            _controls = new ControlsViewModel(this, _buttonMapping);

            // Gameboy Controller events
            _gameBoyController = new GameBoyContollerViewModel(_gameBoy, fileDialogFactory, _breakpoints);
            _gameBoyController.OnFileLoaded += FileLoadedHandler;
            _gameBoyController.OnStep += StepHandler;
            _gameBoyController.OnRun += RunHandler;
            _gameBoyController.OnPause += PauseHandler;
        }
Ejemplo n.º 10
0
        internal SpaceWar2Game()
        {
            _contentManager = new ContentManagerWrapper(Content.ServiceProvider, "Content");
            var graphicsDeviceManager = new GraphicsDeviceManager(this);
            _graphicsDevice = new GraphicsDeviceWrapper(graphicsDeviceManager);

            _universe = Universe.CreateDefault();
            _drawingManager = new DrawingManager(_universe);
            _gravitySimulator = new GravitySimulator();
            _shipComponentFactory = new ShipComponentFactory();
            _graphicsFactory = new GraphicsFactory();

            _gameObjectFactory = new GameObjectFactory(_contentManager, _graphicsFactory, _gravitySimulator, _drawingManager, _universe, _shipComponentFactory);

            _keyboardHandler = new KeyboardHandler(new KeyboardWrapper());

            var actionHandler = new ActionHandler(_keyboardHandler);

            _gameEngine = new GameEngine(_universe, _gravitySimulator, _gameObjectFactory, _keyboardHandler, actionHandler, _drawingManager);

            SetUpActions(actionHandler);
        }
Ejemplo n.º 11
0
 internal KeyboardController(IKeyboardHandler keyboardHandler)
 {
     _keyboardHandler = keyboardHandler;
     _mappings = new Dictionary<Keys, ShipActions>();
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Sets the specified keyboard handler to handle user input.
 /// </summary>
 /// <param name="keyboard">The keyboard handler.</param>
 public void Set(IKeyboardHandler keyboard)
 {
     Keyboard = keyboard;
 }
Ejemplo n.º 13
0
 public void SetUp()
 {
     _keyboardHandler = Substitute.For<IKeyboardHandler>();
     _actionHandler = new ActionHandler(_keyboardHandler);
 }
Ejemplo n.º 14
0
 internal ControllerFactory(IKeyboardHandler keyboardHandler)
 {
     _keyboardHandler = keyboardHandler;
     CreateController1();
     CreateController2();
 }
Ejemplo n.º 15
0
 public void PushKeyboardHandler(IKeyboardHandler Handler)
 {
     HandlerStack.Add(Handler);
 }
Ejemplo n.º 16
0
 public MonoGameSubEngine(GraphicsDeviceManager graphics, SpriteBatch spriteBatch)
 {
     SpriteBatch = new MonoGameSpriteBatch(spriteBatch);
     Camera      = new MonoGameCameraController();
     Keyboard    = new MonoGameKayboardHandler();
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Update all screens and handle handlers
        /// </summary>
        public override void Update(GameTime gameTime)
        {
            _screensToUpdate = new List <GameScreen>(Screens);

            while (_screensToUpdate.Count > 0)
            {
                GameScreen currentScreen = _screensToUpdate[_screensToUpdate.Count - 1];

                _screensToUpdate.RemoveAt(_screensToUpdate.Count - 1);

                // Verifies if we have to delete the screen
                if (currentScreen.IsExiting == true)
                {
                    Screens.Remove(currentScreen);
                    continue;
                }

                // handles mouse input for the screen
                if (currentScreen is IMouseHandler)
                {
                    IMouseHandler handlerScreen     = (IMouseHandler)currentScreen;
                    MouseState    currentMouseState = Mouse.GetState();

                    if (currentMouseState.LeftButton == ButtonState.Pressed && _oldMouseState.LeftButton == ButtonState.Released)
                    {
                        handlerScreen.MouseLeftPressed(currentMouseState);
                    }

                    if (currentMouseState.LeftButton == ButtonState.Released && _oldMouseState.LeftButton == ButtonState.Pressed)
                    {
                        handlerScreen.MouseLeftReleased(currentMouseState);
                    }

                    if (currentMouseState.RightButton == ButtonState.Pressed && _oldMouseState.RightButton == ButtonState.Released)
                    {
                        handlerScreen.MouseRightPressed(currentMouseState);
                    }

                    if (currentMouseState.RightButton == ButtonState.Released && _oldMouseState.RightButton == ButtonState.Pressed)
                    {
                        handlerScreen.MouseRightReleased(currentMouseState);
                    }

                    _oldMouseState = currentMouseState;
                }

                // handles keyboard input for the screen
                if (currentScreen is IKeyboardHandler)
                {
                    IKeyboardHandler handlerScreen        = (IKeyboardHandler)currentScreen;
                    KeyboardState    currentKeyboardState = Keyboard.GetState();

                    Keys[] pressedKeys = currentKeyboardState.GetPressedKeys();

                    handlerScreen.KeysPressed(pressedKeys);
                }

                // handles socket connection for the screen
                if (currentScreen is ISocketHandler)
                {
                    ISocketHandler handlerScreen = (ISocketHandler)currentScreen;
                    var            status        = currentScreen.Socket.Connection.Status;

                    // check for no status
                    if (status != null)
                    {
                        if (status == ConnStatus.Disconnected)
                        {
                            handlerScreen.OnDisconnect(_statusBefore, gameTime);
                        }

                        if (status == ConnStatus.Connecting)
                        {
                            handlerScreen.OnConnecting(_statusBefore, gameTime);
                        }

                        if (status == ConnStatus.Connected)
                        {
                            handlerScreen.OnConnected(_statusBefore, gameTime);
                        }

                        _statusBefore = status;
                    }
                }

                // handles socket datas
                if (currentScreen is ISocketDataHandler)
                {
                    ISocketDataHandler handlerScreen = (ISocketDataHandler)currentScreen;
                    handlerScreen.Receive(ReceiveData);
                    // Select just data that can't be deleted
                    ReceiveData = new List <SocketData>(from d in ReceiveData
                                                        where d.IsDeleting == false
                                                        select d);
                }

                currentScreen.Update(gameTime);
            }
        }
Ejemplo n.º 18
0
 public WindowsInputHandler(IAutoBot bot, IKeyboardHandler keyboard, IMouseHandler mouse, ICollection <IDevice> devices) :
     base(bot, keyboard, mouse, devices)
 {
 }
 protected AbstractPlatformInputTools(IKeyboardHandler keyboardHandler, string platformName) :
     base(platformName)
 {
     this.KeyboardHandler = keyboardHandler;
 }
Ejemplo n.º 20
0
 public WindowsPlatformInputTools(IKeyboardHandler keyboardHandler) :
     base(keyboardHandler, "Windows")
 {
 }
Ejemplo n.º 21
0
 internal ActionHandler(IKeyboardHandler keyboardHandler)
 {
     _keyboardHandler = keyboardHandler;
     _triggerActions = new Dictionary<Keys, Action>();
     _continuousActions = new Dictionary<Keys, Action>();
 }