Esempio n. 1
0
  /**
   * Renders card type selection if needed
   *
   * @param g - refernce to graphic content
   * @param g_src - reference to class which holds informations about rendering
   * @param mouseX - X position of mouse
   * @param mouseY - Y position of mouse
   * @param width - width of display
   * @param height - height of display
   */
  public static void renderSelectType(Graphics g, CGraphics g_src, int mouseX, int mouseY) {
    g.setColor(new Color(88, 88, 88, 180));
    g.fillRect(0, 0, g_src.displayWidth(), g_src.displayHeight());
    Image temp = null;

    String label = "Vyber farbu";
    g.setFont(new Font("Arial", Font.BOLD | Font.ITALIC, 40));
    FontMetrics metrics = g.getFontMetrics();
    g.setColor(Color.RED);
    g.drawString(
        label,
        g_src.displayWidth() / 2 - metrics.stringWidth(label) / 2,
        g_src.displayHeight() / 4 + metrics.getHeight());

    for (int i = 0; i < 4; i++) {

      RoundRectangle2D.Double outline = getTypeOutline(g_src, i);
      boolean mouseon = outline.contains(mouseX, mouseY);
      temp = g_src.getType(i);
      int x = (int) outline.getX();
      int y = (int) outline.getY();
      int width = (int) outline.getWidth();
      g.setColor(new Color(0x6C, 0x43, 0x19));
      g.fillRoundRect(x - 5, y - 5, width + 10, width + 10, 10, 10);
      g.setColor(new Color(0xFF, 0xFF, 0xB8));
      g.fillRoundRect(x, y, width, width, 10, 10);
      g.drawImage(
          temp,
          x + 5,
          y + 5,
          x + width - 5,
          y + width - 5,
          0,
          0,
          temp.getWidth(null),
          temp.getHeight(null),
          null);
      if (!mouseon) {
        g.setColor(new Color(88, 88, 88, 120));
        g.fillRoundRect(x, y, width, width, 10, 10);
      }
    }
  }
Esempio n. 2
0
  /**
   * Displays card type when needed
   *
   * @param g - reference to graphic content
   * @param graphicSource - reference to class that contains informations about rendering
   * @param type - card type
   * @param mouseX - X position of mouse
   * @param mouseY - Y position of mouse
   * @param width - width of display
   * @param height - height of display
   */
  public static void displayCardType(Graphics g, CGraphics g_src, int type) {
    Image img = g_src.getType(type);
    Point deckPos = getDeckPosition(g_src, 'd');
    Point trashPos = getDeckPosition(g_src, 't');
    // get outline in between deck and trash
    int left = deckPos.x + g_src.cardWidth();
    int right = trashPos.x;
    int top = deckPos.y;
    int bottom = top + g_src.cardHeight();

    // adjust indicator box to square with size of 0.8 of space between decks
    int width = (int) ((double) (right - left) * 0.6);
    int offsetX = ((right - left) - width) / 2;
    int offsetY = ((bottom - top) - width) / 2;

    left += offsetX;
    right -= offsetX;
    top += offsetY;
    bottom -= offsetY;

    g.drawImage(img, left, top, right, bottom, 0, 0, img.getWidth(null), img.getHeight(null), null);
  }