Esempio n. 1
0
  public TutorialForm(NetworkSelector network, GUIRoot gui_root) {
    this.gui_root = gui_root;
    this.network = network;
    Label headline =
        new Label(
            Utils.getBundleString(bundle, "tutorial_caption"), Skin.getSkin().getHeadlineFont());
    addChild(headline);

    HorizButton button_tutorial1 = new HorizButton(formatTutorial(TUTORIAL_CAMERA), 120);
    button_tutorial1.addMouseClickListener(new TutorialListener(TUTORIAL_CAMERA));
    addChild(button_tutorial1);
    Label label_tutorial1 =
        new Label(Utils.getBundleString(bundle, "tutorial1_tip"), Skin.getSkin().getEditFont());
    addChild(label_tutorial1);

    HorizButton button_tutorial2 = new HorizButton(formatTutorial(TUTORIAL_QUARTERS), 120);
    button_tutorial2.addMouseClickListener(new TutorialListener(TUTORIAL_QUARTERS));
    addChild(button_tutorial2);
    Label label_tutorial2 =
        new Label(Utils.getBundleString(bundle, "tutorial2_tip"), Skin.getSkin().getEditFont());
    addChild(label_tutorial2);

    HorizButton button_tutorial3 = new HorizButton(formatTutorial(TUTORIAL_ARMORY), 120);
    button_tutorial3.addMouseClickListener(new TutorialListener(TUTORIAL_ARMORY));
    addChild(button_tutorial3);
    Label label_tutorial3 =
        new Label(Utils.getBundleString(bundle, "tutorial3_tip"), Skin.getSkin().getEditFont());
    addChild(label_tutorial3);

    HorizButton button_tutorial4 = new HorizButton(formatTutorial(TUTORIAL_TOWER), 120);
    button_tutorial4.addMouseClickListener(new TutorialListener(TUTORIAL_TOWER));
    addChild(button_tutorial4);
    Label label_tutorial4 =
        new Label(Utils.getBundleString(bundle, "tutorial4_tip"), Skin.getSkin().getEditFont());
    addChild(label_tutorial4);

    HorizButton button_tutorial5 = new HorizButton(formatTutorial(TUTORIAL_CHIEFTAIN), 120);
    button_tutorial5.addMouseClickListener(new TutorialListener(TUTORIAL_CHIEFTAIN));
    addChild(button_tutorial5);
    Label label_tutorial5 =
        new Label(Utils.getBundleString(bundle, "tutorial5_tip"), Skin.getSkin().getEditFont());
    addChild(label_tutorial5);

    HorizButton button_tutorial6 = new HorizButton(formatTutorial(TUTORIAL_BATTLE), 120);
    button_tutorial6.addMouseClickListener(new TutorialListener(TUTORIAL_BATTLE));
    addChild(button_tutorial6);
    Label label_tutorial6 =
        new Label(Utils.getBundleString(bundle, "tutorial6_tip"), Skin.getSkin().getEditFont());
    addChild(label_tutorial6);

    HorizButton cancel_button = new CancelButton(120);
    addChild(cancel_button);
    cancel_button.addMouseClickListener(new CancelListener(this));

    // Place objects
    headline.place();
    button_tutorial1.place(headline, BOTTOM_LEFT);
    label_tutorial1.place(button_tutorial1, RIGHT_MID);
    button_tutorial2.place(button_tutorial1, BOTTOM_LEFT);
    label_tutorial2.place(button_tutorial2, RIGHT_MID);
    button_tutorial3.place(button_tutorial2, BOTTOM_LEFT);
    label_tutorial3.place(button_tutorial3, RIGHT_MID);
    button_tutorial4.place(button_tutorial3, BOTTOM_LEFT);
    label_tutorial4.place(button_tutorial4, RIGHT_MID);
    button_tutorial5.place(button_tutorial4, BOTTOM_LEFT);
    label_tutorial5.place(button_tutorial5, RIGHT_MID);
    button_tutorial6.place(button_tutorial5, BOTTOM_LEFT);
    label_tutorial6.place(button_tutorial6, RIGHT_MID);
    cancel_button.place(ORIGIN_BOTTOM_RIGHT);

    // headline
    compileCanvas();
    centerPos();
  }
Esempio n. 2
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();
  }