com.watabou.utils.Signal Java Examples

The following examples show how to use com.watabou.utils.Signal. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Scene.java    From YetAnotherPixelDungeon with GNU General Public License v3.0 6 votes vote down vote up
public void create() {
	Keys.event.add( keyListener = new Signal.Listener<Keys.Key>() {
		@Override
		public void onSignal( Keys.Key key ) {
			if (Game.instance != null && key.pressed) {
				switch (key.code) {
				case Keys.BACK:
					onBackPressed();
					break;
				case Keys.MENU:
					onMenuPressed();
					break;
				}
			}
		}
	} );
}
 
Example #2
Source File: Scene.java    From PD-classes with GNU General Public License v3.0 6 votes vote down vote up
public void create() {
	Keys.event.add( keyListener = new Signal.Listener<Keys.Key>() {
		@Override
		public void onSignal( Keys.Key key ) {
			if (Game.instance != null && key.pressed) {
				switch (key.code) {
				case Keys.BACK:
					onBackPressed();
					break;
				case Keys.MENU:
					onMenuPressed();
					break;
				}
			}
		}
	} );
}
 
Example #3
Source File: Scene.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 6 votes vote down vote up
public void create() {
	Game.instance.getInputProcessor().addKeyListener(keyListener = new Signal.Listener<NoosaInputProcessor.Key>() {
		@Override
		public void onSignal(NoosaInputProcessor.Key key) {
			if (Game.instance != null && key.pressed) {
				switch (key.code) {
					case Input.Keys.BACK:
					case Input.Keys.ESCAPE:
						onBackPressed();
						break;
					case Input.Keys.MENU:
					case Input.Keys.F5:
						onMenuPressed();
						break;
				}
			}
		}
	});
}
 
Example #4
Source File: Scene.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
public void create() {
	KeyEvent.addKeyListener( keyListener = new Signal.Listener<KeyEvent>() {
		@Override
		public boolean onSignal( KeyEvent event ) {
			if (Game.instance != null && event.pressed) {
				if (KeyBindings.getActionForKey( event ) == GameAction.BACK){
					onBackPressed();
				}
			}
			return false;
		}
	} );
}
 
Example #5
Source File: Button.java    From shattered-pixel-dungeon with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void createChildren() {
	hotArea = new PointerArea( 0, 0, 0, 0 ) {
		@Override
		protected void onPointerDown( PointerEvent event ) {
			pressed = true;
			pressTime = 0;
			processed = false;
			Button.this.onPointerDown();
		}
		@Override
		protected void onPointerUp( PointerEvent event ) {
			pressed = false;
			Button.this.onPointerUp();
		}
		@Override
		protected void onClick( PointerEvent event ) {
			if (!processed) {
				Button.this.onClick();
			}
		}
	};
	add( hotArea );
	
	KeyEvent.addKeyListener( keyListener = new Signal.Listener<KeyEvent>() {
		@Override
		public boolean onSignal ( KeyEvent event ) {
			if ( active && event.pressed && KeyBindings.getActionForKey( event ) == keyAction()){
				onClick();
				return true;
			}
			return false;
		}
	});
}
 
Example #6
Source File: NoosaInputProcessor.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
public void removeMouseListener(Signal.Listener<PDMouseEvent> listener) {
	eventMouse.remove(listener);
}
 
Example #7
Source File: NoosaInputProcessor.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
public void addMouseListener(Signal.Listener<PDMouseEvent> listener) {
	eventMouse.add(listener);
}
 
Example #8
Source File: NoosaInputProcessor.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
public void removeTouchListener(Signal.Listener<Touch> listener) {
	eventTouch.remove(listener);
}
 
Example #9
Source File: NoosaInputProcessor.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
public void addTouchListener(Signal.Listener<Touch> listener) {
	eventTouch.add(listener);
}
 
Example #10
Source File: NoosaInputProcessor.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
public void removeKeyListener(Signal.Listener<Key<T>> listener) {
	eventKey.remove(listener);
}
 
Example #11
Source File: NoosaInputProcessor.java    From shattered-pixel-dungeon-gdx with GNU General Public License v3.0 4 votes vote down vote up
public void addKeyListener(Signal.Listener<Key<T>> listener) {
	eventKey.add(listener);
}
 
Example #12
Source File: ScrollEvent.java    From shattered-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public static void removeScrollListener( Signal.Listener<ScrollEvent> listener ){
	scrollSignal.remove(listener);
}
 
Example #13
Source File: ScrollEvent.java    From shattered-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public static void addScrollListener( Signal.Listener<ScrollEvent> listener ){
	scrollSignal.add(listener);
}
 
Example #14
Source File: PointerEvent.java    From shattered-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public static void removePointerListener( Signal.Listener<PointerEvent> listener ){
	pointerSignal.remove(listener);
}
 
Example #15
Source File: PointerEvent.java    From shattered-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public static void addPointerListener( Signal.Listener<PointerEvent> listener ){
	pointerSignal.add(listener);
}
 
Example #16
Source File: KeyEvent.java    From shattered-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public static void removeKeyListener( Signal.Listener<KeyEvent> listener ){
	keySignal.remove(listener);
}
 
Example #17
Source File: KeyEvent.java    From shattered-pixel-dungeon with GNU General Public License v3.0 4 votes vote down vote up
public static void addKeyListener( Signal.Listener<KeyEvent> listener ){
	keySignal.add(listener);
}