Example #1
0
  public GameMenu(
      GameNetwork game_network,
      GUIRoot gui_root,
      SelectGameMenu owner,
      Game game,
      WorldGenerator generator,
      int player_slot,
      int compare_width,
      int compare_height,
      int button_width) {
    super(Utils.getBundleString(getBundle(), "game_caption"));
    this.game_network = game_network;
    this.owner = owner;
    this.gui_root = gui_root;
    this.local_player_slot = player_slot;
    this.rated = game.isRated();
    this.game = game;

    String tag = "";
    if (rated) tag = Utils.getBundleString(bundle, "rated") + " ";
    Label game_name_label =
        new Label(
            Utils.getBundleString(bundle, "game") + " " + tag + game.getName(),
            Skin.getSkin().getHeadlineFont());
    slot_buttons = new PulldownButton[MatchmakingServerInterface.MAX_PLAYERS];
    race_buttons = new PulldownButton[MatchmakingServerInterface.MAX_PLAYERS];
    team_buttons = new PulldownButton[MatchmakingServerInterface.MAX_PLAYERS];
    ready_marks = new Diode[MatchmakingServerInterface.MAX_PLAYERS];
    ratings = new Label[MatchmakingServerInterface.MAX_PLAYERS];
    Group player_group = new Group();
    GUIObject previous = null;
    for (int i = 0; i < MatchmakingServerInterface.MAX_PLAYERS; i++)
      previous =
          createPlayerPulldown(
              gui_root,
              player_group,
              previous,
              slot_buttons,
              race_buttons,
              team_buttons,
              ready_marks,
              ratings,
              i,
              MatchmakingServerInterface.MAX_PLAYERS);
    player_group.compileCanvas();
    addChild(player_group);

    Box pdata = Skin.getSkin().getPanelData().getBox();
    FormData fdata = Skin.getSkin().getFormData();

    int width = compare_width - pdata.getLeftOffset() - pdata.getRightOffset();
    chat_info =
        new Label(Utils.getBundleString(bundle, "chat"), Skin.getSkin().getEditFont(), width);
    Group chat_line_group = new Group();
    chat_line = new EditLine(width - SEND_BUTTON_WIDTH - fdata.getObjectSpacing(), 100);
    send_button = new HorizButton(Utils.getBundleString(bundle, "send"), SEND_BUTTON_WIDTH);
    send_button.addMouseClickListener(new SendListener());
    chat_line_group.addChild(chat_line);
    chat_line.place();
    chat_line_group.addChild(send_button);
    send_button.place(chat_line, RIGHT_MID);
    chat_line_group.compileCanvas();
    addChild(chat_line_group);

    chat_line.addEnterListener(new ChatListener());
    addChild(game_name_label);
    addChild(chat_info);

    start_button = new HorizButton(Utils.getBundleString(bundle, "start"), button_width);
    if (local_player_slot == 0) {
      addChild(start_button);
      start_button.addMouseClickListener(new StartListener());
    }
    int height =
        compare_height
            - pdata.getTopOffset()
            - pdata.getBottomOffset()
            - chat_info.getHeight()
            - chat_line.getHeight()
            - game_name_label.getHeight()
            - player_group.getHeight()
            - start_button.getHeight()
            - 5 * fdata.getObjectSpacing();
    chat_box = new TextBox(width, height, Skin.getSkin().getEditFont(), -1);
    addChild(chat_box);
    ready_button = new HorizButton(Utils.getBundleString(bundle, "ready"), button_width);
    addChild(ready_button);
    ready_button.addMouseClickListener(new ReadyListener());
    HorizButton cancel_button =
        new HorizButton(Utils.getBundleString(bundle, "cancel"), button_width);
    addChild(cancel_button);
    cancel_button.addMouseClickListener(new CancelButtonListener());
    HorizButton info_button = new HorizButton(Utils.getBundleString(bundle, "info"), button_width);
    addChild(info_button);
    info_button.addMouseClickListener(new InfoButtonListener());

    game_name_label.place();
    player_group.place(game_name_label, BOTTOM_LEFT);
    chat_info.place(player_group, BOTTOM_LEFT);
    chat_box.place(chat_info, BOTTOM_LEFT);
    chat_line_group.place(chat_box, BOTTOM_LEFT);
    cancel_button.place(chat_line_group, BOTTOM_RIGHT);
    info_button.place(chat_line_group, BOTTOM_LEFT);
    ready_button.place(cancel_button, LEFT_MID);
    if (local_player_slot == 0) start_button.place(ready_button, LEFT_MID);
    Font font = Skin.getSkin().getEditFont();
    if (rated) {
      Label rating =
          new Label(Utils.getBundleString(bundle, "rating"), font, RATING_WIDTH, Label.ALIGN_RIGHT);
      addChild(rating);
      rating.place(player_group, TOP_RIGHT);
    }
    compileCanvas();
  }
Example #2
0
 public final void setFocus() {
   chat_line.setFocus();
 }