diff --git a/src/forge/GuiDisplay4.java b/src/forge/GuiDisplay4.java index 3261eec6926..64fa9c4827e 100644 --- a/src/forge/GuiDisplay4.java +++ b/src/forge/GuiDisplay4.java @@ -1,4 +1,3 @@ - package forge; @@ -58,6 +57,8 @@ import javax.swing.JTextArea; import javax.swing.ScrollPaneConstants; import javax.swing.SwingConstants; import javax.swing.SwingUtilities; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; import javax.swing.border.EtchedBorder; import javax.swing.border.TitledBorder; import javax.swing.event.ListSelectionEvent; @@ -81,20 +82,20 @@ import forge.properties.NewConstants; public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewConstants, NewConstants.GUI.GuiDisplay, NewConstants.LANG.GuiDisplay { private static final long serialVersionUID = 4519302185194841060L; - + private GuiInput inputControl; - + //Font statFont = new Font("MS Sans Serif", Font.PLAIN, 12); //Font lifeFont = new Font("MS Sans Serif", Font.PLAIN, 40); //Font checkboxFont = new Font("MS Sans Serif", Font.PLAIN, 9); - + Font statFont = new Font("Dialog", Font.PLAIN, 12); Font lifeFont = new Font("Dialog", Font.PLAIN, 40); Font checkboxFont = new Font("Dialog", Font.PLAIN, 9); - + public static Color greenColor = new Color(0, 164, 0); - + private Action HUMAN_GRAVEYARD_ACTION; private Action HUMAN_REMOVED_ACTION; private Action HUMAN_FLASHBACK_ACTION; @@ -102,45 +103,45 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo private Action COMPUTER_REMOVED_ACTION; private Action CONCEDE_ACTION; public Card cCardHQ; - + //private CardList multiBlockers = new CardList(); - + public GuiDisplay4() { setupActions(); initComponents(); - + addObservers(); addListeners(); addMenu(); inputControl = new GuiInput(); } - + @Override public void setVisible(boolean visible) { if(visible) { //causes an error if put in the constructor, causes some random null pointer exception AllZone.InputControl.updateObservers(); - + //Use both so that when "un"maximizing, the frame isn't tiny setSize(1024, 740); setExtendedState(Frame.MAXIMIZED_BOTH); } super.setVisible(visible); } - + public void assignDamage(Card attacker, CardList blockers, int damage) { new Gui_MultipleBlockers4(attacker, blockers, damage, this); } - + /* public void addAssignDamage(Card attacker, Card blocker, int damage) { - multiBlockers.add(blocker); + multiBlockers.add(blocker); } - + public void addAssignDamage(Card attacker, int damage) { //new Gui_MultipleBlockers3(attacker, blockers, damage, this); - new Gui_MultipleBlockers3(attacker, multiBlockers, damage, this); + new Gui_MultipleBlockers3(attacker, multiBlockers, damage, this); } */ @@ -148,14 +149,14 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo HUMAN_GRAVEYARD_ACTION = new ZoneAction(AllZone.Human_Graveyard, HUMAN_GRAVEYARD); HUMAN_REMOVED_ACTION = new ZoneAction(AllZone.Human_Removed, HUMAN_REMOVED); HUMAN_FLASHBACK_ACTION = new ZoneAction(AllZone.Human_Removed, HUMAN_FLASHBACK) { - + private static final long serialVersionUID = 8120331222693706164L; - + @Override protected Card[] getCards() { return CardFactoryUtil.getFlashbackUnearthCards(Constant.Player.Human).toArray(); } - + @Override protected void doAction(Card c) { SpellAbility[] sa = c.getSpellAbility(); @@ -166,14 +167,14 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo COMPUTER_REMOVED_ACTION = new ZoneAction(AllZone.Computer_Removed, COMPUTER_REMOVED); CONCEDE_ACTION = new ConcedeAction(); } - + private void addMenu() { Object[] obj = { HUMAN_GRAVEYARD_ACTION, HUMAN_REMOVED_ACTION, HUMAN_FLASHBACK_ACTION, COMPUTER_GRAVEYARD_ACTION, COMPUTER_REMOVED_ACTION, new JSeparator(), GuiDisplay4.eotCheckboxForMenu, GuiDisplay4.playsoundCheckboxForMenu, new JSeparator(), ErrorViewer.ALL_THREADS_ACTION, CONCEDE_ACTION}; - + JMenu gameMenu = new JMenu(ForgeProps.getLocalized(MENU_BAR.MENU.TITLE)); for(Object o:obj) { if(o instanceof ForgeAction) gameMenu.add(((ForgeAction) o).setupButton(new JMenuItem())); @@ -181,104 +182,123 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo else if(o instanceof Component) gameMenu.add((Component) o); else throw new AssertionError(); } - + JMenuBar menuBar = new JMenuBar(); menuBar.add(gameMenu); menuBar.add(new MenuItem_HowToPlay()); this.setJMenuBar(menuBar); }//addMenu() - + public MyButton getButtonOK() { MyButton ok = new MyButton() { public void select() { inputControl.selectButtonOK(); } - + public boolean isSelectable() { return okButton.isEnabled(); } - + public void setSelectable(boolean b) { okButton.setEnabled(b); } - + public String getText() { return okButton.getText(); } - + public void setText(String text) { okButton.setText(text); } - + public void reset() { okButton.setText("OK"); } }; - + return ok; }//getButtonOK() - + public MyButton getButtonCancel() { MyButton cancel = new MyButton() { public void select() { inputControl.selectButtonCancel(); } - + public boolean isSelectable() { return cancelButton.isEnabled(); } - + public void setSelectable(boolean b) { cancelButton.setEnabled(b); } - + public String getText() { return cancelButton.getText(); } - + public void setText(String text) { cancelButton.setText(text); } - + public void reset() { cancelButton.setText("Cancel"); } }; return cancel; }//getButtonCancel() - + public void showCombat(String message) { combatArea.setText(message); } - + public void showMessage(String s) { + + messageArea.setText(s); + messageArea.setText(s); + Border border = new EmptyBorder(1, 1, 1, 1); + + messageArea.setBorder(border); + + int thickness = 3; + + if (s.contains("Main")) + border = BorderFactory.createLineBorder(new Color(30, 0, 255), thickness); + else if (s.contains("To Block")) + border = BorderFactory.createLineBorder(new Color(13, 179, 0), thickness); + else if (s.contains("Play Instants and Abilities") ) + border = BorderFactory.createLineBorder(new Color(255, 174, 0), thickness); + else if (s.contains("Declare Attackers")) + border = BorderFactory.createLineBorder(new Color(255, 0, 0), thickness); + + messageArea.setBorder(border); } - + //returned Object could be null public T getChoiceOptional(String message, T... choices) { if(choices == null || choices.length == 0) return null; List choice = getChoices(message, 0, 1, choices); return choice.isEmpty()? null:choice.get(0); }//getChoiceOptional() - + // returned Object will never be null public T getChoice(String message, T... choices) { List choice = getChoices(message, 1, 1, choices); assert choice.size() == 1; return choice.get(0); }//getChoice() - + // returned Object will never be null public List getChoicesOptional(String message, T... choices) { return getChoices(message, 0, choices.length, choices); }//getChoice() - + // returned Object will never be null public List getChoices(String message, T... choices) { return getChoices(message, 1, choices.length, choices); }//getChoice() - + // returned Object will never be null public List getChoices(String message, int min, int max, T... choices) { ListChooser c = new ListChooser(message, min, max, choices); @@ -293,13 +313,13 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo c.show(); return c.getSelectedValues(); }//getChoice() - + private void addListeners() { //mouse Card Detail playerHandPanel.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent me) { - Card c = playerHandPanel.getCardFromMouseOverPanel(); + Card c = playerHandPanel.getCardFromMouseOverPanel(); if(c != null) { setCard(c); } @@ -307,73 +327,74 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo }); playerLandPanel.addMouseMotionListener(GuiDisplayUtil.getCardDetailMouse(this)); playerCreaturePanel.addMouseMotionListener(GuiDisplayUtil.getCardDetailMouse(this)); - + oppLandPanel.addMouseMotionListener(GuiDisplayUtil.getCardDetailMouse(this)); oppCreaturePanel.addMouseMotionListener(GuiDisplayUtil.getCardDetailMouse(this)); - + + //opponent life mouse listener oppLifeLabel.addMouseListener(new MouseAdapter() { - + @Override public void mousePressed(MouseEvent e) { inputControl.selectPlayer(Constant.Player.Computer); } }); - + //self life mouse listener playerLifeLabel.addMouseListener(new MouseAdapter() { - + @Override public void mousePressed(MouseEvent e) { inputControl.selectPlayer(Constant.Player.Human); } }); - + //self play (land) ---- Mouse playerLandPanel.addMouseListener(new MouseAdapter() { - + @Override public void mousePressed(MouseEvent e) { Object o = playerLandPanel.getComponentAt(e.getPoint()); if(o instanceof CardPanel) { CardPanel cardPanel = (CardPanel) o; - + if(cardPanel.getCard().isUntapped()) { MP3Player mp3 = new MP3Player("tap.mp3"); mp3.play(); } - + if(cardPanel.getCard().isTapped() && (inputControl.input instanceof Input_PayManaCost || inputControl.input instanceof Input_PayManaCost_Ability)) { - + while(cardPanel.connectedCard != null) { cardPanel = cardPanel.connectedCard; - + if(cardPanel.getCard().isUntapped()) { - + break; } } } - + inputControl.selectCard(cardPanel.getCard(), AllZone.Human_Play); - + } } }); //self play (no land) ---- Mouse playerCreaturePanel.addMouseListener(new MouseAdapter() { - + @Override public void mousePressed(MouseEvent e) { Object o = playerCreaturePanel.getComponentAt(e.getPoint()); if(o instanceof CardPanel) { CardPanel cardPanel = (CardPanel) o; - + CardList att = new CardList(AllZone.Combat.getAttackers()); //CardList block = AllZone.Combat.getAllBlockers(); - + if((cardPanel.getCard().isTapped() || cardPanel.getCard().hasSickness() || ((cardPanel.getCard().getKeyword().contains("Vigilance")) && att.contains(cardPanel.getCard()))) && (inputControl.input instanceof Input_Attack)) { while(cardPanel.connectedCard != null) { @@ -389,16 +410,16 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo cardPanel.getCard().untap(); AllZone.Combat.removeFromCombat(cardPanel.getCard()); } - + /* // won't work yet: else if (block.contains(cardPanel.getCard()) && inputControl.input instanceof Input_Block) { - Card crd = cardPanel.getCard(); - AllZone.Combat.removeFromCombat(crd); + Card crd = cardPanel.getCard(); + AllZone.Combat.removeFromCombat(crd); } */ - + } else inputControl.selectCard(cardPanel.getCard(), AllZone.Human_Play); @@ -407,24 +428,24 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo }); //self hand ---- Mouse playerHandPanel.addMouseListener(new MouseAdapter() { - + @Override public void mousePressed(MouseEvent e) { - if(e.getButton() != MouseEvent.BUTTON1) return; + if(e.getButton() != MouseEvent.BUTTON1) return; Card c = playerHandPanel.getCardFromMouseOverPanel(); - if(c != null) { + if(c != null) { inputControl.selectCard(c, AllZone.Human_Hand); okButton.requestFocusInWindow(); } } }); - + //***************************************************************** //computer - + //computer play (land) ---- Mouse oppLandPanel.addMouseListener(new MouseAdapter() { - + @Override public void mousePressed(MouseEvent e) { Object o = oppLandPanel.getComponentAt(e.getPoint()); @@ -434,10 +455,10 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo } } }); - + //computer play (no land) ---- Mouse oppCreaturePanel.addMouseListener(new MouseAdapter() { - + @Override public void mousePressed(MouseEvent e) { Object o = oppCreaturePanel.getComponentAt(e.getPoint()); @@ -447,19 +468,19 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo } } }); - + }//addListener() - + public Card getCard() { return detail.getCard(); } - + public void setCard(Card card) { detail.setCard(card); picture.setCard(card); } - + private void addObservers() { //Human Hand, Graveyard, and Library totals {//make sure to not interfer with anything below, since this is a very long method @@ -470,14 +491,14 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo playerLibraryValue.setText("" + AllZone.Human_Library.getCards().length); playerFBValue.setText("" + CardFactoryUtil.getFlashbackUnearthCards(Constant.Player.Human).size()); playerRemovedValue.setText("" + AllZone.Human_Removed.getCards().length); - + } }; AllZone.Human_Hand.addObserver(o); AllZone.Human_Graveyard.addObserver(o); AllZone.Human_Library.addObserver(o); } - + //opponent Hand, Graveyard, and Library totals {//make sure to not interfer with anything below, since this is a very long method Observer o = new Observer() { @@ -492,7 +513,7 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo AllZone.Computer_Graveyard.addObserver(o); AllZone.Computer_Library.addObserver(o); } - + //opponent life oppLifeLabel.setText("" + AllZone.Computer_Life.getLife()); @@ -503,20 +524,20 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo } }); AllZone.Computer_Life.updateObservers(); - + if (AllZone.QuestData != null) { - File base = ForgeProps.getFile(IMAGE_ICON); - String iconName = ""; - if (Constant.Quest.oppIconName[0] != null) { - iconName = Constant.Quest.oppIconName[0]; - File file = new File(base, iconName); - ImageIcon icon = new ImageIcon(file.toString()); - oppIconLabel.setIcon(icon); - oppIconLabel.setAlignmentX(100); - - } + File base = ForgeProps.getFile(IMAGE_ICON); + String iconName = ""; + if (Constant.Quest.oppIconName[0] != null) { + iconName = Constant.Quest.oppIconName[0]; + File file = new File(base, iconName); + ImageIcon icon = new ImageIcon(file.toString()); + oppIconLabel.setIcon(icon); + oppIconLabel.setAlignmentX(100); + + } } - + oppPCLabel.setText("Poison Counters: " + AllZone.Computer_PoisonCounter.getPoisonCounters()); AllZone.Computer_PoisonCounter.addObserver(new Observer() { public void update(Observable a, Object b) { @@ -525,7 +546,7 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo } }); AllZone.Computer_PoisonCounter.updateObservers(); - + //player life playerLifeLabel.setText("" + AllZone.Human_Life.getLife()); AllZone.Human_Life.addObserver(new Observer() { @@ -535,7 +556,7 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo } }); AllZone.Human_Life.updateObservers(); - + playerPCLabel.setText("Poison Counters: " + AllZone.Human_PoisonCounter.getPoisonCounters()); AllZone.Human_PoisonCounter.addObserver(new Observer() { public void update(Observable a, Object b) { @@ -544,7 +565,7 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo } }); AllZone.Human_PoisonCounter.updateObservers(); - + //stack AllZone.Stack.addObserver(new Observer() { public void update(Observable a, Object b) { @@ -552,36 +573,37 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo MagicStack stack = AllZone.Stack; int count = 1; JLabel label; - + for(int i = stack.size() - 1; 0 <= i; i--) { label = new JLabel("" + (count++) + ". " + stack.peek(i).getStackDescription()); - + + //update card detail final CardPanel cardPanel = new CardPanel(stack.peek(i).getSourceCard()); cardPanel.setLayout(new BorderLayout()); cardPanel.add(label); cardPanel.addMouseMotionListener(new MouseMotionAdapter() { - + @Override public void mouseMoved(MouseEvent me) { setCard(cardPanel.getCard()); }//mouseMoved }); - + stackPanel.add(cardPanel); } - + stackPanel.revalidate(); stackPanel.repaint(); - + okButton.requestFocusInWindow(); - + } }); AllZone.Stack.updateObservers(); //END, stack - + //self hand AllZone.Human_Hand.addObserver(new Observer() { @@ -589,59 +611,59 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo PlayerZone pZone = (PlayerZone) a; HandArea p = playerHandPanel; //p.removeAllCardPanels(); - + Card c[] = pZone.getCards(); - + List tmp, diff; tmp = new ArrayList(); for(arcane.ui.CardPanel cpa : p.cardPanels) - tmp.add(cpa.gameCard); + tmp.add(cpa.gameCard); diff = new ArrayList(tmp); diff.removeAll(Arrays.asList(c)); if(diff.size() == p.cardPanels.size()) - p.clear(); + p.clear(); else { - for(Card card : diff) { - p.removeCardPanel(p.getCardPanel(card.getUniqueNumber())); - } + for(Card card : diff) { + p.removeCardPanel(p.getCardPanel(card.getUniqueNumber())); + } } diff = new ArrayList(Arrays.asList(c)); diff.removeAll(tmp); - + int fromZoneX = 0, fromZoneY = 0; Rectangle pb = playerLibraryValue.getBounds(); Point zoneLocation = SwingUtilities.convertPoint(playerLibraryValue, Math.round(pb.width / 2.0f), Math.round(pb.height / 2.0f), layeredPane); - fromZoneX = zoneLocation.x; - fromZoneY = zoneLocation.y; - int startWidth, startX, startY; - startWidth = 10; - startX = fromZoneX - Math.round(startWidth / 2.0f); - startY = fromZoneY - Math.round(Math.round(startWidth * arcane.ui.CardPanel.ASPECT_RATIO) / 2.0f); - + fromZoneX = zoneLocation.x; + fromZoneY = zoneLocation.y; + int startWidth, startX, startY; + startWidth = 10; + startX = fromZoneX - Math.round(startWidth / 2.0f); + startY = fromZoneY - Math.round(Math.round(startWidth * arcane.ui.CardPanel.ASPECT_RATIO) / 2.0f); + int endWidth, endX, endY; arcane.ui.CardPanel toPanel = null; - + for(Card card : diff) { - toPanel = p.addCard(card); - endWidth = toPanel.getCardWidth(); - Point toPos = SwingUtilities.convertPoint(playerHandPanel, toPanel.getCardLocation(), layeredPane); - endX = toPos.x; - endY = toPos.y; - arcane.ui.CardPanel animationPanel = new arcane.ui.CardPanel(card); - Animation.moveCard(startX, startY, startWidth, endX, endY, endWidth, animationPanel, toPanel, layeredPane, 500); + toPanel = p.addCard(card); + endWidth = toPanel.getCardWidth(); + Point toPos = SwingUtilities.convertPoint(playerHandPanel, toPanel.getCardLocation(), layeredPane); + endX = toPos.x; + endY = toPos.y; + arcane.ui.CardPanel animationPanel = new arcane.ui.CardPanel(card); + Animation.moveCard(startX, startY, startWidth, endX, endY, endWidth, animationPanel, toPanel, layeredPane, 500); } } }); AllZone.Human_Hand.updateObservers(); //END, self hand - + //self play (land) AllZone.Human_Play.addObserver(new Observer() { public void update(Observable a, Object b) { //PlayerZone pZone = (PlayerZone) a; //unused JPanel p = playerLandPanel; p.removeAll(); - + GuiDisplayUtil.setupLandPanel(p, AllZone.Human_Play.getCards()); p.revalidate(); p.repaint(); @@ -649,7 +671,7 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo }); AllZone.Human_Play.updateObservers(); //END - self play (only land) - + //self play (no land) AllZone.Human_Play.addObserver(new Observer() { @@ -657,7 +679,7 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo //PlayerZone pZone = (PlayerZone) a; //unused JPanel p = playerCreaturePanel; p.removeAll(); - + GuiDisplayUtil.setupNoLandPanel(p, AllZone.Human_Play.getCards()); p.revalidate(); p.repaint(); @@ -665,7 +687,7 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo }); AllZone.Human_Play.updateObservers(); //END - self play (no land) - + //computer play (no land) AllZone.Computer_Play.addObserver(new Observer() { @@ -673,23 +695,23 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo //PlayerZone pZone = (PlayerZone) a; //unused JPanel p = oppCreaturePanel; p.removeAll(); - + GuiDisplayUtil.setupNoLandPanel(p, AllZone.Computer_Play.getCards()); - + p.revalidate(); p.repaint(); } }); AllZone.Computer_Play.updateObservers(); //END - computer play (no land) - + //computer play (land) AllZone.Computer_Play.addObserver(new Observer() { public void update(Observable a, Object b) { //PlayerZone pZone = (PlayerZone) a; //unused JPanel p = oppLandPanel; p.removeAll(); - + GuiDisplayUtil.setupLandPanel(p, AllZone.Computer_Play.getCards()); p.revalidate(); p.repaint(); @@ -697,9 +719,9 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo }); AllZone.Computer_Play.updateObservers(); //END - computer play (only land) - + }//addObservers() - + private void initComponents() { //Preparing the Frame setTitle(ForgeProps.getLocalized(LANG.PROGRAM_NAME)); @@ -710,7 +732,7 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo public void windowClosing(WindowEvent evt) { concede(); } - + @Override public void windowClosed(WindowEvent e) { File f = ForgeProps.getFile(LAYOUT); @@ -724,7 +746,7 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo } } }); - + //making the multi split pane Node model; File f = ForgeProps.getFile(LAYOUT); @@ -756,11 +778,11 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo } pane.getMultiSplitLayout().setFloatingDividers(false); getContentPane().add(pane); - + //adding the individual parts - + if(!Gui_NewGame.useLAFFonts.isSelected()) initFonts(pane); - + initMsgYesNo(pane); initOpp(pane); initStackCombat(pane); @@ -768,38 +790,38 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo initZones(pane); initCardPicture(pane); } - + private void initFonts(JPanel pane) { messageArea.setFont(getFont()); - + oppLifeLabel.setFont(lifeFont); - + oppPCLabel.setFont(statFont); oppLibraryLabel.setFont(statFont); - + oppHandValue.setFont(statFont); oppLibraryValue.setFont(statFont); oppRemovedValue.setFont(statFont); oppGraveValue.setFont(statFont); - + playerLifeLabel.setFont(lifeFont); playerPCLabel.setFont(statFont); - + playerHandValue.setFont(statFont); playerLibraryValue.setFont(statFont); playerRemovedValue.setFont(statFont); playerGraveValue.setFont(statFont); playerFBValue.setFont(statFont); - + combatArea.setFont(getFont()); } - + private void initMsgYesNo(JPanel pane) { // messageArea.setBorder(BorderFactory.createEtchedBorder()); messageArea.setEditable(false); messageArea.setLineWrap(true); messageArea.setWrapStyleWord(true); - + cancelButton.setText("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { @@ -811,7 +833,7 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { okButtonActionPerformed(evt); - + if(AllZone.Phase.isNeedToNextPhase() == true) { //for debugging: System.out.println("There better be no nextPhase in the stack."); AllZone.Phase.setNeedToNextPhase(false); @@ -833,16 +855,16 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo } } }); - + okButton.requestFocusInWindow(); - + //if(okButton.isEnabled()) //okButton.doClick(); JPanel yesNoPanel = new JPanel(new FlowLayout()); yesNoPanel.setBorder(new EtchedBorder()); yesNoPanel.add(cancelButton); yesNoPanel.add(okButton); - + JPanel panel = new JPanel(new BorderLayout()); JScrollPane scroll = new JScrollPane(messageArea); scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); @@ -850,39 +872,40 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo panel.add(yesNoPanel, BorderLayout.SOUTH); pane.add(new ExternalPanel(panel), "info"); } - + private void initOpp(JPanel pane) { //oppLifeLabel.setHorizontalAlignment(SwingConstants.CENTER); - + //oppPCLabel.setHorizontalAlignment(SwingConstants.TOP); oppPCLabel.setForeground(greenColor); - + JLabel oppHandLabel = new JLabel(ForgeProps.getLocalized(COMPUTER_HAND.TITLE), SwingConstants.TRAILING); if(!Gui_NewGame.useLAFFonts.isSelected()) oppHandLabel.setFont(statFont); - + //JLabel oppGraveLabel = new JLabel("Grave:", SwingConstants.TRAILING); JButton oppGraveButton = new JButton(COMPUTER_GRAVEYARD_ACTION); oppGraveButton.setText((String) COMPUTER_GRAVEYARD_ACTION.getValue("buttonText")); oppGraveButton.setMargin(new Insets(0, 0, 0, 0)); oppGraveButton.setHorizontalAlignment(SwingConstants.TRAILING); if(!Gui_NewGame.useLAFFonts.isSelected()) oppGraveButton.setFont(statFont); - + + JPanel gravePanel = new JPanel(new BorderLayout()); gravePanel.add(oppGraveButton, BorderLayout.EAST); - + JButton oppRemovedButton = new JButton(COMPUTER_REMOVED_ACTION); oppRemovedButton.setText((String) COMPUTER_REMOVED_ACTION.getValue("buttonText")); oppRemovedButton.setMargin(new Insets(0, 0, 0, 0)); //removedButton.setHorizontalAlignment(SwingConstants.TRAILING); if(!Gui_NewGame.useLAFFonts.isSelected()) oppRemovedButton.setFont(statFont); - + oppHandValue.setHorizontalAlignment(SwingConstants.LEADING); oppLibraryValue.setHorizontalAlignment(SwingConstants.LEADING); oppGraveValue.setHorizontalAlignment(SwingConstants.LEADING); oppRemovedValue.setHorizontalAlignment(SwingConstants.LEADING); - + JPanel oppNumbersPanel = new JPanel(new GridLayout(0, 2, 3, 1)); oppNumbersPanel.add(oppHandLabel); oppNumbersPanel.add(oppHandValue); @@ -892,13 +915,13 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo oppNumbersPanel.add(oppLibraryValue); oppNumbersPanel.add(gravePanel); oppNumbersPanel.add(oppGraveValue); - + oppLifeLabel.setHorizontalAlignment(SwingConstants.CENTER); - + JPanel oppIconLifePanel = new JPanel(new GridLayout(0, 1, 0, 0)); oppIconLifePanel.add(oppIconLabel); oppIconLifePanel.add(oppLifeLabel); - + JPanel oppPanel = new JPanel(); oppPanel.setBorder(new TitledBorder(new EtchedBorder(), ForgeProps.getLocalized(COMPUTER_TITLE))); oppPanel.setLayout(new BorderLayout()); @@ -909,71 +932,71 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo oppPanel.add(oppPCLabel, BorderLayout.AFTER_LAST_LINE); pane.add(new ExternalPanel(oppPanel), "compy"); } - + private void initStackCombat(JPanel pane) { stackPanel.setLayout(new GridLayout(0, 1, 10, 10)); JScrollPane stackPane = new JScrollPane(stackPanel); stackPane.setBorder(new EtchedBorder()); pane.add(new ExternalPanel(stackPane), "stack"); - + combatArea.setEditable(false); combatArea.setLineWrap(true); combatArea.setWrapStyleWord(true); - + JScrollPane combatPane = new JScrollPane(combatArea); - + combatPane.setBorder(new TitledBorder(new EtchedBorder(), ForgeProps.getLocalized(COMBAT))); pane.add(new ExternalPanel(combatPane), "combat"); } - + private void initPlayer(JPanel pane) { //int fontSize = 12; playerLifeLabel.setHorizontalAlignment(SwingConstants.CENTER); - + playerPCLabel.setForeground(greenColor); - + JLabel playerLibraryLabel = new JLabel(ForgeProps.getLocalized(HUMAN_LIBRARY.TITLE), SwingConstants.TRAILING); if(!Gui_NewGame.useLAFFonts.isSelected()) playerLibraryLabel.setFont(statFont); - + JLabel playerHandLabel = new JLabel(ForgeProps.getLocalized(HUMAN_HAND.TITLE), SwingConstants.TRAILING); if(!Gui_NewGame.useLAFFonts.isSelected()) playerHandLabel.setFont(statFont); - + //JLabel playerGraveLabel = new JLabel("Grave:", SwingConstants.TRAILING); JButton playerGraveButton = new JButton(HUMAN_GRAVEYARD_ACTION); playerGraveButton.setText((String) HUMAN_GRAVEYARD_ACTION.getValue("buttonText")); playerGraveButton.setMargin(new Insets(0, 0, 0, 0)); playerGraveButton.setHorizontalAlignment(SwingConstants.TRAILING); if(!Gui_NewGame.useLAFFonts.isSelected()) playerGraveButton.setFont(statFont); - + JButton playerFlashBackButton = new JButton(HUMAN_FLASHBACK_ACTION); playerFlashBackButton.setText((String) HUMAN_FLASHBACK_ACTION.getValue("buttonText")); playerFlashBackButton.setMargin(new Insets(0, 0, 0, 0)); playerFlashBackButton.setHorizontalAlignment(SwingConstants.TRAILING); if(!Gui_NewGame.useLAFFonts.isSelected()) playerFlashBackButton.setFont(statFont); - + JPanel gravePanel = new JPanel(new BorderLayout()); gravePanel.add(playerGraveButton, BorderLayout.EAST); - + JPanel playerFBPanel = new JPanel(new BorderLayout()); playerFBPanel.add(playerFlashBackButton, BorderLayout.EAST); - + JButton playerRemovedButton = new JButton(HUMAN_REMOVED_ACTION); playerRemovedButton.setText((String) HUMAN_REMOVED_ACTION.getValue("buttonText")); playerRemovedButton.setMargin(new Insets(0, 0, 0, 0)); //removedButton.setHorizontalAlignment(SwingConstants.TRAILING); if(!Gui_NewGame.useLAFFonts.isSelected()) playerRemovedButton.setFont(statFont); - + playerHandValue.setHorizontalAlignment(SwingConstants.LEADING); playerLibraryValue.setHorizontalAlignment(SwingConstants.LEADING); playerGraveValue.setHorizontalAlignment(SwingConstants.LEADING); playerFBValue.setHorizontalAlignment(SwingConstants.LEADING); - + //playerRemovedValue.setFont(new Font("MS Sans Serif", 0, fontSize)); playerRemovedValue.setHorizontalAlignment(SwingConstants.LEADING); - + JPanel playerNumbersPanel = new JPanel(new GridLayout(0, 2, 5, 1)); playerNumbersPanel.add(playerHandLabel); playerNumbersPanel.add(playerHandValue); @@ -985,7 +1008,7 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo playerNumbersPanel.add(playerGraveValue); playerNumbersPanel.add(playerFBPanel); playerNumbersPanel.add(playerFBValue); - + JPanel playerPanel = new JPanel(); playerPanel.setBorder(new TitledBorder(new EtchedBorder(), ForgeProps.getLocalized(HUMAN_TITLE))); playerPanel.setLayout(new BorderLayout()); @@ -994,7 +1017,7 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo playerPanel.add(playerPCLabel, BorderLayout.AFTER_LAST_LINE); pane.add(new ExternalPanel(playerPanel), "human"); } - + private void initZones(JPanel pane) { JScrollPane handScroll = new JScrollPane(); playerHandPanel = new HandArea(handScroll, this); @@ -1002,9 +1025,9 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo Dimension di = playerHandPanel.getPreferredSize(); di.height = 100; playerHandPanel.setPreferredSize(di); - handScroll.setViewportView(playerHandPanel); - pane.add(new ExternalPanel(handScroll), "humanHand"); - + handScroll.setViewportView(playerHandPanel); + pane.add(new ExternalPanel(handScroll), "humanHand"); + JPanel[] zones = {oppLandPanel, oppCreaturePanel, playerCreaturePanel, playerLandPanel}; String[] names = {"compyLand", "compyPlay", "humanPlay", "humanLand"}; for(int i = 0; i < names.length; i++) { @@ -1016,21 +1039,21 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo pane.add(new ExternalPanel(new JScrollPane(zones[i])), names[i]); } } - + private void initCardPicture(JPanel pane) { pane.add(new ExternalPanel(detail), "detail"); pane.add(new ExternalPanel(picturePanel), "picture"); picturePanel.setCardPanel(picture); } - + private void cancelButtonActionPerformed(ActionEvent evt) { inputControl.selectButtonCancel(); } - + private void okButtonActionPerformed(ActionEvent evt) { inputControl.selectButtonOK(); } - + /** * Exit the Application */ @@ -1038,28 +1061,28 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo dispose(); Constant.Runtime.WinLose.addLose(); if (!Constant.Quest.fantasyQuest[0]) - new Gui_WinLose(); + new Gui_WinLose(); else { - //new Gui_WinLose(Constant.Quest.humanList[0], Constant.Quest.computerList[0],Constant.Quest.humanLife[0], Constant.Quest.computerLife[0]); - CardList humanList = QuestUtil.getHumanPlantAndPet(AllZone.QuestData, AllZone.QuestAssignment); - CardList computerList = QuestUtil.getComputerCreatures(AllZone.QuestData, AllZone.QuestAssignment); - - int humanLife = QuestUtil.getLife(AllZone.QuestData); - int computerLife = 20; - - if (AllZone.QuestAssignment!=null) - computerLife = AllZone.QuestAssignment.getComputerLife(); - new Gui_WinLose(humanList, computerList, humanLife, computerLife); + //new Gui_WinLose(Constant.Quest.humanList[0], Constant.Quest.computerList[0],Constant.Quest.humanLife[0], Constant.Quest.computerLife[0]); + CardList humanList = QuestUtil.getHumanPlantAndPet(AllZone.QuestData, AllZone.QuestAssignment); + CardList computerList = QuestUtil.getComputerCreatures(AllZone.QuestData, AllZone.QuestAssignment); + + int humanLife = QuestUtil.getLife(AllZone.QuestData); + int computerLife = 20; + + if (AllZone.QuestAssignment!=null) + computerLife = AllZone.QuestAssignment.getComputerLife(); + new Gui_WinLose(humanList, computerList, humanLife, computerLife); } } - + public boolean stopEOT() { return eotCheckboxForMenu.isSelected(); } - + public static JCheckBoxMenuItem eotCheckboxForMenu = new JCheckBoxMenuItem("Stop at End of Turn", true); public static JCheckBoxMenuItem playsoundCheckboxForMenu = new JCheckBoxMenuItem("Play Sound", false); - + JXMultiSplitPane pane = new JXMultiSplitPane(); JButton cancelButton = new JButton(); JButton okButton = new JButton(); @@ -1073,7 +1096,7 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo HandArea playerHandPanel = null; JPanel cdPanel = new JPanel(); JLabel oppLifeLabel = new JLabel(); - JLabel oppIconLabel = new JLabel(); + JLabel oppIconLabel = new JLabel(); JLabel playerLifeLabel = new JLabel(); JLabel oppPCLabel = new JLabel(); JLabel playerPCLabel = new JLabel(); @@ -1089,35 +1112,35 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo JLabel playerGraveValue = new JLabel(); JLabel playerFBValue = new JLabel(); JLabel playerRemovedValue = new JLabel(); - + CardDetailPanel detail = new CardDetailPanel(null); ViewPanel picturePanel = new ViewPanel(); arcane.ui.CardPanel picture = new arcane.ui.CardPanel(null); JLayeredPane layeredPane = SwingUtilities.getRootPane(this).getLayeredPane(); - + private class ZoneAction extends ForgeAction { private static final long serialVersionUID = -5822976087772388839L; private PlayerZone zone; private String title; - + public ZoneAction(PlayerZone zone, String property) { super(property); title = ForgeProps.getLocalized(property + "/title"); this.zone = zone; } - + public void actionPerformed(ActionEvent e) { Card[] c = getCards(); - + if(AllZone.NameChanger.shouldChangeCardName()) c = AllZone.NameChanger.changeCard(c); - + if(c.length == 0) AllZone.Display.getChoiceOptional(title, new String[] {"no cards"}); else { Card choice = AllZone.Display.getChoiceOptional(title, c); if(choice != null) doAction(choice); } } - + /* protected PlayerZone getZone() { return zone; @@ -1126,24 +1149,24 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo protected Card[] getCards() { return zone.getCards(); } - + protected void doAction(Card c) {} } - + private class ConcedeAction extends ForgeAction { - + private static final long serialVersionUID = -6976695235601916762L; - + public ConcedeAction() { super(CONCEDE); } - + public void actionPerformed(ActionEvent e) { concede(); } } - - + + public class CustomListener extends MouseAdapter { // TODO reenable // @Override @@ -1184,7 +1207,8 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo // } // } } - + + } @@ -1193,12 +1217,12 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo class Gui_MultipleBlockers4 extends JFrame { private static final long serialVersionUID = 7622818310877381045L; - + private int assignDamage; private Card att; - private CardList blockers; + private CardList blockers; private CardContainer guiDisplay; - + private BorderLayout borderLayout1 = new BorderLayout(); private JPanel mainPanel = new JPanel(); private JScrollPane jScrollPane1 = new JScrollPane(); @@ -1206,19 +1230,19 @@ class Gui_MultipleBlockers4 extends JFrame { private JPanel jPanel3 = new JPanel(); private BorderLayout borderLayout3 = new BorderLayout(); private JPanel creaturePanel = new JPanel(); - - + + public static void main(String[] args) { CardList list = new CardList(); list.add(AllZone.CardFactory.getCard("Elvish Piper", "")); list.add(AllZone.CardFactory.getCard("Lantern Kami", "")); list.add(AllZone.CardFactory.getCard("Frostling", "")); list.add(AllZone.CardFactory.getCard("Frostling", "")); - + for(int i = 0; i < 2; i++) new Gui_MultipleBlockers4(null, list, i + 1, null); } - + Gui_MultipleBlockers4(Card attacker, CardList creatureList, int damage, CardContainer display) { this(); assignDamage = damage; @@ -1226,25 +1250,25 @@ class Gui_MultipleBlockers4 extends JFrame { guiDisplay = display; att = attacker; blockers = creatureList; - + for(int i = 0; i < creatureList.size(); i++) creaturePanel.add(new CardPanel(creatureList.get(i))); - + if (att.getKeyword().contains("Trample")) { - Card player = new Card(); - player.setName("Player"); - player.addIntrinsicKeyword("Shroud"); - player.addIntrinsicKeyword("Indestructible"); - creaturePanel.add(new CardPanel(player)); + Card player = new Card(); + player.setName("Player"); + player.addIntrinsicKeyword("Shroud"); + player.addIntrinsicKeyword("Indestructible"); + creaturePanel.add(new CardPanel(player)); } - + JDialog dialog = new JDialog(this, true); dialog.setTitle("Multiple Blockers"); dialog.setContentPane(mainPanel); dialog.setSize(470, 260); dialog.setVisible(true); } - + public Gui_MultipleBlockers4() { try { jbInit(); @@ -1254,7 +1278,7 @@ class Gui_MultipleBlockers4 extends JFrame { // setSize(470, 280); // show(); } - + private void jbInit() throws Exception { this.getContentPane().setLayout(borderLayout1); this.setTitle("Multiple Blockers"); @@ -1283,75 +1307,76 @@ class Gui_MultipleBlockers4 extends JFrame { jScrollPane1.getViewport().add(creaturePanel, null); this.getContentPane().add(mainPanel, BorderLayout.CENTER); } - + void okButton_actionPerformed(ActionEvent e) { dispose(); } - + void creaturePanel_mousePressed(MouseEvent e) { Object o = creaturePanel.getComponentAt(e.getPoint()); if(o instanceof CardPanel) { - - boolean assignedDamage = true; - + + boolean assignedDamage = true; + CardContainer cardPanel = (CardContainer) o; Card c = cardPanel.getCard(); //c.setAssignedDamage(c.getAssignedDamage() + 1); CardList cl = new CardList(); cl.add(att); - + boolean assignedLethalDamageToAllBlockers = true; - for (Card crd : blockers ) - { - if (crd.getTotalAssignedDamage() < ( crd.getNetDefense() - crd.getDamage() )) - assignedLethalDamageToAllBlockers = false; - } - - + for (Card crd : blockers ) + { + if (crd.getTotalAssignedDamage() < ( crd.getNetDefense() - crd.getDamage() )) + assignedLethalDamageToAllBlockers = false; + } + + if (c.getName().equals("Player") && att.getKeyword().contains("Trample") && assignedLethalDamageToAllBlockers) { - //what happens with Double Strike??? - if (att.getKeyword().contains("First Strike")) - AllZone.Combat.addDefendingFirstStrikeDamage(1, att); - else - AllZone.Combat.addDefendingDamage(1, att); - - AllZone.GameAction.addAssignedDamage(c, att, 1); + //what happens with Double Strike??? + if (att.getKeyword().contains("First Strike")) + AllZone.Combat.addDefendingFirstStrikeDamage(1, att); + else + AllZone.Combat.addDefendingDamage(1, att); + + AllZone.GameAction.addAssignedDamage(c, att, 1); } else if (!c.getName().equals("Player")){ - AllZone.GameAction.addAssignedDamage(c, att, /*c.getTotalAssignedDamage() +*/1); + AllZone.GameAction.addAssignedDamage(c, att, /*c.getTotalAssignedDamage() +*/1); } else - assignedDamage = false; - + assignedDamage = false; + if (assignedDamage) { - assignDamage--; - updateDamageLabel(); - if(assignDamage == 0) dispose(); + assignDamage--; + updateDamageLabel(); + if(assignDamage == 0) dispose(); } - + if(guiDisplay != null) { guiDisplay.setCard(c); } } //reduce damage, show new user message, exit if necessary - + }//creaturePanel_mousePressed() - + void updateDamageLabel() { numberLabel.setText("Assign " + assignDamage + " damage - click on card to assign damage"); } - + void creaturePanel_mouseMoved(MouseEvent e) { Object o = creaturePanel.getComponentAt(e.getPoint()); if(o instanceof CardPanel) { CardContainer cardPanel = (CardContainer) o; Card c = cardPanel.getCard(); - + if(guiDisplay != null) { guiDisplay.setCard(c); } } } } +