From b65aa3705c87f52ccbd99b8926c45e2002371da5 Mon Sep 17 00:00:00 2001 From: jendave Date: Wed, 26 Oct 2011 08:29:38 +0000 Subject: [PATCH] checkstyle --- .gitattributes | 1 + src/main/java/forge/gui/input/Input.java | 87 +++--- .../java/forge/gui/input/InputControl.java | 167 +++++++---- .../java/forge/gui/input/Input_Attack.java | 41 ++- .../java/forge/gui/input/Input_Block.java | 55 ++-- .../java/forge/gui/input/Input_Cleanup.java | 23 +- .../java/forge/gui/input/Input_Mulligan.java | 64 +++-- .../forge/gui/input/Input_PassPriority.java | 34 ++- .../forge/gui/input/Input_PayManaCost.java | 113 +++++--- .../gui/input/Input_PayManaCostUtil.java | 178 +++++++----- .../gui/input/Input_PayManaCost_Ability.java | 120 +++++--- .../java/forge/gui/input/package-info.java | 2 +- src/main/java/forge/gui/skin/FButton.java | 92 ++++--- src/main/java/forge/gui/skin/FPanel.java | 54 ++-- .../java/forge/gui/skin/FRoundedPanel.java | 259 ++++++++++-------- src/main/java/forge/gui/skin/FSkin.java | 256 ++++++++++------- .../java/forge/gui/skin/package-info.java | 2 + 17 files changed, 942 insertions(+), 606 deletions(-) create mode 100644 src/main/java/forge/gui/skin/package-info.java diff --git a/.gitattributes b/.gitattributes index 922352762f5..2e4f9f57f11 100644 --- a/.gitattributes +++ b/.gitattributes @@ -10474,6 +10474,7 @@ src/main/java/forge/gui/skin/FButton.java -text src/main/java/forge/gui/skin/FPanel.java -text src/main/java/forge/gui/skin/FRoundedPanel.java -text src/main/java/forge/gui/skin/FSkin.java -text +src/main/java/forge/gui/skin/package-info.java svneol=native#text/plain src/main/java/forge/item/BoosterPack.java -text src/main/java/forge/item/CardDb.java -text src/main/java/forge/item/CardPrinted.java -text diff --git a/src/main/java/forge/gui/input/Input.java b/src/main/java/forge/gui/input/Input.java index 806ce608506..d4b95654843 100644 --- a/src/main/java/forge/gui/input/Input.java +++ b/src/main/java/forge/gui/input/Input.java @@ -5,64 +5,81 @@ import forge.Card; import forge.Player; import forge.PlayerZone; - /** - *

Abstract Input class.

- * + *

+ * Abstract Input class. + *

+ * * @author Forge * @version $Id$ */ public abstract class Input implements java.io.Serializable { - /** Constant serialVersionUID=-6539552513871194081L */ + /** Constant serialVersionUID=-6539552513871194081L. */ private static final long serialVersionUID = -6539552513871194081L; private boolean isFree = false; - //showMessage() is always the first method called + // showMessage() is always the first method called /** - *

showMessage.

+ *

+ * showMessage. + *

*/ public void showMessage() { AllZone.getDisplay().showMessage("Blank Input"); } /** - *

selectCard.

- * - * @param c a {@link forge.Card} object. - * @param zone a {@link forge.PlayerZone} object. + *

+ * selectCard. + *

+ * + * @param c + * a {@link forge.Card} object. + * @param zone + * a {@link forge.PlayerZone} object. */ - public void selectCard(Card c, PlayerZone zone) { + public void selectCard(final Card c, final PlayerZone zone) { } /** - *

selectPlayer.

- * - * @param player a {@link forge.Player} object. + *

+ * selectPlayer. + *

+ * + * @param player + * a {@link forge.Player} object. */ public void selectPlayer(final Player player) { } /** - *

selectButtonOK.

+ *

+ * selectButtonOK. + *

*/ public void selectButtonOK() { } /** - *

selectButtonCancel.

+ *

+ * selectButtonCancel. + *

*/ public void selectButtonCancel() { } - //helper methods, since they are used alot - //to be used by anything in CardFactory like SetTargetInput - //NOT TO BE USED by Input_Main or any of the "regular" Inputs objects that are not set using AllZone.getInputControl().setInput(Input) + // helper methods, since they are used alot + // to be used by anything in CardFactory like SetTargetInput + // NOT TO BE USED by Input_Main or any of the "regular" Inputs objects that + // are not set using AllZone.getInputControl().setInput(Input) /** - *

stop.

+ *

+ * stop. + *

*/ final public void stop() { - //clears a "temp" Input like Input_PayManaCost if there is one + // clears a "temp" Input like Input_PayManaCost if there is one AllZone.getInputControl().resetInput(); if (AllZone.getPhase().isNeedToNextPhase()) { @@ -72,11 +89,14 @@ public abstract class Input implements java.io.Serializable { } } - //exits the "current" Input and sets the next Input + // exits the "current" Input and sets the next Input /** - *

stopSetNext.

- * - * @param in a {@link forge.gui.input.Input} object. + *

+ * stopSetNext. + *

+ * + * @param in + * a {@link forge.gui.input.Input} object. */ final public void stopSetNext(Input in) { stop(); @@ -87,20 +107,25 @@ public abstract class Input implements java.io.Serializable { @Override public String toString() { return "blank"; - }//returns the Input name like "EmptyStack" + }// returns the Input name like "EmptyStack" /** - *

setFree.

- * - * @param isFree a boolean. + *

+ * setFree. + *

+ * + * @param isFree + * a boolean. */ public void setFree(boolean isFree) { this.isFree = isFree; } /** - *

isFree.

- * + *

+ * isFree. + *

+ * * @return a boolean. */ public boolean isFree() { diff --git a/src/main/java/forge/gui/input/InputControl.java b/src/main/java/forge/gui/input/InputControl.java index fbdd4db2529..62657ce95fc 100644 --- a/src/main/java/forge/gui/input/InputControl.java +++ b/src/main/java/forge/gui/input/InputControl.java @@ -1,6 +1,5 @@ package forge.gui.input; - import java.util.LinkedList; import java.util.Stack; @@ -12,53 +11,67 @@ import forge.Player; import forge.model.FModel; /** - *

InputControl class.

- * + *

+ * InputControl class. + *

+ * * @author Forge * @version $Id$ */ public class InputControl extends MyObservable implements java.io.Serializable { - /** Constant serialVersionUID=3955194449319994301L */ + /** Constant serialVersionUID=3955194449319994301L. */ private static final long serialVersionUID = 3955194449319994301L; private Input input; - /** Constant n=0 */ + + /** Constant n=0. */ static int n = 0; private Stack inputStack = new Stack(); private Stack resolvingStack = new Stack(); private LinkedList resolvingQueue = new LinkedList(); private final FModel model; - private ComputerAI_Input aiInput; // initialized at runtime to be the latest object created + private ComputerAI_Input aiInput; // initialized at runtime to be the latest + // object created /** - * TODO: Write javadoc for Constructor. - * @param model + * TODO Write javadoc for Constructor. + * + * @param fModel + * the f model */ - public InputControl(FModel fModel) { + public InputControl(final FModel fModel) { model = fModel; } /** - *

Setter for the field input.

- * - * @param in a {@link forge.gui.input.Input} object. + *

+ * Setter for the field input. + *

+ * + * @param in + * a {@link forge.gui.input.Input} object. */ - public void setInput(final Input in) { - if (model.getGameState().getStack().getResolving() || !(input == null || input instanceof Input_PassPriority)) + public final void setInput(final Input in) { + if (model.getGameState().getStack().getResolving() || !(input == null || input instanceof Input_PassPriority)) { inputStack.add(in); - else + } else { input = in; + } updateObservers(); } /** - *

Setter for the field input.

- * - * @param in a {@link forge.gui.input.Input} object. - * @param bAddToResolving a boolean. + *

+ * Setter for the field input. + *

+ * + * @param in + * a {@link forge.gui.input.Input} object. + * @param bAddToResolving + * a boolean. */ - public void setInput(final Input in, boolean bAddToResolving) { + public final void setInput(final Input in, final boolean bAddToResolving) { // Make this if (!bAddToResolving) { setInput(in); @@ -71,9 +84,12 @@ public class InputControl extends MyObservable implements java.io.Serializable { } /** - *

changeInput.

- * - * @param in a {@link forge.gui.input.Input} object. + *

+ * changeInput. + *

+ * + * @param in + * a {@link forge.gui.input.Input} object. */ private void changeInput(final Input in) { input = in; @@ -81,71 +97,84 @@ public class InputControl extends MyObservable implements java.io.Serializable { } /** - *

Getter for the field input.

- * + *

+ * Getter for the field input. + *

+ * * @return a {@link forge.gui.input.Input} object. */ - public Input getInput() { + public final Input getInput() { return input; } /** - *

clearInput.

+ *

+ * clearInput. + *

*/ - public void clearInput() { + public final void clearInput() { input = null; resolvingQueue.clear(); inputStack.clear(); } /** - *

resetInput.

+ *

+ * resetInput. + *

*/ - public void resetInput() { + public final void resetInput() { input = null; updateObservers(); } /** - *

resetInput.

- * - * @param update a boolean. + *

+ * resetInput. + *

+ * + * @param update + * a boolean. */ - public void resetInput(boolean update) { + public final void resetInput(final boolean update) { input = null; - if (update) + if (update) { updateObservers(); + } } /** - *

updateInput.

- * + *

+ * updateInput. + *

+ * * @return a {@link forge.gui.input.Input} object. */ - public Input updateInput() { + public final Input updateInput() { final String phase = model.getGameState().getPhase().getPhase(); final Player playerTurn = model.getGameState().getPhase().getPlayerTurn(); final Player priority = model.getGameState().getPhase().getPriorityPlayer(); - // TODO: this resolving portion needs more work, but fixes Death Cloud issues + // TODO this resolving portion needs more work, but fixes Death Cloud + // issues if (resolvingStack.size() > 0) { if (input != null) { return input; } - // if an SA is resolving, only change input for something that is part of the resolving SA + // if an SA is resolving, only change input for something that is + // part of the resolving SA changeInput(resolvingStack.pop()); return input; } - if (model.getGameState().getStack().getResolving()) + if (model.getGameState().getStack().getResolving()) { return null; + } - - if (input != null) + if (input != null) { return input; - - else if (inputStack.size() > 0) { // incoming input to Control + } else if (inputStack.size() > 0) { // incoming input to Control changeInput(inputStack.pop()); return input; } @@ -156,16 +185,19 @@ public class InputControl extends MyObservable implements java.io.Serializable { return updateInput(); } - // If the Phase we're in doesn't allow for Priority, return null to move to next phase - if (model.getGameState().getPhase().isNeedToNextPhase()) + // If the Phase we're in doesn't allow for Priority, return null to move + // to next phase + if (model.getGameState().getPhase().isNeedToNextPhase()) { return null; + } - // Special Inputs needed for the following phases: + // Special Inputs needed for the following phases: if (phase.equals(Constant.Phase.Combat_Declare_Attackers)) { model.getGameState().getStack().freezeStack(); - if (playerTurn.isHuman()) + if (playerTurn.isHuman()) { return new Input_Attack(); + } } else if (phase.equals(Constant.Phase.Combat_Declare_Blockers)) { model.getGameState().getStack().freezeStack(); if (playerTurn.isHuman()) { @@ -176,33 +208,48 @@ public class InputControl extends MyObservable implements java.io.Serializable { // no active attackers, skip the Blocking phase model.getGameState().getPhase().setNeedToNextPhase(true); return null; - } else + } else { return new Input_Block(); + } } - } else if (phase.equals(Constant.Phase.Cleanup)) // Player needs to discard - if (model.getGameState().getStack().size() == 0) // fall through to resolve things like Madness + } else if (phase.equals(Constant.Phase.Cleanup)) { + // discard + if (model.getGameState().getStack().size() == 0) { + // resolve things + // like Madness return new Input_Cleanup(); + } + } // ********************* - // Special phases handled above, everything else is handled simply by priority + // Special phases handled above, everything else is handled simply by + // priority if (priority.isHuman()) { boolean skip = model.getGameState().getPhase().doSkipPhase(); model.getGameState().getPhase().setSkipPhase(false); - if (model.getGameState().getStack().size() == 0 && !forge.AllZone.getDisplay().stopAtPhase(playerTurn, phase) && skip) { + if (model.getGameState().getStack().size() == 0 + && !forge.AllZone.getDisplay().stopAtPhase(playerTurn, phase) && skip) { model.getGameState().getPhase().passPriority(); return null; - } else + } else { return new Input_PassPriority(); - } else if (playerTurn.isComputer()) + } + } else if (playerTurn.isComputer()) { return aiInput; - else { + } else { aiInput.getComputer().stack_not_empty(); return null; } - }//getInput() + }// getInput() - public void setComputer(ComputerAI_Input computerAI_Input) { + /** + * Sets the computer. + * + * @param computerAI_Input + * the new computer + */ + public final void setComputer(final ComputerAI_Input computerAI_Input) { aiInput = computerAI_Input; } -}//InputControl +}// InputControl diff --git a/src/main/java/forge/gui/input/Input_Attack.java b/src/main/java/forge/gui/input/Input_Attack.java index 2e486498ec7..7a93ed61051 100644 --- a/src/main/java/forge/gui/input/Input_Attack.java +++ b/src/main/java/forge/gui/input/Input_Attack.java @@ -11,12 +11,11 @@ import forge.Constant.Zone; import forge.GameActionUtil; import forge.PlayerZone; - - - /** - *

Input_Attack class.

- * + *

+ * Input_Attack class. + *

+ * * @author Forge * @version $Id$ */ @@ -48,8 +47,7 @@ public class Input_Attack extends Input { possibleAttackers = possibleAttackers.getType("Creature"); for (int i = 0; i < possibleAttackers.size(); i++) { Card c = possibleAttackers.get(i); - if (c.hasKeyword("CARDNAME attacks each turn if able.") - && CombatUtil.canAttack(c, AllZone.getCombat()) + if (c.hasKeyword("CARDNAME attacks each turn if able.") && CombatUtil.canAttack(c, AllZone.getCombat()) && !c.isAttacking()) { AllZone.getCombat().addAttacker(c); @@ -84,14 +82,23 @@ public class Input_Attack extends Input { && CombatUtil.canAttack(card, AllZone.getCombat())) { - // TODO add the propaganda code here and remove it in Phase.nextPhase() + // TODO add the propaganda code here and remove it in + // Phase.nextPhase() // if (!CombatUtil.checkPropagandaEffects(card)) // return; AllZone.getCombat().addAttacker(card); - AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers(); // just to make sure the attack symbol is marked + AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers(); // just + // to + // make + // sure + // the + // attack + // symbol + // is + // marked - //for Castle Raptors, since it gets a bonus if untapped + // for Castle Raptors, since it gets a bonus if untapped for (String effect : AllZone.getStaticEffects().getStateBasedMap().keySet()) { Command com = GameActionUtil.commands.get(effect); com.execute(); @@ -99,13 +106,17 @@ public class Input_Attack extends Input { CombatUtil.showCombat(); } - } //selectCard() + } // selectCard() /** - *

unselectCard.

- * - * @param card a {@link forge.Card} object. - * @param zone a {@link forge.PlayerZone} object. + *

+ * unselectCard. + *

+ * + * @param card + * a {@link forge.Card} object. + * @param zone + * a {@link forge.PlayerZone} object. */ public void unselectCard(final Card card, final PlayerZone zone) { diff --git a/src/main/java/forge/gui/input/Input_Block.java b/src/main/java/forge/gui/input/Input_Block.java index 5a02c32e0d4..78135e5236f 100644 --- a/src/main/java/forge/gui/input/Input_Block.java +++ b/src/main/java/forge/gui/input/Input_Block.java @@ -12,10 +12,11 @@ import forge.Constant; import forge.GameActionUtil; import forge.PlayerZone; - /** - *

Input_Block class.

- * + *

+ * Input_Block class. + *

+ * * @author Forge * @version $Id$ */ @@ -27,9 +28,12 @@ public class Input_Block extends Input { private ArrayList allBlocking = new ArrayList(); /** - *

removeFromAllBlocking.

- * - * @param c a {@link forge.Card} object. + *

+ * removeFromAllBlocking. + *

+ * + * @param c + * a {@link forge.Card} object. */ public final void removeFromAllBlocking(final Card c) { allBlocking.remove(c); @@ -38,37 +42,33 @@ public class Input_Block extends Input { /** {@inheritDoc} */ @Override public final void showMessage() { - //for Castle Raptors, since it gets a bonus if untapped + // for Castle Raptors, since it gets a bonus if untapped for (String effect : AllZone.getStaticEffects().getStateBasedMap().keySet()) { Command com = GameActionUtil.commands.get(effect); com.execute(); } - //could add "Reset Blockers" button + // could add "Reset Blockers" button ButtonUtil.enableOnlyOK(); - if (currentAttacker == null) { /* - //Lure - CardList attackers = new CardList(AllZone.getCombat().getAttackers()); - for(Card attacker:attackers) { - if(attacker.hasKeyword("All creatures able to block CARDNAME do so.")) { - CardList bls = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); - for(Card bl:bls) { - if(CombatUtil.canBlock(attacker, bl, AllZone.getCombat())) { - allBlocking.add(bl); - AllZone.getCombat().addBlocker(attacker, bl); - } - } - } - }*/ + * //Lure CardList attackers = new + * CardList(AllZone.getCombat().getAttackers()); for(Card + * attacker:attackers) { + * if(attacker.hasKeyword("All creatures able to block CARDNAME do so." + * )) { CardList bls = + * AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + * for(Card bl:bls) { if(CombatUtil.canBlock(attacker, bl, + * AllZone.getCombat())) { allBlocking.add(bl); + * AllZone.getCombat().addBlocker(attacker, bl); } } } } + */ AllZone.getDisplay().showMessage("To Block, click on your Opponents attacker first, then your blocker(s)"); } else { String attackerName = currentAttacker.isFaceDown() ? "Morph" : currentAttacker.getName(); - AllZone.getDisplay().showMessage("Select a creature to block " + attackerName + " (" - + currentAttacker.getUniqueNumber() + ") "); + AllZone.getDisplay().showMessage( + "Select a creature to block " + attackerName + " (" + currentAttacker.getUniqueNumber() + ") "); } CombatUtil.showCombat(); @@ -88,17 +88,16 @@ public class Input_Block extends Input { /** {@inheritDoc} */ @Override public final void selectCard(final Card card, final PlayerZone zone) { - //is attacking? + // is attacking? if (CardUtil.toList(AllZone.getCombat().getAttackers()).contains(card)) { currentAttacker = card; } else if (zone.is(Constant.Zone.Battlefield, AllZone.getHumanPlayer()) && card.isCreature() - && CombatUtil.canBlock(currentAttacker, card, AllZone.getCombat())) - { + && CombatUtil.canBlock(currentAttacker, card, AllZone.getCombat())) { if (currentAttacker != null && (!allBlocking.contains(card))) { allBlocking.add(card); AllZone.getCombat().addBlocker(currentAttacker, card); } } showMessage(); - } //selectCard() + } // selectCard() } diff --git a/src/main/java/forge/gui/input/Input_Cleanup.java b/src/main/java/forge/gui/input/Input_Cleanup.java index 00cdcef60cc..6d84f0e3a41 100644 --- a/src/main/java/forge/gui/input/Input_Cleanup.java +++ b/src/main/java/forge/gui/input/Input_Cleanup.java @@ -8,11 +8,11 @@ import forge.Constant; import forge.Constant.Zone; import forge.PlayerZone; - - /** - *

Input_Cleanup class.

- * + *

+ * Input_Cleanup class. + *

+ * * @author Forge * @version $Id$ */ @@ -31,18 +31,20 @@ public class Input_Cleanup extends Input { ButtonUtil.disableAll(); int n = AllZone.getHumanPlayer().getCardsIn(Zone.Hand).size(); - //MUST showMessage() before stop() or it will overwrite the next Input's message + // MUST showMessage() before stop() or it will overwrite the next + // Input's message StringBuffer sb = new StringBuffer(); sb.append("Cleanup Phase: You can only have a maximum of ").append(AllZone.getHumanPlayer().getMaxHandSize()); sb.append(" cards, you currently have ").append(n).append(" cards in your hand - select a card to discard"); AllZone.getDisplay().showMessage(sb.toString()); - //goes to the next phase + // goes to the next phase if (n <= AllZone.getHumanPlayer().getMaxHandSize() || AllZone.getHumanPlayer().getMaxHandSize() == -1) { CombatUtil.removeAllDamage(); AllZone.getPhase().setNeedToNextPhase(true); - AllZone.getPhase().nextPhase(); // TODO keep an eye on this code, see if we can get rid of it. + AllZone.getPhase().nextPhase(); // TODO keep an eye on this code, + // see if we can get rid of it. } } @@ -55,11 +57,12 @@ public class Input_Cleanup extends Input { showMessage(); } } - } //selectCard() - + } // selectCard() /** - *

AI_CleanupDiscard.

+ *

+ * AI_CleanupDiscard. + *

*/ public void AI_CleanupDiscard() { int size = AllZone.getComputerPlayer().getCardsIn(Zone.Hand).size(); diff --git a/src/main/java/forge/gui/input/Input_Mulligan.java b/src/main/java/forge/gui/input/Input_Mulligan.java index a83e5a8b6c8..e346b318068 100644 --- a/src/main/java/forge/gui/input/Input_Mulligan.java +++ b/src/main/java/forge/gui/input/Input_Mulligan.java @@ -19,8 +19,10 @@ import forge.game.GamePlayerRating; import forge.quest.data.QuestData; /** - *

Input_Mulligan class.

- * + *

+ * Input_Mulligan class. + *

+ * * @author Forge * @version $Id$ */ @@ -49,16 +51,25 @@ public class Input_Mulligan extends Input { /** * * TODO Write javadoc for this method. - * @param player a Player object - * @param playerRating a GamePlayerRating object + * + * @param player + * a Player object + * @param playerRating + * a GamePlayerRating object * @return an int */ public final int doMulligan(final Player player, final GamePlayerRating playerRating) { CardList hand = player.getCardsIn(Zone.Hand); - for (Card c : hand) { AllZone.getGameAction().moveToLibrary(c); } - for (int i = 0; i < MAGIC_NUMBER_OF_SHUFFLES; i++) { player.shuffle(); } + for (Card c : hand) { + AllZone.getGameAction().moveToLibrary(c); + } + for (int i = 0; i < MAGIC_NUMBER_OF_SHUFFLES; i++) { + player.shuffle(); + } int newHand = hand.size() - 1; - for (int i = 0; i < newHand; i++) { player.drawCard(); } + for (int i = 0; i < newHand; i++) { + player.drawCard(); + } playerRating.notifyHasMulliganed(); playerRating.notifyOpeningHandSize(newHand); return newHand; @@ -69,7 +80,7 @@ public class Input_Mulligan extends Input { public final void selectButtonCancel() { Player humanPlayer = AllZone.getHumanPlayer(); GamePlayerRating humanRating = AllZone.getGameInfo().getPlayerRating(humanPlayer.getName()); - + int newHand = doMulligan(humanPlayer, humanRating); QuestData quest = AllZone.getQuestData(); @@ -81,18 +92,21 @@ public class Input_Mulligan extends Input { if (newHand == 0) { end(); } - } //selectButtonOK() + } // selectButtonOK() /** - *

end.

+ *

+ * end. + *

*/ final void end() { - //Computer mulligan + // Computer mulligan Player aiPlayer = AllZone.getComputerPlayer(); GamePlayerRating aiRating = AllZone.getGameInfo().getPlayerRating(aiPlayer.getName()); boolean aiTakesMulligan = true; - //Computer mulligans if there are no cards with converted mana cost of 0 in its hand + // Computer mulligans if there are no cards with converted mana cost of + // 0 in its hand while (aiTakesMulligan) { CardList handList = aiPlayer.getCardsIn(Zone.Hand); @@ -104,7 +118,7 @@ public class Input_Mulligan extends Input { } } - //Human Leylines & Chancellors + // Human Leylines & Chancellors ButtonUtil.reset(); AbilityFactory af = new AbilityFactory(); CardList humanOpeningHand = AllZone.getHumanPlayer().getCardsIn(Zone.Hand); @@ -119,7 +133,8 @@ public class Input_Mulligan extends Input { SpellAbility effect = af.getAbility(c.getSVar(effName), c); if (GameActionUtil.showYesNoDialog(c, "Use this card's ability?")) { - //If we ever let the AI memorize cards in the players hand, this would be a place to do so. + // If we ever let the AI memorize cards in the players + // hand, this would be a place to do so. AllZone.getGameAction().playSpellAbility_NoStack(effect, false); } } @@ -131,7 +146,7 @@ public class Input_Mulligan extends Input { } } - //Computer Leylines & Chancellors + // Computer Leylines & Chancellors CardList aiOpeningHand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); for (Card c : aiOpeningHand) { if (!c.getName().startsWith("Leyline")) { @@ -144,28 +159,27 @@ public class Input_Mulligan extends Input { SpellAbility effect = af.getAbility(c.getSVar(effName), c); - //Is there a better way for the AI to decide this? + // Is there a better way for the AI to decide this? if (effect.doTrigger(false)) { - GameActionUtil.showInfoDialg("Computer reveals " - + c.getName() + "(" + c.getUniqueNumber() + ")."); + GameActionUtil.showInfoDialg("Computer reveals " + c.getName() + "(" + c.getUniqueNumber() + + ")."); ComputerUtil.playNoStack(effect); } } } } - if (c.getName().startsWith("Leyline") && !(c.getName().startsWith("Leyline of Singularity") - && AllZoneUtil.getCardsIn(Zone.Battlefield, "Leyline of Singularity").size() > 0)) - { + if (c.getName().startsWith("Leyline") + && !(c.getName().startsWith("Leyline of Singularity") && AllZoneUtil.getCardsIn(Zone.Battlefield, + "Leyline of Singularity").size() > 0)) { AllZone.getGameAction().moveToPlay(c); AllZone.getGameAction().checkStateEffects(); } } AllZone.getGameAction().checkStateEffects(); - - if (AllZone.getGameAction().isStartCut() && !(humanOpeningHand.contains(AllZone.getGameAction().getHumanCut()) - || aiOpeningHand.contains(AllZone.getGameAction().getComputerCut()))) - { + if (AllZone.getGameAction().isStartCut() + && !(humanOpeningHand.contains(AllZone.getGameAction().getHumanCut()) || aiOpeningHand.contains(AllZone + .getGameAction().getComputerCut()))) { AllZone.getGameAction().moveTo(AllZone.getHumanPlayer().getZone(Constant.Zone.Library), AllZone.getGameAction().getHumanCut()); AllZone.getGameAction().moveTo(AllZone.getComputerPlayer().getZone(Constant.Zone.Library), diff --git a/src/main/java/forge/gui/input/Input_PassPriority.java b/src/main/java/forge/gui/input/Input_PassPriority.java index 77e5cb86637..d3b2e4fffde 100644 --- a/src/main/java/forge/gui/input/Input_PassPriority.java +++ b/src/main/java/forge/gui/input/Input_PassPriority.java @@ -1,20 +1,27 @@ package forge.gui.input; -import forge.*; +import forge.AllZone; +import forge.ButtonUtil; +import forge.Card; +import forge.GuiDisplayUtil; +import forge.Player; +import forge.PlayerZone; /** - *

Input_PassPriority class.

- * + *

+ * Input_PassPriority class. + *

+ * * @author Forge * @version $Id$ */ public class Input_PassPriority extends Input implements java.io.Serializable { - /** Constant serialVersionUID=-581477682214137181L */ + /** Constant serialVersionUID=-581477682214137181L. */ private static final long serialVersionUID = -581477682214137181L; /** {@inheritDoc} */ @Override - public void showMessage() { + public final void showMessage() { GuiDisplayUtil.updateGUI(); ButtonUtil.enableOnlyOK(); @@ -30,10 +37,11 @@ public class Input_PassPriority extends Input implements java.io.Serializable { sb.append("Turn : ").append(AllZone.getPhase().getPlayerTurn()).append("\n"); sb.append("Phase: ").append(phase).append("\n"); sb.append("Stack: "); - if (AllZone.getStack().size() != 0) + if (AllZone.getStack().size() != 0) { sb.append(AllZone.getStack().size()).append(" to Resolve."); - else + } else { sb.append("Empty"); + } sb.append("\n"); sb.append("Priority: ").append(player); @@ -42,19 +50,21 @@ public class Input_PassPriority extends Input implements java.io.Serializable { /** {@inheritDoc} */ @Override - public void selectButtonOK() { + public final void selectButtonOK() { AllZone.getPhase().passPriority(); GuiDisplayUtil.updateGUI(); Input in = AllZone.getInputControl().getInput(); - if (in == this || in == null) + if (in == this || in == null) { AllZone.getInputControl().resetInput(); // Clear out PassPriority after clicking button + } } /** {@inheritDoc} */ @Override - public void selectCard(Card card, PlayerZone zone) { - if (AllZone.getGameAction().playCard(card)) + public final void selectCard(final Card card, final PlayerZone zone) { + if (AllZone.getGameAction().playCard(card)) { AllZone.getPhase().setPriority(AllZone.getHumanPlayer()); - }//selectCard() + } + } // selectCard() } diff --git a/src/main/java/forge/gui/input/Input_PayManaCost.java b/src/main/java/forge/gui/input/Input_PayManaCost.java index 7807620266e..bbeae6c025a 100644 --- a/src/main/java/forge/gui/input/Input_PayManaCost.java +++ b/src/main/java/forge/gui/input/Input_PayManaCost.java @@ -1,7 +1,12 @@ package forge.gui.input; -import forge.*; +import forge.AllZone; +import forge.ButtonUtil; +import forge.Card; import forge.Constant.Zone; +import forge.Phase; +import forge.Player; +import forge.PlayerZone; import forge.card.mana.ManaCost; import forge.card.spellability.SpellAbility; @@ -9,19 +14,23 @@ import forge.card.spellability.SpellAbility; //the card is removed from the players hand if the cost is paid //CANNOT be used for ABILITIES /** - *

Input_PayManaCost class.

- * + *

+ * Input_PayManaCost class. + *

+ * * @author Forge * @version $Id$ */ public class Input_PayManaCost extends Input { // anything that uses this should be converted to Ability_Cost - /** Constant serialVersionUID=3467312982164195091L */ + /** Constant serialVersionUID=3467312982164195091L. */ private static final long serialVersionUID = 3467312982164195091L; private final String originalManaCost; private final Card originalCard; + + /** The mana cost. */ public ManaCost manaCost; private final SpellAbility spell; @@ -31,12 +40,16 @@ public class Input_PayManaCost extends Input { private int phyLifeToLose = 0; /** - *

Constructor for Input_PayManaCost.

- * - * @param sa a {@link forge.card.spellability.SpellAbility} object. - * @param noStack a boolean. + *

+ * Constructor for Input_PayManaCost. + *

+ * + * @param sa + * a {@link forge.card.spellability.SpellAbility} object. + * @param noStack + * a boolean. */ - public Input_PayManaCost(SpellAbility sa, boolean noStack) { + public Input_PayManaCost(final SpellAbility sa, final boolean noStack) { skipStack = noStack; originalManaCost = sa.getManaCost(); // Change originalCard = sa.getSourceCard(); @@ -45,8 +58,9 @@ public class Input_PayManaCost extends Input { if (Phase.getGameBegins() == 1) { if (sa.getSourceCard().isCopiedSpell() && sa.isSpell()) { - if (spell.getAfterPayMana() != null) stopSetNext(spell.getAfterPayMana()); - else { + if (spell.getAfterPayMana() != null) { + stopSetNext(spell.getAfterPayMana()); + } else { manaCost = new ManaCost("0"); AllZone.getStack().add(spell); } @@ -59,11 +73,14 @@ public class Input_PayManaCost extends Input { } /** - *

Constructor for Input_PayManaCost.

- * - * @param sa a {@link forge.card.spellability.SpellAbility} object. + *

+ * Constructor for Input_PayManaCost. + *

+ * + * @param sa + * a {@link forge.card.spellability.SpellAbility} object. */ - public Input_PayManaCost(SpellAbility sa) { + public Input_PayManaCost(final SpellAbility sa) { originalManaCost = sa.getManaCost(); // Change originalCard = sa.getSourceCard(); @@ -71,8 +88,9 @@ public class Input_PayManaCost extends Input { if (Phase.getGameBegins() == 1) { if (sa.getSourceCard().isCopiedSpell() && sa.isSpell()) { - if (spell.getAfterPayMana() != null) stopSetNext(spell.getAfterPayMana()); - else { + if (spell.getAfterPayMana() != null) { + stopSetNext(spell.getAfterPayMana()); + } else { manaCost = new ManaCost("0"); AllZone.getStack().add(spell); } @@ -85,7 +103,9 @@ public class Input_PayManaCost extends Input { } /** - *

resetManaCost.

+ *

+ * resetManaCost. + *

*/ private void resetManaCost() { manaCost = new ManaCost(originalManaCost); @@ -94,20 +114,24 @@ public class Input_PayManaCost extends Input { /** {@inheritDoc} */ @Override - public void selectCard(Card card, PlayerZone zone) { - //this is a hack, to prevent lands being able to use mana to pay their own abilities from cards like - //Kher Keep, Pendelhaven, Blinkmoth Nexus, and Mikokoro, Center of the Sea, .... + public final void selectCard(final Card card, final PlayerZone zone) { + // this is a hack, to prevent lands being able to use mana to pay their + // own abilities from cards like + // Kher Keep, Pendelhaven, Blinkmoth Nexus, and Mikokoro, Center of the + // Sea, .... if (originalCard.equals(card) && spell.isTapAbility()) { - // I'm not sure if this actually prevents anything that wouldn't be handled by canPlay below + // I'm not sure if this actually prevents anything that wouldn't be + // handled by canPlay below return; } manaCost = Input_PayManaCostUtil.activateManaAbility(spell, card, manaCost); // only show message if this is the active input - if (AllZone.getInputControl().getInput() == this) + if (AllZone.getInputControl().getInput() == this) { showMessage(); + } if (manaCost.isPaid()) { originalCard.setSunburstValue(manaCost.getSunburst()); @@ -117,7 +141,7 @@ public class Input_PayManaCost extends Input { /** {@inheritDoc} */ @Override - public void selectPlayer(Player player) { + public final void selectPlayer(final Player player) { if (player.isHuman()) { if (manaCost.payPhyrexian()) { @@ -130,36 +154,43 @@ public class Input_PayManaCost extends Input { } /** - *

done.

+ *

+ * done. + *

*/ private void done() { - if (phyLifeToLose > 0) + if (phyLifeToLose > 0) { AllZone.getHumanPlayer().payLife(phyLifeToLose, originalCard); + } if (spell.getSourceCard().isCopiedSpell()) { if (spell.getAfterPayMana() != null) { stopSetNext(spell.getAfterPayMana()); - } else + } else { AllZone.getInputControl().resetInput(); + } } else { AllZone.getHumanPlayer().getManaPool().clearPay(spell, false); resetManaCost(); // if tap ability, tap card - if (spell.isTapAbility()) + if (spell.isTapAbility()) { originalCard.tap(); - if (spell.isUntapAbility()) + } + if (spell.isUntapAbility()) { originalCard.untap(); + } // if this is a spell, move it to the Stack ZOne - if (spell.isSpell()) // already checked for if its a copy + if (spell.isSpell()) { AllZone.getGameAction().moveToStack(originalCard); + } - if (spell.getAfterPayMana() != null) + if (spell.getAfterPayMana() != null) { stopSetNext(spell.getAfterPayMana()); - else { + } else { if (skipStack) { - spell.resolve(); + spell.resolve(); } else { AllZone.getStack().add(spell); } @@ -170,17 +201,26 @@ public class Input_PayManaCost extends Input { /** {@inheritDoc} */ @Override - public void selectButtonCancel() { + public final void selectButtonCancel() { resetManaCost(); AllZone.getHumanPlayer().getManaPool().unpaid(spell, true); - AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers();//DO NOT REMOVE THIS, otherwise the cards don't always tap + AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers(); // DO + // NOT + // REMOVE + // THIS, + // otherwise + // the + // cards + // don't + // always + // tap stop(); } /** {@inheritDoc} */ @Override - public void showMessage() { + public final void showMessage() { ButtonUtil.enableOnlyCancel(); StringBuilder msg = new StringBuilder("Pay Mana Cost: " + manaCost.toString()); @@ -200,6 +240,5 @@ public class Input_PayManaCost extends Input { done(); } - } } diff --git a/src/main/java/forge/gui/input/Input_PayManaCostUtil.java b/src/main/java/forge/gui/input/Input_PayManaCostUtil.java index 950fb6a61e2..cbac05e0acb 100644 --- a/src/main/java/forge/gui/input/Input_PayManaCostUtil.java +++ b/src/main/java/forge/gui/input/Input_PayManaCostUtil.java @@ -1,5 +1,10 @@ package forge.gui.input; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + import forge.AllZone; import forge.Card; import forge.Constant; @@ -11,52 +16,65 @@ import forge.card.spellability.Ability_Mana; import forge.card.spellability.SpellAbility; import forge.gui.GuiUtils; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - /** - *

Input_PayManaCostUtil class.

- * + *

+ * Input_PayManaCostUtil class. + *

+ * * @author Forge * @version $Id$ */ public class Input_PayManaCostUtil { - //all mana abilities start with this and typical look like "tap: add G" - //mana abilities are Strings and are retrieved by calling card.getKeyword() - //taps any card that has mana ability, not just land + // all mana abilities start with this and typical look like "tap: add G" + // mana abilities are Strings and are retrieved by calling card.getKeyword() + // taps any card that has mana ability, not just land /** - *

activateManaAbility.

- * - * @param sa a {@link forge.card.spellability.SpellAbility} object. - * @param card a {@link forge.Card} object. - * @param manaCost a {@link forge.card.mana.ManaCost} object. + *

+ * activateManaAbility. + *

+ * + * @param sa + * a {@link forge.card.spellability.SpellAbility} object. + * @param card + * a {@link forge.Card} object. + * @param manaCost + * a {@link forge.card.mana.ManaCost} object. * @return a {@link forge.card.mana.ManaCost} object. */ - public static ManaCost activateManaAbility(SpellAbility sa, Card card, ManaCost manaCost) { - //make sure computer's lands aren't selected - if (card.getController().isComputer()) + public static ManaCost activateManaAbility(final SpellAbility sa, final Card card, ManaCost manaCost) { + // make sure computer's lands aren't selected + if (card.getController().isComputer()) { return manaCost; + } - if (card instanceof ManaPool) + if (card instanceof ManaPool) { return ((ManaPool) card).subtractMana(sa, manaCost); + } ArrayList abilities = getManaAbilities(card); StringBuilder cneeded = new StringBuilder(); boolean choice = true; boolean skipExpress = false; - for (String color : Constant.Color.ManaColors) - if (manaCost.isNeeded(color)) + for (String color : Constant.Color.ManaColors) { + if (manaCost.isNeeded(color)) { cneeded.append(getShortColorString(color)); + } + } - Iterator it = abilities.iterator();//you can't remove unneeded abilities inside a for(am:abilities) loop :( + Iterator it = abilities.iterator(); // you can't remove + // unneeded abilities + // inside a + // for(am:abilities) + // loop :( while (it.hasNext()) { Ability_Mana ma = it.next(); ma.setActivatingPlayer(AllZone.getHumanPlayer()); - if (!ma.canPlay()) it.remove(); - else if (!canMake(ma, cneeded.toString())) it.remove(); + if (!ma.canPlay()) { + it.remove(); + } else if (!canMake(ma, cneeded.toString())) { + it.remove(); + } if (!skipExpress) { // skip express mana if the ability is not undoable @@ -66,11 +84,13 @@ public class Input_PayManaCostUtil { } } } - if (abilities.isEmpty()) + if (abilities.isEmpty()) { return manaCost; + } // TODO when implementing sunburst - // If the card has sunburst or any other ability that tracks mana spent, skip express Mana choice + // If the card has sunburst or any other ability that tracks mana spent, + // skip express Mana choice // if (card.getTrackManaPaid()) skipExpress = true; if (!skipExpress) { @@ -78,25 +98,30 @@ public class Input_PayManaCostUtil { ArrayList colorMatches = new ArrayList(); for (Ability_Mana am : abilities) { - if (am.isReflectedMana()){ - ArrayList reflectableColors = AbilityFactory_Mana.reflectableMana(am, am.getAbilityFactory(), new ArrayList(), new ArrayList()); - for (String color : reflectableColors){ - if (manaCost.isColor(color)) // convert to long before checking if color + if (am.isReflectedMana()) { + ArrayList reflectableColors = AbilityFactory_Mana.reflectableMana(am, + am.getAbilityFactory(), new ArrayList(), new ArrayList()); + for (String color : reflectableColors) { + if (manaCost.isColor(color)) { + // checking if color colorMatches.add(am); + } } - } - else{ + } else { String[] m = ManaPool.formatMana(am); - for (String color : m) - if (manaCost.isColor(color)) // convert to long before checking if color + for (String color : m) { + if (manaCost.isColor(color)) { + // checking if color colorMatches.add(am); + } + } } } - if (colorMatches.size() == 0 || colorMatches.size() == abilities.size()) + if (colorMatches.size() == 0 || colorMatches.size() == abilities.size()) { // can only match colorless just grab the first and move on. choice = false; - else if (colorMatches.size() < abilities.size()) { + } else if (colorMatches.size() < abilities.size()) { // leave behind only color matches abilities = colorMatches; } @@ -105,8 +130,9 @@ public class Input_PayManaCostUtil { Ability_Mana chosen = abilities.get(0); if (1 < abilities.size() && choice) { HashMap ability = new HashMap(); - for (Ability_Mana am : abilities) + for (Ability_Mana am : abilities) { ability.put(am.toString(), am); + } chosen = (Ability_Mana) GuiUtils.getChoice("Choose mana ability", abilities.toArray()); } @@ -114,48 +140,56 @@ public class Input_PayManaCostUtil { manaCost = AllZone.getHumanPlayer().getManaPool().subtractMana(sa, manaCost, chosen); - AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers();//DO NOT REMOVE THIS, otherwise the cards don't always tap (copied) + AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers(); + // DO NOT REMOVE THIS, otherwise the cards don't always tap (copied) return manaCost; } /** - *

getManaAbilities.

- * - * @param card a {@link forge.Card} object. + *

+ * getManaAbilities. + *

+ * + * @param card + * a {@link forge.Card} object. * @return a {@link java.util.ArrayList} object. */ - public static ArrayList getManaAbilities(Card card) { + public static ArrayList getManaAbilities(final Card card) { return card.getManaAbility(); } - //color is like "G", returns "Green" + // color is like "G", returns "Green" /** - *

canMake.

- * - * @param am a {@link forge.card.spellability.Ability_Mana} object. - * @param mana a {@link java.lang.String} object. + *

+ * canMake. + *

+ * + * @param am + * a {@link forge.card.spellability.Ability_Mana} object. + * @param mana + * a {@link java.lang.String} object. * @return a boolean. */ - public static boolean canMake(Ability_Mana am, String mana) { - if (mana.contains("1")){ + public static boolean canMake(final Ability_Mana am, final String mana) { + if (mana.contains("1")) { return true; } - if (mana.contains("S") && am.isSnow()){ + if (mana.contains("S") && am.isSnow()) { return true; } - - if (am.isReflectedMana()){ - ArrayList reflectableColors = AbilityFactory_Mana.reflectableMana(am, am.getAbilityFactory(), new ArrayList(), new ArrayList()); - for (String color : reflectableColors){ - if (mana.contains(getShortColorString(color))){ + + if (am.isReflectedMana()) { + ArrayList reflectableColors = AbilityFactory_Mana.reflectableMana(am, am.getAbilityFactory(), + new ArrayList(), new ArrayList()); + for (String color : reflectableColors) { + if (mana.contains(getShortColorString(color))) { return true; } } - } - else{ - for (String color : ManaPool.formatMana(am)){ - if (mana.contains(color)){ + } else { + for (String color : ManaPool.formatMana(am)) { + if (mana.contains(color)) { return true; } } @@ -164,12 +198,15 @@ public class Input_PayManaCostUtil { } /** - *

getLongColorString.

- * - * @param color a {@link java.lang.String} object. + *

+ * getLongColorString. + *

+ * + * @param color + * a {@link java.lang.String} object. * @return a {@link java.lang.String} object. */ - public static String getLongColorString(String color) { + public static String getLongColorString(final String color) { Map m = new HashMap(); m.put("G", Constant.Color.Green); m.put("R", Constant.Color.Red); @@ -180,20 +217,23 @@ public class Input_PayManaCostUtil { Object o = m.get(color); - if (o == null) + if (o == null) { o = Constant.Color.Colorless; - + } return o.toString(); } /** - *

getShortColorString.

- * - * @param color a {@link java.lang.String} object. + *

+ * getShortColorString. + *

+ * + * @param color + * a {@link java.lang.String} object. * @return a {@link java.lang.String} object. */ - public static String getShortColorString(String color) { + public static String getShortColorString(final String color) { Map m = new HashMap(); m.put(Constant.Color.Green, "G"); m.put(Constant.Color.Red, "R"); diff --git a/src/main/java/forge/gui/input/Input_PayManaCost_Ability.java b/src/main/java/forge/gui/input/Input_PayManaCost_Ability.java index 24ae1df1767..99b20960226 100644 --- a/src/main/java/forge/gui/input/Input_PayManaCost_Ability.java +++ b/src/main/java/forge/gui/input/Input_PayManaCost_Ability.java @@ -1,20 +1,26 @@ package forge.gui.input; -import forge.*; +import forge.AllZone; +import forge.ButtonUtil; +import forge.Card; +import forge.Command; +import forge.PlayerZone; import forge.card.mana.ManaCost; import forge.card.spellability.SpellAbility; //if cost is paid, Command.execute() is called /** - *

Input_PayManaCost_Ability class.

- * + *

+ * Input_PayManaCost_Ability class. + *

+ * * @author Forge * @version $Id$ */ public class Input_PayManaCost_Ability extends Input { /** - * Constant serialVersionUID=3836655722696348713L + * Constant serialVersionUID=3836655722696348713L. */ private static final long serialVersionUID = 3836655722696348713L; @@ -26,52 +32,78 @@ public class Input_PayManaCost_Ability extends Input { private Command paidCommand; private Command unpaidCommand; - //only used for X costs: + // only used for X costs: private boolean showOnlyOKButton = false; /** - *

Constructor for Input_PayManaCost_Ability.

- * - * @param manaCost a {@link java.lang.String} object. - * @param paid a {@link forge.Command} object. + *

+ * Constructor for Input_PayManaCost_Ability. + *

+ * + * @param manaCost + * a {@link java.lang.String} object. + * @param paid + * a {@link forge.Command} object. */ - public Input_PayManaCost_Ability(String manaCost, Command paid) { + public Input_PayManaCost_Ability(final String manaCost, final Command paid) { this(manaCost, paid, Command.Blank); } /** - *

Constructor for Input_PayManaCost_Ability.

- * - * @param manaCost_2 a {@link java.lang.String} object. - * @param paidCommand_2 a {@link forge.Command} object. - * @param unpaidCommand_2 a {@link forge.Command} object. + *

+ * Constructor for Input_PayManaCost_Ability. + *

+ * + * @param manaCost_2 + * a {@link java.lang.String} object. + * @param paidCommand_2 + * a {@link forge.Command} object. + * @param unpaidCommand_2 + * a {@link forge.Command} object. */ - public Input_PayManaCost_Ability(String manaCost_2, Command paidCommand_2, Command unpaidCommand_2) { + public Input_PayManaCost_Ability(final String manaCost_2, + final Command paidCommand_2, final Command unpaidCommand_2) { this("", manaCost_2, paidCommand_2, unpaidCommand_2); } /** - *

Constructor for Input_PayManaCost_Ability.

- * - * @param m a {@link java.lang.String} object. - * @param manaCost_2 a {@link java.lang.String} object. - * @param paidCommand_2 a {@link forge.Command} object. - * @param unpaidCommand_2 a {@link forge.Command} object. + *

+ * Constructor for Input_PayManaCost_Ability. + *

+ * + * @param m + * a {@link java.lang.String} object. + * @param manaCost_2 + * a {@link java.lang.String} object. + * @param paidCommand_2 + * a {@link forge.Command} object. + * @param unpaidCommand_2 + * a {@link forge.Command} object. */ - public Input_PayManaCost_Ability(String m, String manaCost_2, Command paidCommand_2, Command unpaidCommand_2) { + public Input_PayManaCost_Ability(final String m, final String manaCost_2, + final Command paidCommand_2, final Command unpaidCommand_2) { this(m, manaCost_2, paidCommand_2, unpaidCommand_2, false); } /** - *

Constructor for Input_PayManaCost_Ability.

- * - * @param m a {@link java.lang.String} object. - * @param manaCost_2 a {@link java.lang.String} object. - * @param paidCommand_2 a {@link forge.Command} object. - * @param unpaidCommand_2 a {@link forge.Command} object. - * @param showOKButton a boolean. + *

+ * Constructor for Input_PayManaCost_Ability. + *

+ * + * @param m + * a {@link java.lang.String} object. + * @param manaCost_2 + * a {@link java.lang.String} object. + * @param paidCommand_2 + * a {@link forge.Command} object. + * @param unpaidCommand_2 + * a {@link forge.Command} object. + * @param showOKButton + * a boolean. */ - public Input_PayManaCost_Ability(String m, String manaCost_2, Command paidCommand_2, Command unpaidCommand_2, boolean showOKButton) { + public Input_PayManaCost_Ability(final String m, final String manaCost_2, + final Command paidCommand_2, final Command unpaidCommand_2, + final boolean showOKButton) { fakeAbility = new SpellAbility(SpellAbility.Ability, null) { @Override public void resolve() { @@ -91,34 +123,34 @@ public class Input_PayManaCost_Ability extends Input { showOnlyOKButton = showOKButton; } - /** - *

resetManaCost.

+ *

+ * resetManaCost. + *

*/ - public void resetManaCost() { + public final void resetManaCost() { manaCost = new ManaCost(originalManaCost); } /** {@inheritDoc} */ @Override - public void selectCard(Card card, PlayerZone zone) { - //only tap card if the mana is needed + public final void selectCard(final Card card, final PlayerZone zone) { + // only tap card if the mana is needed manaCost = Input_PayManaCostUtil.activateManaAbility(fakeAbility, card, manaCost); - + if (manaCost.isPaid()) { resetManaCost(); AllZone.getHumanPlayer().getManaPool().clearPay(fakeAbility, false); stop(); paidCommand.execute(); - } - else{ + } else { showMessage(); } } /** {@inheritDoc} */ @Override - public void selectButtonCancel() { + public final void selectButtonCancel() { resetManaCost(); AllZone.getHumanPlayer().getManaPool().unpaid(fakeAbility, true); stop(); @@ -127,7 +159,7 @@ public class Input_PayManaCost_Ability extends Input { /** {@inheritDoc} */ @Override - public void selectButtonOK() { + public final void selectButtonOK() { if (showOnlyOKButton) { stop(); unpaidCommand.execute(); @@ -136,12 +168,12 @@ public class Input_PayManaCost_Ability extends Input { /** {@inheritDoc} */ @Override - public void showMessage() { + public final void showMessage() { ButtonUtil.enableOnlyCancel(); - if (showOnlyOKButton) + if (showOnlyOKButton) { ButtonUtil.enableOnlyOK(); + } AllZone.getDisplay().showMessage(message + "Pay Mana Cost: \r\n" + manaCost.toString()); } - } diff --git a/src/main/java/forge/gui/input/package-info.java b/src/main/java/forge/gui/input/package-info.java index a13d64e74d3..c72a362af11 100644 --- a/src/main/java/forge/gui/input/package-info.java +++ b/src/main/java/forge/gui/input/package-info.java @@ -1,2 +1,2 @@ -/** Forge Card Game */ +/** Forge Card Game. */ package forge.gui.input; diff --git a/src/main/java/forge/gui/skin/FButton.java b/src/main/java/forge/gui/skin/FButton.java index 560b9c9aa71..cdf7c7417c5 100644 --- a/src/main/java/forge/gui/skin/FButton.java +++ b/src/main/java/forge/gui/skin/FButton.java @@ -8,91 +8,103 @@ import java.awt.Graphics2D; import java.awt.Image; import java.awt.Insets; import java.awt.RenderingHints; + import javax.swing.JButton; + import forge.AllZone; -/** - * The core JButton used throughout the Forge project. - * Follows skin font and theme button styling. - * +/** + * The core JButton used throughout the Forge project. Follows skin font and + * theme button styling. + * */ @SuppressWarnings("serial") -public class FButton extends JButton { +public class FButton extends JButton { + + /** The img r. */ protected Image imgL, imgM, imgR; private int w, h = 0; private boolean allImagesPresent = false; private FSkin skin; - private AlphaComposite disabledComposite = - AlphaComposite.getInstance(AlphaComposite.SRC_OVER,0.25f); - + private AlphaComposite disabledComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.25f); + + /** + * Instantiates a new f button. + * + * @param msg + * the msg + */ public FButton(String msg) { super(msg); this.skin = AllZone.getSkin(); this.setOpaque(false); - this.setForeground(skin.txt1a); + this.setForeground(skin.txt1a); this.setBackground(Color.red); this.setContentAreaFilled(false); - this.setMargin(new Insets(0,25,0,25)); - this.setFont(skin.font1.deriveFont(Font.BOLD,15)); + this.setMargin(new Insets(0, 25, 0, 25)); + this.setFont(skin.font1.deriveFont(Font.BOLD, 15)); this.imgL = skin.btnLup.getImage(); this.imgM = skin.btnMup.getImage(); this.imgR = skin.btnRup.getImage(); - - if(this.imgL != null && this.imgM != null && this.imgR != null) { + + if (this.imgL != null && this.imgM != null && this.imgR != null) { allImagesPresent = true; } - + this.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseEntered(java.awt.event.MouseEvent evt) { - if(isEnabled()) { + if (isEnabled()) { imgL = skin.btnLover.getImage(); imgM = skin.btnMover.getImage(); imgR = skin.btnRover.getImage(); } } + public void mouseExited(java.awt.event.MouseEvent evt) { - if(isEnabled()) { + if (isEnabled()) { imgL = skin.btnLup.getImage(); imgM = skin.btnMup.getImage(); imgR = skin.btnRup.getImage(); } } + public void mousePressed(java.awt.event.MouseEvent evt) { - if(isEnabled()) { + if (isEnabled()) { imgL = skin.btnLdown.getImage(); imgM = skin.btnMdown.getImage(); imgR = skin.btnRdown.getImage(); } } - }); + }); } - + + /* + * (non-Javadoc) + * + * @see javax.swing.JComponent#paintComponent(java.awt.Graphics) + */ protected void paintComponent(Graphics g) { - if(!allImagesPresent) { + if (!allImagesPresent) { return; } - - Graphics2D g2d = (Graphics2D)g; - g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, - RenderingHints.VALUE_TEXT_ANTIALIAS_ON); - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - g2d.setRenderingHint(RenderingHints.KEY_RENDERING, - RenderingHints.VALUE_RENDER_QUALITY); - g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, - RenderingHints.VALUE_FRACTIONALMETRICS_ON); - - if(!isEnabled()) { + + Graphics2D g2d = (Graphics2D) g; + g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); + g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); + + if (!isEnabled()) { g2d.setComposite(disabledComposite); } - + w = this.getWidth(); - h = this.getHeight(); - - g2d.drawImage(imgL,0,0,h,h,null); - g2d.drawImage(imgM,h,0,w - 2*h,h,null); - g2d.drawImage(imgR,w-h,0,h,h,null); - + h = this.getHeight(); + + g2d.drawImage(imgL, 0, 0, h, h, null); + g2d.drawImage(imgM, h, 0, w - 2 * h, h, null); + g2d.drawImage(imgR, w - h, 0, h, h, null); + super.paintComponent(g); } -} \ No newline at end of file +} diff --git a/src/main/java/forge/gui/skin/FPanel.java b/src/main/java/forge/gui/skin/FPanel.java index 204db44b565..969ad8c23c7 100644 --- a/src/main/java/forge/gui/skin/FPanel.java +++ b/src/main/java/forge/gui/skin/FPanel.java @@ -2,39 +2,54 @@ package forge.gui.skin; import java.awt.Graphics; import java.awt.LayoutManager; + import javax.swing.ImageIcon; import javax.swing.JPanel; -/**

FPanel.

- * The core JPanel used throughout the Forge project. - * Allows tiled images and ... - * +/** + *

+ * FPanel. + *

+ * The core JPanel used throughout the Forge project. Allows tiled images and + * ... + * */ @SuppressWarnings("serial") public class FPanel extends JPanel { - private ImageIcon bgImg = null; - private int w, h, iw, ih, x, y = 0; - + private ImageIcon bgImg = null; + private int w, h, iw, ih, x, y = 0; + + /** + * Instantiates a new f panel. + */ public FPanel() { super(); } - + + /** + * Instantiates a new f panel. + * + * @param lm the lm + */ public FPanel(LayoutManager lm) { this(); this.setLayout(lm); } + /* (non-Javadoc) + * @see javax.swing.JComponent#paintComponent(java.awt.Graphics) + */ protected void paintComponent(Graphics g) { - //System.out.print("\nRepainting. "); - if(this.bgImg != null) { + // System.out.print("\nRepainting. "); + if (this.bgImg != null) { w = getWidth(); h = getHeight(); iw = this.bgImg.getIconWidth(); ih = this.bgImg.getIconHeight(); - while(x < w) { - while(y < h) { - g.drawImage(bgImg.getImage(),x,y,null); + while (x < w) { + while (y < h) { + g.drawImage(bgImg.getImage(), x, y, null); y += ih; } x += iw; @@ -42,13 +57,18 @@ public class FPanel extends JPanel { } x = 0; } - + super.paintComponent(g); } - + + /** + * Sets the bG img. + * + * @param icon the new bG img + */ public void setBGImg(ImageIcon icon) { - this.bgImg = icon; - if(this.bgImg != null) { + this.bgImg = icon; + if (this.bgImg != null) { this.setOpaque(false); } } diff --git a/src/main/java/forge/gui/skin/FRoundedPanel.java b/src/main/java/forge/gui/skin/FRoundedPanel.java index fd322161ae9..7e3df126408 100644 --- a/src/main/java/forge/gui/skin/FRoundedPanel.java +++ b/src/main/java/forge/gui/skin/FRoundedPanel.java @@ -5,27 +5,35 @@ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.LayoutManager; import java.awt.RenderingHints; + import javax.swing.JPanel; -/**

FRoundedPanel.

- * A subclass of JPanel with any of four corners rounded, - * drop shadow, and 1px line border. +/** + *

+ * FRoundedPanel. + *

+ * A subclass of JPanel with any of four corners rounded, drop shadow, and 1px + * line border. * * Limitations: Cannot tile background image, cannot set border width. - * + * */ @SuppressWarnings("serial") public class FRoundedPanel extends JPanel { - public boolean[] corners = {true,true,true,true}; //NW, SW, SE, NE - - private Color shadowColor = new Color(150,150,150,150); - private Color borderColor = Color.black; - private int shadowOffset = 5; - private int cornerRadius = 10; - private boolean showShadow = false; - + + /** The corners. */ + public boolean[] corners = { true, true, true, true }; // NW, SW, SE, NE + + private Color shadowColor = new Color(150, 150, 150, 150); + private Color borderColor = Color.black; + private int shadowOffset = 5; + private int cornerRadius = 10; + private boolean showShadow = false; + /** - *

FRoundedPanel.

+ *

+ * FRoundedPanel. + *

* * Constructor, null layout manager. */ @@ -33,12 +41,16 @@ public class FRoundedPanel extends JPanel { super(); this.setOpaque(false); } - + /** - *

FRoundedPanel.

+ *

+ * FRoundedPanel. + *

* * Constructor. - * @param {@link java.awt.LayoutManager} + * + * @param lm + * the lm */ public FRoundedPanel(LayoutManager lm) { this(); @@ -46,10 +58,14 @@ public class FRoundedPanel extends JPanel { } /** - *

FRoundedPanel.

+ *

+ * FRoundedPanel. + *

* * Constructor. - * @param {@link java.awt.Graphics} + * + * @param g + * the g */ protected void paintComponent(Graphics g) { super.paintComponent(g); @@ -57,45 +73,40 @@ public class FRoundedPanel extends JPanel { int h = getHeight(); int so = shadowOffset; int r = cornerRadius; - + Graphics2D g2d = (Graphics2D) g; - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); - - if(showShadow) { + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + + if (showShadow) { // Mid, left, right rectangles: shadow g2d.setColor(shadowColor); - g2d.fillRect(r + so, so, w - 2*r - so, h - so); - g2d.fillRect(so, r + so, r, h - 2*r - so); - g2d.fillRect(w - r, r + so, r, h - 2*r - so); - + g2d.fillRect(r + so, so, w - 2 * r - so, h - so); + g2d.fillRect(so, r + so, r, h - 2 * r - so); + g2d.fillRect(w - r, r + so, r, h - 2 * r - so); + // Corners: shadow // NW - if(corners[0]) { - g2d.fillArc(so, so, 2*r, 2*r, 90, 90); - } - else { + if (corners[0]) { + g2d.fillArc(so, so, 2 * r, 2 * r, 90, 90); + } else { g2d.fillRect(so, so, r, r); - } - // SW - if(corners[1]) { - g2d.fillArc(so, h - 2*r, 2*r, 2*r, 180, 90); } - else { + // SW + if (corners[1]) { + g2d.fillArc(so, h - 2 * r, 2 * r, 2 * r, 180, 90); + } else { g2d.fillRect(so, h - r, r, r); } // SE - if(corners[2]) { - g2d.fillArc(w - 2*r, h - 2*r, 2*r, 2*r, 270, 90); - } - else { + if (corners[2]) { + g2d.fillArc(w - 2 * r, h - 2 * r, 2 * r, 2 * r, 270, 90); + } else { g2d.fillRect(w - r, h - r, r, r); } // NE - if(corners[3]) { - g2d.fillArc(w - 2*r, so, 2*r, 2*r, 0, 90); - } - else { + if (corners[3]) { + g2d.fillArc(w - 2 * r, so, 2 * r, 2 * r, 0, 90); + } else { g2d.fillRect(w - r, so, r, r); } } // End if(showShadow) @@ -103,146 +114,160 @@ public class FRoundedPanel extends JPanel { so = 0; so = 0; } - + // Mid, left, right rectangles: content g2d.setColor(getBackground()); - g2d.fillRect(r, 0, w - 2*r - so, h - so); - g2d.fillRect(0, r, r, h - 2*r - so); - g2d.fillRect(w - r - so, r, r, h - 2*r - so); - + g2d.fillRect(r, 0, w - 2 * r - so, h - so); + g2d.fillRect(0, r, r, h - 2 * r - so); + g2d.fillRect(w - r - so, r, r, h - 2 * r - so); + // Corners: content // NW - if(corners[0]) { - g2d.fillArc(0, 0, 2*r, 2*r, 90, 90); - } - else { + if (corners[0]) { + g2d.fillArc(0, 0, 2 * r, 2 * r, 90, 90); + } else { g2d.fillRect(0, 0, r, r); - } - // SW - if(corners[1]) { - g2d.fillArc(0, h - 2*r - so, 2*r, 2*r, 180, 90); } - else { + // SW + if (corners[1]) { + g2d.fillArc(0, h - 2 * r - so, 2 * r, 2 * r, 180, 90); + } else { g2d.fillRect(0, h - r - so, r, r); } // SE - if(corners[2]) { - g2d.fillArc(w - 2*r - so, h - 2*r - so, 2*r, 2*r, 270, 90); - } - else { + if (corners[2]) { + g2d.fillArc(w - 2 * r - so, h - 2 * r - so, 2 * r, 2 * r, 270, 90); + } else { g2d.fillRect(w - r - so, h - r - so, r, r); } // NE - if(corners[3]) { - g2d.fillArc(w - 2*r - so, 0, 2*r, 2*r, 0, 90); - } - else { + if (corners[3]) { + g2d.fillArc(w - 2 * r - so, 0, 2 * r, 2 * r, 0, 90); + } else { g2d.fillRect(w - r - so, 0, r, r); } - + // Mid, left, right rectangles: border g2d.setColor(this.borderColor); g2d.drawLine(r, 0, w - r - so, 0); g2d.drawLine(r, h - so - 1, w - r - so, h - so - 1); g2d.drawLine(0, r, 0, h - r - so); g2d.drawLine(w - so - 1, r, w - so - 1, h - r - so); - + // Corners: border // NW - if(corners[0]) { - g2d.drawArc(0, 0, 2*r, 2*r, 90, 90); - } - else { + if (corners[0]) { + g2d.drawArc(0, 0, 2 * r, 2 * r, 90, 90); + } else { g2d.drawLine(0, 0, r, 0); g2d.drawLine(0, 0, 0, r); - } - // SW - if(corners[1]) { - g2d.drawArc(0, h - 2*r - so, 2*r, 2*r - 1, 180, 90); } - else { + // SW + if (corners[1]) { + g2d.drawArc(0, h - 2 * r - so, 2 * r, 2 * r - 1, 180, 90); + } else { g2d.drawLine(0, h - so - 1, 0, h - r - so - 1); g2d.drawLine(0, h - so - 1, r, h - so - 1); } // SE - if(corners[2]) { - g2d.drawArc(w - 2*r - so, h - 2*r - so, 2*r - 1, 2*r - 1, 270, 90); - } - else { + if (corners[2]) { + g2d.drawArc(w - 2 * r - so, h - 2 * r - so, 2 * r - 1, 2 * r - 1, 270, 90); + } else { g2d.drawLine(w - so - 1, h - so - 1, w - so - 1, h - r - so); g2d.drawLine(w - so - 1, h - so - 1, w - r - so, h - so - 1); } // NE - if(corners[3]) { - g2d.drawArc(w - 2*r - so, 0, 2*r - 1, 2*r - 1, 0, 90); - } - else { + if (corners[3]) { + g2d.drawArc(w - 2 * r - so, 0, 2 * r - 1, 2 * r - 1, 0, 90); + } else { g2d.drawLine(w - so - 1, 0, w - so - r, 0); - g2d.drawLine(w - so - 1, 0, w - so - 1, r); + g2d.drawLine(w - so - 1, 0, w - so - 1, r); } } - + /** - *

setShadowColor.

- * Sets color of shadow behind rounded panel. - * - * @param {@link java.awt.Color} + *

+ * setShadowColor. + *

+ * Sets color of shadow behind rounded panel. + * + * @param c + * the new shadow color */ public void setShadowColor(Color c) { this.shadowColor = c; } - + /** - *

setBorderColor.

- * Sets color of border around rounded panel. - * - * @param {@link java.awt.Color} + *

+ * setBorderColor. + *

+ * Sets color of border around rounded panel. + * + * @param c + * the new border color */ public void setBorderColor(Color c) { this.borderColor = c; } - + /** - *

setShadowOffset.

+ *

+ * setShadowOffset. + *

* Sets offset of shadow from rounded panel. - * - * @param {@link java.lang.Integer} side + * + * @param i + * the new shadow offset */ public void setShadowOffset(int i) { - if(i < 0) { + if (i < 0) { i = 0; } this.shadowOffset = i; } - + /** - *

setCornerRadius.

+ *

+ * setCornerRadius. + *

* Sets radius of each corner on rounded panel. - * - * @param {@link java.lang.Integer} r + * + * @param r + * the new corner radius */ public void setCornerRadius(int r) { - if(r < 0) { + if (r < 0) { r = 0; } - + this.cornerRadius = r; - } - + } + /** - *

setCorners.

- * Sets if corners should be rounded or not in the following order: - * NW, SW, SE, NE - * @param boolean vals[] must be length 4 + *

+ * setCorners. + *

+ * Sets if corners should be rounded or not in the following order: NW, SW, + * SE, NE + * + * @param vals + * the new corners */ - public void setCorners(boolean vals[] ) { - if(vals.length!=4) { + public void setCorners(boolean vals[]) { + if (vals.length != 4) { throw new IllegalArgumentException("FRoundedPanel > setCorners requires an array of booleans of length 4."); } - + corners = vals; } - + + /** + * Sets the show shadow. + * + * @param b + * the new show shadow + */ public void setShowShadow(boolean b) { showShadow = b; } diff --git a/src/main/java/forge/gui/skin/FSkin.java b/src/main/java/forge/gui/skin/FSkin.java index 06d8281def4..573a21f8118 100644 --- a/src/main/java/forge/gui/skin/FSkin.java +++ b/src/main/java/forge/gui/skin/FSkin.java @@ -11,107 +11,161 @@ import javax.swing.ImageIcon; import forge.gui.GuiUtils; -/** - * Assembles settings from selected or default theme as appropriate. - * Saves in a hashtable, access using .get(settingName) method. - * +/** + * Assembles settings from selected or default theme as appropriate. Saves in a + * hashtable, access using .get(settingName) method. + * */ public class FSkin { - //===== Public fields - public Font font1 = null; - public Font font2 = null; - public ImageIcon texture1 = null; - public ImageIcon texture2 = null; - public ImageIcon texture3 = null; - public ImageIcon btnLup = null; - public ImageIcon btnMup = null; - public ImageIcon btnRup = null; - public ImageIcon btnLover = null; - public ImageIcon btnMover = null; - public ImageIcon btnRover = null; - public ImageIcon btnLdown = null; - public ImageIcon btnMdown = null; - public ImageIcon btnRdown = null; - public ImageIcon splash = null; - - public Color bg1a = Color.red; - public Color bg1b = Color.red; - public Color bg2a = Color.red; - public Color bg2b = Color.red; - public Color bg3a = Color.red; - public Color bg3b = Color.red; - - public Color txt1a = Color.red; - public Color txt1b = Color.red; - public Color txt2a = Color.red; - public Color txt2b = Color.red; - public Color txt3a = Color.red; - public Color txt3b = Color.red; - - public String name = "default"; - - //===== Private fields - private final String paletteFile = "palette.jpg"; - private final String font1file = "font1.ttf"; - private final String font2file = "font2.ttf"; - private final String texture1file = "texture1.jpg"; - private final String texture2file = "texture2.jpg"; - private final String texture3file = "texture3.jpg"; - private final String btnLupfile = "btnLup.png"; - private final String btnMupfile = "btnMup.png"; - private final String btnRupfile = "btnRup.png"; - private final String btnLoverfile = "btnLover.png"; - private final String btnMoverfile = "btnMover.png"; - private final String btnRoverfile = "btnRover.png"; - private final String btnLdownfile = "btnLdown.png"; - private final String btnMdownfile = "btnMdown.png"; - private final String btnRdownfile = "btnRdown.png"; - private final String splashfile = "bg_splash.jpg"; - + // ===== Public fields + /** The font1. */ + public Font font1 = null; + + /** The font2. */ + public Font font2 = null; + + /** The texture1. */ + public ImageIcon texture1 = null; + + /** The texture2. */ + public ImageIcon texture2 = null; + + /** The texture3. */ + public ImageIcon texture3 = null; + + /** The btn lup. */ + public ImageIcon btnLup = null; + + /** The btn mup. */ + public ImageIcon btnMup = null; + + /** The btn rup. */ + public ImageIcon btnRup = null; + + /** The btn lover. */ + public ImageIcon btnLover = null; + + /** The btn mover. */ + public ImageIcon btnMover = null; + + /** The btn rover. */ + public ImageIcon btnRover = null; + + /** The btn ldown. */ + public ImageIcon btnLdown = null; + + /** The btn mdown. */ + public ImageIcon btnMdown = null; + + /** The btn rdown. */ + public ImageIcon btnRdown = null; + + /** The splash. */ + public ImageIcon splash = null; + + /** The bg1a. */ + public Color bg1a = Color.red; + + /** The bg1b. */ + public Color bg1b = Color.red; + + /** The bg2a. */ + public Color bg2a = Color.red; + + /** The bg2b. */ + public Color bg2b = Color.red; + + /** The bg3a. */ + public Color bg3a = Color.red; + + /** The bg3b. */ + public Color bg3b = Color.red; + + /** The txt1a. */ + public Color txt1a = Color.red; + + /** The txt1b. */ + public Color txt1b = Color.red; + + /** The txt2a. */ + public Color txt2a = Color.red; + + /** The txt2b. */ + public Color txt2b = Color.red; + + /** The txt3a. */ + public Color txt3a = Color.red; + + /** The txt3b. */ + public Color txt3b = Color.red; + + /** The name. */ + public String name = "default"; + + // ===== Private fields + private final String paletteFile = "palette.jpg"; + private final String font1file = "font1.ttf"; + private final String font2file = "font2.ttf"; + private final String texture1file = "texture1.jpg"; + private final String texture2file = "texture2.jpg"; + private final String texture3file = "texture3.jpg"; + private final String btnLupfile = "btnLup.png"; + private final String btnMupfile = "btnMup.png"; + private final String btnRupfile = "btnRup.png"; + private final String btnLoverfile = "btnLover.png"; + private final String btnMoverfile = "btnMover.png"; + private final String btnRoverfile = "btnRover.png"; + private final String btnLdownfile = "btnLdown.png"; + private final String btnMdownfile = "btnMdown.png"; + private final String btnRdownfile = "btnRdown.png"; + private final String splashfile = "bg_splash.jpg"; + private ImageIcon tempImg; private Font tempFont; private String skin; - private String notfound = "FSkin.java: \""+skin+ - "\" skin can't find "; + private String notfound = "FSkin.java: \"" + skin + "\" skin can't find "; /** - * FSkin constructor. No arguments, will generate default skin settings, + * FSkin constructor. No arguments, will generate default skin settings, * fonts, and backgrounds. * * @throws Exception + * the exception */ public FSkin() throws Exception { this("default"); } - + /** * FSkin constructor, using skin name. Generates custom skin settings, * fonts, and backgrounds. * - * @param themeName + * @param skinName + * the skin name * @throws Exception + * the exception */ public FSkin(String skinName) throws Exception { - loadFontAndImages("default"); - - if(!skinName.equals("default")) { + loadFontAndImages("default"); + + if (!skinName.equals("default")) { loadFontAndImages(skinName); } } - + /** * Loads objects from skin folder, prints brief error if not found. * * @param skinName */ private void loadFontAndImages(String skinName) { - String dirName = "res/images/skins/"+skinName+"/"; - + String dirName = "res/images/skins/" + skinName + "/"; + // Fonts font1 = retrieveFont(dirName + font1file); font2 = retrieveFont(dirName + font2file); - + // Images texture1 = retrieveImage(dirName + texture1file); texture2 = retrieveImage(dirName + texture2file); @@ -126,53 +180,57 @@ public class FSkin { btnMdown = retrieveImage(dirName + btnMdownfile); btnRdown = retrieveImage(dirName + btnRdownfile); splash = retrieveImage(dirName + splashfile); - + // Color palette - File file= new File(dirName + paletteFile); + File file = new File(dirName + paletteFile); BufferedImage image; try { image = ImageIO.read(file); - bg1a = getColorFromPixel(image.getRGB(10,30)); - bg1b = getColorFromPixel(image.getRGB(30,30)); - bg2a = getColorFromPixel(image.getRGB(50,30)); - bg2b = getColorFromPixel(image.getRGB(70,30)); - bg3a = getColorFromPixel(image.getRGB(90,30)); - bg3b = getColorFromPixel(image.getRGB(110,30)); - - txt1a = getColorFromPixel(image.getRGB(10,70)); - txt1b = getColorFromPixel(image.getRGB(30,70)); - txt2a = getColorFromPixel(image.getRGB(50,70)); - txt2b = getColorFromPixel(image.getRGB(70,70)); - txt3a = getColorFromPixel(image.getRGB(90,70)); - txt3b = getColorFromPixel(image.getRGB(110,70)); + bg1a = getColorFromPixel(image.getRGB(10, 30)); + bg1b = getColorFromPixel(image.getRGB(30, 30)); + bg2a = getColorFromPixel(image.getRGB(50, 30)); + bg2b = getColorFromPixel(image.getRGB(70, 30)); + bg3a = getColorFromPixel(image.getRGB(90, 30)); + bg3b = getColorFromPixel(image.getRGB(110, 30)); + + txt1a = getColorFromPixel(image.getRGB(10, 70)); + txt1b = getColorFromPixel(image.getRGB(30, 70)); + txt2a = getColorFromPixel(image.getRGB(50, 70)); + txt2b = getColorFromPixel(image.getRGB(70, 70)); + txt3a = getColorFromPixel(image.getRGB(90, 70)); + txt3b = getColorFromPixel(image.getRGB(110, 70)); } catch (IOException e) { System.err.println(notfound + paletteFile); } - + } - + /** - *

retrieveImage.

- * Tries to instantiate an image icon from a filename. - * Error reported if not found. + *

+ * retrieveImage. + *

+ * Tries to instantiate an image icon from a filename. Error reported if not + * found. * * @param {@link java.lang.String} address * @return a ImageIcon */ private ImageIcon retrieveImage(String address) { tempImg = new ImageIcon(address); - if(tempImg.getIconWidth()==-1) { + if (tempImg.getIconWidth() == -1) { System.err.println(notfound + address); } return tempImg; } - + /** - *

retrieveFont.

- * Uses GuiUtils to grab a font file at an address. - * Error will be reported by GuiUtils if not found. - * Error also reported by this method if not found. + *

+ * retrieveFont. + *

+ * Uses GuiUtils to grab a font file at an address. Error will be reported + * by GuiUtils if not found. Error also reported by this method if not + * found. * * @param {@link java.lang.String} address * @return a Font @@ -182,17 +240,15 @@ public class FSkin { return tempFont; } - + /** - *

getColorFromPixel.

+ *

+ * getColorFromPixel. + *

* * @param {@link java.lang.Integer} pixel information */ private Color getColorFromPixel(int pixel) { - return new Color( - (pixel & 0x00ff0000) >> 16, - (pixel & 0x0000ff00) >> 8, - (pixel & 0x000000ff) - ); + return new Color((pixel & 0x00ff0000) >> 16, (pixel & 0x0000ff00) >> 8, (pixel & 0x000000ff)); } } diff --git a/src/main/java/forge/gui/skin/package-info.java b/src/main/java/forge/gui/skin/package-info.java new file mode 100644 index 00000000000..91ab7e42755 --- /dev/null +++ b/src/main/java/forge/gui/skin/package-info.java @@ -0,0 +1,2 @@ +/** Forge Card Game. */ +package forge.gui.skin;