Java 类org.newdawn.slick.KeyListener 实例源码

项目:Tower-Scaler    文件:MainEngine.java   
@Override
public void keyReleased(int key, char c){
    super.keyReleased(key, c);
    for(KeyListener listener : keyListeners){
        listener.keyReleased(key, c);
    }
}
项目:Tower-Scaler    文件:MainEngine.java   
@Override
public void inputEnded(){
    super.inputEnded();
    for(KeyListener listener : keyListeners){
        listener.inputEnded();
    }
}
项目:Tower-Scaler    文件:MainEngine.java   
@Override
public void inputStarted(){
    super.inputStarted();
    for(KeyListener listener : keyListeners){
        listener.inputStarted();
    }
}
项目:Tower-Scaler    文件:MainEngine.java   
@Override
public void setInput(Input input){
    super.setInput(input);
    for(KeyListener listener : keyListeners){
        listener.setInput(input);
    }
}
项目:Tower-Scaler    文件:MainEngine.java   
@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);
    }
}
项目:Tower-Scaler    文件:MainEngine.java   
public void addKeyListener(KeyListener listener){
    keyListeners.add(listener);
}
项目:Tower-Scaler    文件:MainEngine.java   
public void removeKeyListener(KeyListener listener){
    keyListeners.remove(listener);
}
项目:Tower-Scaler    文件:MainEngine.java   
public Set<KeyListener> getKeyListeners(){
    return keyListeners;
}