Esempio n. 1
0
 void refresh() {
   heroes.removeAll();
   for (Hero hero : player.getPlayList()) {
     JLabel heroLabel = new JLabel(hero.portraitSmall);
     heroLabel.addMouseListener(
         new MouseAdapter() {
           @Override
           public void mouseClicked(java.awt.event.MouseEvent evt) {
             player.removeHero(hero);
             refresh();
           }
         });
     heroes.add(heroLabel);
   }
   heroes.revalidate();
   heroes.repaint();
 }
Esempio n. 2
0
    public ModifyPlayerPopup(Player playerPassed, Screen callerScreen, Team team) {

      cancel.addActionListener(
          (ActionEvent e) -> {
            Cain.dispose();
          });

      save.addActionListener(
          (ActionEvent e) -> {
            player.name = name.getText();

            if (player.globalIndex == -1) {
              player.savePlayer();
            } else {
              Global.Players.set(player.globalIndex, player);
              player.writePlayer();
            }
            if (team != null) {
              team.addPlayer(player);
            }

            callerScreen.refresh();
            Cain.dispose();
          });

      if (playerPassed != null) {
        // We're editing a current player
        player = playerPassed;
        for (Hero hero : player.getPlayList()) {
          JLabel heroLabel = new JLabel(hero.portraitSmall);
          heroLabel.addMouseListener(
              new MouseAdapter() {
                @Override
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                  player.removeHero(hero);
                  refresh();
                }
              });
          heroes.add(heroLabel);
        }
        name.setText(player.name);
      } else {
        // This is a new Player
        Cain.setTitle("Add a player");
        player = new Player("New Player");
      }
      addHeroes.setMargin(new Insets(0, 0, 0, 0));
      addHeroes.addActionListener(
          (ActionEvent e) -> {
            pool = new PoolBuilder(false, "small", new Returner(), player.getPlayList());
            back = new JButton("Cancel");
            back.addActionListener(
                (ActionEvent p) -> {
                  inner.removeAll();
                  popup.dispose();
                });
            JLabel note = new JLabel("Right click to add multiple heroes.");
            inner.add(back, "wrap");
            inner.add(note, "wrap");
            inner.add(pool.pool, "growx");
            popup.add(inner);
            popup.setSize(700, 500);
            popup.setLocation(MouseInfo.getPointerInfo().getLocation());
            popup.setVisible(true);
          });

      name.setFont(new Font("Ariel", Font.PLAIN, 20));
      name.select(0, name.getText().length());

      heroes.setBorder(BorderFactory.createLineBorder(Color.black));

      south.add(addHeroes);
      south.add(new JLabel("Heroes"));
      south.add(heroes, "span, grow");
      south.add(cancel, "span, right, split 2");
      south.add(save, "span, right");

      Enoch.add(name);
      Enoch.add(south);

      Cain.add(Enoch);
      Cain.setMinimumSize(new Dimension(400, 350));
      Cain.setVisible(true);
    }
Esempio n. 3
0
    void drawScreen() {
      matchup.add(teamName);
      matchup.add(new JLabel("vs."));
      matchup.add(enemyName);

      myPicksFrame.add(new JLabel("picks"), "span, center, wrap");
      for (JLabel portait : myPicks) {
        myPicksPortraits.add(portait);
      }
      myPicksFrame.add(myPicksPortraits);

      theirPicks.add(new JLabel("picks"), "span, center, wrap");
      for (JLabel portait : enemyPicks) {
        theirPicksPortraits.add(portait);
      }
      theirPicks.add(theirPicksPortraits);

      myBansFrame.add(new JLabel("bans"), "span, center, wrap");
      for (JLabel portait : myBans) {
        myBansPortraits.add(portait);
      }
      myBansFrame.add(myBansPortraits);

      theirBans.add(new JLabel("bans"), "span, center, wrap");
      for (JLabel portait : enemyBans) {
        theirBansPortraits.add(portait);
      }
      theirBans.add(theirBansPortraits);

      if (team == null) {
        allyPool = new PoolBuilder(false, "small", null, null);
        players.add(allyPool.pool);
      } else {
        for (Player player : team.getPlayers()) {
          players.add(new JLabel(player.name));
          JPanel heroes = new JPanel(new MigLayout("", "[grow 49, fill][grow 1][grow 49, fill]"));
          JPanel regHeroes = new JPanel(new WrapLayout(FlowLayout.LEADING));
          JPanel stunHeroes = new JPanel(new WrapLayout(FlowLayout.LEADING));
          int numOfStuns = 0;
          for (Hero hero : player.getPlayList()) {
            if (hero.hasCharacteristic(Global.Characteristics.RSTUN)) {
              stunHeroes.add(new JLabel(hero.portraitSmall));
              numOfStuns++;
            } else {
              regHeroes.add(new JLabel(hero.portraitSmall));
            }
          }
          heroes.add(regHeroes);
          if (numOfStuns > 0) {
            heroes.add(new JSeparator(SwingConstants.VERTICAL), "growy");
            heroes.add(stunHeroes);
          }
          heroes.setBorder(BorderFactory.createLineBorder(Color.black));
          players.add(heroes);
        }
      }
      enemyPool = new PoolBuilder(false, "small", new Returner(), null);
      theirPool.add(enemyPool.pool);

      Eve.add(matchup, "span, grow");
      Eve.add(myPicksFrame, "c");
      Eve.add(theirPicks, "c");
      Eve.add(myBansFrame, "c");
      Eve.add(theirBans, "c");
      // Eve.add(players, "top, span");
      Eve.add(theirPool);
      // Eve.add(back);

      Adam.setSize(windowSize);
    }