@Override
  public void onButtonClick(Button button) {

    if (button.equals(button1)) {
      spoutp.getMainScreen().getActivePopup().close();
      spoutp.getMainScreen().attachPopupScreen(new PrimClassesGUI(plugin, spoutp));
    } else if (button.equals(button2)) {
      spoutp.getMainScreen().getActivePopup().close();
      spoutp.getMainScreen().attachPopupScreen(new ProfClassesGUI(plugin, spoutp));
    }
  }
 private void handleScreenClose(SpoutPlayer player, ScreenCloseEvent e, boolean update) {
   PopupScreen p = player.getMainScreen().getActivePopup();
   if (update && p != null) {
     p.onScreenClose(e);
   }
   if (e.isCancelled()) {
     handleScreenCloseCancelled(player, e, false);
     return;
   }
   player.getMainScreen().closePopup();
   if (player.getItemOnCursor() != null && p != null) {
     p.handleItemOnCursor(player.getItemOnCursor());
     player.setItemOnCursor(null);
   }
 }
  private void doOwnerList(
      FPlayer player, SpoutPlayer sPlayer, FLocation here, Faction factionHere) {
    // ----------
    // Owner list
    // ----------
    if (Conf.spoutTerritoryDisplayPosition > 0
        && Conf.spoutTerritoryDisplaySize > 0
        && Conf.spoutTerritoryOwnersShow
        && Conf.ownedAreasEnabled) {
      GenericLabel label;
      if (ownerLabels.containsKey(player.getName())) label = ownerLabels.get(player.getName());
      else {
        label = new GenericLabel();
        label
            .setWidth(1)
            .setHeight(1); // prevent Spout's questionable new "no default size" warning
        label.setScale(Conf.spoutTerritoryDisplaySize);
        label.setY((int) (10 * Conf.spoutTerritoryDisplaySize));
        sPlayer.getMainScreen().attachWidget(P.p, label);
        ownerLabels.put(player.getName(), label);
      }

      String msg = "";

      if (player.getFaction() == factionHere) {
        msg = factionHere.getOwnerListString(here);

        if (!msg.isEmpty()) msg = Conf.ownedLandMessage + msg;
      }

      label.setText(msg);
      alignLabel(label, msg);
      label.setDirty(true);
    }
  }
  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);
  }
示例#5
0
 public Container getContainer(SpoutPlayer player, String anchorName, int offsetX, int offsetY) {
   int X = offsetX;
   int Y = offsetY;
   WidgetAnchor anchor = WidgetAnchor.SCALE;
   if ("TOP_LEFT".equalsIgnoreCase(anchorName)) {
     anchor = WidgetAnchor.TOP_LEFT;
   } else if ("TOP_CENTER".equalsIgnoreCase(anchorName)) {
     anchor = WidgetAnchor.TOP_CENTER;
     X -= 213;
   } else if ("TOP_RIGHT".equalsIgnoreCase(anchorName)) {
     anchor = WidgetAnchor.TOP_RIGHT;
     X = -427 - X;
   } else if ("CENTER_LEFT".equalsIgnoreCase(anchorName)) {
     anchor = WidgetAnchor.CENTER_LEFT;
     Y -= 120;
   } else if ("CENTER_CENTER".equalsIgnoreCase(anchorName)) {
     anchor = WidgetAnchor.CENTER_CENTER;
     X -= 213;
     Y -= 120;
   } else if ("CENTER_RIGHT".equalsIgnoreCase(anchorName)) {
     anchor = WidgetAnchor.CENTER_RIGHT;
     X = -427 - X;
     Y -= 120;
   } else if ("BOTTOM_LEFT".equalsIgnoreCase(anchorName)) {
     anchor = WidgetAnchor.BOTTOM_LEFT;
     Y = -240 - Y;
   } else if ("BOTTOM_CENTER".equalsIgnoreCase(anchorName)) {
     anchor = WidgetAnchor.BOTTOM_CENTER;
     X -= 213;
     Y = -240 - Y;
   } else if ("BOTTOM_RIGHT".equalsIgnoreCase(anchorName)) {
     anchor = WidgetAnchor.BOTTOM_RIGHT;
     X = -427 - X;
     Y = -240 - Y;
   }
   MMOHUDEvent event = new MMOHUDEvent(player, this, anchor, X, Y);
   this.getServer().getPluginManager().callEvent(event);
   Container container =
       (Container)
           new GenericContainer()
               .setAlign(event.getAnchor())
               .setAnchor(event.getAnchor())
               .setFixed(true)
               .setX(event.getOffsetX())
               .setY(event.getOffsetY())
               .setWidth(427)
               .setHeight(240);
   player.getMainScreen().attachWidget(this, container);
   return container;
 }
  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
  }
 private void handleScreenCloseCancelled(SpoutPlayer player, ScreenCloseEvent e, boolean update) {
   this.action = (byte) ScreenAction.Close.getId();
   PopupScreen screen = player.getMainScreen().getActivePopup();
   if (screen != null) {
     if (update) {
       screen.onScreenClose(e);
     }
     if (!e.isCancelled() && ScreenType.getType(this.screen) == ScreenType.CUSTOM_SCREEN) {
       handleScreenClose(player, e, false);
       return;
     }
     screen.setDirty(true);
     player.sendImmediatePacket(new PacketWidget(screen, screen.getId()));
   }
 }
 @Override
 public void run(int playerId) {
   SpoutPlayer player = SpoutManager.getPlayerFromId(playerId);
   ScreenEvent event;
   switch (ScreenAction.getScreenActionFromId(action)) {
     case Close:
       event =
           new ScreenCloseEvent(
               player, player.getMainScreen().getActivePopup(), ScreenType.getType(this.screen));
       Bukkit.getServer().getPluginManager().callEvent(event);
       if (event.isCancelled()) {
         handleScreenCloseCancelled(player, (ScreenCloseEvent) event, true);
       } else if (ScreenType.getType(this.screen) == ScreenType.CUSTOM_SCREEN) {
         handleScreenClose(player, (ScreenCloseEvent) event, true);
       }
       if (!event.isCancelled()) {
         player.openScreen(ScreenType.GAME_SCREEN, false);
       }
       break;
     case Open:
       event =
           new ScreenOpenEvent(
               player, player.getMainScreen().getActivePopup(), ScreenType.getType(this.screen));
       Bukkit.getServer().getPluginManager().callEvent(event);
       if (event.isCancelled()) {
         PopupScreen screen = player.getMainScreen().getActivePopup();
         if (screen != null) {
           screen.setDirty(true);
           player.sendImmediatePacket(new PacketWidget(screen, screen.getId()));
         }
       } else {
         player.openScreen(ScreenType.getType(this.screen), false);
       }
       break;
   }
 }
 @Override
 public void keyReleased(KeyBindingEvent keyBindingEvent) {
   Keyboard key = keyBindingEvent.getBinding().getDefaultKey();
   if (key == Keyboard.KEY_K) {
     SpoutPlayer p = keyBindingEvent.getPlayer();
     Screen screen = p.getMainScreen();
     if (p.getActiveScreen() == ScreenType.GAME_SCREEN) {
       if (gui.skillTreeIsOpen(screen)) {
         gui.closeSkillTree();
       } else {
         gui.openSkillTree(p);
       }
     }
   }
   if (key == Keyboard.KEY_LCONTROL) {
     SpoutPlayer p = keyBindingEvent.getPlayer();
     holdingCtrl.remove(p);
     lastWep.remove(p);
   }
 }
示例#10
0
 @EventHandler(priority = EventPriority.MONITOR)
 public void onScreenOpen(final ScreenOpenEvent event) {
   if (!event.isCancelled() && event.getScreenType() == ScreenType.CHAT_SCREEN) {
     Color black = new Color(0f, 0f, 0f, 0.5f), white = new Color(1f, 1f, 1f, 0.5f);
     SpoutPlayer player = event.getPlayer();
     Widget label, bar = chatbar.get(player);
     if (bar == null) {
       bar =
           new GenericContainer(
                   label =
                       new GenericLabel(
                               ChatColor.GRAY
                                   + Herochat.getChatterManager()
                                       .getChatter(player)
                                       .getActiveChannel()
                                       .getName())
                           .setResize(true)
                           .setFixed(true)
                           .setMargin(3, 3, 0, 3),
                   new GenericGradient(black).setPriority(RenderPriority.Highest),
                   new GenericGradient(white)
                       .setMaxWidth(1)
                       .setPriority(RenderPriority.High)
                       .setVisible(false),
                   new GenericGradient(white)
                       .setMaxWidth(1)
                       .setMarginLeft(label.getWidth() + 5)
                       .setPriority(RenderPriority.High),
                   new GenericGradient(white).setMaxHeight(1).setPriority(RenderPriority.High))
               .setLayout(ContainerType.OVERLAY)
               .setAnchor(WidgetAnchor.BOTTOM_LEFT)
               .setY(-27)
               .setX(4)
               .setHeight(13)
               .setWidth(label.getWidth() + 6);
       chatbar.put(player, bar);
       player.getMainScreen().attachWidget(this, bar);
     }
     bar.setVisible(true);
   }
 }
示例#11
0
  public void handleSpoutEditing(Player player, Sign sign) {

    if (!plugin.getSelectionHandler().checkForSelectionRights(player, sign.getBlock())) {

      QSUtil.tell(player, "You don't own this sign.");
      return;
    }

    if (!plugin.getBlackList().allows(sign, player)) {

      QSUtil.tell(player, "You cannot edit this sign: its contents are blacklisted.");
      return;
    }

    SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player);

    PopupScreen popup = new GenericPopup();

    int y = 30;
    UUID[] widgets = new UUID[5];

    for (int i = 0; i < 4; i++) {

      GenericTextField textField = new GenericTextField();

      String line0 = sign.getLine(i).replaceAll("\u00A7([0-9a-fA-Fk-oK-OrR])", "&$1");
      textField
          .setText(line0)
          .setCursorPosition(line0.length() - 1)
          .setFieldColor(new Color(0, 0, 0, 1.0F));
      textField.setBorderColor(new Color(1.0F, 1.0F, 1.0F, 1.0F));
      textField.setMaximumCharacters(15).setHeight(20).setWidth(100);
      textField.setX(170).setY(y);
      textField.setAnchor(WidgetAnchor.SCALE);
      popup.attachWidget(plugin, textField);
      y += 30;
      widgets[i] = textField.getId();
    }

    GenericButton button = new GenericButton("Done");

    button.setColor(new Color(1.0F, 1.0F, 1.0F, 1.0F));
    button.setHoverColor(new Color(1.0F, 1.0F, 0, 1.0F));
    button.setX(170).setY(150);
    button.setWidth(100).setHeight(20);
    widgets[4] = button.getId();

    popup.attachWidget(plugin, button);

    attachColorLabels(popup);

    popup.setTransparent(true);

    spoutPlayer.getMainScreen().attachPopupScreen(popup);

    SpoutEditSession session = (SpoutEditSession) plugin.getSession(player);

    session.setPopup(popup);
    session.addSign(sign);
    session.setWidgets(widgets);
  }
示例#12
0
 public void redrawAll(Player player) {
   SpoutPlayer splayer = SpoutManager.getPlayer(player);
   if (splayer.isSpoutCraftEnabled())
     for (Widget widget : splayer.getMainScreen().getAttachedWidgets())
       if ((widget.getPlugin() instanceof Features)) widget.setDirty(true);
 }
示例#13
0
  public void open() {
    player.getMainScreen().attachPopupScreen(this);

    scriptField.setText(script.getScript());
  }
示例#14
0
  private void doLabels(FPlayer player, SpoutPlayer sPlayer, boolean notify) {
    FLocation here = player.getLastStoodAt();
    Faction factionHere = Board.getFactionAt(here);
    String tag = factionHere.getColorTo(player).toString() + factionHere.getTag();

    // ----------------------
    // Main territory display
    // ----------------------
    if (Conf.spoutTerritoryDisplayPosition > 0 && Conf.spoutTerritoryDisplaySize > 0) {
      GenericLabel label;
      if (territoryLabels.containsKey(player.getName()))
        label = territoryLabels.get(player.getName());
      else {
        label = new GenericLabel();
        label
            .setWidth(1)
            .setHeight(1); // prevent Spout's questionable new "no default size" warning
        label.setScale(Conf.spoutTerritoryDisplaySize);

        sPlayer.getMainScreen().attachWidget(P.p, label);
        territoryLabels.put(player.getName(), label);
      }

      String msg = tag;

      if (Conf.spoutTerritoryDisplayShowDescription && !factionHere.getDescription().isEmpty())
        msg += " - " + factionHere.getDescription();

      label.setText(msg);
      alignLabel(label, msg);
      label.setDirty(true);
    }

    // -----------------------
    // Fading territory notice
    // -----------------------
    if (notify && Conf.spoutTerritoryNoticeShow && Conf.spoutTerritoryNoticeSize > 0) {
      NoticeLabel label;
      if (territoryChangeLabels.containsKey(player.getName()))
        label = territoryChangeLabels.get(player.getName());
      else {
        label = new NoticeLabel(Conf.spoutTerritoryNoticeLeaveAfterSeconds);
        label
            .setWidth(1)
            .setHeight(1); // prevent Spout's questionable new "no default size" warning
        label.setScale(Conf.spoutTerritoryNoticeSize);
        label.setY(Conf.spoutTerritoryNoticeTop);
        sPlayer.getMainScreen().attachWidget(P.p, label);
        territoryChangeLabels.put(player.getName(), label);
      }

      String msg = tag;

      if (Conf.spoutTerritoryNoticeShowDescription && !factionHere.getDescription().isEmpty())
        msg += " - " + factionHere.getDescription();

      label.setText(msg);
      alignLabel(label, msg, 2);
      label.resetNotice();
      label.setDirty(true);
    }

    // and owner list, of course
    doOwnerList(player, sPlayer, here, factionHere);
  }