public static void open(
      Plugin plugin, SpoutPlayer splayer) { // method used to open the GUI for a player
    GenericTexture face = new GenericTexture();

    int width = splayer.getCurrentScreen().getWidth();
    int height = splayer.getCurrentScreen().getHeight();
    face.setUrl(
        "http://landoflegend.net/forums/images/CoderGreen/site_logo.png"); // this must be a png
                                                                           // image
    face.setWidth(splayer.getCurrentScreen().getWidth() / 8)
        .setHeight(
            splayer.getCurrentScreen().getHeight()
                / 8); // you can manipulate the size of most widgets
    // face.setAnchor(WidgetAnchor.CENTER_CENTER); // the enum type WidgetAnchor provides a
    // convenience method for placing widgets
    face.setX(width / 2 - face.getWidth() / 2);
    face.setY(height - face.getHeight() - 5);

    //        GenericButton button = new GenericButton("The Drogans?!");
    //        button.setWidth(80);
    //        button.setHeight(20);
    //        button.setX(width/4);
    //        button.setY(height/2);
    //        button.setAnchor(WidgetAnchor.CENTER_LEFT);

    GenericListWidget scrollTry = new GenericListWidget();
    ListWidgetItem item = new ListWidgetItem("Drogans", "Drogans");
    scrollTry.addItem(item);

    scrollTry.setX(width / 4);
    scrollTry.setY(height / 2);

    GenericLabel label = new GenericLabel("Clans - First try");
    // label.setAnchor(WidgetAnchor.CENTER_RIGHT);
    label.setWidth(80);
    label.setHeight(40);
    label.setScale(1);
    label.setX(width / 2 - label.getWidth() / 2);
    label.setY(20);

    GenericPopup popup = new GenericPopup(); // create the popup (A popup will "free the mouse")
    popup.attachWidget(plugin, face); // attach any widgets we want to the popup
    popup.attachWidget(plugin, scrollTry);
    popup.attachWidget(plugin, label);

    //        button.set

    splayer.closeActiveWindow();
    splayer.getMainScreen().attachPopupScreen(popup); // attach the popup to the players screen
  }
Esempio n. 2
0
  public void openTabScreen() {
    tabHeader = new GenericTexture("http://i.imgur.com/t8CPF.png");
    tabHeader.setDrawAlphaChannel(true);
    tabHeader.setAnchor(WidgetAnchor.CENTER_CENTER);
    tabHeader.setWidth(212);
    tabHeader.setHeight(8);
    tabHeader.shiftYPos(-100);
    tabHeader.shiftXPos(tabHeader.getWidth() / -2 + 20);

    @SuppressWarnings({"unchecked", "rawtypes"})
    List<PlayerStats> sortedStats =
        new ArrayList(ZArena.getInstance().getGameHandler().getPlayerStats().values());
    Collections.sort(sortedStats);

    int index = 0;
    for (PlayerStats stats : sortedStats) {
      GenericTexture part = new GenericTexture("http://i.imgur.com/qvrX8.png");
      part.setDrawAlphaChannel(true);
      part.setAnchor(WidgetAnchor.CENTER_CENTER);
      part.setWidth(255);
      part.setHeight(15);
      part.shiftYPos(-90 + index * 15);
      part.shiftXPos(part.getWidth() / -2);
      part.setPriority(RenderPriority.Low);
      tabMain.add(part);

      Player player = stats.getPlayer();

      GenericLabel name = new GenericLabel(player.getName());
      name.setAnchor(WidgetAnchor.CENTER_CENTER);
      name.setAlign(WidgetAnchor.TOP_CENTER);
      name.setHeight(11);
      name.setWidth(10);
      name.shiftYPos(-86 + index * 15);
      name.shiftXPos(-75);

      GenericLabel kills = new GenericLabel(stats.getKills() + "");
      kills.setAnchor(WidgetAnchor.CENTER_CENTER);
      kills.setAlign(WidgetAnchor.TOP_CENTER);
      kills.setHeight(11);
      kills.setWidth(10);
      kills.shiftYPos(-86 + index * 15);

      GenericLabel money = new GenericLabel("$" + stats.getMoney());
      money.setAnchor(WidgetAnchor.CENTER_CENTER);
      money.setAlign(WidgetAnchor.TOP_CENTER);
      money.setHeight(11);
      money.setWidth(10);
      money.shiftYPos(-86 + index * 15);
      money.shiftXPos(50);

      GenericLabel health = new GenericLabel((stats.isAlive()) ? player.getHealth() + "" : "DEAD");
      health.setTextColor(
          (!stats.isAlive())
              ? new Color(150, 0, 0)
              : (player.getHealth() > 15)
                  ? new Color(0, 200, 0)
                  : (player.getHealth() > 10)
                      ? new Color(255, 255, 0)
                      : (player.getHealth() > 5) ? new Color(255, 140, 0) : new Color(200, 0, 0));
      health.setAnchor(WidgetAnchor.CENTER_CENTER);
      health.setAlign(WidgetAnchor.TOP_CENTER);
      health.setHeight(11);
      health.setWidth(10);
      health.shiftYPos(-86 + index * 15);
      health.shiftXPos(100);

      tabText.add(name);
      tabText.add(money);
      tabText.add(kills);
      tabText.add(health);

      index++;
    }

    ((SpoutPlayer) Bukkit.getPlayer(player))
        .getMainScreen()
        .attachWidget(ZArena.getInstance(), tabHeader);
    for (GenericTexture part : tabMain) {
      ((SpoutPlayer) Bukkit.getPlayer(player))
          .getMainScreen()
          .attachWidget(ZArena.getInstance(), part);
    }
    for (GenericLabel text : tabText) {
      ((SpoutPlayer) Bukkit.getPlayer(player))
          .getMainScreen()
          .attachWidget(ZArena.getInstance(), text);
    }
  }