Exemplo n.º 1
0
  /** DOCUMENT ME! */
  public void doLayout() {
    int x = getInsets().left;
    int y = getInsets().top;
    int width = getSize().width - getInsets().left - getInsets().right;
    int height = getSize().height - getInsets().top - getInsets().bottom;
    int space = 5;

    int cfx = playerInterface.getInsets().left;
    int cfy = playerInterface.getInsets().top;
    int cfwidth =
        playerInterface.getSize().width
            - playerInterface.getInsets().left
            - playerInterface.getInsets().right;
    int cfheight =
        playerInterface.getSize().height
            - playerInterface.getInsets().top
            - playerInterface.getInsets().bottom;

    int sqwidth = ColorSquare.WIDTH;
    int sqspace = (width - (5 * sqwidth)) / 5;

    int keepY;
    int discY;

    /* put the dialog in the center of the game window */
    setLocation(cfx + ((cfwidth - width) / 2), cfy + ((cfheight - height) / 2));

    try {
      msg.setBounds((width - 188) / 2, getInsets().top, 180, 20);
      discardBut.setBounds((width - 88) / 2, (getInsets().bottom + height) - 25, 80, 25);
      youHave.setBounds(getInsets().left, getInsets().top + 20 + space, 70, 20);
      discThese.setBounds(
          getInsets().left, getInsets().top + 20 + space + 20 + space + sqwidth + space, 100, 20);
    } catch (NullPointerException e) {
    }

    keepY = getInsets().top + 20 + space + 20 + space;
    discY = keepY + sqwidth + space + 20 + space;

    try {
      for (int i = 0; i < 5; i++) {
        keep[i].setSize(sqwidth, sqwidth);
        keep[i].setLocation((i * sqspace) + ((width - ((3 * sqspace) + (4 * sqwidth))) / 2), keepY);
        disc[i].setSize(sqwidth, sqwidth);
        disc[i].setLocation((i * sqspace) + ((width - ((3 * sqspace) + (4 * sqwidth))) / 2), discY);
      }
    } catch (NullPointerException e) {
    }
  }
Exemplo n.º 2
0
  /**
   * DOCUMENT ME!
   *
   * @param b DOCUMENT ME!
   */
  public void setVisible(boolean b) {
    if (b) {
      /** set initial values */
      SOCPlayer player =
          playerInterface.getGame().getPlayer(playerInterface.getClient().getNickname());
      SOCResourceSet resources = player.getResources();
      keep[0].setIntValue(resources.getAmount(SOCResourceConstants.CLAY));
      keep[1].setIntValue(resources.getAmount(SOCResourceConstants.ORE));
      keep[2].setIntValue(resources.getAmount(SOCResourceConstants.SHEEP));
      keep[3].setIntValue(resources.getAmount(SOCResourceConstants.WHEAT));
      keep[4].setIntValue(resources.getAmount(SOCResourceConstants.WOOD));

      discardBut.requestFocus();
    }

    super.setVisible(b);
  }
  /**
   * DOCUMENT ME!
   *
   * @param e DOCUMENT ME!
   */
  public void actionPerformed(ActionEvent e) {
    try {
      Object target = e.getSource();

      for (int i = 0; i < 5; i++) {
        if (target == rsrcBut[i]) {
          /** Note: This only works if SOCResourceConstants.CLAY == 1 */
          pi.getClient().monopolyPick(pi.getGame(), i + 1);
          dispose();

          break;
        }
      }
    } catch (Throwable th) {
      pi.chatPrintStackTrace(th);
    }
  }
Exemplo n.º 4
0
  /**
   * DOCUMENT ME!
   *
   * @param e DOCUMENT ME!
   */
  public void actionPerformed(ActionEvent e) {
    Object target = e.getSource();

    if (target == discardBut) {
      SOCResourceSet rsrcs =
          new SOCResourceSet(
              disc[0].getIntValue(),
              disc[1].getIntValue(),
              disc[2].getIntValue(),
              disc[3].getIntValue(),
              disc[4].getIntValue(),
              0);

      if (rsrcs.getTotal() == numDiscards) {
        playerInterface.getClient().discard(playerInterface.getGame(), rsrcs);
        dispose();
      }
    }
  }
  /** DOCUMENT ME! */
  public void doLayout() {
    int width = getSize().width - getInsets().left - getInsets().right;
    int height = getSize().height - getInsets().top - getInsets().bottom;
    int space = 5;

    int pix = pi.getInsets().left;
    int piy = pi.getInsets().top;
    int piwidth = pi.getSize().width - pi.getInsets().left - pi.getInsets().right;
    int piheight = pi.getSize().height - pi.getInsets().top - pi.getInsets().bottom;

    int buttonW = 60;
    int button2X = (width - ((2 * buttonW) + space)) / 2;
    int button3X = (width - ((3 * buttonW) + (2 * space))) / 2;

    /* put the dialog in the center of the game window */
    setLocation(pix + ((piwidth - width) / 2), piy + ((piheight - height) / 2));

    try {
      msg.setBounds((width - 188) / 2, getInsets().top, 210, 20);
      rsrcBut[0].setBounds(
          button2X, (getInsets().bottom + height) - (50 + (2 * space)), buttonW, 25);
      rsrcBut[1].setBounds(
          button2X + buttonW + space,
          (getInsets().bottom + height) - (50 + (2 * space)),
          buttonW,
          25);
      rsrcBut[2].setBounds(button3X, (getInsets().bottom + height) - (25 + space), buttonW, 25);
      rsrcBut[3].setBounds(
          button3X + space + buttonW, (getInsets().bottom + height) - (25 + space), buttonW, 25);
      rsrcBut[4].setBounds(
          button3X + (2 * (space + buttonW)),
          (getInsets().bottom + height) - (25 + space),
          buttonW,
          25);
    } catch (NullPointerException e) {
    }
  }