Exemplo n.º 1
0
    void drawScreen() {

      teams.add(myTeams);
      teams.add(manageTeams, "growx");
      teams.add(new JSeparator(), "growx");

      for (Team team : Global.Teams) {
        JPanel thisTeam = team.teamPreview();
        JButton startTeam = new JButton("Draft!");
        startTeam.addActionListener(
            (ActionEvent e) -> {
              DraftScreen called = new DraftScreen(team, this);
              called.Switch();
            });
        thisTeam.add(startTeam, "east");
        thisTeam.setBorder(BorderFactory.createLineBorder(Color.black));
        teamsInner.add(thisTeam, "growx");
      }
      teams.add(teamScroll);

      players.add(myPlayers);
      players.add(managePlayers, "growx");
      players.add(new JSeparator());

      for (Player player : Global.Players) {
        JPanel thisPlayer = player.playerPreview();
        JButton modify = new JButton(ResourceRetriever.getImage("edit.png", 16, 16));
        modify.setMargin(new Insets(0, 0, 0, 0));
        modify.addActionListener(
            (ActionEvent e) -> {
              new ModifyPlayerPopup(player, this, null);
            });
        thisPlayer.add(modify, "east");
        thisPlayer.setBorder(BorderFactory.createLineBorder(Color.black));
        playersInner.add(thisPlayer, "growx");
      }
      players.add(playerScroll);

      teamDraft.add(teamDraftL, "span, center");
      teamDraft.add(teams, "grow");
      teamDraft.add(players, "grow");

      Eve.add(quick);
      Eve.add(viewAll);
      Eve.add(teamDraft, "span");

      Adam.add(Eve);
      Adam.setSize(windowSize);
    }
Exemplo n.º 2
0
    void drawScreen(Team teamPassed) {

      if (teamPassed != null) {
        // We're editing a current team
        team = teamPassed;
        for (Player player : team.getPlayers()) {
          JPanel thisPlayer = player.playerPreview();
          JButton modify = new JButton(ResourceRetriever.getImage("edit.png", 16, 16));
          modify.setMargin(new Insets(0, 0, 0, 0));
          modify.addActionListener(
              (ActionEvent e) -> {
                new ModifyPlayerPopup(player, this, null);
              });
          JButton delete = new JButton(ResourceRetriever.getImage("X.png", 16, 16));
          delete.setMargin(new Insets(0, 0, 0, 0));
          delete.addActionListener(
              (ActionEvent e) -> {
                Object[] options = {"Remove Player from team", "Delete Player", "Cancel"};
                JFrame frame = new JFrame();
                int answer =
                    JOptionPane.showOptionDialog(
                        frame,
                        "Are you sure you would like to delete \"" + player.name + "?\"",
                        "Confirm Delete",
                        JOptionPane.YES_NO_OPTION,
                        JOptionPane.QUESTION_MESSAGE,
                        Global.QUESTIONPIC,
                        options,
                        options[2]);
                if (answer == 0) {
                  team.removePlayer(player);
                  refresh();
                } else if (answer == 1) {
                  // Teams without uniqueID's don't get added to players yet,
                  //   so the player needs to be manually removed.
                  if (team.globalIndex == -1) {
                    team.removePlayer(player);
                  }
                  player.delete();
                  refresh();
                }
              });
          thisPlayer.add(delete, "east");
          thisPlayer.add(modify, "east");
          thisPlayer.setBorder(BorderFactory.createLineBorder(Color.black));
          players.add(thisPlayer, "growx");
        }
        name.setText(team.name);
      } else {
        // This is a new Team
        team = new Team("New Team");
        name.setText(team.name);
        name.setFont(new Font("Ariel", Font.PLAIN, 20));
        name.select(0, name.getText().length());
      }

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

      south.add(addPlayers);
      south.add(new JLabel("Players"));
      south.add(players, "span, grow");
      south.add(cancel, "span, right, split 2");
      south.add(save, "span, right");

      Eve.add(name);
      Eve.add(south);
    }
Exemplo n.º 3
0
    public ModifyTeamScreen(Team teamPassed, Screen callerScreen) {

      Eve.setLayout(new MigLayout("flowy", "[grow, fill]", "[][grow, fill]"));

      cancel.addActionListener(
          (ActionEvent e) -> {
            caller.Return();
          });

      save.addActionListener(
          (ActionEvent e) -> {
            team.name = name.getText();
            if (team.globalIndex == -1) {
              team.saveTeam(true);
            } else {
              team.saveTeam(false);
            }
            callerScreen.refresh();
            caller.Return();
          });
      addPlayers.setMargin(new Insets(0, 0, 0, 0));
      addPlayers.addActionListener(
          (ActionEvent e) -> {
            if (team.getPlayers().length < 5) {
              JButton cancelB = new JButton("Cancel");
              cancelB.addActionListener(
                  (ActionEvent f) -> {
                    inner.removeAll();
                    popup.dispose();
                  });
              inner.add(cancelB);
              JButton newPlayer = new JButton("New Player");
              newPlayer.addActionListener(
                  (ActionEvent f) -> {
                    inner.removeAll();
                    popup.dispose();
                    ModifyPlayerPopup addNewPlayer = new ModifyPlayerPopup(null, this, team);
                  });
              inner.add(newPlayer);
              inner.add(new JSeparator(), "growx");
              for (Player player : Global.Players) {
                boolean playerInCurrentTeam = false;
                for (Player teamPlayer : team.getPlayers()) {
                  if (teamPlayer.globalIndex == player.globalIndex) {
                    playerInCurrentTeam = true;
                    break;
                  }
                }
                if (!playerInCurrentTeam) {
                  JPanel oldPlayer = player.playerPreview();
                  JButton choose = new JButton("Add!");
                  choose.addActionListener(
                      (ActionEvent f) -> {
                        team.addPlayer(player);
                        inner.removeAll();
                        popup.dispose();
                        refresh();
                      });
                  oldPlayer.add(choose, "east");
                  oldPlayer.setBorder(BorderFactory.createLineBorder(Color.black));
                  inner.add(oldPlayer);
                }
              }
              innerScroll.getVerticalScrollBar().setUnitIncrement(16);
              innerScroll.setHorizontalScrollBarPolicy(HORIZONTAL_SCROLLBAR_NEVER);
              popup.add(innerScroll);
              popup.setSize(350, 400);
              popup.setLocation(MouseInfo.getPointerInfo().getLocation());
              popup.setVisible(true);
            } else {
              JOptionPane.showMessageDialog(
                  null,
                  "You cannot add more than 5 players per team.\nPlease remove one before adding another.");
            }
          });

      caller = callerScreen;

      drawScreen(teamPassed);
    }
Exemplo n.º 4
0
    void drawScreen() {

      Eve.add(back, "span 2");
      Eve.add(info, "spany 2, grow");
      Eve.add(addB);
      Eve.add(label);
      Eve.add(viewScroll, "span, grow");

      switch (type) {
        case "team":
          label.setText("Teams:");
          if (Global.Teams.isEmpty()) {
            view.add(new JLabel("No teams to display"));
          } else {
            for (Team team : Global.Teams) {
              JPanel thisTeam = team.teamPreview();
              JButton modify = new JButton(ResourceRetriever.getImage("edit.png", 16, 16));
              modify.setMargin(new Insets(0, 0, 0, 0));
              modify.addActionListener(
                  (ActionEvent e) -> {
                    called = new ModifyTeamScreen(team, this);
                    called.Switch();
                  });
              JButton delete = new JButton(ResourceRetriever.getImage("X.png", 16, 16));
              delete.setMargin(new Insets(0, 0, 0, 0));
              delete.addActionListener(
                  (ActionEvent e) -> {
                    Object[] options = {"Yes", "No"};
                    JFrame frame = new JFrame();
                    int answer =
                        JOptionPane.showOptionDialog(
                            frame,
                            "Are you sure you would like to delete team \"" + team.name + "?\"",
                            "Confirm Delete",
                            JOptionPane.YES_NO_OPTION,
                            JOptionPane.QUESTION_MESSAGE,
                            Global.QUESTIONPIC,
                            options,
                            options[1]);
                    if (answer == 0) {
                      team.delete();
                      refresh();
                    }
                  });
              thisTeam.add(delete, "east");
              thisTeam.add(modify, "east");
              thisTeam.setBorder(BorderFactory.createLineBorder(Color.black));
              view.add(thisTeam, "growx");
            }
          }
          break;
        case "player":
          label.setText("Players:");
          if (Global.Players.isEmpty()) {
            view.add(new JLabel("No players to display"));
          } else {
            for (Player player : Global.Players) {
              JPanel thisPlayer = player.playerPreview();
              JButton modify = new JButton(ResourceRetriever.getImage("edit.png", 16, 16));
              modify.setMargin(new Insets(0, 0, 0, 0));
              modify.addActionListener(
                  (ActionEvent e) -> {
                    new ModifyPlayerPopup(player, this, null);
                  });
              JButton delete = new JButton(ResourceRetriever.getImage("X.png", 16, 16));
              delete.setMargin(new Insets(0, 0, 0, 0));
              delete.addActionListener(
                  (ActionEvent e) -> {
                    Object[] options = {"I didn't like him anyways...", "No"};
                    JFrame frame = new JFrame();
                    int answer =
                        JOptionPane.showOptionDialog(
                            frame,
                            "Are you sure you would like to delete \"" + player.name + "?\"",
                            "Confirm Delete",
                            JOptionPane.YES_NO_OPTION,
                            JOptionPane.QUESTION_MESSAGE,
                            Global.QUESTIONPIC,
                            options,
                            options[1]);
                    if (answer == 0) {
                      player.delete();
                      refresh();
                    }
                  });
              thisPlayer.add(delete, "east");
              thisPlayer.add(modify, "east");
              thisPlayer.setBorder(BorderFactory.createLineBorder(Color.black));
              view.add(thisPlayer, "growx");
            }
          }
          break;
      }
    }