@Override public void keyReleased(int key, char c){ super.keyReleased(key, c); for(KeyListener listener : keyListeners){ listener.keyReleased(key, c); } }
@Override public void inputEnded(){ super.inputEnded(); for(KeyListener listener : keyListeners){ listener.inputEnded(); } }
@Override public void inputStarted(){ super.inputStarted(); for(KeyListener listener : keyListeners){ listener.inputStarted(); } }
@Override public void setInput(Input input){ super.setInput(input); for(KeyListener listener : keyListeners){ listener.setInput(input); } }
@Override public void keyPressed(int key, char c){ super.keyPressed(key, c); listen: { if(key == Input.KEY_ESCAPE){ for(TSMenu menu : getMenus()){ if(menu.isVisible()){ menu.close(); break listen; } } if(ge.isActive()){ ge.paused = true; setForegroundEngine(me); break listen; } else if(mge.isActive()){ mge.paused = true; setForegroundEngine(me); break listen; } else if(me.isActive()){ if(Main.debug){ System.out.println("Exiting system"); } System.exit(0); } } if(key == Input.KEY_SPACE){ if(me.isActive()){ if(hasInputFocus()){ ge.setArcadeMode(true); startGame(); } } break listen; } if(key == Input.KEY_ENTER){ if(me.isActive()){ if(hasInputFocus()){ ge.setArcadeMode(false); startGame(); } } break listen; } if(getHighScoreMenu().hasInputFocus()){ if(key == Input.KEY_RIGHT){ getHighScoreMenu().setIndex( getHighScoreMenu().getIndex() + 10); break listen; } if(key == Input.KEY_LEFT){ getHighScoreMenu().setIndex( getHighScoreMenu().getIndex() - 10); break listen; } } if(getStatsMenu().hasInputFocus()){ getStatsMenu().pushChar(key, c); break listen; } if(getMultiplayerMenu().hasInputFocus()){ getMultiplayerMenu().pushChar(key, c); break listen; } } for(KeyListener listener : keyListeners){ listener.keyPressed(key, c); } }
public void addKeyListener(KeyListener listener){ keyListeners.add(listener); }
public void removeKeyListener(KeyListener listener){ keyListeners.remove(listener); }
public Set<KeyListener> getKeyListeners(){ return keyListeners; }