Пример #1
0
  public HeroesSelectGUI(HeroesHUD plugin, SpoutPlayer spoutp) {
    this.plugin = plugin;
    this.spoutp = spoutp;

    GenericTexture backgroundMain = new GenericTexture();

    int screenWidth = spoutp.getMainScreen().getWidth();
    int screenHeight = spoutp.getMainScreen().getHeight();
    int x = (screenWidth / 2) - 170;
    int y = (screenHeight / 2) - 100;

    // BackgroundMain!

    backgroundMain.setX(x).setY(y);
    backgroundMain.setWidth(340).setHeight(200);
    backgroundMain.setUrl(plugin.HeroesSelectGuiBackgroundMain);
    backgroundMain.setFixed(false);
    backgroundMain.setPriority(RenderPriority.Highest);

    // Button1 Main
    button1 = new GenericButton();
    button1.setText("Primary");
    button1
        .setWidth(GenericLabel.getStringWidth(button1.getText()) + 5 + 30)
        .setHeight(GenericLabel.getStringHeight(button1.getText()) + 5);
    button1.setX(backgroundMain.getX() + 20);
    button1.setY(backgroundMain.getY() + 65);
    button1.setDirty(true);
    button1.setAutoDirty(true);

    // Button2 Main
    button2 = new GenericButton();
    button2.setText("Profession");
    button2
        .setWidth(GenericLabel.getStringWidth(button2.getText()) + 5 + 30)
        .setHeight(GenericLabel.getStringHeight(button2.getText()) + 5);
    button2.setX(backgroundMain.getX() + 235);
    button2.setY(backgroundMain.getY() + 65);
    button2.setDirty(true);
    button2.setAutoDirty(true);

    super.attachWidgets(plugin, backgroundMain, button1, button2);
    super.setAnchor(WidgetAnchor.TOP_LEFT);
  }
Пример #2
0
  public void alignLabel(GenericLabel label, String text, int alignment) {
    int labelWidth =
        (int) ((float) GenericLabel.getStringWidth(text) * Conf.spoutTerritoryDisplaySize);
    if (labelWidth > SCREEN_WIDTH) {
      label.setX(0);
      return;
    }

    switch (alignment) {
      case 1: // left aligned
        label.setX(0);
        break;
      case 2: // center aligned
        label.setX((SCREEN_WIDTH - labelWidth) / 2);
        break;
      default: // right aligned
        label.setX(SCREEN_WIDTH - labelWidth);
    }
  }