diff --git a/src/main/java/forge/gui/home/sanctioned/CSubmenuDraft.java b/src/main/java/forge/gui/home/sanctioned/CSubmenuDraft.java index 0eb0507dd80..58f4e9fb14f 100644 --- a/src/main/java/forge/gui/home/sanctioned/CSubmenuDraft.java +++ b/src/main/java/forge/gui/home/sanctioned/CSubmenuDraft.java @@ -4,7 +4,6 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.List; -import java.util.Random; import javax.swing.JOptionPane; import javax.swing.SwingUtilities; @@ -27,7 +26,6 @@ import forge.gui.deckeditor.CDeckEditorUI; import forge.gui.deckeditor.controllers.CEditorDraftingProcess; import forge.gui.framework.ICDoc; import forge.gui.match.CMatchUI; -import forge.gui.toolbox.FSkin; /** * Controls the draft submenu in the home UI. @@ -40,47 +38,6 @@ public enum CSubmenuDraft implements ICDoc { /** */ SINGLETON_INSTANCE; - private final String[] opponentNames = new String[] { - "Abigail", "Ada", "Adeline", "Adriana", "Agatha", "Agnes", "Aileen", "Alba", "Alcyon", - "Alethea", "Alice", "Alicia", "Alison", "Amanda", "Amelia", "Amy", "Andrea", "Angelina", - "Anita", "Ann", "Annabel", "Anne", "Audrey", "Barbara", "Belinda", "Bernice", "Bertha", - "Bonnie", "Brenda", "Bridget", "Bunny", "Carmen", "Carol", "Catherine", "Cheryl", - "Christine", "Cinderalla", "Claire", "Clarice", "Claudia", "Constance", "Cora", - "Corinne", "Cnythia", "Daisy", "Daphne", "Dawn", "Deborah", "Diana", "Dolly", "Dora", - "Doreen", "Doris", "Dorothy", "Eileen", "Elaine", "Elizabeth", "Emily", "Emma", "Ethel", - "Evelyn", "Fiona", "Florence", "Frances", "Geraldine", "Gertrude", "Gladys", "Gloria", - "Grace", "Greta", "Harriet", "Hazel", "Helen", "Hilda", "Ida", "Ingrid", "Irene", - "Isabel", "Jacinta", "Jackie", "Jane", "Janet", "Janice", "Jennifer", "Jessie", "Joan", - "Jocelyn", "Josephine", "Joyce", "Judith", "Julia", "Juliana", "Karina", "Kathleen", - "Laura", "Lilian", "Lily", "Linda", "Lisa", "Lilita", "Lora", "Lorna", "Lucy", "Lydia", - "Mabel", "Madeline", "Maggie", "Maria", "Mariam", "Marilyn", "Mary", "Matilda", "Mavis", - "Melanie", "Melinda", "Melody", "Michelle", "Mildred", "Molly", "Mona", "Monica", - "Nancy", "Nora", "Norma", "Olga", "Pamela", "Patricia", "Paula", "Pauline", "Pearl", - "Peggy", "Penny", "Phoebe", "Phyllis", "Polly", "Priscilla", "Rachel", "Rebecca", - "Rita", "Rosa", "Rosalind", "Rose", "Rosemary", "Rowena", "Ruby", "Sally", "Samantha", - "Sarah", "Selina", "Sharon", "Sheila", "Shirley", "Sonya", "Stella", "Sue", "Susan", - "Sylvia", "Tina", "Tracy", "Ursula", "Valentine", "Valerie", "Vanessa", "Veronica", - "Victoria", "Violet", "Vivian", "Wendy", "Winnie", "Yvonne", "Aaron", "Abraham", "Adam", - "Adrain", "Alain", "Alan", "Alban", "Albert", "Alec", "Alexander", "Alfonso", "Alfred", - "Allan", "Allen", "Alonso", "Aloysius", "Alphonso", "Alvin", "Andrew", "Andy", "Amadeus", - "Amselm", "Anthony", "Arnold", "Augusta", "Austin", "Barnaby", "Benedict", "Benjamin", - "Bertie", "Bertram", "Bill", "Bob", "Boris", "Brady", "Brian", "Bruce", "Burt", "Byron", - "Calvin", "Carl", "Carter", "Casey", "Cecil", "Charles", "Christian", "Christopher", - "Clarence", "Clement", "Colin", "Conan", "Dalton", "Damian", "Daniel", "David", "Denis", - "Derek", "Desmond", "Dick", "Dominic", "Donald", "Douglas", "Duncan", "Edmund", - "Edward", "Ellen", "Elton", "Elvis", "Eric", "Eugene", "Felix", "Francis", "Frank", - "Frederick", "Gary", "Geoffrey", "George", "Gerald", "Gerry", "Gordon", "Hamish", - "Hardy", "Harold", "Harry", "Henry", "Herbert", "Ignatius", "Jack", "James", "Jeffrey", - "Jim", "Joe", "John", "Joseph", "Karl", "Keith", "Kenneth", "Kevin", "Larry", "Lawrence", - "Leonard", "Lionel", "Louis", "Lucas", "Malcolm", "Mark", "Martin", "Mathew", "Maurice", - "Max", "Melvin", "Michael", "Milton", "Morgan", "Morris", "Murphy", "Neville", - "Nicholas", "Noel", "Norman", "Oliver", "Oscar", "Patrick", "Paul", "Perkin", "Peter", - "Philip", "Ralph", "Randy", "Raymond", "Richard", "Ricky", "Robert", "Robin", "Rodney", - "Roger", "Roland", "Ronald", "Roy", "Sam", "Sebastian", "Simon", "Stanley", "Stephen", - "Stuart", "Terence", "Thomas", "Tim", "Tom", "Tony", "Victor", "Vincent", "Wallace", - "Walter", "Wilfred", "William", "Winston" - }; - private final Command cmdDeckSelect = new Command() { @Override public void execute() { @@ -97,9 +54,8 @@ public enum CSubmenuDraft implements ICDoc { view.getLstHumanDecks().setSelectCommand(cmdDeckSelect); - view.getBtnBuildDeck().addMouseListener( - new MouseAdapter() { @Override - public void mousePressed(MouseEvent e) { setupDraft(); } }); + view.getBtnBuildDeck().setCommand(new Command() { @Override + public void execute() { setupDraft(); } }); view.getBtnStart().addMouseListener( new MouseAdapter() { @@ -108,39 +64,11 @@ public enum CSubmenuDraft implements ICDoc { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - startGame(true); + startGame(); } }); } }); - - view.getBtnPlayThisOpponent().addMouseListener( - new MouseAdapter() { - @Override - public void mouseReleased(final MouseEvent e) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - startGame(false); - } - }); - } - }); - - view.getBtnDirections().addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - view.showDirections(); - } - @Override - public void mouseEntered(MouseEvent e) { - view.getBtnDirections().setForeground(FSkin.getColor(FSkin.Colors.CLR_HOVER)); - } - @Override - public void mouseExited(MouseEvent e) { - view.getBtnDirections().setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT)); - } - }); } /* (non-Javadoc) @@ -148,10 +76,6 @@ public enum CSubmenuDraft implements ICDoc { */ @Override public void update() { - VSubmenuDraft.SINGLETON_INSTANCE.getLstAIDecks().setListData(generateNames()); - VSubmenuDraft.SINGLETON_INSTANCE.getLstAIDecks().setSelectedIndex( - (int) Math.floor(Math.random() * VSubmenuDraft.SINGLETON_INSTANCE.getLstAIDecks().getModel().getSize())); - List human = new ArrayList(); for (DeckGroup d : Singletons.getModel().getDecks().getDraft()) { human.add(d.getHumanDeck()); @@ -164,9 +88,11 @@ public enum CSubmenuDraft implements ICDoc { } } - private void startGame(final boolean gauntlet) { + private void startGame() { + final boolean gauntlet = VSubmenuDraft.SINGLETON_INSTANCE.getRadSingle().isSelected() ? false : true; + final Deck human = VSubmenuDraft.SINGLETON_INSTANCE.getLstHumanDecks().getSelectedDeck(); - final int aiIndex = VSubmenuDraft.SINGLETON_INSTANCE.getLstAIDecks().getSelectedIndex(); + final int aiIndex = (int) Math.floor(Math.random() * 8); if (human == null) { JOptionPane.showMessageDialog(null, @@ -209,8 +135,8 @@ public enum CSubmenuDraft implements ICDoc { CMatchUI.SINGLETON_INSTANCE.initMatch(null); Singletons.getModel().getMatchState().setGameType(GameType.Draft); - GameNew.newGame( new PlayerStartsGame(AllZone.getHumanPlayer(), human), - new PlayerStartsGame(AllZone.getComputerPlayer(), aiDeck) ); + GameNew.newGame(new PlayerStartsGame(AllZone.getHumanPlayer(), human), + new PlayerStartsGame(AllZone.getComputerPlayer(), aiDeck)); return null; } @@ -256,23 +182,6 @@ public enum CSubmenuDraft implements ICDoc { CDeckEditorUI.SINGLETON_INSTANCE.setCurrentEditorController(draft); } - private String[] generateNames() { - // Generate random selection of names for display - Random generator = new Random(); - int i = opponentNames.length; - String[] ai = { - opponentNames[generator.nextInt(i)], - opponentNames[generator.nextInt(i)], - opponentNames[generator.nextInt(i)], - opponentNames[generator.nextInt(i)], - opponentNames[generator.nextInt(i)], - opponentNames[generator.nextInt(i)], - opponentNames[generator.nextInt(i)] - }; - - return ai; - } - /* (non-Javadoc) * @see forge.gui.framework.ICDoc#getCommandOnSelect() */ diff --git a/src/main/java/forge/gui/home/sanctioned/VSubmenuConstructed.java b/src/main/java/forge/gui/home/sanctioned/VSubmenuConstructed.java index 5e08b0facae..d0de9636d1f 100644 --- a/src/main/java/forge/gui/home/sanctioned/VSubmenuConstructed.java +++ b/src/main/java/forge/gui/home/sanctioned/VSubmenuConstructed.java @@ -54,8 +54,6 @@ public enum VSubmenuConstructed implements IVSubmenu { .text("Double click a non-random deck for its decklist.") .fontSize(12).build(); - private final JPanel pnlDecksHuman = new JPanel(new MigLayout("insets 0, gap 0, wrap")); - private final JPanel pnlDecksAI = new JPanel(new MigLayout("insets 0, gap 0, wrap")); private final JPanel pnlRadiosHuman = new JPanel(new MigLayout("insets 0, gap 0, wrap")); private final JPanel pnlRadiosAI = new JPanel(new MigLayout("insets 0, gap 0, wrap")); private final JPanel pnlStart = new JPanel(new MigLayout("insets 0, gap 0, wrap 2")); @@ -85,12 +83,7 @@ public enum VSubmenuConstructed implements IVSubmenu { JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); private final ExperimentalLabel btnHumanRandom = new ExperimentalLabel("Random"); - //new FLabel.Builder().text("Random").fontSize(14).opaque(true) - //.hoverable(true).build(); - private final ExperimentalLabel btnAIRandom = new ExperimentalLabel("Random"); - //new FLabel.Builder().text("Random").fontSize(14).opaque(true) - //.hoverable(true).build(); private VSubmenuConstructed() { // Radio button group: Human @@ -178,7 +171,7 @@ public enum VSubmenuConstructed implements IVSubmenu { VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(pnlRadiosHuman, "w 44%!, gap 4% 4% 20px 20px"); VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(scrDecksAI, "w 44%!, growy, pushy"); VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(scrDecksUser, "w 44%!, gap 4% 4% 0 0, growy, pushy"); - VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(pnlStart, "span 2, gap 1% 0 50px 50px, ax center"); + VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(pnlStart, "span 2, gap 0 0 50px 50px, ax center"); VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().revalidate(); VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().repaintSelf(); diff --git a/src/main/java/forge/gui/home/sanctioned/VSubmenuDraft.java b/src/main/java/forge/gui/home/sanctioned/VSubmenuDraft.java index 7befbc3d141..9686eeadeee 100644 --- a/src/main/java/forge/gui/home/sanctioned/VSubmenuDraft.java +++ b/src/main/java/forge/gui/home/sanctioned/VSubmenuDraft.java @@ -1,36 +1,32 @@ package forge.gui.home.sanctioned; -import java.awt.Rectangle; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; +import java.awt.Font; +import javax.swing.ButtonGroup; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; -import javax.swing.JTextPane; +import javax.swing.JRadioButton; import javax.swing.ListSelectionModel; import javax.swing.SwingConstants; -import javax.swing.text.SimpleAttributeSet; -import javax.swing.text.StyleConstants; -import javax.swing.text.StyledDocument; import net.miginfocom.swing.MigLayout; import forge.game.GameType; -import forge.gui.SOverlayUtils; import forge.gui.framework.DragCell; import forge.gui.framework.DragTab; import forge.gui.framework.EDocID; import forge.gui.framework.ICDoc; import forge.gui.home.EMenuGroup; import forge.gui.home.IVSubmenu; +import forge.gui.home.LblHeader; import forge.gui.home.StartButton; import forge.gui.home.VHomeUI; import forge.gui.toolbox.DeckLister; -import forge.gui.toolbox.FButton; +import forge.gui.toolbox.ExperimentalLabel; import forge.gui.toolbox.FLabel; import forge.gui.toolbox.FList; -import forge.gui.toolbox.FPanel; +import forge.gui.toolbox.FRadioButton; import forge.gui.toolbox.FScrollPane; import forge.gui.toolbox.FSkin; @@ -48,26 +44,27 @@ public enum VSubmenuDraft implements IVSubmenu { private final DragTab tab = new DragTab("Draft Mode"); /** */ - private final FLabel lblTitle = new FLabel.Builder() - .text("Sanctioned Format: Draft").fontAlign(SwingConstants.CENTER) - .fontSize(16).opaque(true).build(); + private final LblHeader lblTitle = new LblHeader("Sanctioned Format: Draft"); + private final JPanel pnlStart = new JPanel(); private final StartButton btnStart = new StartButton(); private final DeckLister lstHumanDecks = new DeckLister(GameType.Draft); private final JList lstAI = new FList(); - private final JLabel lblAI = new FLabel.Builder() - .text("Who will you play?").fontSize(16).fontAlign(SwingConstants.CENTER).build(); + private final JRadioButton radSingle = new FRadioButton("Play one opponent"); + private final JRadioButton radAll = new FRadioButton("Play all 8 opponents"); private final JLabel lblHuman = new FLabel.Builder() - .text("Select your deck:").fontSize(16).fontAlign(SwingConstants.CENTER).build(); - private final JLabel btnPlayThisOpponent = new FLabel.Builder() - .fontSize(16).opaque(true).hoverable(true).text("Play this opponent").build(); - private final JLabel btnBuildDeck = new FLabel.Builder() - .fontSize(16).opaque(true).hoverable(true).text("Start A New Draft").build(); - private final JLabel btnDirections = new FLabel.Builder() - .fontSize(16).opaque(true).hoverable(true).text("How To Play").build(); + .fontAlign(SwingConstants.LEFT).fontSize(16).fontStyle(Font.BOLD) + .text("Build or select a deck").build(); + + private final FLabel lblDirections = new FLabel.Builder() + .text("In Draft mode, three booster packs are rotated around eight players. Build a deck from the cards you choose.") + .fontSize(12).build(); + + private final ExperimentalLabel btnBuildDeck = new ExperimentalLabel("Start A New Draft"); + /** * Constructor. @@ -77,6 +74,17 @@ public enum VSubmenuDraft implements IVSubmenu { btnStart.setEnabled(false); lblTitle.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2)); + + final ButtonGroup grp = new ButtonGroup(); + grp.add(radSingle); + grp.add(radAll); + radSingle.setSelected(true); + + pnlStart.setLayout(new MigLayout("insets 0, gap 0, wrap 2")); + pnlStart.setOpaque(false); + pnlStart.add(radSingle, "w 200px!, h 30px!, gap 0 20px 0 0"); + pnlStart.add(btnStart, "span 1 2, growx, pushx"); + pnlStart.add(radAll, "w 200px!, h 30px!, gap 0 20px 0 0"); } /* (non-Javadoc) @@ -103,13 +111,8 @@ public enum VSubmenuDraft implements IVSubmenu { return EDocID.HOME_DRAFT; } - /** @return {@link javax.swing.JLabel} */ - public JLabel getBtnDirections() { - return this.btnDirections; - } - - /** @return {@link javax.swing.JLabel} */ - public JLabel getBtnBuildDeck() { + /** @return {@link forge.gui.toolbox.ExperimentalLabel} */ + public ExperimentalLabel getBtnBuildDeck() { return this.btnBuildDeck; } @@ -118,14 +121,9 @@ public enum VSubmenuDraft implements IVSubmenu { return this.btnStart; } - /** @return {@link javax.swing.JButton} */ - public JLabel getBtnPlayThisOpponent() { - return this.btnPlayThisOpponent; - } - - /** @return {@link javax.swing.JList} */ - public JList getLstAIDecks() { - return lstAI; + /** @return {@link javax.swing.JRadioButton} */ + public JRadioButton getRadSingle() { + return this.radSingle; } /** @return {@link forge.gui.toolbox.DeckLister} */ @@ -133,62 +131,6 @@ public enum VSubmenuDraft implements IVSubmenu { return lstHumanDecks; } - /** */ - public void showDirections() { - final JPanel overlay = SOverlayUtils.genericOverlay(); - final int w = overlay.getWidth(); - - final String instructions = "BOOSTER DRAFT MODE INSTRUCTIONS" - + "\r\n\r\n" - + "In a booster draft, several players (usually eight) are seated " - + "around a table and each player is given three booster packs." - + "\r\n\r\n" - + "Each player opens a pack, selects a card from it and passes the remaining " - + "cards to his or her left. Each player then selects one of the 14 remaining " - + "cards from the pack that was just passed to him or her, and passes the " - + "remaining cards to the left again. This continues until all of the cards " - + "are depleted. The process is repeated with the second and third packs, " - + "except that the cards are passed to the right in the second pack." - + "\r\n\r\n" - + "Players then build decks out of any of the cards that they selected " - + "during the drafting and add as many basic lands as they want." - + "\r\n\r\n" - + "Credit: Wikipedia"; - - // Init directions text pane - final JTextPane tpnDirections = new JTextPane(); - tpnDirections.setOpaque(false); - tpnDirections.setForeground(FSkin.getColor(FSkin.Colors.CLR_TEXT)); - tpnDirections.setFont(FSkin.getFont(15)); - tpnDirections.setAlignmentX(SwingConstants.CENTER); - tpnDirections.setFocusable(false); - tpnDirections.setEditable(false); - tpnDirections.setBorder(null); - tpnDirections.setText(instructions); - - final StyledDocument doc = tpnDirections.getStyledDocument(); - final SimpleAttributeSet center = new SimpleAttributeSet(); - StyleConstants.setAlignment(center, StyleConstants.ALIGN_CENTER); - doc.setParagraphAttributes(0, doc.getLength(), center, false); - - final JButton btnCloseBig = new FButton("OK"); - btnCloseBig.setBounds(new Rectangle((w / 2 - 100), 510, 200, 30)); - btnCloseBig.addActionListener(new ActionListener() { @Override - public void actionPerformed(final ActionEvent arg0) { SOverlayUtils.hideOverlay(); } }); - - final FPanel pnl = new FPanel(); - pnl.setCornerDiameter(0); - pnl.setBackgroundTexture(FSkin.getIcon(FSkin.Backgrounds.BG_TEXTURE)); - pnl.setLayout(new MigLayout("insets 0, gap 0")); - pnl.add(tpnDirections, "w 90%!, h 90%!, gap 5% 0 5% 0"); - pnl.setBounds(new Rectangle((w / 2 - 250), 80, 500, 400)); - - overlay.setLayout(null); - overlay.add(btnCloseBig); - overlay.add(pnl); - SOverlayUtils.showOverlay(); - } - //========== Overridden from IVDoc /* (non-Javadoc) @@ -197,20 +139,16 @@ public enum VSubmenuDraft implements IVSubmenu { @Override public void populate() { VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().removeAll(); - VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().setLayout(new MigLayout("insets 0, gap 0, wrap 2, hidemode 2")); - VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(lblTitle, "w 98%!, h 30px!, gap 1% 0 15px 15px, span 2"); + VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().setLayout(new MigLayout("insets 0, gap 0, wrap, ax right")); + VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(lblTitle, "w 80%!, h 40px!, gap 0 0 15px 15px, ax right"); - VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(lblHuman, "w 60%!, gap 1% 8% 0 15px"); - VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(lblAI, "w 30%!, gap 0 0 0 15px"); + VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(lblHuman, "w 80%!, h 30px!, gap 0 10% 20px 0"); + VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(lblDirections, "gap 0 0 0 20px"); - VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(new FScrollPane(lstHumanDecks), "w 60%!, gap 1% 8% 0 0, pushy, growy"); - VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(new FScrollPane(lstAI), "w 30%!, pushy, growy"); + VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(btnBuildDeck, "w 200px!, h 30px!, ax center, gap 0 10% 0 20px"); + VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(new FScrollPane(lstHumanDecks), "w 80%!, gap 0 10% 0 0, pushy, growy"); - VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(btnBuildDeck, "w 60%!, h 30px!, gap 1% 5% 10px 0"); - VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(btnPlayThisOpponent, "w 30%!, h 30px!, gap 0 0 10px 0"); - - VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(btnDirections, "w 200px!, h 30px!, gap 1% 0 20px 0, span 2, ax center"); - VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(btnStart, "w 98%!, gap 1% 0 50px 50px, ax center, span 2"); + VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().add(pnlStart, "gap 0 10% 50px 50px, ax center"); VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().repaint(); VHomeUI.SINGLETON_INSTANCE.getPnlDisplay().revalidate();