@Override
  public void bind(final Nifty nifty, final Screen screen) {
    this.nifty = nifty;
    this.screen = screen;

    this.consolePopup = nifty.createPopup("consolePopup");
    this.console = this.consolePopup.findNiftyControl("console", Console.class);

    consoleCommands = new ConsoleCommands(nifty, console);

    ConsoleCommand showCommand = new ShowCommand();

    consoleCommands.registerCommand("show DropDown", showCommand);

    NiftyCommand niftyCommand = new NiftyCommand();
    consoleCommands.registerCommand("nifty screen", niftyCommand);

    ConsoleCommand helpCommand = new HelpCommand();
    consoleCommands.registerCommand("help", helpCommand);

    ConsoleCommand clearCommand = new ClearCommand();
    consoleCommands.registerCommand("clear", clearCommand);

    ConsoleCommand exitCommand = new ExitCommand();
    consoleCommands.registerCommand("exit", exitCommand);

    // enable the nifty command line completion
    consoleCommands.enableCommandCompletion(true);

    // get all resolutions available into the resolutions drop down
    fillResolutionDropDown(screen);
  }
  public void OpenMenuPopup() {
    CloseMenuPopup();
    Game game = Main.app.getStateManager().getState(Game.class);
    game.Pause(true);

    MenuPopup = nifty.createPopup("MenuPopup");
    nifty.showPopup(screen, MenuPopup.getId(), null);
  }
  public void OpenPopulationPopup() {
    ClosePopulationPopup();
    Game game = Main.app.getStateManager().getState(Game.class);
    game.Pause(true);
    // prevent mouse wheel interfering with scrolling a menu
    // TODO there may be a better way of doing this, e.g. nifty not passing the mousewheel event to
    // the game.
    disableMouseWheel();

    PopulationPopup = nifty.createPopup("PopulationPopup");
    nifty.showPopup(screen, PopulationPopup.getId(), null);
  }
  @Override
  public void initialize(AppStateManager stateManager, Application app) {
    super.initialize(stateManager, app);
    this.app = (SimpleApplication) app;
    this.assetManager = this.app.getAssetManager();
    this.inputManager = this.app.getInputManager();
    this.cam = this.app.getCamera();
    this.stateManager = stateManager;
    this.guiNode = this.app.getGuiNode();
    this.rootNode = this.app.getRootNode();
    this.audioRenderer = this.app.getAudioRenderer();
    this.viewPort = this.app.getViewPort();
    this.space = this.stateManager.getState(BulletAppState.class).getPhysicsSpace();
    this.guiViewPort = this.app.getGuiViewPort();

    rootNode.attachChild(localRootNode);

    factory = new GameFactory();
    gameState = new RaceObjects();

    niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, viewPort);
    nifty = niftyDisplay.getNifty();
    nifty.fromXml("Interface/Nifty/startscreen.xml", "start", this);
    guiViewPort.addProcessor(niftyDisplay);

    audio = new AudioNode(this.app.getAssetManager(), "Sounds/default.wav");
    audio.play();
    audio.setLooping(true);

    textfield = nifty.getScreen("name").findNiftyControl("name", TextField.class);

    settingsList = nifty.getScreen("settings").findNiftyControl("resolutions", ListBox.class);
    settingsList.addItem("640*480 32bpp");
    settingsList.addItem("800*600 32bpp");
    settingsList.addItem("864*648 32bpp");
    settingsList.addItem("960*720 32bpp");
    settingsList.addItem("1024*768 32bpp");

    popup = nifty.createPopup("popupExit");
  }