Beispiel #1
0
  /** Creates an Icon for a non-BlockFamily class */
  public Icon() {
    _element = new UIGraphicsElement("items");
    _blockFamily = null;

    _element.setSize(new Vector2f(32, 32));
    _element.getTextureSize().set(new Vector2f(0.0624f, 0.0624f));
    _element.setVisible(true);
    _element.setPosition(new Vector2f(-10f, -16f));

    setAtlasPosition(0, 0);
  }
Beispiel #2
0
  private void setAtlasPosition(int x, int y) {
    _x = x;
    _y = y;

    if (_element == null) {
      return;
    }

    _element.getTextureOrigin().set(new Vector2f(x * 0.0625f, y * 0.0625f));
  }
Beispiel #3
0
  public UIInventory() {
    setSize(new Vector2f(176.0f * 2.5f, 167.0f * 2.5f));

    _background = new UIGraphicsElement("inventory");
    _background.setSize(getSize());
    _background.getTextureSize().set(new Vector2f(176.0f / 256.0f, 167.0f / 256.0f));
    _background.setVisible(true);

    addDisplayElement(_background);

    _cells = new UIToolbarCell[27];

    for (int i = 9; i < _cells.length; i++) {
      UIInventoryCell cell = new UIInventoryCell(i);
      cell.setVisible(true);
      addDisplayElement(cell);
    }

    for (int i = 0; i < 9; i++) {
      UIInventoryCell cell = new UIInventoryCell(i);
      cell.setVisible(true);
      addDisplayElement(cell);
    }
  }
Beispiel #4
0
  /** Draw the icon. */
  public void render() {
    if (_blockFamily == null) {
      _element.renderTransformed();
    } else {
      GL11.glEnable(GL11.GL_TEXTURE_2D);

      GL11.glPushMatrix();
      glTranslatef(4f, 0f, 0f);
      GL11.glScalef(20f, 20f, 20f);
      GL11.glRotatef(170f, 1f, 0f, 0f);
      GL11.glRotatef(-16f, 0f, 1f, 0f);
      TextureManager.getInstance().bindTexture("terrain");

      Block block = _blockFamily.getArchetypeBlock();
      block.render();

      GL11.glPopMatrix();

      GL11.glDisable(GL11.GL_TEXTURE_2D);
    }
  }