Ejemplo n.º 1
0
  @Override
  public void render(float arg0) {
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    camera.update();
    if (Gdx.input.isKeyPressed(Input.Keys.ESCAPE)) {
      if (focused) {
        focused = false;
      } else {
        goBack();
      }
    }

    if (focused) {
      shapeRenderer.begin(ShapeType.FilledRectangle);
      Color c = new Color(0.15f, 0.4f, 0.15f, 1f);
      shapeRenderer.setColor(c);
      shapeRenderer.filledRect(focusedBox.x, focusedBox.y, focusedBox.width, focusedBox.height);
      shapeRenderer.end();
    }

    batch.begin();
    ObjectMap.Entries<String, Rectangle> it = bindingButtons.entries();
    // draw back button text
    font.draw(batch, "Back", backButton.x, backButton.y + backButton.height);
    // draw option texts
    while (it.hasNext()) {
      ObjectMap.Entry<String, Rectangle> entry = it.next();
      Rectangle bounds = entry.value;
      font.draw(batch, entry.key, bounds.x, bounds.y + bounds.height);
      Binding binding = game.getBindings().get(entry.key);
      font.draw(batch, binding.character, bounds.x + 200.0f, bounds.y + bounds.height);
    }
    batch.end();
  }
Ejemplo n.º 2
0
  @Override
  public void show() {
    font =
        new BitmapFont(
            Gdx.files.internal("assets/font.fnt"), Gdx.files.internal("assets/font.png"), false);
    batch = new SpriteBatch();
    shapeRenderer = new ShapeRenderer();
    bindingButtons = new ObjectMap<String, Rectangle>();
    backButton = new Rectangle(40.0f, 730.0f, 100.0f, 32.0f);

    // setup interface
    ObjectMap.Entries<String, Binding> it = game.getBindings().entries();
    float y = 700.0f;
    while (it.hasNext()) {
      ObjectMap.Entry<String, Binding> entry = it.next();
      Rectangle button = new Rectangle(300.0f, y, 150.0f, 32);
      y -= 40;
      bindingButtons.put(entry.key, button);
    }
    mousePos = new Vector3();
    camera = new OrthographicCamera();
    camera.setToOrtho(false);
    Gdx.input.setInputProcessor(this);
    focusedBox = new Rectangle();
  }
Ejemplo n.º 3
0
 public void updateBinding(int keycode) {
   ObjectMap<String, Binding> bindings = game.getBindings();
   Binding binding = bindings.get(this.focusedAction);
   String character = game.map.get(keycode);
   if (character != null) {
     binding.character = character;
     binding.keyCode = keycode;
     System.out.println(
         "Updating action: " + this.focusedAction + " to " + keycode + " " + binding.character);
     bindings.put(focusedAction, binding);
   } else {
     System.out.println("Couldnt map character: " + keycode);
   }
 }
Ejemplo n.º 4
0
 public void goBack() {
   game.setScreen(game.mainMenuScreen);
 }