mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
Merge GuiRefactoring back into trunk.
Note that this changes ALL the display code to not pass game objects directly into the GUI, so bear that in mind when merging local changes (and in future commits).
This commit is contained in:
19
.gitattributes
vendored
19
.gitattributes
vendored
@@ -509,6 +509,7 @@ forge-game/src/main/java/forge/game/event/GameEventPlayerDamaged.java -text
|
||||
forge-game/src/main/java/forge/game/event/GameEventPlayerLivesChanged.java -text
|
||||
forge-game/src/main/java/forge/game/event/GameEventPlayerPoisoned.java -text
|
||||
forge-game/src/main/java/forge/game/event/GameEventPlayerPriority.java -text
|
||||
forge-game/src/main/java/forge/game/event/GameEventPlayerStatsChanged.java -text
|
||||
forge-game/src/main/java/forge/game/event/GameEventShuffle.java -text
|
||||
forge-game/src/main/java/forge/game/event/GameEventSpellAbilityCast.java -text
|
||||
forge-game/src/main/java/forge/game/event/GameEventSpellRemovedFromStack.java -text
|
||||
@@ -717,6 +718,7 @@ forge-gui-desktop/src/main/html/js/jquery/jquery-1.9.1.js -text
|
||||
forge-gui-desktop/src/main/html/js/jquery/jquery-1.9.1.min.js -text
|
||||
forge-gui-desktop/src/main/html/js/observable.js -text
|
||||
forge-gui-desktop/src/main/html/js/socket.js -text
|
||||
forge-gui-desktop/src/main/java/forge/GuiBase.java -text
|
||||
forge-gui-desktop/src/main/java/forge/GuiDesktop.java -text
|
||||
forge-gui-desktop/src/main/java/forge/ImageCache.java -text
|
||||
forge-gui-desktop/src/main/java/forge/ImageLoader.java -text
|
||||
@@ -1123,6 +1125,7 @@ forge-gui-mobile/libs/gdx.jar -text
|
||||
forge-gui-mobile/pom.xml -text
|
||||
forge-gui-mobile/src/forge/Forge.java -text
|
||||
forge-gui-mobile/src/forge/Graphics.java -text
|
||||
forge-gui-mobile/src/forge/GuiBase.java -text
|
||||
forge-gui-mobile/src/forge/GuiMobile.java -text
|
||||
forge-gui-mobile/src/forge/animation/AbilityEffect.java -text
|
||||
forge-gui-mobile/src/forge/animation/ForgeAnimation.java -text
|
||||
@@ -1281,6 +1284,7 @@ forge-gui-mobile/src/forge/toolbox/ListChooser.java -text
|
||||
forge-gui-mobile/src/forge/util/LayoutHelper.java -text
|
||||
forge-gui-mobile/src/forge/util/PhysicsObject.java -text
|
||||
forge-gui-mobile/src/forge/util/Utils.java -text
|
||||
forge-gui-mobile/src/forge/util/WaitCallback.java -text
|
||||
forge-gui-mobile/src/forge/util/WaitRunnable.java -text
|
||||
forge-gui/.classpath -text
|
||||
forge-gui/.project -text
|
||||
@@ -16650,7 +16654,6 @@ forge-gui/src/main/html/js/jquery/jquery-1.9.1.min.js -text
|
||||
forge-gui/src/main/html/js/observable.js -text
|
||||
forge-gui/src/main/html/js/socket.js -text
|
||||
forge-gui/src/main/java/forge/FThreads.java -text
|
||||
forge-gui/src/main/java/forge/GuiBase.java -text
|
||||
forge-gui/src/main/java/forge/UiCommand.java svneol=native#text/plain
|
||||
forge-gui/src/main/java/forge/achievement/Achievement.java -text
|
||||
forge-gui/src/main/java/forge/achievement/AchievementCollection.java -text
|
||||
@@ -16739,7 +16742,6 @@ forge-gui/src/main/java/forge/limited/WinstonDraft.java -text
|
||||
forge-gui/src/main/java/forge/limited/WinstonDraftAI.java -text
|
||||
forge-gui/src/main/java/forge/limited/package-info.java svneol=native#text/plain
|
||||
forge-gui/src/main/java/forge/match/MatchConstants.java -text
|
||||
forge-gui/src/main/java/forge/match/MatchUtil.java -text
|
||||
forge-gui/src/main/java/forge/match/input/ButtonUtil.java -text
|
||||
forge-gui/src/main/java/forge/match/input/Input.java -text
|
||||
forge-gui/src/main/java/forge/match/input/InputAttack.java -text
|
||||
@@ -16848,6 +16850,7 @@ forge-gui/src/main/java/forge/sound/SoundEffectType.java -text
|
||||
forge-gui/src/main/java/forge/sound/SoundSystem.java -text
|
||||
forge-gui/src/main/java/forge/util/Base64Coder.java svneol=native#text/plain
|
||||
forge-gui/src/main/java/forge/util/Callback.java -text
|
||||
forge-gui/src/main/java/forge/util/DevModeUtil.java -text
|
||||
forge-gui/src/main/java/forge/util/Evaluator.java -text
|
||||
forge-gui/src/main/java/forge/util/GuiDisplayUtil.java -text
|
||||
forge-gui/src/main/java/forge/util/HttpUtil.java svneol=native#text/plain
|
||||
@@ -16855,12 +16858,22 @@ forge-gui/src/main/java/forge/util/IgnoringXStream.java -text
|
||||
forge-gui/src/main/java/forge/util/LineReader.java -text
|
||||
forge-gui/src/main/java/forge/util/MultiplexOutputStream.java svneol=native#text/plain
|
||||
forge-gui/src/main/java/forge/util/OperatingSystem.java -text
|
||||
forge-gui/src/main/java/forge/util/WaitCallback.java -text
|
||||
forge-gui/src/main/java/forge/util/XmlUtil.java -text
|
||||
forge-gui/src/main/java/forge/util/gui/SGuiChoose.java -text
|
||||
forge-gui/src/main/java/forge/util/gui/SGuiDialog.java -text
|
||||
forge-gui/src/main/java/forge/util/gui/SOptionPane.java -text
|
||||
forge-gui/src/main/java/forge/util/package-info.java -text
|
||||
forge-gui/src/main/java/forge/view/Cache.java -text
|
||||
forge-gui/src/main/java/forge/view/CardView.java -text
|
||||
forge-gui/src/main/java/forge/view/CombatView.java -text
|
||||
forge-gui/src/main/java/forge/view/GameEntityView.java -text
|
||||
forge-gui/src/main/java/forge/view/IGameView.java -text
|
||||
forge-gui/src/main/java/forge/view/LocalGameView.java -text
|
||||
forge-gui/src/main/java/forge/view/PlayerView.java -text
|
||||
forge-gui/src/main/java/forge/view/SpellAbilityView.java -text
|
||||
forge-gui/src/main/java/forge/view/StackItemView.java -text
|
||||
forge-gui/src/main/java/forge/view/ViewUtil.java -text
|
||||
forge-gui/src/main/java/forge/view/WatchLocalGame.java -text
|
||||
forge-gui/src/main/resources/proxy-template.ftl -text
|
||||
forge-gui/src/site/apt/index.apt -text
|
||||
forge-gui/tools/PerSetTracking.py svneol=native#text/x-python
|
||||
|
||||
4
.project
4
.project
@@ -1,9 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>ForgeLocal</name>
|
||||
<name>forge</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
|
||||
@@ -43,8 +43,8 @@ public class LobbyPlayerAi extends LobbyPlayer implements IGameEntitiesFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player createIngamePlayer(Game game) {
|
||||
Player ai = new Player(getName(), game);
|
||||
public Player createIngamePlayer(Game game, final int id) {
|
||||
Player ai = new Player(getName(), game, id);
|
||||
ai.setFirstController(createControllerFor(ai));
|
||||
|
||||
if( rotateProfileEachGame ) {
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.StaticData;
|
||||
import forge.card.CardDb.SetPreference;
|
||||
import forge.deck.CardPool;
|
||||
@@ -30,9 +31,11 @@ import forge.util.Aggregates;
|
||||
import forge.util.FileSection;
|
||||
import forge.util.FileUtil;
|
||||
import forge.util.IItemReader;
|
||||
import forge.util.MyRandom;
|
||||
import forge.util.storage.StorageBase;
|
||||
import forge.util.storage.StorageReaderBase;
|
||||
import forge.util.storage.StorageReaderFolder;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
@@ -484,4 +487,19 @@ public final class CardEdition implements Comparable<CardEdition> { // immutable
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
public static int getRandomFoil(final String setCode) {
|
||||
FoilType foilType = FoilType.NOT_SUPPORTED;
|
||||
if (setCode != null
|
||||
&& StaticData.instance().getEditions().get(setCode) != null) {
|
||||
foilType = StaticData.instance().getEditions().get(setCode)
|
||||
.getFoilType();
|
||||
}
|
||||
if (foilType != FoilType.NOT_SUPPORTED) {
|
||||
return foilType == FoilType.MODERN
|
||||
? MyRandom.getRandom().nextInt(9) + 1
|
||||
: MyRandom.getRandom().nextInt(9) + 11;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ public class MagicColor {
|
||||
public static final int NUMBER_OR_COLORS = 5;
|
||||
|
||||
public static final byte[] WUBRG = new byte[] { WHITE, BLUE, BLACK, RED, GREEN };
|
||||
public static final byte[] WUBRGC = new byte[] { WHITE, BLUE, BLACK, RED, GREEN, COLORLESS };
|
||||
|
||||
public static byte fromName(String s) {
|
||||
if (s == null) {
|
||||
|
||||
@@ -168,9 +168,10 @@ public class Game implements IGameStateObject {
|
||||
}
|
||||
}
|
||||
|
||||
int plId = 0;
|
||||
for (RegisteredPlayer psc : players0) {
|
||||
IGameEntitiesFactory factory = (IGameEntitiesFactory)psc.getPlayer();
|
||||
Player pl = factory.createIngamePlayer(this);
|
||||
Player pl = factory.createIngamePlayer(this, plId++);
|
||||
players.add(pl);
|
||||
ingamePlayers.add(pl);
|
||||
|
||||
|
||||
@@ -23,13 +23,10 @@ import forge.game.io.GameStateDeserializer;
|
||||
import forge.game.io.GameStateSerializer;
|
||||
import forge.game.io.IGameStateObject;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Observable;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* GameLog class.
|
||||
@@ -64,7 +61,6 @@ public class GameLog extends Observable implements IGameStateObject {
|
||||
* Instantiates a new game log.
|
||||
*/
|
||||
public GameLog() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,11 +80,6 @@ public class GameLog extends Observable implements IGameStateObject {
|
||||
this.notifyObservers();
|
||||
}
|
||||
|
||||
public String getLogText(final GameLogEntryType logLevel) {
|
||||
List<GameLogEntry> filteredAndReversed = getLogEntries(logLevel);
|
||||
return StringUtils.join(filteredAndReversed, "\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the log entries below a certain level as a list.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package forge.game.ability.effects;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.GameObject;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
import forge.game.player.Player;
|
||||
@@ -9,6 +11,7 @@ import forge.game.spellability.SpellAbilityStackInstance;
|
||||
import forge.game.spellability.TargetChoices;
|
||||
import forge.game.zone.MagicStack;
|
||||
import forge.util.Aggregates;
|
||||
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -87,8 +90,8 @@ public class ChangeTargetsEffect extends SpellAbilityEffect {
|
||||
SpellAbility changingTgtSA = changingTgtSI.getSpellAbility();
|
||||
if (sa.hasParam("RandomTarget")){
|
||||
changingTgtSA.resetTargets();
|
||||
List<GameObject> candidates = changingTgtSA.getTargetRestrictions().getAllCandidates(changingTgtSA, true);
|
||||
GameObject choice = Aggregates.random(candidates);
|
||||
List<GameEntity> candidates = changingTgtSA.getTargetRestrictions().getAllCandidates(changingTgtSA, true);
|
||||
GameEntity choice = Aggregates.random(candidates);
|
||||
changingTgtSA.getTargets().add(choice);
|
||||
changingTgtSI.updateTarget(changingTgtSA.getTargets());
|
||||
} else if (sa.hasParam("DefinedMagnet")){
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package forge.game.ability.effects;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import forge.game.GameObject;
|
||||
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.ability.SpellAbilityEffect;
|
||||
import forge.game.card.Card;
|
||||
@@ -94,7 +95,7 @@ public class CopySpellAbilityEffect extends SpellAbilityEffect {
|
||||
if (targetedSA == null) {
|
||||
return;
|
||||
}
|
||||
List<GameObject> candidates = targetedSA.getTargetRestrictions().getAllCandidates(targetedSA, true);
|
||||
final List<GameEntity> candidates = targetedSA.getTargetRestrictions().getAllCandidates(targetedSA, true);
|
||||
if (sa.hasParam("CanTargetPlayer")) {
|
||||
// Radiate
|
||||
// Remove targeted players because getAllCandidates include all the valid players
|
||||
@@ -102,7 +103,7 @@ public class CopySpellAbilityEffect extends SpellAbilityEffect {
|
||||
candidates.remove(p);
|
||||
|
||||
mayChoseNewTargets = false;
|
||||
for (GameObject o : candidates) {
|
||||
for (GameEntity o : candidates) {
|
||||
SpellAbility copy = CardFactory.copySpellAbilityAndSrcCard(card, chosenSA.getHostCard(), chosenSA, true);
|
||||
copy.resetFirstTarget(o, targetedSA);
|
||||
copies.add(copy);
|
||||
@@ -110,7 +111,7 @@ public class CopySpellAbilityEffect extends SpellAbilityEffect {
|
||||
} else {// Precursor Golem, Ink-Treader Nephilim
|
||||
final String type = sa.getParam("CopyForEachCanTarget");
|
||||
List<Card> valid = new ArrayList<Card>();
|
||||
for (final Object o : candidates) {
|
||||
for (final GameEntity o : candidates) {
|
||||
if (o instanceof Card) {
|
||||
valid.add((Card) o);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,6 @@ import forge.item.PaperCard;
|
||||
import forge.util.CollectionSuppliers;
|
||||
import forge.util.Expressions;
|
||||
import forge.util.Lang;
|
||||
import forge.util.MyRandom;
|
||||
import forge.util.TextUtil;
|
||||
import forge.util.maps.HashMapOfLists;
|
||||
import forge.util.maps.MapOfLists;
|
||||
@@ -1607,29 +1606,15 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* TODO Write javadoc for this method.
|
||||
*
|
||||
* @param globalChanges
|
||||
* an ArrayList<CardColor>
|
||||
* @return a CardColor
|
||||
* @return a {@link ColorSet}.
|
||||
* @see CardCharacteristics#determineColor()
|
||||
*/
|
||||
public final ColorSet determineColor() {
|
||||
if (this.isImmutable()) {
|
||||
return ColorSet.getNullColor();
|
||||
}
|
||||
|
||||
List<CardColor> colorList = this.getCharacteristics().getCardColor();
|
||||
|
||||
byte colors = 0;
|
||||
for (int i = colorList.size() - 1;i >= 0;i--) {
|
||||
final CardColor cc = colorList.get(i);
|
||||
colors |= cc.getColorMask();
|
||||
if (!cc.isAdditional()) {
|
||||
return ColorSet.fromMask(colors);
|
||||
}
|
||||
}
|
||||
return ColorSet.fromMask(colors);
|
||||
return this.getCharacteristics().determineColor();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2359,7 +2344,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
boolean primaryCost = true;
|
||||
for (final SpellAbility sa : this.getSpellAbilities()) {
|
||||
// only add abilities not Spell portions of cards
|
||||
if (!this.isPermanent()) {
|
||||
if (sa == null || !this.isPermanent()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -8255,13 +8240,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
* removed.
|
||||
*/
|
||||
public final void setRandomFoil() {
|
||||
CardEdition.FoilType foilType = CardEdition.FoilType.NOT_SUPPORTED;
|
||||
if (this.getCurSetCode() != null && StaticData.instance().getEditions().get(this.getCurSetCode()) != null) {
|
||||
foilType = StaticData.instance().getEditions().get(this.getCurSetCode()).getFoilType();
|
||||
}
|
||||
if (foilType != CardEdition.FoilType.NOT_SUPPORTED) {
|
||||
this.setFoil(foilType == CardEdition.FoilType.MODERN ? MyRandom.getRandom().nextInt(9) + 1 : MyRandom.getRandom().nextInt(9) + 11);
|
||||
}
|
||||
this.setFoil(CardEdition.getRandomFoil(this.getCurSetCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -8885,6 +8864,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
Zone zone = this.getZone();
|
||||
if (zone == null) { return true; } //cards outside any zone are visible to all
|
||||
|
||||
final Player controller = this.getController();
|
||||
switch (zone.getZoneType()) {
|
||||
case Ante:
|
||||
case Command:
|
||||
@@ -8893,33 +8873,31 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
case Graveyard:
|
||||
case Stack:
|
||||
//cards in these zones are visible to all
|
||||
if (isFaceDown() && getController().isOpponentOf(viewer) && !hasKeyword("Your opponent may look at this card.")
|
||||
&& !isVisibleToWhileFaceDown(viewer)) { //Support Lens of Clarity
|
||||
break; //exception is face down cards controlled by opponents
|
||||
}
|
||||
return true;
|
||||
case Hand:
|
||||
if (getController().hasKeyword("Play with your hand revealed.")) {
|
||||
if (controller.hasKeyword("Play with your hand revealed.")) {
|
||||
return true;
|
||||
}
|
||||
//fall through
|
||||
case Sideboard:
|
||||
//face-up cards in these zones are hidden to opponents unless they specify otherwise
|
||||
if (getController().isOpponentOf(viewer) && !hasKeyword("Your opponent may look at this card.")) {
|
||||
if (controller.isOpponentOf(viewer) && !hasKeyword("Your opponent may look at this card.")) {
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
case Library:
|
||||
case PlanarDeck:
|
||||
case SchemeDeck:
|
||||
//cards in these zones are hidden to all unless they specify otherwise
|
||||
if (getController() == viewer && hasKeyword("You may look at this card.")) {
|
||||
if (controller == viewer && hasKeyword("You may look at this card.")) {
|
||||
return true;
|
||||
}
|
||||
if (getController().isOpponentOf(viewer) && hasKeyword("Your opponent may look at this card.")) {
|
||||
if (controller.isOpponentOf(viewer) && hasKeyword("Your opponent may look at this card.")) {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case SchemeDeck:
|
||||
// true for now, to actually see the Scheme cards (can't see deck anyway)
|
||||
return true;
|
||||
}
|
||||
|
||||
//one last check to see if card can be shown
|
||||
@@ -8934,15 +8912,25 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
}
|
||||
|
||||
//if viewer is controlled by another player, also check if card can be shown to that player
|
||||
if (viewer.isMindSlaved()) {
|
||||
return canBeShownTo(viewer.getMindSlaveMaster());
|
||||
if (controller.isMindSlaved() && viewer == controller.getMindSlaveMaster()) {
|
||||
return canBeShownTo(controller);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isVisibleToWhileFaceDown(final Player viewer) {
|
||||
return viewer != null && viewer.getAmountOfKeyword("CanSeeOpponentsFaceDownCards") > 0;
|
||||
public boolean canCardFaceBeShownTo(final Player viewer) {
|
||||
if (!this.isFaceDown()) {
|
||||
return true;
|
||||
}
|
||||
if (viewer.hasKeyword("CanSeeOpponentsFaceDownCards")) {
|
||||
return true;
|
||||
}
|
||||
//if viewer is controlled by another player, also check if face can be shown to that player
|
||||
if (viewer.isMindSlaved() && canCardFaceBeShownTo(viewer.getMindSlaveMaster())) {
|
||||
return true;
|
||||
}
|
||||
return !getController().isOpponentOf(viewer) || hasKeyword("Your opponent may look at this card.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
package forge.game.card;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.CardRarity;
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.game.replacement.ReplacementEffect;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
@@ -41,6 +43,7 @@ public class CardCharacteristics {
|
||||
private List<String> type = new CopyOnWriteArrayList<String>();
|
||||
private ManaCost manaCost = ManaCost.NO_COST;
|
||||
private List<CardColor> cardColor = new ArrayList<CardColor>();
|
||||
private String oracleText = "";
|
||||
private int baseAttack = 0;
|
||||
private int baseDefense = 0;
|
||||
private List<String> intrinsicKeyword = new ArrayList<String>();
|
||||
@@ -143,6 +146,20 @@ public class CardCharacteristics {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the oracleText
|
||||
*/
|
||||
public String getOracleText() {
|
||||
return oracleText;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param oracleText the oracleText to set
|
||||
*/
|
||||
public void setOracleText(final String oracleText) {
|
||||
this.oracleText = oracleText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the base attack.
|
||||
*
|
||||
@@ -211,8 +228,10 @@ public class CardCharacteristics {
|
||||
|
||||
public final void setSpellAbility(SpellAbility sa) {
|
||||
this.spellAbility.clear();
|
||||
if (sa != null) {
|
||||
this.spellAbility.add(sa);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the intrinsic ability.
|
||||
@@ -432,7 +451,6 @@ public class CardCharacteristics {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public CardRarity getRarity() {
|
||||
return rarity;
|
||||
}
|
||||
@@ -452,4 +470,22 @@ public class CardCharacteristics {
|
||||
this.curSetCode = curSetCode;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine the colors.
|
||||
*
|
||||
* @return a {@link ColorSet}.
|
||||
*/
|
||||
public final ColorSet determineColor() {
|
||||
final List<CardColor> colorList = this.getCardColor();
|
||||
byte colors = 0;
|
||||
for (int i = colorList.size() - 1;i >= 0;i--) {
|
||||
final CardColor cc = colorList.get(i);
|
||||
colors |= cc.getColorMask();
|
||||
if (!cc.isAdditional()) {
|
||||
return ColorSet.fromMask(colors);
|
||||
}
|
||||
}
|
||||
return ColorSet.fromMask(colors);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,6 +418,8 @@ public class CardFactory {
|
||||
c.setText(face.getNonAbilityText());
|
||||
if( face.getInitialLoyalty() > 0 ) c.setBaseLoyalty(face.getInitialLoyalty());
|
||||
|
||||
c.getCharacteristics().setOracleText(face.getOracleText().replace("\\n", "\r\n"));
|
||||
|
||||
// Super and 'middle' types should use enums.
|
||||
List<String> coreTypes = face.getType().getTypesBeforeDash();
|
||||
coreTypes.addAll(face.getType().getSubTypes());
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package forge.game.event;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.game.player.Player;
|
||||
import forge.util.Lang;
|
||||
|
||||
/**
|
||||
* This means card's characteristics have changed on server, clients must re-request them
|
||||
*/
|
||||
public class GameEventPlayerStatsChanged extends GameEvent {
|
||||
|
||||
public final Collection<Player> players;
|
||||
public GameEventPlayerStatsChanged(Player affected) {
|
||||
players = Arrays.asList(affected);
|
||||
}
|
||||
|
||||
public GameEventPlayerStatsChanged(Collection<Player> affected) {
|
||||
players = affected;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.game.event.GameEvent#visit(forge.game.event.IGameEventVisitor)
|
||||
*/
|
||||
@Override
|
||||
public <T> T visit(IGameEventVisitor<T> visitor) {
|
||||
// TODO Auto-generated method stub
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (null == players || Iterables.isEmpty(players)) {
|
||||
return "Player state changes: (empty list)";
|
||||
}
|
||||
return String.format("Player state changes: %s", Lang.joinHomogenous(players));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,6 +33,7 @@ public interface IGameEventVisitor<T> {
|
||||
T visit(GameEventPlayerDamaged gameEventPlayerDamaged);
|
||||
T visit(GameEventPlayerPoisoned event);
|
||||
T visit(GameEventPlayerPriority event);
|
||||
T visit(GameEventPlayerStatsChanged event);
|
||||
T visit(GameEventShuffle event);
|
||||
T visit(GameEventSpellAbilityCast gameEventSpellAbilityCast);
|
||||
T visit(GameEventSpellResolved event);
|
||||
@@ -72,6 +73,7 @@ public interface IGameEventVisitor<T> {
|
||||
public T visit(GameEventPlayerControl event) { return null; }
|
||||
public T visit(GameEventPlayerPoisoned event) { return null; }
|
||||
public T visit(GameEventPlayerPriority event) { return null; }
|
||||
public T visit(GameEventPlayerStatsChanged event) { return null; }
|
||||
public T visit(GameEventShuffle event) { return null; }
|
||||
public T visit(GameEventSpellResolved event) { return null; }
|
||||
public T visit(GameEventSpellAbilityCast event) { return null; }
|
||||
|
||||
@@ -2,10 +2,8 @@ package forge.game.player;
|
||||
|
||||
import forge.game.Game;
|
||||
|
||||
|
||||
|
||||
public interface IGameEntitiesFactory
|
||||
{
|
||||
PlayerController createControllerFor(Player p);
|
||||
Player createIngamePlayer(Game game);
|
||||
Player createIngamePlayer(Game game, int id);
|
||||
}
|
||||
|
||||
@@ -71,6 +71,8 @@ import java.util.concurrent.ConcurrentSkipListMap;
|
||||
* @version $Id$
|
||||
*/
|
||||
public class Player extends GameEntity implements Comparable<Player> {
|
||||
private final int id;
|
||||
|
||||
private final Map<Card,Integer> commanderDamage = new HashMap<Card,Integer>();
|
||||
|
||||
/** The poison counters. */
|
||||
@@ -206,7 +208,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
* @param myPoisonCounters
|
||||
* a int.
|
||||
*/
|
||||
public Player(String name, Game game0) {
|
||||
public Player(String name, Game game0, final int id) {
|
||||
game = game0;
|
||||
for (final ZoneType z : Player.ALL_ZONES) {
|
||||
final PlayerZone toPut = z == ZoneType.Battlefield ? new PlayerZoneBattlefield(z, this) : new PlayerZone(z, this);
|
||||
@@ -214,6 +216,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
}
|
||||
|
||||
this.setName(chooseName(name));
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
private String chooseName(String originalName) {
|
||||
@@ -234,6 +237,10 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
return nameCandidate;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Game getGame() { // I'll probably regret about this
|
||||
return game;
|
||||
@@ -1159,9 +1166,11 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
}
|
||||
|
||||
this.changedKeywords.put(timestamp, new KeywordsChange(addKeywords, removeKeywords, false));
|
||||
game.fireEvent(new GameEventPlayerStatsChanged(this));
|
||||
}
|
||||
|
||||
public final KeywordsChange removeChangedKeywords(final Long timestamp) {
|
||||
game.fireEvent(new GameEventPlayerStatsChanged(this));
|
||||
return changedKeywords.remove(Long.valueOf(timestamp));
|
||||
}
|
||||
|
||||
@@ -1205,6 +1214,8 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
this.changedKeywords.remove(ck.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
game.fireEvent(new GameEventPlayerStatsChanged(this));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -3,6 +3,7 @@ package forge.game.player;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import forge.LobbyPlayer;
|
||||
import forge.card.ColorSet;
|
||||
@@ -38,12 +39,10 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* A prototype for player controller class
|
||||
*
|
||||
@@ -83,11 +82,11 @@ public abstract class PlayerController {
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically pass priority until reaching the given phase of the current turn
|
||||
* @param phase
|
||||
* Automatically pass priority until reaching the Cleanup phase of the
|
||||
* current turn.
|
||||
*/
|
||||
public void autoPassUntil(PhaseType phase) {
|
||||
autoPassUntilPhase = phase;
|
||||
public void autoPassUntilEndOfTurn() {
|
||||
autoPassUntilPhase = PhaseType.CLEANUP;
|
||||
}
|
||||
|
||||
protected PhaseType getAutoPassUntilPhase() {
|
||||
@@ -118,14 +117,14 @@ public abstract class PlayerController {
|
||||
}
|
||||
|
||||
// Abilities to auto-yield to
|
||||
private Set<String> autoYields = new HashSet<String>();
|
||||
private final Set<String> autoYields = Sets.newHashSet();
|
||||
public Iterable<String> getAutoYields() {
|
||||
return autoYields;
|
||||
}
|
||||
public boolean shouldAutoYield(String key) {
|
||||
public boolean shouldAutoYield(final String key) {
|
||||
return autoYields.contains(key);
|
||||
}
|
||||
public void setShouldAutoYield(String key, boolean autoYield) {
|
||||
public void setShouldAutoYield(final String key, final boolean autoYield) {
|
||||
if (autoYield) {
|
||||
autoYields.add(key);
|
||||
}
|
||||
|
||||
@@ -17,21 +17,22 @@
|
||||
*/
|
||||
package forge.game.spellability;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.card.CardType;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameObject;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Target class.
|
||||
@@ -473,9 +474,9 @@ public class TargetRestrictions {
|
||||
* Check Valid Candidates and Targeting
|
||||
* @return a List<Object>.
|
||||
*/
|
||||
public final List<GameObject> getAllCandidates(final SpellAbility sa, final boolean isTargeted) {
|
||||
public final List<GameEntity> getAllCandidates(final SpellAbility sa, final boolean isTargeted) {
|
||||
final Game game = sa.getActivatingPlayer().getGame();
|
||||
List<GameObject> candidates = new ArrayList<GameObject>();
|
||||
final List<GameEntity> candidates = Lists.newArrayList();
|
||||
for (Player player : game.getPlayers()) {
|
||||
if (sa.canTarget(player)) {
|
||||
candidates.add(player);
|
||||
|
||||
@@ -20,7 +20,6 @@ import javax.swing.MenuElement;
|
||||
import javax.swing.MenuSelectionManager;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
@@ -31,19 +30,12 @@ import forge.control.FControl;
|
||||
import forge.deck.CardPool;
|
||||
import forge.error.BugReportDialog;
|
||||
import forge.events.UiEvent;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.GameObject;
|
||||
import forge.game.GameType;
|
||||
import forge.game.Match;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.event.GameEventTurnBegan;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.IHasIcon;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.RegisteredPlayer;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.BoxedProductCardListViewer;
|
||||
import forge.gui.CardListViewer;
|
||||
@@ -81,6 +73,11 @@ import forge.toolbox.MouseTriggerEvent;
|
||||
import forge.toolbox.special.PhaseLabel;
|
||||
import forge.util.BuildInfo;
|
||||
import forge.util.ITriggerEvent;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CombatView;
|
||||
import forge.view.GameEntityView;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.SpellAbilityView;
|
||||
|
||||
public class GuiDesktop implements IGuiBase {
|
||||
|
||||
@@ -125,17 +122,6 @@ public class GuiDesktop implements IGuiBase {
|
||||
return SwingUtilities.isEventDispatchThread();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAssetsDir() {
|
||||
return StringUtils.containsIgnoreCase(BuildInfo.getVersionString(), "svn") ?
|
||||
"../forge-gui/" : "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mayShowCard(Card card) {
|
||||
return Singletons.getControl().mayShowCard(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISkinImage getSkinIcon(FSkinProp skinProp) {
|
||||
if (skinProp == null) { return null; }
|
||||
@@ -153,9 +139,9 @@ public class GuiDesktop implements IGuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int showCardOptionDialog(final Card card, String message, String title, FSkinProp skinIcon, String[] options, int defaultOption) {
|
||||
public int showCardOptionDialog(final CardView card, String message, String title, FSkinProp skinIcon, String[] options, int defaultOption) {
|
||||
if (card != null) {
|
||||
FThreads.invokeInEdtAndWait(new Runnable() {
|
||||
FThreads.invokeInEdtAndWait(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
GuiBase.getInterface().setCard(card);
|
||||
@@ -167,17 +153,30 @@ public class GuiDesktop implements IGuiBase {
|
||||
|
||||
@Override
|
||||
public <T> T showInputDialog(String message, String title, FSkinProp icon, T initialInput, T[] inputOptions) {
|
||||
if (initialInput instanceof GameObject || (inputOptions != null && inputOptions.length > 0 && inputOptions[0] instanceof GameObject)) {
|
||||
System.err.println("Warning: GameObject passed to GUI! Printing stack trace.");
|
||||
Thread.dumpStack();
|
||||
}
|
||||
return FOptionPane.showInputDialog(message, title, icon == null ? null : FSkin.getImage(icon), initialInput, inputOptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> getChoices(final String message, final int min, final int max, final Collection<T> choices, final T selected, final Function<T, String> display) {
|
||||
if ((choices != null && !choices.isEmpty() && choices.iterator().next() instanceof GameObject) || selected instanceof GameObject) {
|
||||
System.err.println("Warning: GameObject passed to GUI! Printing stack trace.");
|
||||
Thread.dumpStack();
|
||||
}
|
||||
return GuiChoose.getChoices(message, min, max, choices, selected, display);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> order(final String title, final String top, final int remainingObjectsMin, final int remainingObjectsMax,
|
||||
final List<T> sourceChoices, final List<T> destChoices, final Card referenceCard, final boolean sideboardingMode) {
|
||||
final List<T> sourceChoices, final List<T> destChoices, final CardView referenceCard, final boolean sideboardingMode) {
|
||||
if ((sourceChoices != null && !sourceChoices.isEmpty() && sourceChoices.iterator().next() instanceof GameObject)
|
||||
|| (destChoices != null && !destChoices.isEmpty() && destChoices.iterator().next() instanceof GameObject)) {
|
||||
System.err.println("Warning: GameObject passed to GUI! Printing stack trace.");
|
||||
Thread.dumpStack();
|
||||
}
|
||||
return GuiChoose.order(title, top, remainingObjectsMin, remainingObjectsMax, sourceChoices, destChoices, referenceCard, sideboardingMode);
|
||||
}
|
||||
|
||||
@@ -215,7 +214,7 @@ public class GuiDesktop implements IGuiBase {
|
||||
public void focusButton(final IButton button) {
|
||||
// ensure we don't steal focus from an overlay
|
||||
if (!SOverlayUtils.overlayHasFocus()) {
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
((FButton)button).requestFocusInWindow();
|
||||
@@ -231,10 +230,8 @@ public class GuiDesktop implements IGuiBase {
|
||||
|
||||
@Override
|
||||
public void updatePhase() {
|
||||
PhaseHandler pH = Singletons.getControl().getObservedGame().getPhaseHandler();
|
||||
Player p = pH.getPlayerTurn();
|
||||
PhaseType ph = pH.getPhase();
|
||||
|
||||
final PlayerView p = Singletons.getControl().getGameView().getPlayerTurn();
|
||||
final PhaseType ph = Singletons.getControl().getGameView().getPhase();
|
||||
final CMatchUI matchUi = CMatchUI.SINGLETON_INSTANCE;
|
||||
PhaseLabel lbl = matchUi.getFieldViewFor(p).getPhaseIndicator().getLabelFor(ph);
|
||||
|
||||
@@ -245,10 +242,10 @@ public class GuiDesktop implements IGuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTurn(final GameEventTurnBegan event, final Game game) {
|
||||
VField nextField = CMatchUI.SINGLETON_INSTANCE.getFieldViewFor(event.turnOwner);
|
||||
public void updateTurn(final PlayerView player) {
|
||||
VField nextField = CMatchUI.SINGLETON_INSTANCE.getFieldViewFor(player);
|
||||
SDisplayUtil.showTab(nextField);
|
||||
CPrompt.SINGLETON_INSTANCE.updateText(game);
|
||||
CPrompt.SINGLETON_INSTANCE.updateText();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -273,7 +270,7 @@ public class GuiDesktop implements IGuiBase {
|
||||
|
||||
@Override
|
||||
public void finishGame() {
|
||||
new ViewWinLose(Singletons.getControl().getObservedGame());
|
||||
new ViewWinLose(Singletons.getControl().getGameView());
|
||||
if (showOverlay) {
|
||||
SOverlayUtils.showOverlay();
|
||||
}
|
||||
@@ -290,12 +287,12 @@ public class GuiDesktop implements IGuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPanelSelection(Card c) {
|
||||
public void setPanelSelection(final CardView c) {
|
||||
GuiUtils.setPanelSelection(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellAbility getAbilityToPlay(List<SpellAbility> abilities, ITriggerEvent triggerEvent) {
|
||||
public SpellAbilityView getAbilityToPlay(List<SpellAbilityView> abilities, ITriggerEvent triggerEvent) {
|
||||
if (triggerEvent == null) {
|
||||
if (abilities.isEmpty()) {
|
||||
return null;
|
||||
@@ -309,7 +306,7 @@ public class GuiDesktop implements IGuiBase {
|
||||
if (abilities.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
if (abilities.size() == 1 && !abilities.get(0).promptIfOnlyPossibleAbility()) {
|
||||
if (abilities.size() == 1 && !abilities.get(0).isPromptIfOnlyPossibleAbility()) {
|
||||
if (abilities.get(0).canPlay()) {
|
||||
return abilities.get(0); //only return ability if it's playable, otherwise return null
|
||||
}
|
||||
@@ -322,7 +319,7 @@ public class GuiDesktop implements IGuiBase {
|
||||
boolean enabled;
|
||||
boolean hasEnabled = false;
|
||||
int shortcut = KeyEvent.VK_1; //use number keys as shortcuts for abilities 1-9
|
||||
for (final SpellAbility ab : abilities) {
|
||||
for (final SpellAbilityView ab : abilities) {
|
||||
enabled = ab.canPlay();
|
||||
if (enabled) {
|
||||
hasEnabled = true;
|
||||
@@ -332,7 +329,7 @@ public class GuiDesktop implements IGuiBase {
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CPrompt.SINGLETON_INSTANCE.getInputControl().selectAbility(ab);
|
||||
CPrompt.SINGLETON_INSTANCE.selectAbility(ab);
|
||||
}
|
||||
}, enabled);
|
||||
if (shortcut > 0) {
|
||||
@@ -374,32 +371,32 @@ public class GuiDesktop implements IGuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCard(Card card) {
|
||||
public void setCard(final CardView card) {
|
||||
CMatchUI.SINGLETON_INSTANCE.setCard(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showCombat(Combat combat) {
|
||||
public void showCombat(final CombatView combat) {
|
||||
CMatchUI.SINGLETON_INSTANCE.showCombat(combat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUsedToPay(Card card, boolean b) {
|
||||
public void setUsedToPay(final CardView card, final boolean b) {
|
||||
CMatchUI.SINGLETON_INSTANCE.setUsedToPay(card, b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHighlighted(Player player, boolean b) {
|
||||
public void setHighlighted(final PlayerView player, final boolean b) {
|
||||
CMatchUI.SINGLETON_INSTANCE.setHighlighted(player, b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showPromptMessage(String message) {
|
||||
public void showPromptMessage(final String message) {
|
||||
CMatchUI.SINGLETON_INSTANCE.showMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stopAtPhase(Player playerTurn, PhaseType phase) {
|
||||
public boolean stopAtPhase(final PlayerView playerTurn, PhaseType phase) {
|
||||
return CMatchUI.SINGLETON_INSTANCE.stopAtPhase(playerTurn, phase);
|
||||
}
|
||||
|
||||
@@ -408,24 +405,19 @@ public class GuiDesktop implements IGuiBase {
|
||||
return FControl.instance.getInputQueue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Game getGame() {
|
||||
return FControl.instance.getObservedGame();
|
||||
}
|
||||
|
||||
public Object showManaPool(Player player) {
|
||||
public Object showManaPool(final PlayerView player) {
|
||||
return null; //not needed since mana pool icons are always visible
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideManaPool(Player player, Object zoneToRestore) {
|
||||
public void hideManaPool(final PlayerView player, final Object zoneToRestore) {
|
||||
//not needed since mana pool icons are always visible
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean openZones(List<ZoneType> zones, Map<Player, Object> players) {
|
||||
public boolean openZones(final Collection<ZoneType> zones, final Map<PlayerView, Object> players) {
|
||||
if (zones.size() == 1) {
|
||||
switch (zones.get(0)) {
|
||||
switch (zones.iterator().next()) {
|
||||
case Battlefield:
|
||||
case Hand:
|
||||
return true; //don't actually need to open anything, but indicate that zone can be opened
|
||||
@@ -437,31 +429,31 @@ public class GuiDesktop implements IGuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreOldZones(Map<Player, Object> playersToRestoreZonesFor) {
|
||||
public void restoreOldZones(final Map<PlayerView, Object> playersToRestoreZonesFor) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateZones(List<Pair<Player, ZoneType>> zonesToUpdate) {
|
||||
public void updateZones(final List<Pair<PlayerView, ZoneType>> zonesToUpdate) {
|
||||
CMatchUI.SINGLETON_INSTANCE.updateZones(zonesToUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCards(Set<Card> cardsToUpdate) {
|
||||
public void updateCards(final Set<CardView> cardsToUpdate) {
|
||||
CMatchUI.SINGLETON_INSTANCE.updateCards(cardsToUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshCardDetails(Collection<Card> cards) {
|
||||
public void refreshCardDetails(final Iterable<CardView> cards) {
|
||||
CMatchUI.SINGLETON_INSTANCE.refreshCardDetails(cards);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateManaPool(List<Player> manaPoolUpdate) {
|
||||
public void updateManaPool(final List<PlayerView> manaPoolUpdate) {
|
||||
CMatchUI.SINGLETON_INSTANCE.updateManaPool(manaPoolUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLives(List<Player> livesUpdate) {
|
||||
public void updateLives(final List<PlayerView> livesUpdate) {
|
||||
CMatchUI.SINGLETON_INSTANCE.updateLives(livesUpdate);
|
||||
}
|
||||
|
||||
@@ -471,10 +463,11 @@ public class GuiDesktop implements IGuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Card, Integer> getDamageToAssign(Card attacker, List<Card> blockers,
|
||||
int damageDealt, GameEntity defender, boolean overrideOrder) {
|
||||
return CMatchUI.SINGLETON_INSTANCE.getDamageToAssign(attacker, blockers,
|
||||
damageDealt, defender, overrideOrder);
|
||||
public Map<CardView, Integer> getDamageToAssign(final CardView attacker,
|
||||
final List<CardView> blockers, final int damageDealt,
|
||||
final GameEntityView defender, final boolean overrideOrder) {
|
||||
return CMatchUI.SINGLETON_INSTANCE.getDamageToAssign(attacker,
|
||||
blockers, damageDealt, defender, overrideOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,16 @@
|
||||
*/
|
||||
package forge;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader.InvalidCacheLoadException;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
@@ -24,21 +34,11 @@ import com.mortennobel.imagescaling.ResampleOp;
|
||||
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.assets.ImageUtil;
|
||||
import forge.game.card.Card;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinIcon;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import forge.view.CardView;
|
||||
|
||||
/**
|
||||
* This class stores ALL card images in a cache with soft values. this means
|
||||
@@ -80,13 +80,8 @@ public class ImageCache {
|
||||
* retrieve an image from the cache. returns null if the image is not found in the cache
|
||||
* and cannot be loaded from disk. pass -1 for width and/or height to avoid resizing in that dimension.
|
||||
*/
|
||||
public static BufferedImage getImage(Card card, int width, int height) {
|
||||
final String key;
|
||||
if (!Singletons.getControl().mayShowCard(card) || card.isFaceDown()) {
|
||||
key = ImageKeys.TOKEN_PREFIX + ImageKeys.MORPH_IMAGE;
|
||||
} else {
|
||||
key = card.getImageKey();
|
||||
}
|
||||
public static BufferedImage getImage(final CardView card, final int width, final int height) {
|
||||
final String key = card.getOriginal().getImageKey();
|
||||
return scaleImage(key, width, height, true);
|
||||
}
|
||||
|
||||
@@ -199,7 +194,7 @@ public class ImageCache {
|
||||
* Returns the Image corresponding to the key.
|
||||
*/
|
||||
private static BufferedImage getImage(final String key) {
|
||||
FThreads.assertExecutedByEdt(true);
|
||||
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
|
||||
try {
|
||||
return ImageCache._CACHE.get(key);
|
||||
} catch (final ExecutionException ex) {
|
||||
|
||||
@@ -92,7 +92,7 @@ final class ImageLoader extends CacheLoader<String, BufferedImage> {
|
||||
return ImageIO.read(file);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
BugReporter.reportException(ex, "Could not read image file " + file.getAbsolutePath() + " ");
|
||||
BugReporter.reportException(ex, GuiBase.getInterface(), "Could not read image file " + file.getAbsolutePath() + " ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package forge;
|
||||
|
||||
import forge.control.FControl;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgeProfileProperties;
|
||||
import forge.view.FView;
|
||||
|
||||
/**
|
||||
@@ -37,7 +38,7 @@ public final class Singletons {
|
||||
public static FControl getControl() { return control; }
|
||||
|
||||
public static void initializeOnce(boolean withUi) {
|
||||
FThreads.assertExecutedByEdt(false);
|
||||
FThreads.assertExecutedByEdt(GuiBase.getInterface(), false);
|
||||
|
||||
synchronized (Singletons.class) {
|
||||
if (initialized) {
|
||||
@@ -46,11 +47,13 @@ public final class Singletons {
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
ForgeProfileProperties.init(GuiBase.getInterface());
|
||||
|
||||
if (withUi) {
|
||||
view = FView.SINGLETON_INSTANCE;
|
||||
}
|
||||
|
||||
FModel.initialize(view == null ? null : view.getSplash().getProgressBar());
|
||||
FModel.initialize(GuiBase.getInterface(), view == null ? null : view.getSplash().getProgressBar());
|
||||
|
||||
if (withUi) {
|
||||
control = FControl.instance;
|
||||
|
||||
@@ -17,6 +17,26 @@
|
||||
*/
|
||||
package forge.control;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.KeyEventDispatcher;
|
||||
import java.awt.KeyboardFocusManager;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JLayeredPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.ImageCache;
|
||||
@@ -30,20 +50,26 @@ import forge.game.Game;
|
||||
import forge.game.GameRules;
|
||||
import forge.game.GameType;
|
||||
import forge.game.Match;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.RegisteredPlayer;
|
||||
import forge.gui.GuiDialog;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.gui.framework.*;
|
||||
import forge.player.GamePlayerUtil;
|
||||
import forge.player.LobbyPlayerHuman;
|
||||
import forge.gui.framework.EDocID;
|
||||
import forge.gui.framework.FScreen;
|
||||
import forge.gui.framework.InvalidLayoutFileException;
|
||||
import forge.gui.framework.SDisplayUtil;
|
||||
import forge.gui.framework.SLayoutIO;
|
||||
import forge.gui.framework.SOverflowUtil;
|
||||
import forge.gui.framework.SResizingUtil;
|
||||
import forge.match.input.InputQueue;
|
||||
import forge.menus.ForgeMenu;
|
||||
import forge.model.FModel;
|
||||
import forge.player.GamePlayerUtil;
|
||||
import forge.player.LobbyPlayerHuman;
|
||||
import forge.player.PlayerControllerHuman;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.quest.QuestController;
|
||||
import forge.quest.data.QuestPreferences.QPref;
|
||||
import forge.quest.io.QuestDataIO;
|
||||
@@ -53,7 +79,6 @@ import forge.screens.match.VMatchUI;
|
||||
import forge.screens.match.controllers.CDock;
|
||||
import forge.screens.match.controllers.CLog;
|
||||
import forge.screens.match.controllers.CPlayers;
|
||||
import forge.screens.match.controllers.CPrompt;
|
||||
import forge.screens.match.controllers.CStack;
|
||||
import forge.screens.match.views.VAntes;
|
||||
import forge.screens.match.views.VDev;
|
||||
@@ -68,17 +93,10 @@ import forge.util.MyRandom;
|
||||
import forge.util.NameGenerator;
|
||||
import forge.view.FFrame;
|
||||
import forge.view.FView;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import forge.view.IGameView;
|
||||
import forge.view.LocalGameView;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.WatchLocalGame;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -97,7 +115,7 @@ public enum FControl implements KeyEventDispatcher {
|
||||
private FScreen currentScreen;
|
||||
private boolean altKeyLastDown;
|
||||
private CloseAction closeAction;
|
||||
private Player localPlayer;
|
||||
private PlayerView localPlayer;
|
||||
|
||||
public static enum CloseAction {
|
||||
NONE,
|
||||
@@ -105,7 +123,7 @@ public enum FControl implements KeyEventDispatcher {
|
||||
EXIT_FORGE
|
||||
}
|
||||
|
||||
private final SoundSystem soundSystem = new SoundSystem();
|
||||
private SoundSystem soundSystem;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -173,10 +191,10 @@ public enum FControl implements KeyEventDispatcher {
|
||||
public boolean canExitForge(boolean forRestart) {
|
||||
String action = (forRestart ? "Restart" : "Exit");
|
||||
String userPrompt = "Are you sure you wish to " + (forRestart ? "restart" : "exit") + " Forge?";
|
||||
if (this.game != null) {
|
||||
if (this.gameView != null) {
|
||||
userPrompt = "A game is currently active. " + userPrompt;
|
||||
}
|
||||
if (!FOptionPane.showConfirmDialog(userPrompt, action + " Forge", action, "Cancel", this.game == null)) { //default Yes if no game active
|
||||
if (!FOptionPane.showConfirmDialog(userPrompt, action + " Forge", action, "Cancel", this.gameView == null)) { //default Yes if no game active
|
||||
return false;
|
||||
}
|
||||
if (!CDeckEditorUI.SINGLETON_INSTANCE.canSwitchAway(true)) {
|
||||
@@ -199,6 +217,8 @@ public enum FControl implements KeyEventDispatcher {
|
||||
// Preloads skin components (using progress bar).
|
||||
FSkin.loadFull(true);
|
||||
|
||||
this.soundSystem = new SoundSystem(GuiBase.getInterface());
|
||||
|
||||
this.shortcuts = KeyboardShortcuts.attachKeyboardShortcuts();
|
||||
this.display = FView.SINGLETON_INSTANCE.getLpnDocument();
|
||||
|
||||
@@ -351,31 +371,6 @@ public enum FControl implements KeyEventDispatcher {
|
||||
if (children.length != 0) { children[0].setSize(display.getSize()); }
|
||||
}
|
||||
|
||||
public Player getCurrentPlayer() {
|
||||
// try current priority
|
||||
Player currentPriority = game.getPhaseHandler().getPriorityPlayer();
|
||||
if (null != currentPriority && currentPriority.getLobbyPlayer() == getGuiPlayer()) {
|
||||
return currentPriority;
|
||||
}
|
||||
|
||||
// otherwise find just any player, belonging to this lobbyplayer
|
||||
for (Player p : game.getPlayers()) {
|
||||
if (p.getLobbyPlayer() == getGuiPlayer()) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean mayShowCard(Card c) {
|
||||
return game == null || !gameHasHumanPlayer || ForgePreferences.DEV_MODE || c.canBeShownTo(getCurrentPlayer());
|
||||
}
|
||||
|
||||
public boolean maySeeFaceDownCard(Card c) {
|
||||
return game == null || !gameHasHumanPlayer || ForgePreferences.DEV_MODE || c.isVisibleToWhileFaceDown(getCurrentPlayer());
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @return
|
||||
@@ -385,13 +380,13 @@ public enum FControl implements KeyEventDispatcher {
|
||||
}
|
||||
|
||||
private Game game;
|
||||
private boolean gameHasHumanPlayer;
|
||||
private IGameView gameView;
|
||||
|
||||
public Game getObservedGame() {
|
||||
return game;
|
||||
public IGameView getGameView() {
|
||||
return this.gameView;
|
||||
}
|
||||
|
||||
public Player getLocalPlayer() {
|
||||
public PlayerView getLocalPlayer() {
|
||||
return localPlayer;
|
||||
}
|
||||
|
||||
@@ -423,111 +418,148 @@ public enum FControl implements KeyEventDispatcher {
|
||||
inputQueue.onGameOver(false); //release any waiting input, effectively passing priority
|
||||
}
|
||||
|
||||
if (playbackControl != null) {
|
||||
playbackControl.onGameStopRequested();
|
||||
}
|
||||
}
|
||||
|
||||
private InputQueue inputQueue;
|
||||
public InputQueue getInputQueue() {
|
||||
return inputQueue;
|
||||
}
|
||||
|
||||
public final void startGameWithUi(final Match match) {
|
||||
public final void startGameInSameMatch() {
|
||||
this.startGameWithUi(this.game.getMatch());
|
||||
}
|
||||
public final void startGameAndClearMatch() {
|
||||
if (this.game != null) {
|
||||
this.game.getMatch().clearGamesPlayed();
|
||||
}
|
||||
startGameInSameMatch();
|
||||
}
|
||||
|
||||
public final void startGameWithUi(final Match match) {
|
||||
if (this.gameView != null) {
|
||||
this.setCurrentScreen(FScreen.MATCH_SCREEN);
|
||||
SOverlayUtils.hideOverlay();
|
||||
FOptionPane.showMessageDialog("Cannot start a new game while another game is already in progress.");
|
||||
return; //TODO: See if it's possible to run multiple games at once without crashing
|
||||
}
|
||||
setPlayerName(match.getPlayers());
|
||||
final Game newGame = match.createGame();
|
||||
attachToGame(newGame);
|
||||
this.game = match.createGame();
|
||||
inputQueue = new InputQueue(game);
|
||||
|
||||
boolean anyPlayerIsAi = false;
|
||||
for (final Player p : game.getPlayers()) {
|
||||
if (p.getLobbyPlayer() instanceof LobbyPlayerAi) {
|
||||
anyPlayerIsAi = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
final LobbyPlayer me = getGuiPlayer();
|
||||
for (final Player p : game.getPlayers()) {
|
||||
if (p.getLobbyPlayer().equals(me)) {
|
||||
final PlayerControllerHuman controller = (PlayerControllerHuman) p.getController();
|
||||
this.gameView = controller.getGameView();
|
||||
this.fcVisitor = new FControlGameEventHandler(GuiBase.getInterface(), controller.getGameView());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!anyPlayerIsAi) {
|
||||
// If there are no AI's, allow all players to see all cards (hotseat
|
||||
// mode).
|
||||
for (final Player p : game.getPlayers()) {
|
||||
if (p.getController() instanceof PlayerControllerHuman) {
|
||||
final PlayerControllerHuman controller = (PlayerControllerHuman) p.getController();
|
||||
controller.setMayLookAtAllCards(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.gameView == null) {
|
||||
// Watch game but do not participate
|
||||
final LocalGameView gameView = new WatchLocalGame(game, inputQueue);
|
||||
this.gameView = gameView;
|
||||
this.fcVisitor = new FControlGameEventHandler(GuiBase.getInterface(), gameView);
|
||||
this.playbackControl = new FControlGamePlayback(GuiBase.getInterface(), gameView);
|
||||
this.playbackControl.setGame(game);
|
||||
this.game.subscribeToEvents(playbackControl);
|
||||
}
|
||||
|
||||
attachToGame(this.gameView);
|
||||
|
||||
// It's important to run match in a different thread to allow GUI inputs to be invoked from inside game.
|
||||
// Game is set on pause while gui player takes decisions
|
||||
game.getAction().invoke(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
match.startGame(newGame);
|
||||
match.startGame(game);
|
||||
}
|
||||
});
|
||||
SOverlayUtils.hideOverlay();
|
||||
}
|
||||
|
||||
public final void endCurrentGame() {
|
||||
if (this.game == null) { return; }
|
||||
if (this.gameView == null) { return; }
|
||||
|
||||
Singletons.getView().getNavigationBar().closeTab(FScreen.MATCH_SCREEN);
|
||||
this.game = null;
|
||||
|
||||
this.gameView = null;
|
||||
}
|
||||
|
||||
private final FControlGameEventHandler fcVisitor = new FControlGameEventHandler();
|
||||
private final FControlGamePlayback playbackControl = new FControlGamePlayback();
|
||||
private void attachToGame(Game game0) {
|
||||
if (game0.getRules().getGameType() == GameType.Quest) {
|
||||
private FControlGameEventHandler fcVisitor;
|
||||
private FControlGamePlayback playbackControl;
|
||||
private void attachToGame(final IGameView game0) {
|
||||
if (game0.getGameType().equals(GameType.Quest)) {
|
||||
QuestController qc = FModel.getQuest();
|
||||
// Reset new list when the Match round starts, not when each game starts
|
||||
if (game0.getMatch().getPlayedGames().isEmpty()) {
|
||||
if (game0.isFirstGameInMatch()) {
|
||||
qc.getCards().resetNewList();
|
||||
}
|
||||
game0.subscribeToEvents(qc); // this one listens to player's mulligans ATM
|
||||
}
|
||||
|
||||
inputQueue = new InputQueue();
|
||||
|
||||
this.game = game0;
|
||||
game.subscribeToEvents(Singletons.getControl().getSoundSystem());
|
||||
game0.subscribeToEvents(Singletons.getControl().getSoundSystem());
|
||||
|
||||
//switch back to match screen music
|
||||
Singletons.getControl().getSoundSystem().setBackgroundMusic(MusicPlaylist.MATCH);
|
||||
|
||||
LobbyPlayer humanLobbyPlayer = getGuiPlayer();
|
||||
final LobbyPlayer humanLobbyPlayer = getGuiPlayer();
|
||||
// The UI controls should use these game data as models
|
||||
CMatchUI.SINGLETON_INSTANCE.initMatch(game.getRegisteredPlayers(), humanLobbyPlayer);
|
||||
final List<PlayerView> players = game0.getPlayers();
|
||||
CMatchUI.SINGLETON_INSTANCE.initMatch(game0, players, humanLobbyPlayer);
|
||||
|
||||
localPlayer = null;
|
||||
for (Player p : game.getPlayers()) {
|
||||
for (final PlayerView p : players) {
|
||||
if (p.getLobbyPlayer() == humanLobbyPlayer) {
|
||||
localPlayer = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CDock.SINGLETON_INSTANCE.setModel(game, humanLobbyPlayer);
|
||||
CStack.SINGLETON_INSTANCE.setModel(game.getStack(), localPlayer);
|
||||
CPlayers.SINGLETON_INSTANCE.setModel(game);
|
||||
CLog.SINGLETON_INSTANCE.setModel(game.getGameLog());
|
||||
CDock.SINGLETON_INSTANCE.setModel(game0);
|
||||
CStack.SINGLETON_INSTANCE.setModel(game0, localPlayer);
|
||||
CPlayers.SINGLETON_INSTANCE.setModel(game0);
|
||||
CLog.SINGLETON_INSTANCE.setModel(game0);
|
||||
|
||||
actuateMatchPreferences();
|
||||
VAntes.SINGLETON_INSTANCE.setModel(game.getRegisteredPlayers());
|
||||
VAntes.SINGLETON_INSTANCE.setModel(players);
|
||||
|
||||
setCurrentScreen(FScreen.MATCH_SCREEN);
|
||||
SDisplayUtil.showTab(EDocID.REPORT_LOG.getDoc());
|
||||
|
||||
CPrompt.SINGLETON_INSTANCE.getInputControl().setGame(game);
|
||||
|
||||
// Listen to DuelOutcome event to show ViewWinLose
|
||||
game.subscribeToEvents(fcVisitor);
|
||||
|
||||
// Add playback controls to match if needed
|
||||
gameHasHumanPlayer = false;
|
||||
for (Player p : game.getPlayers()) {
|
||||
if (p.getController().getLobbyPlayer() == getGuiPlayer())
|
||||
gameHasHumanPlayer = true;
|
||||
}
|
||||
|
||||
if (!gameHasHumanPlayer) {
|
||||
game.subscribeToEvents(playbackControl);
|
||||
}
|
||||
|
||||
for (final VField field : VMatchUI.SINGLETON_INSTANCE.getFieldViews()) {
|
||||
field.getDetailsPanel().getLblLibrary().setHoverable(ForgePreferences.DEV_MODE);
|
||||
}
|
||||
game0.subscribeToEvents(fcVisitor);
|
||||
|
||||
// per player observers were set in CMatchUI.SINGLETON_INSTANCE.initMatch
|
||||
//Set Field shown to current player.
|
||||
VField nextField = CMatchUI.SINGLETON_INSTANCE.getFieldViewFor(game.getPlayers().get(0));
|
||||
if (localPlayer != null) {
|
||||
final VField nextField = CMatchUI.SINGLETON_INSTANCE.getFieldViewFor(localPlayer);
|
||||
SDisplayUtil.showTab(nextField);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.awt.KeyEventDispatcher#dispatchKeyEvent(java.awt.event.KeyEvent)
|
||||
@@ -575,7 +607,7 @@ public enum FControl implements KeyEventDispatcher {
|
||||
boolean isPlayerOneHuman = players.get(0).getPlayer() instanceof LobbyPlayerHuman;
|
||||
boolean isPlayerTwoComputer = players.get(1).getPlayer() instanceof LobbyPlayerAi;
|
||||
if (isPlayerOneHuman && isPlayerTwoComputer) {
|
||||
GamePlayerUtil.setPlayerName();
|
||||
GamePlayerUtil.setPlayerName(GuiBase.getInterface());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -601,7 +633,7 @@ public enum FControl implements KeyEventDispatcher {
|
||||
final Match mc = new Match(rules, players);
|
||||
SOverlayUtils.startGameOverlay();
|
||||
SOverlayUtils.showOverlay();
|
||||
FThreads.invokeInEdtLater(new Runnable(){
|
||||
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
startGameWithUi(mc);
|
||||
@@ -663,22 +695,7 @@ public enum FControl implements KeyEventDispatcher {
|
||||
final ForgePreferences prefs = FModel.getPreferences();
|
||||
final List<VField> fieldViews = VMatchUI.SINGLETON_INSTANCE.getFieldViews();
|
||||
|
||||
// AI field is at index [0]
|
||||
PhaseIndicator fvAi = fieldViews.get(1).getPhaseIndicator();
|
||||
fvAi.getLblUpkeep().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_UPKEEP));
|
||||
fvAi.getLblDraw().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_DRAW));
|
||||
fvAi.getLblMain1().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_MAIN1));
|
||||
fvAi.getLblBeginCombat().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_BEGINCOMBAT));
|
||||
fvAi.getLblDeclareAttackers().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_DECLAREATTACKERS));
|
||||
fvAi.getLblDeclareBlockers().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_DECLAREBLOCKERS));
|
||||
fvAi.getLblFirstStrike().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_FIRSTSTRIKE));
|
||||
fvAi.getLblCombatDamage().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_COMBATDAMAGE));
|
||||
fvAi.getLblEndCombat().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_ENDCOMBAT));
|
||||
fvAi.getLblMain2().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_MAIN2));
|
||||
fvAi.getLblEndTurn().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_EOT));
|
||||
fvAi.getLblCleanup().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_CLEANUP));
|
||||
|
||||
// Human field is at index [1]
|
||||
// Human field is at index [0]
|
||||
PhaseIndicator fvHuman = fieldViews.get(0).getPhaseIndicator();
|
||||
fvHuman.getLblUpkeep().setEnabled(prefs.getPrefBoolean(FPref.PHASE_HUMAN_UPKEEP));
|
||||
fvHuman.getLblDraw().setEnabled(prefs.getPrefBoolean(FPref.PHASE_HUMAN_DRAW));
|
||||
@@ -693,6 +710,23 @@ public enum FControl implements KeyEventDispatcher {
|
||||
fvHuman.getLblEndTurn().setEnabled(prefs.getPrefBoolean(FPref.PHASE_HUMAN_EOT));
|
||||
fvHuman.getLblCleanup().setEnabled(prefs.getPrefBoolean(FPref.PHASE_HUMAN_CLEANUP));
|
||||
|
||||
// AI field is at index [1], ...
|
||||
for (int i = 1; i < fieldViews.size(); i++) {
|
||||
PhaseIndicator fvAi = fieldViews.get(i).getPhaseIndicator();
|
||||
fvAi.getLblUpkeep().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_UPKEEP));
|
||||
fvAi.getLblDraw().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_DRAW));
|
||||
fvAi.getLblMain1().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_MAIN1));
|
||||
fvAi.getLblBeginCombat().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_BEGINCOMBAT));
|
||||
fvAi.getLblDeclareAttackers().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_DECLAREATTACKERS));
|
||||
fvAi.getLblDeclareBlockers().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_DECLAREBLOCKERS));
|
||||
fvAi.getLblFirstStrike().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_FIRSTSTRIKE));
|
||||
fvAi.getLblCombatDamage().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_COMBATDAMAGE));
|
||||
fvAi.getLblEndCombat().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_ENDCOMBAT));
|
||||
fvAi.getLblMain2().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_MAIN2));
|
||||
fvAi.getLblEndTurn().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_EOT));
|
||||
fvAi.getLblCleanup().setEnabled(prefs.getPrefBoolean(FPref.PHASE_AI_CLEANUP));
|
||||
}
|
||||
|
||||
//Singletons.getView().getViewMatch().setLayoutParams(prefs.getPref(FPref.UI_LAYOUT_PARAMS));
|
||||
}
|
||||
|
||||
@@ -725,7 +759,7 @@ public enum FControl implements KeyEventDispatcher {
|
||||
return player;
|
||||
}
|
||||
|
||||
private final LobbyPlayer guiPlayer = new LobbyPlayerHuman("Human");
|
||||
private final LobbyPlayer guiPlayer = new LobbyPlayerHuman("Human", GuiBase.getInterface());
|
||||
public final LobbyPlayer getGuiPlayer() {
|
||||
return guiPlayer;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package forge.deckchooser;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.UiCommand;
|
||||
import forge.deck.ColorDeckGenerator;
|
||||
import forge.deck.Deck;
|
||||
@@ -50,7 +51,7 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
||||
|
||||
//Show dialog to select a deck
|
||||
public static Deck promptForDeck(String title, DeckType defaultDeckType, boolean forAi) {
|
||||
FThreads.assertExecutedByEdt(true);
|
||||
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
|
||||
final FDeckChooser chooser = new FDeckChooser(forAi);
|
||||
chooser.initialize(defaultDeckType);
|
||||
chooser.populate();
|
||||
@@ -130,7 +131,7 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
|
||||
"White", "Blue", "Black", "Red", "Green" };
|
||||
ArrayList<DeckProxy> decks = new ArrayList<DeckProxy>();
|
||||
for (int i = 0; i < colors.length; i++) {
|
||||
decks.add(new ColorDeckGenerator(colors[i], i, lstDecks, isAi));
|
||||
decks.add(new ColorDeckGenerator(GuiBase.getInterface(), colors[i], i, lstDecks, isAi));
|
||||
}
|
||||
|
||||
lstDecks.setPool(decks);
|
||||
|
||||
@@ -1,27 +1,7 @@
|
||||
package forge.deckchooser;
|
||||
|
||||
import forge.deck.CardPool;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckSection;
|
||||
import forge.game.card.Card;
|
||||
import forge.gui.CardDetailPanel;
|
||||
import forge.gui.CardPicturePanel;
|
||||
import forge.item.PaperCard;
|
||||
import forge.itemmanager.CardManager;
|
||||
import forge.itemmanager.ItemManagerConfig;
|
||||
import forge.itemmanager.ItemManagerContainer;
|
||||
import forge.itemmanager.ItemManagerModel;
|
||||
import forge.itemmanager.views.*;
|
||||
import forge.toolbox.FButton;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.view.FDialog;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
@@ -29,6 +9,29 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.deck.CardPool;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckSection;
|
||||
import forge.gui.CardDetailPanel;
|
||||
import forge.gui.CardPicturePanel;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.PaperCard;
|
||||
import forge.itemmanager.CardManager;
|
||||
import forge.itemmanager.ItemManagerConfig;
|
||||
import forge.itemmanager.ItemManagerContainer;
|
||||
import forge.itemmanager.ItemManagerModel;
|
||||
import forge.itemmanager.views.ImageView;
|
||||
import forge.toolbox.FButton;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.view.CardView;
|
||||
import forge.view.FDialog;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class FDeckViewer extends FDialog {
|
||||
private final Deck deck;
|
||||
@@ -36,7 +39,7 @@ public class FDeckViewer extends FDialog {
|
||||
private final CardManager cardManager;
|
||||
private DeckSection currentSection;
|
||||
|
||||
private final CardDetailPanel cardDetail = new CardDetailPanel(null);
|
||||
private final CardDetailPanel cardDetail = new CardDetailPanel();
|
||||
private final CardPicturePanel cardPicture = new CardPicturePanel();
|
||||
private final FButton btnCopyToClipboard = new FButton("Copy to Clipboard");
|
||||
private final FButton btnChangeSection = new FButton("Change Section");
|
||||
@@ -59,11 +62,11 @@ public class FDeckViewer extends FDialog {
|
||||
return new ImageView<PaperCard>(this, model0) {
|
||||
@Override
|
||||
protected void showHoveredItem(PaperCard item) {
|
||||
Card card = Card.getCardForUi(item);
|
||||
final CardView card = ViewUtil.getCardForUi(item);
|
||||
if (card == null) { return; }
|
||||
|
||||
cardDetail.setCard(card);
|
||||
cardPicture.setCard(card, true);
|
||||
cardPicture.setCard(card.getOriginal());
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -72,14 +75,14 @@ public class FDeckViewer extends FDialog {
|
||||
this.cardManager.addSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e) {
|
||||
PaperCard paperCard = cardManager.getSelectedItem();
|
||||
final IPaperCard paperCard = cardManager.getSelectedItem();
|
||||
if (paperCard == null) { return; }
|
||||
|
||||
Card card = Card.getCardForUi(paperCard);
|
||||
final CardView card = ViewUtil.getCardForUi(paperCard);
|
||||
if (card == null) { return; }
|
||||
|
||||
cardDetail.setCard(card);
|
||||
cardPicture.setCard(card, true);
|
||||
cardPicture.setCard(card.getOriginal());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package forge.download;
|
||||
|
||||
import java.net.Proxy;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.UiCommand;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.gui.SOverlayUtils;
|
||||
@@ -95,7 +96,7 @@ public class GuiDownloader extends DefaultBoundedRangeModel {
|
||||
pnl.add(pnlDialog, "w 400px!, h 350px!, ax center, ay center");
|
||||
SOverlayUtils.showOverlay();
|
||||
|
||||
service.initialize(txtAddress, txtPort, progressBar, btnStart, cmdClose, null, new Runnable() {
|
||||
service.initialize(GuiBase.getInterface(), txtAddress, txtPort, progressBar, btnStart, cmdClose, null, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fireStateChanged();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package forge.error;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.gui.WrapLayout;
|
||||
import forge.toolbox.FHyperlink;
|
||||
import forge.toolbox.FLabel;
|
||||
@@ -92,7 +93,7 @@ public class BugReportDialog {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
BugReporter.copyAndGoToForums(text.getText());
|
||||
BugReporter.copyAndGoToForums(GuiBase.getInterface(), text.getText());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +109,7 @@ public class BugReportDialog {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
BugReporter.saveToFile(area.getText());
|
||||
BugReporter.saveToFile(GuiBase.getInterface(), area.getText());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,19 @@
|
||||
|
||||
package forge.gui;
|
||||
|
||||
import forge.game.card.Card;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowFocusListener;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.AbstractListModel;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import forge.item.PaperCard;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
@@ -26,17 +38,7 @@ import forge.toolbox.FButton;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.view.FDialog;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowFocusListener;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* A simple class that shows a list of cards in a dialog with preview in its
|
||||
@@ -99,7 +101,7 @@ public class BoxedProductCardListViewer extends FDialog {
|
||||
public BoxedProductCardListViewer(final String title, final String message, final List<PaperCard> list, final Icon dialogIcon) {
|
||||
this.list = Collections.unmodifiableList(list);
|
||||
this.jList = new JList<PaperCard>(new ChooserListModel());
|
||||
this.detail = new CardDetailPanel(null);
|
||||
this.detail = new CardDetailPanel();
|
||||
this.picture = new CardPicturePanel();
|
||||
this.picture.setOpaque(false);
|
||||
|
||||
@@ -187,7 +189,7 @@ public class BoxedProductCardListViewer extends FDialog {
|
||||
// (String) jList.getSelectedValue();
|
||||
if ((row >= 0) && (row < BoxedProductCardListViewer.this.list.size())) {
|
||||
final PaperCard cp = BoxedProductCardListViewer.this.list.get(row);
|
||||
BoxedProductCardListViewer.this.detail.setCard(Card.getCardForUi(cp));
|
||||
BoxedProductCardListViewer.this.detail.setCard(ViewUtil.getCardForUi(cp));
|
||||
BoxedProductCardListViewer.this.picture.setCard(cp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
|
||||
package forge.gui;
|
||||
|
||||
import forge.game.card.Card;
|
||||
import forge.view.CardView;
|
||||
|
||||
/**
|
||||
* The class CardContainer. A card container is an object that references a
|
||||
* card.
|
||||
* {@link CardView}.
|
||||
*
|
||||
* @author Clemens Koza
|
||||
* @version V0.0 17.02.2010
|
||||
@@ -34,17 +34,17 @@ public interface CardContainer {
|
||||
* </p>
|
||||
*
|
||||
* @param card
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* a {@link CardView} object.
|
||||
*/
|
||||
void setCard(Card card);
|
||||
void setCard(CardView card);
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* getCard.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link forge.game.card.Card} object.
|
||||
* @return a {@link CardView} object.
|
||||
*/
|
||||
Card getCard();
|
||||
CardView getCard();
|
||||
|
||||
}
|
||||
|
||||
@@ -18,27 +18,33 @@
|
||||
|
||||
package forge.gui;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.card.CardCharacteristicName;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.MouseListener;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.card.CardDetailUtil;
|
||||
import forge.card.CardDetailUtil.DetailColors;
|
||||
import forge.card.CardEdition;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.InventoryItemFromSet;
|
||||
import forge.model.FModel;
|
||||
import forge.toolbox.*;
|
||||
import forge.toolbox.FHtmlViewer;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedPanel;
|
||||
import forge.view.FDialog;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseListener;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* The class CardDetailPanel. Shows the details of a card.
|
||||
@@ -62,7 +68,7 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
private final FHtmlViewer cdArea;
|
||||
private final FScrollPane scrArea;
|
||||
|
||||
public CardDetailPanel(final Card card) {
|
||||
public CardDetailPanel() {
|
||||
super();
|
||||
this.setLayout(null);
|
||||
this.setOpaque(false);
|
||||
@@ -74,7 +80,7 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
this.setInfoLabel = new JLabel();
|
||||
this.setInfoLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
|
||||
Font font = new Font("Dialog", 0, 14);
|
||||
final Font font = new Font("Dialog", 0, 14);
|
||||
this.nameCostLabel.setFont(font);
|
||||
this.typeLabel.setFont(font);
|
||||
this.idLabel.setFont(font);
|
||||
@@ -91,8 +97,6 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
this.add(this.powerToughnessLabel);
|
||||
this.add(this.setInfoLabel);
|
||||
this.add(this.scrArea);
|
||||
|
||||
this.setCard(card);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -121,13 +125,13 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
this.scrArea.setBounds(0, y, getWidth(), getHeight() - y);
|
||||
}
|
||||
|
||||
public final void setItem(InventoryItemFromSet item) {
|
||||
public final void setItem(final InventoryItemFromSet item) {
|
||||
nameCostLabel.setText(item.getName());
|
||||
typeLabel.setVisible(false);
|
||||
powerToughnessLabel.setVisible(false);
|
||||
idLabel.setText("");
|
||||
cdArea.setText(CardDetailUtil.getItemDescription(item));
|
||||
this.updateBorder(item instanceof IPaperCard ? Card.getCardForUi((IPaperCard)item) : null, false);
|
||||
this.updateBorder(item instanceof IPaperCard ? ViewUtil.getCardForUi((IPaperCard)item).getOriginal() : null);
|
||||
|
||||
String set = item.getEdition();
|
||||
setInfoLabel.setText(set);
|
||||
@@ -155,8 +159,11 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
});
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public final void setCard(Card card) {
|
||||
public final void setCard(final CardView card) {
|
||||
this.setCard(card, false);
|
||||
}
|
||||
|
||||
public final void setCard(final CardView card, final boolean isInAltState) {
|
||||
this.nameCostLabel.setText("");
|
||||
this.typeLabel.setVisible(true);
|
||||
this.typeLabel.setText("");
|
||||
@@ -169,36 +176,26 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
this.setInfoLabel.setBorder(null);
|
||||
this.cdArea.setText("");
|
||||
if (card == null) {
|
||||
this.updateBorder(null, false);
|
||||
this.updateBorder(null);
|
||||
return;
|
||||
}
|
||||
|
||||
card = card.getCardForUi();
|
||||
final CardStateView state = card.getState(isInAltState);
|
||||
|
||||
boolean canShowThis = false;
|
||||
if (state.getManaCost().isNoCost()) {
|
||||
this.nameCostLabel.setText(CardDetailUtil.formatCardName(state));
|
||||
} else {
|
||||
final String manaCost;
|
||||
if (card.isSplitCard() && card.hasAltState()) {
|
||||
manaCost = card.getOriginal().getManaCost() + " // " + card.getAlternate().getManaCost();
|
||||
} else {
|
||||
manaCost = state.getManaCost().toString();
|
||||
}
|
||||
this.nameCostLabel.setText(FSkin.encodeSymbols(CardDetailUtil.formatCardName(state) + " - " + manaCost, true));
|
||||
}
|
||||
this.typeLabel.setText(CardDetailUtil.formatCardType(state));
|
||||
|
||||
if (card.isFaceDown() && !Singletons.getControl().maySeeFaceDownCard(card)) {
|
||||
if (card.isInZone(ZoneType.Battlefield)) {
|
||||
this.nameCostLabel.setText("???");
|
||||
this.typeLabel.setText("Creature");
|
||||
}
|
||||
}
|
||||
else if (Singletons.getControl().mayShowCard(card) || FDialog.isModalOpen()) { //allow showing cards while modal open to account for revealing, picking, and ordering cards
|
||||
canShowThis = true;
|
||||
|
||||
if (card.getManaCost().isNoCost()) {
|
||||
this.nameCostLabel.setText(card.getName());
|
||||
}
|
||||
else {
|
||||
String manaCost = card.getManaCost().toString();
|
||||
if ( card.isSplitCard() && card.getCurState() == CardCharacteristicName.Original) {
|
||||
manaCost = card.getRules().getMainPart().getManaCost().toString() + " // " + card.getRules().getOtherPart().getManaCost().toString();
|
||||
}
|
||||
this.nameCostLabel.setText(FSkin.encodeSymbols(card.getName() + " - " + manaCost, true));
|
||||
}
|
||||
this.typeLabel.setText(CardDetailUtil.formatCardType(card));
|
||||
|
||||
String set = card.getCurSetCode();
|
||||
String set = card.getSetCode();
|
||||
this.setInfoLabel.setText(set);
|
||||
if (null != set && !set.isEmpty()) {
|
||||
CardEdition edition = FModel.getMagicDb().getEditions().get(set);
|
||||
@@ -239,18 +236,17 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
this.setInfoLabel.setForeground(foreColor);
|
||||
this.setInfoLabel.setBorder(BorderFactory.createLineBorder(foreColor));
|
||||
}
|
||||
}
|
||||
|
||||
this.updateBorder(card, canShowThis);
|
||||
this.updateBorder(state);
|
||||
|
||||
this.powerToughnessLabel.setText(CardDetailUtil.formatPowerToughness(card));
|
||||
this.powerToughnessLabel.setText(CardDetailUtil.formatPowerToughness(state));
|
||||
|
||||
this.idLabel.setText(CardDetailUtil.formatCardId(card));
|
||||
this.idLabel.setText(CardDetailUtil.formatCardId(state));
|
||||
|
||||
// fill the card text
|
||||
this.cdArea.setText(FSkin.encodeSymbols(CardDetailUtil.composeCardText(card, canShowThis), true));
|
||||
this.cdArea.setText(FSkin.encodeSymbols(CardDetailUtil.composeCardText(state), true));
|
||||
|
||||
if (card.isFaceDown() && card.isInZone(ZoneType.Battlefield)) {
|
||||
if (card.isFaceDown() && card.getZone() == ZoneType.Battlefield) {
|
||||
this.nameCostLabel.setText("???");
|
||||
this.typeLabel.setText("Creature");
|
||||
this.cdArea.setText(FSkin.encodeSymbols("(You may look at this card.)", true));
|
||||
@@ -289,7 +285,7 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
return this.cdArea;
|
||||
}
|
||||
|
||||
private void updateBorder(final Card card, final boolean canShow) {
|
||||
private void updateBorder(final CardStateView card) {
|
||||
// color info
|
||||
if (card == null) {
|
||||
this.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
|
||||
@@ -297,7 +293,7 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
return;
|
||||
}
|
||||
|
||||
Color color = fromDetailColor(CardDetailUtil.getBorderColor(card, canShow));
|
||||
Color color = fromDetailColor(CardDetailUtil.getBorderColor(card));
|
||||
this.setBorder(BorderFactory.createLineBorder(color, 2));
|
||||
scrArea.setBorder(BorderFactory.createMatteBorder(2, 0, 0, 0, color));
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package forge.gui;
|
||||
|
||||
import forge.game.card.Card;
|
||||
import forge.item.PaperCard;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
@@ -27,10 +26,12 @@ import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.view.FDialog;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import java.awt.event.*;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -53,7 +54,7 @@ public class CardListChooser extends FDialog {
|
||||
public CardListChooser(final String title, final String message, final List<PaperCard> list) {
|
||||
this.list = Collections.unmodifiableList(list);
|
||||
this.jList = new JList<>(new ChooserListModel());
|
||||
this.detail = new CardDetailPanel(null);
|
||||
this.detail = new CardDetailPanel();
|
||||
this.picture = new CardPicturePanel();
|
||||
this.picture.setOpaque(false);
|
||||
|
||||
@@ -172,7 +173,7 @@ public class CardListChooser extends FDialog {
|
||||
final int row = CardListChooser.this.jList.getSelectedIndex();
|
||||
if ((row >= 0) && (row < CardListChooser.this.list.size())) {
|
||||
final PaperCard cp = CardListChooser.this.list.get(row);
|
||||
CardListChooser.this.detail.setCard(Card.getCardForUi(cp));
|
||||
CardListChooser.this.detail.setCard(ViewUtil.getCardForUi(cp));
|
||||
CardListChooser.this.picture.setCard(cp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,19 @@
|
||||
|
||||
package forge.gui;
|
||||
|
||||
import forge.game.card.Card;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowFocusListener;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.AbstractListModel;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import forge.item.PaperCard;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
@@ -26,17 +38,7 @@ import forge.toolbox.FButton;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.view.FDialog;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowFocusListener;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* A simple class that shows a list of cards in a dialog with preview in its
|
||||
@@ -97,7 +99,7 @@ public class CardListViewer extends FDialog {
|
||||
public CardListViewer(final String title, final String message, final List<PaperCard> list, final Icon dialogIcon) {
|
||||
this.list = Collections.unmodifiableList(list);
|
||||
this.jList = new JList<PaperCard>(new ChooserListModel());
|
||||
this.detail = new CardDetailPanel(null);
|
||||
this.detail = new CardDetailPanel();
|
||||
this.picture = new CardPicturePanel();
|
||||
this.picture.setOpaque(false);
|
||||
|
||||
@@ -170,7 +172,7 @@ public class CardListViewer extends FDialog {
|
||||
// (String) jList.getSelectedValue();
|
||||
if ((row >= 0) && (row < CardListViewer.this.list.size())) {
|
||||
final PaperCard cp = CardListViewer.this.list.get(row);
|
||||
CardListViewer.this.detail.setCard(Card.getCardForUi(cp));
|
||||
CardListViewer.this.detail.setCard(ViewUtil.getCardForUi(cp));
|
||||
CardListViewer.this.picture.setCard(cp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,21 +18,20 @@
|
||||
|
||||
package forge.gui;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import forge.ImageCache;
|
||||
import forge.ImageKeys;
|
||||
import forge.card.CardCharacteristicName;
|
||||
import forge.game.card.Card;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.toolbox.imaging.FImagePanel;
|
||||
import forge.toolbox.imaging.FImageUtil;
|
||||
import forge.toolbox.imaging.FImagePanel.AutoSizeImageMode;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import forge.toolbox.imaging.FImageUtil;
|
||||
import forge.view.CardView.CardStateView;
|
||||
|
||||
/**
|
||||
* Displays image associated with a card or inventory item.
|
||||
@@ -48,7 +47,6 @@ public final class CardPicturePanel extends JPanel {
|
||||
|
||||
private final FImagePanel panel;
|
||||
private BufferedImage currentImage;
|
||||
private boolean mayShowCard;
|
||||
|
||||
public CardPicturePanel() {
|
||||
super(new BorderLayout());
|
||||
@@ -59,25 +57,14 @@ public final class CardPicturePanel extends JPanel {
|
||||
|
||||
public void setCard(final InventoryItem cp) {
|
||||
this.displayed = cp;
|
||||
this.mayShowCard = true;
|
||||
this.setImage();
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void setCard(final Card c, boolean mayShowCard) {
|
||||
public void setCard(final CardStateView c) {
|
||||
this.displayed = c;
|
||||
this.mayShowCard = mayShowCard;
|
||||
this.setImage();
|
||||
}
|
||||
|
||||
public void setCardImage(CardCharacteristicName flipState) {
|
||||
BufferedImage image = FImageUtil.getImage((Card)displayed, flipState);
|
||||
if (image != null && image != this.currentImage) {
|
||||
this.currentImage = image;
|
||||
this.panel.setImage(image, getAutoSizeImageMode());
|
||||
}
|
||||
}
|
||||
|
||||
public void setImage() {
|
||||
BufferedImage image = getImage();
|
||||
if (image != null && image != this.currentImage) {
|
||||
@@ -88,14 +75,10 @@ public final class CardPicturePanel extends JPanel {
|
||||
|
||||
public BufferedImage getImage() {
|
||||
if (displayed instanceof InventoryItem) {
|
||||
InventoryItem item = (InventoryItem) displayed;
|
||||
final InventoryItem item = (InventoryItem) displayed;
|
||||
return ImageCache.getOriginalImage(ImageKeys.getImageKey(item, false), true);
|
||||
}
|
||||
else if (displayed instanceof Card) {
|
||||
if (mayShowCard) {
|
||||
return FImageUtil.getImage((Card)displayed);
|
||||
}
|
||||
return ImageCache.getOriginalImage(ImageKeys.TOKEN_PREFIX + ImageKeys.MORPH_IMAGE, true);
|
||||
} else if (displayed instanceof CardStateView) {
|
||||
return FImageUtil.getImage((CardStateView)displayed);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,38 @@
|
||||
package forge.gui;
|
||||
|
||||
import forge.game.card.Card;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.PaperCard;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.toolbox.*;
|
||||
import forge.view.FDialog;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.ListModel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.event.ListDataEvent;
|
||||
import javax.swing.event.ListDataListener;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.PaperCard;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.toolbox.FButton;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FList;
|
||||
import forge.toolbox.FPanel;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.view.CardView;
|
||||
import forge.view.FDialog;
|
||||
import forge.view.SpellAbilityView;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
// An input box for handling the order of choices.
|
||||
// Left box has the original choices
|
||||
@@ -310,13 +325,13 @@ public class DualListBox<T> extends FDialog {
|
||||
if (!showCard || null == obj) {
|
||||
return;
|
||||
}
|
||||
Card card = null;
|
||||
if (obj instanceof Card) {
|
||||
card = (Card) obj;
|
||||
} else if (obj instanceof SpellAbility) {
|
||||
card = ((SpellAbility) obj).getHostCard();
|
||||
CardView card = null;
|
||||
if (obj instanceof CardView) {
|
||||
card = (CardView) obj;
|
||||
} else if (obj instanceof SpellAbilityView) {
|
||||
card = ((SpellAbilityView) obj).getHostCard();
|
||||
} else if (obj instanceof PaperCard) {
|
||||
card = Card.getCardForUi((IPaperCard) obj);
|
||||
card = ViewUtil.getCardForUi((IPaperCard) obj);
|
||||
}
|
||||
|
||||
GuiUtils.clearPanelSelections();
|
||||
|
||||
@@ -1,24 +1,31 @@
|
||||
package forge.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
import javax.swing.JList;
|
||||
import javax.swing.WindowConstants;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.Singletons;
|
||||
import forge.game.card.Card;
|
||||
import forge.GuiBase;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.toolbox.FOptionPane;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.FutureTask;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
@@ -200,14 +207,17 @@ public class GuiChoose {
|
||||
list.addListSelectionListener(new ListSelectionListener() {
|
||||
@Override
|
||||
public void valueChanged(final ListSelectionEvent ev) {
|
||||
if (list.getSelectedValue() instanceof Card) {
|
||||
Card card = (Card) list.getSelectedValue();
|
||||
if (card.isFaceDown() && Singletons.getControl().mayShowCard(card)) {
|
||||
CMatchUI.SINGLETON_INSTANCE.setCard(card, true);
|
||||
final T sel = list.getSelectedValue();
|
||||
final CardView card;
|
||||
if (sel instanceof CardStateView) {
|
||||
card = ((CardStateView) sel).getCard();
|
||||
} else if (sel instanceof CardView) {
|
||||
card = (CardView) sel;
|
||||
} else {
|
||||
card = null;
|
||||
}
|
||||
else {
|
||||
if (card != null) {
|
||||
CMatchUI.SINGLETON_INSTANCE.setCard(card);
|
||||
}
|
||||
|
||||
GuiUtils.clearPanelSelections();
|
||||
GuiUtils.setPanelSelection(card);
|
||||
@@ -231,7 +241,7 @@ public class GuiChoose {
|
||||
};
|
||||
|
||||
FutureTask<List<T>> future = new FutureTask<List<T>>(showChoice);
|
||||
FThreads.invokeInEdtAndWait(future);
|
||||
FThreads.invokeInEdtAndWait(GuiBase.getInterface(), future);
|
||||
try {
|
||||
return future.get();
|
||||
} catch (Exception e) { // should be no exception here
|
||||
@@ -240,17 +250,17 @@ public class GuiChoose {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static <T> List<T> many(final String title, final String topCaption, int cnt, final List<T> sourceChoices, Card referenceCard) {
|
||||
public static <T> List<T> many(final String title, final String topCaption, int cnt, final List<T> sourceChoices, final CardView referenceCard) {
|
||||
return order(title, topCaption, cnt, cnt, sourceChoices, null, referenceCard, false);
|
||||
}
|
||||
|
||||
public static <T> List<T> many(final String title, final String topCaption, int min, int max, final List<T> sourceChoices, Card referenceCard) {
|
||||
public static <T> List<T> many(final String title, final String topCaption, int min, int max, final List<T> sourceChoices, final CardView referenceCard) {
|
||||
int m2 = min >= 0 ? sourceChoices.size() - min : -1;
|
||||
int m1 = max >= 0 ? sourceChoices.size() - max : -1;
|
||||
return order(title, topCaption, m1, m2, sourceChoices, null, referenceCard, false);
|
||||
}
|
||||
|
||||
public static <T> List<T> order(final String title, final String top, final List<T> sourceChoices, Card referenceCard) {
|
||||
public static <T> List<T> order(final String title, final String top, final List<T> sourceChoices, final CardView referenceCard) {
|
||||
return order(title, top, 0, 0, sourceChoices, null, referenceCard, false);
|
||||
}
|
||||
|
||||
@@ -261,7 +271,7 @@ public class GuiChoose {
|
||||
}
|
||||
|
||||
public static <T> List<T> order(final String title, final String top, final int remainingObjectsMin, final int remainingObjectsMax,
|
||||
final List<T> sourceChoices, final List<T> destChoices, final Card referenceCard, final boolean sideboardingMode) {
|
||||
final List<T> sourceChoices, final List<T> destChoices, final CardView referenceCard, final boolean sideboardingMode) {
|
||||
// An input box for handling the order of choices.
|
||||
|
||||
Callable<List<T>> callable = new Callable<List<T>>() {
|
||||
@@ -290,7 +300,7 @@ public class GuiChoose {
|
||||
};
|
||||
|
||||
FutureTask<List<T>> ft = new FutureTask<List<T>>(callable);
|
||||
FThreads.invokeInEdtAndWait(ft);
|
||||
FThreads.invokeInEdtAndWait(GuiBase.getInterface(), ft);
|
||||
try {
|
||||
return ft.get();
|
||||
} catch (Exception e) { // we have waited enough
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
package forge.gui;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.game.card.Card;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.toolbox.FOptionPane;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.view.CardView;
|
||||
|
||||
/**
|
||||
* Holds player interactions using standard windows
|
||||
*
|
||||
@@ -19,17 +20,17 @@ import java.util.concurrent.FutureTask;
|
||||
public class GuiDialog {
|
||||
private static final String[] defaultConfirmOptions = { "Yes", "No" };
|
||||
|
||||
public static boolean confirm(final Card c, final String question) {
|
||||
public static boolean confirm(final CardView c, final String question) {
|
||||
return GuiDialog.confirm(c, question, true, null);
|
||||
}
|
||||
public static boolean confirm(final Card c, final String question, final boolean defaultChoice) {
|
||||
public static boolean confirm(final CardView c, final String question, final boolean defaultChoice) {
|
||||
return GuiDialog.confirm(c, question, defaultChoice, null);
|
||||
}
|
||||
public static boolean confirm(final Card c, final String question, String[] options) {
|
||||
public static boolean confirm(final CardView c, final String question, String[] options) {
|
||||
return GuiDialog.confirm(c, question, true, options);
|
||||
}
|
||||
|
||||
public static boolean confirm(final Card c, final String question, final boolean defaultIsYes, final String[] options) {
|
||||
public static boolean confirm(final CardView c, final String question, final boolean defaultIsYes, final String[] options) {
|
||||
Callable<Boolean> confirmTask = new Callable<Boolean>() {
|
||||
@Override
|
||||
public Boolean call() throws Exception {
|
||||
@@ -37,7 +38,7 @@ public class GuiDialog {
|
||||
CMatchUI.SINGLETON_INSTANCE.setCard(c);
|
||||
}
|
||||
|
||||
final String title = c == null ? "Question" : c.getCardForUi().getName() + " - Ability";
|
||||
final String title = c == null ? "Question" : c + " - Ability";
|
||||
String questionToUse = StringUtils.isBlank(question) ? "Activate card's ability?" : question;
|
||||
String[] opts = options == null ? defaultConfirmOptions : options;
|
||||
int answer = FOptionPane.showOptionDialog(questionToUse, title, FOptionPane.QUESTION_ICON, opts, defaultIsYes ? 0 : 1);
|
||||
@@ -45,7 +46,7 @@ public class GuiDialog {
|
||||
}};
|
||||
|
||||
FutureTask<Boolean> future = new FutureTask<Boolean>(confirmTask);
|
||||
FThreads.invokeInEdtAndWait(future);
|
||||
FThreads.invokeInEdtAndWait(GuiBase.getInterface(), future);
|
||||
try {
|
||||
return future.get().booleanValue();
|
||||
}
|
||||
@@ -68,7 +69,7 @@ public class GuiDialog {
|
||||
}
|
||||
|
||||
public static void message(final String message, final String title) {
|
||||
FThreads.invokeInEdtAndWait(new Runnable() {
|
||||
FThreads.invokeInEdtAndWait(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FOptionPane.showMessageDialog(message, title, null);
|
||||
|
||||
@@ -17,20 +17,26 @@
|
||||
*/
|
||||
package forge.gui;
|
||||
|
||||
import forge.game.card.Card;
|
||||
import forge.screens.match.VMatchUI;
|
||||
import forge.screens.match.views.VField;
|
||||
import forge.view.arcane.CardPanel;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontFormatException;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.KeyStroke;
|
||||
|
||||
import forge.screens.match.VMatchUI;
|
||||
import forge.screens.match.views.VField;
|
||||
import forge.view.CardView;
|
||||
import forge.view.arcane.CardPanel;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* GuiUtils class.
|
||||
@@ -81,15 +87,15 @@ public final class GuiUtils {
|
||||
/**
|
||||
* Highlight a card on the playfield.
|
||||
*
|
||||
* @param c
|
||||
* @param card
|
||||
* a card to be highlighted
|
||||
*/
|
||||
public static void setPanelSelection(final Card c) {
|
||||
public static void setPanelSelection(final CardView card) {
|
||||
mainLoop:
|
||||
for (VField v : VMatchUI.SINGLETON_INSTANCE.getFieldViews()) {
|
||||
List<CardPanel> panels = v.getTabletop().getCardPanels();
|
||||
for (CardPanel p : panels) {
|
||||
if (p.getCard().equals(c)) {
|
||||
for (final VField v : VMatchUI.SINGLETON_INSTANCE.getFieldViews()) {
|
||||
final List<CardPanel> panels = v.getTabletop().getCardPanels();
|
||||
for (final CardPanel p : panels) {
|
||||
if (p.getCard().equals(card)) {
|
||||
p.setSelected(true);
|
||||
break mainLoop;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package forge.gui;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.UiCommand;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.error.BugReporter;
|
||||
@@ -513,7 +514,7 @@ public class ImportDialog {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override public void run() {
|
||||
_progressBar.setString("Error");
|
||||
BugReporter.reportException(e);
|
||||
BugReporter.reportException(e, GuiBase.getInterface());
|
||||
}
|
||||
});
|
||||
} finally {
|
||||
@@ -777,7 +778,7 @@ public class ImportDialog {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override public void run() {
|
||||
// we never interrupt the thread, so this is not expected to happen
|
||||
BugReporter.reportException(e);
|
||||
BugReporter.reportException(e, GuiBase.getInterface());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -936,7 +937,7 @@ public class ImportDialog {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override public void run() {
|
||||
_progressBar.setString("Error");
|
||||
BugReporter.reportException(e);
|
||||
BugReporter.reportException(e, GuiBase.getInterface());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.google.common.base.Function;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.toolbox.FList;
|
||||
import forge.toolbox.FMouseAdapter;
|
||||
import forge.toolbox.FOptionPane;
|
||||
@@ -75,7 +76,7 @@ public class ListChooser<T> {
|
||||
private FOptionPane optionPane;
|
||||
|
||||
public ListChooser(final String title, final int minChoices, final int maxChoices, final Collection<T> list, final Function<T, String> display) {
|
||||
FThreads.assertExecutedByEdt(true);
|
||||
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
|
||||
this.minChoices = minChoices;
|
||||
this.maxChoices = maxChoices;
|
||||
this.list = list.getClass().isInstance(List.class) ? (List<T>)list : Lists.newArrayList(list);
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package forge.gui.framework;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.view.FFrame;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
@@ -100,7 +102,7 @@ public class SDisplayUtil {
|
||||
}
|
||||
}
|
||||
};
|
||||
FThreads.invokeInEdtLater(showTabRoutine);
|
||||
FThreads.invokeInEdtLater(GuiBase.getInterface(), showTabRoutine);
|
||||
}
|
||||
|
||||
public static GraphicsDevice getGraphicsDevice(Point point) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.itemmanager.views;
|
||||
|
||||
import forge.ImageCache;
|
||||
import forge.game.card.Card;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.deck.DeckProxy;
|
||||
import forge.gui.framework.ILocalRepaint;
|
||||
@@ -20,6 +19,8 @@ import forge.toolbox.FSkin.SkinColor;
|
||||
import forge.toolbox.FSkin.SkinFont;
|
||||
import forge.toolbox.FSkin.SkinImage;
|
||||
import forge.toolbox.special.CardZoomer;
|
||||
import forge.view.CardView;
|
||||
import forge.view.ViewUtil;
|
||||
import forge.view.arcane.CardPanel;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -232,7 +233,7 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
ItemInfo item = getItemAtPoint(e.getPoint());
|
||||
if (item != null && item.item instanceof IPaperCard) {
|
||||
setLockHoveredItem(true); //lock hoveredItem while zoomer open
|
||||
Card card = Card.getCardForUi((IPaperCard) item.item);
|
||||
final CardView card = ViewUtil.getCardForUi((IPaperCard) item.item);
|
||||
CardZoomer.SINGLETON_INSTANCE.doMouseButtonZoom(card);
|
||||
}
|
||||
}
|
||||
@@ -1099,8 +1100,8 @@ public class ImageView<T extends InventoryItem> extends ItemView<T> {
|
||||
if (item instanceof IPaperCard) {
|
||||
IPaperCard paperCard = (IPaperCard)item;
|
||||
if (paperCard.isFoil()) {
|
||||
Card card = Card.getCardForUi(paperCard);
|
||||
if (card.getFoil() == 0) { //if foil finish not yet established, assign a random one
|
||||
final CardView card = ViewUtil.getCardForUi(paperCard);
|
||||
if (card.getFoilIndex() == 0) { //if foil finish not yet established, assign a random one
|
||||
card.setRandomFoil();
|
||||
}
|
||||
CardPanel.drawFoilEffect(g, card, bounds.x, bounds.y, bounds.width, bounds.height, borderSize);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.screens.bazaar;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.UiCommand;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.gui.framework.FScreen;
|
||||
@@ -42,7 +43,7 @@ public enum VBazaarUI implements IVTopLevelUI {
|
||||
|
||||
final FLabel lbl = new FLabel.ButtonBuilder().text(s + " ")
|
||||
.fontAlign(SwingConstants.RIGHT).iconInBackground(true).selectable()
|
||||
.fontSize(16).icon((SkinImage)bazaar.getStall(s).getIcon()).build();
|
||||
.fontSize(16).icon((SkinImage)GuiBase.getInterface().getSkinIcon(bazaar.getStall(s).getIcon())).build();
|
||||
|
||||
pnlAllStalls.add(lbl, "h 80px!, w 90%!, gap 0 0 10px 10px");
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import forge.deck.DeckBase;
|
||||
import forge.deck.io.DeckHtmlSerializer;
|
||||
import forge.deck.io.DeckSerializer;
|
||||
import forge.deck.io.DeckStorage;
|
||||
import forge.error.BugReporter;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.properties.ForgeConstants;
|
||||
@@ -156,7 +155,7 @@ public enum CCurrentDeck implements ICDoc {
|
||||
}
|
||||
});
|
||||
} catch (final Exception ex) {
|
||||
BugReporter.reportException(ex);
|
||||
//BugReporter.reportException(ex);
|
||||
throw new RuntimeException("Error creating new deck. " + ex);
|
||||
}
|
||||
}
|
||||
@@ -175,7 +174,7 @@ public enum CCurrentDeck implements ICDoc {
|
||||
.setModel(DeckSerializer.fromFile(file));
|
||||
|
||||
} catch (final Exception ex) {
|
||||
BugReporter.reportException(ex);
|
||||
//BugReporter.reportException(ex);
|
||||
throw new RuntimeException("Error importing deck." + ex);
|
||||
}
|
||||
}
|
||||
@@ -219,7 +218,7 @@ public enum CCurrentDeck implements ICDoc {
|
||||
DeckSerializer.writeDeck(deck, filename);
|
||||
controller.setModel(DeckSerializer.fromFile(filename)); //reload deck from file so everything is in sync
|
||||
} catch (final Exception ex) {
|
||||
BugReporter.reportException(ex);
|
||||
//BugReporter.reportException(ex);
|
||||
throw new RuntimeException("Error exporting deck." + ex);
|
||||
}
|
||||
}
|
||||
@@ -237,7 +236,7 @@ public enum CCurrentDeck implements ICDoc {
|
||||
((DeckController<Deck>) CDeckEditorUI.SINGLETON_INSTANCE
|
||||
.getCurrentEditorController().getDeckController()).getModel(), filename);
|
||||
} catch (final Exception ex) {
|
||||
BugReporter.reportException(ex);
|
||||
//BugReporter.reportException(ex);
|
||||
throw new RuntimeException("Error exporting deck." + ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package forge.screens.deckeditor.controllers;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.UiCommand;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.deck.DeckBase;
|
||||
@@ -148,7 +149,7 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
|
||||
return;
|
||||
}
|
||||
|
||||
QuestSpellShop.buy(items, this.getCatalogManager(), this.getDeckManager(), true);
|
||||
QuestSpellShop.buy(GuiBase.getInterface(), items, this.getCatalogManager(), this.getDeckManager(), true);
|
||||
updateCreditsLabel();
|
||||
}
|
||||
|
||||
@@ -159,7 +160,7 @@ public final class CEditorQuestCardShop extends ACEditorBase<InventoryItem, Deck
|
||||
protected void onRemoveItems(Iterable<Entry<InventoryItem, Integer>> items, boolean toAlternate) {
|
||||
if (showingFullCatalog || toAlternate) { return; }
|
||||
|
||||
QuestSpellShop.sell(items, this.getCatalogManager(), this.getDeckManager(), true);
|
||||
QuestSpellShop.sell(GuiBase.getInterface(), items, this.getCatalogManager(), this.getDeckManager(), true);
|
||||
updateCreditsLabel();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.screens.home.quest;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.UiCommand;
|
||||
import forge.Singletons;
|
||||
import forge.gui.framework.EDocID;
|
||||
@@ -42,29 +43,29 @@ public enum CSubmenuChallenges implements ICDoc {
|
||||
|
||||
view.getBtnSpellShop().setCommand(
|
||||
new UiCommand() { @Override
|
||||
public void run() { QuestUtil.showSpellShop(); } });
|
||||
public void run() { QuestUtil.showSpellShop(GuiBase.getInterface()); } });
|
||||
|
||||
view.getBtnBazaar().setCommand(
|
||||
new UiCommand() { @Override
|
||||
public void run() { QuestUtil.showBazaar(); } });
|
||||
public void run() { QuestUtil.showBazaar(GuiBase.getInterface()); } });
|
||||
|
||||
view.getBtnUnlock().setCommand(
|
||||
new UiCommand() { @Override
|
||||
public void run() { QuestUtil.chooseAndUnlockEdition(); CSubmenuChallenges.this.update(); } });
|
||||
public void run() { QuestUtil.chooseAndUnlockEdition(GuiBase.getInterface()); CSubmenuChallenges.this.update(); } });
|
||||
|
||||
view.getBtnTravel().setCommand(
|
||||
new UiCommand() { @Override
|
||||
public void run() { QuestUtil.travelWorld(); CSubmenuChallenges.this.update(); } });
|
||||
public void run() { QuestUtil.travelWorld(GuiBase.getInterface()); CSubmenuChallenges.this.update(); } });
|
||||
|
||||
view.getBtnStart().addActionListener(
|
||||
new ActionListener() { @Override
|
||||
public void actionPerformed(final ActionEvent e) { QuestUtil.startGame(); } });
|
||||
public void actionPerformed(final ActionEvent e) { QuestUtil.startGame(GuiBase.getInterface()); } });
|
||||
|
||||
((FLabel) view.getLblZep()).setCommand(
|
||||
new UiCommand() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!QuestUtil.checkActiveQuest("Launch a Zeppelin.")) {
|
||||
if (!QuestUtil.checkActiveQuest(GuiBase.getInterface(), "Launch a Zeppelin.")) {
|
||||
return;
|
||||
}
|
||||
FModel.getQuest().getAchievements().setCurrentChallenges(null);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.screens.home.quest;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.UiCommand;
|
||||
import forge.gui.framework.EDocID;
|
||||
import forge.gui.framework.ICDoc;
|
||||
@@ -36,23 +37,23 @@ public enum CSubmenuDuels implements ICDoc {
|
||||
|
||||
view.getBtnSpellShop().setCommand(
|
||||
new UiCommand() { @Override
|
||||
public void run() { QuestUtil.showSpellShop(); } });
|
||||
public void run() { QuestUtil.showSpellShop(GuiBase.getInterface()); } });
|
||||
|
||||
view.getBtnBazaar().setCommand(
|
||||
new UiCommand() { @Override
|
||||
public void run() { QuestUtil.showBazaar(); } });
|
||||
public void run() { QuestUtil.showBazaar(GuiBase.getInterface()); } });
|
||||
|
||||
view.getBtnTravel().setCommand(
|
||||
new UiCommand() { @Override
|
||||
public void run() { QuestUtil.travelWorld(); CSubmenuDuels.this.update(); } });
|
||||
public void run() { QuestUtil.travelWorld(GuiBase.getInterface()); CSubmenuDuels.this.update(); } });
|
||||
|
||||
view.getBtnUnlock().setCommand(
|
||||
new UiCommand() { @Override
|
||||
public void run() { QuestUtil.chooseAndUnlockEdition(); CSubmenuDuels.this.update(); } });
|
||||
public void run() { QuestUtil.chooseAndUnlockEdition(GuiBase.getInterface()); CSubmenuDuels.this.update(); } });
|
||||
|
||||
view.getBtnStart().addActionListener(
|
||||
new ActionListener() { @Override
|
||||
public void actionPerformed(final ActionEvent e) { QuestUtil.startGame(); } });
|
||||
public void actionPerformed(final ActionEvent e) { QuestUtil.startGame(GuiBase.getInterface()); } });
|
||||
|
||||
final QuestController quest = FModel.getQuest();
|
||||
view.getCbPlant().addActionListener(new ActionListener() {
|
||||
@@ -86,11 +87,11 @@ public enum CSubmenuDuels implements ICDoc {
|
||||
view.getBtnRandomOpponent().setCommand(new UiCommand() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (QuestUtil.canStartGame()) {
|
||||
if (QuestUtil.canStartGame(GuiBase.getInterface())) {
|
||||
FModel.getQuest().getDuelsManager().randomizeOpponents();
|
||||
final List<QuestEventDuel> duels = FModel.getQuest().getDuelsManager().generateDuels();
|
||||
QuestUtil.setEvent(duels.get((int) (Math.random() * duels.size())));
|
||||
QuestUtil.startGame();
|
||||
QuestUtil.startGame(GuiBase.getInterface());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.screens.home.quest;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.UiCommand;
|
||||
import forge.Singletons;
|
||||
import forge.deck.DeckProxy;
|
||||
@@ -56,7 +57,7 @@ public enum CSubmenuQuestDecks implements ICDoc {
|
||||
VSubmenuQuestDecks.SINGLETON_INSTANCE.getBtnNewDeck().setCommand(new UiCommand() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!QuestUtil.checkActiveQuest("Create a Deck.")) {
|
||||
if (!QuestUtil.checkActiveQuest(GuiBase.getInterface(), "Create a Deck.")) {
|
||||
return;
|
||||
}
|
||||
Singletons.getControl().setCurrentScreen(FScreen.DECK_EDITOR_QUEST);
|
||||
|
||||
@@ -329,7 +329,7 @@ public enum CSubmenuQuestDraft implements ICDoc {
|
||||
view.setMode(Mode.TOURNAMENT_ACTIVE);
|
||||
}
|
||||
|
||||
QuestDraftUtils.update();
|
||||
QuestDraftUtils.update(GuiBase.getInterface());
|
||||
|
||||
switch (view.getMode()) {
|
||||
|
||||
@@ -513,7 +513,7 @@ public enum CSubmenuQuestDraft implements ICDoc {
|
||||
|
||||
drafting = true;
|
||||
|
||||
BoosterDraft draft = draftEvent.enter();
|
||||
BoosterDraft draft = draftEvent.enter(GuiBase.getInterface());
|
||||
|
||||
final CEditorQuestDraftingProcess draftController = new CEditorQuestDraftingProcess();
|
||||
draftController.showGui(draft);
|
||||
@@ -553,7 +553,7 @@ public enum CSubmenuQuestDraft implements ICDoc {
|
||||
return;
|
||||
}
|
||||
|
||||
QuestDraftUtils.startNextMatch();
|
||||
QuestDraftUtils.startNextMatch(GuiBase.getInterface());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package forge.screens.home.quest;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.UiCommand;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.model.FModel;
|
||||
import forge.quest.QuestUtil;
|
||||
import forge.quest.bazaar.IQuestBazaarItem;
|
||||
@@ -75,7 +77,23 @@ public class ViewItem extends FPanel {
|
||||
final QuestAssets qA = FModel.getQuest().getAssets();
|
||||
IQuestBazaarItem bazaarItem = ViewItem.this.getItem();
|
||||
|
||||
ViewItem.this.lblIcon.setIcon((SkinImage)bazaarItem.getIcon(qA));
|
||||
SkinImage i;
|
||||
try {
|
||||
final FSkinProp f = FSkinProp.valueOf(FSkinProp.class, bazaarItem.getIcon(qA));
|
||||
i = (SkinImage) GuiBase.getInterface().getSkinIcon(f);
|
||||
} catch (final IllegalArgumentException e) {
|
||||
// Failed to parse FSkinProp
|
||||
try {
|
||||
i = (SkinImage) GuiBase.getInterface().getUnskinnedIcon(bazaarItem.getIcon(qA));
|
||||
} catch (final Exception e1) {
|
||||
// give up, icon unknown
|
||||
e1.printStackTrace();
|
||||
i = (SkinImage) GuiBase.getInterface().getSkinIcon(FSkinProp.ICO_UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
ViewItem.this.lblIcon.setIcon(i);
|
||||
|
||||
ViewItem.this.lblName.setText(bazaarItem.getPurchaseName());
|
||||
ViewItem.this.lblPrice.setText("Cost: " + String.valueOf(bazaarItem.getBuyingPrice(qA)) + " credits");
|
||||
String desc = bazaarItem.getPurchaseDescription(qA);
|
||||
|
||||
@@ -114,11 +114,11 @@ public enum CSubmenuDraft implements ICDoc {
|
||||
}
|
||||
}
|
||||
|
||||
FModel.getGauntletMini().resetGauntletDraft();
|
||||
FModel.getGauntletMini(GuiBase.getInterface()).resetGauntletDraft();
|
||||
|
||||
if (gauntlet) {
|
||||
int rounds = FModel.getDecks().getDraft().get(humanDeck.getName()).getAiDecks().size();
|
||||
FModel.getGauntletMini().launch(rounds, humanDeck.getDeck(), gameType);
|
||||
FModel.getGauntletMini(GuiBase.getInterface()).launch(rounds, humanDeck.getDeck(), gameType);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ public enum CSubmenuDraft implements ICDoc {
|
||||
final LimitedPoolType poolType = GuiChoose.oneOrNone("Choose Draft Format", LimitedPoolType.values());
|
||||
if (poolType == null) { return; }
|
||||
|
||||
BoosterDraft draft = BoosterDraft.createDraft(poolType);
|
||||
BoosterDraft draft = BoosterDraft.createDraft(GuiBase.getInterface(), poolType);
|
||||
if (draft == null) { return; }
|
||||
|
||||
final CEditorDraftingProcess draftController = new CEditorDraftingProcess();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.screens.home.sanctioned;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.UiCommand;
|
||||
import forge.Singletons;
|
||||
import forge.deck.*;
|
||||
@@ -16,6 +17,7 @@ import forge.screens.deckeditor.CDeckEditorUI;
|
||||
import forge.screens.deckeditor.controllers.ACEditorBase;
|
||||
import forge.screens.deckeditor.controllers.CEditorLimited;
|
||||
import forge.toolbox.FOptionPane;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
@@ -108,12 +110,12 @@ public enum CSubmenuSealed implements ICDoc {
|
||||
}
|
||||
|
||||
int matches = FModel.getDecks().getSealed().get(human.getName()).getAiDecks().size();
|
||||
FModel.getGauntletMini().launch(matches, human.getDeck(), gameType);
|
||||
FModel.getGauntletMini(GuiBase.getInterface()).launch(matches, human.getDeck(), gameType);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends DeckBase> void setupSealed() {
|
||||
final DeckGroup sealed = SealedCardPoolGenerator.generateSealedDeck(true);
|
||||
final DeckGroup sealed = SealedCardPoolGenerator.generateSealedDeck(GuiBase.getInterface(), true);
|
||||
if (sealed == null) { return; }
|
||||
|
||||
final ACEditorBase<? extends InventoryItem, T> editor = (ACEditorBase<? extends InventoryItem, T>) new CEditorLimited(
|
||||
|
||||
@@ -142,7 +142,7 @@ public enum CSubmenuWinston implements ICDoc {
|
||||
final LimitedPoolType poolType = GuiChoose.oneOrNone("Choose Draft Format", LimitedPoolType.values());
|
||||
if (poolType == null) { return; }
|
||||
|
||||
WinstonDraft draft = WinstonDraft.createDraft(poolType);
|
||||
WinstonDraft draft = WinstonDraft.createDraft(GuiBase.getInterface(), poolType);
|
||||
if (draft == null) { return; }
|
||||
|
||||
final CEditorWinstonProcess draftController = new CEditorWinstonProcess();
|
||||
|
||||
@@ -1,19 +1,46 @@
|
||||
package forge.screens.home.sanctioned;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
import forge.UiCommand;
|
||||
import forge.Singletons;
|
||||
import forge.UiCommand;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.deck.DeckProxy;
|
||||
import forge.deck.DeckSection;
|
||||
import forge.deck.DeckType;
|
||||
import forge.game.GameType;
|
||||
import forge.game.card.Card;
|
||||
import forge.gui.CardDetailPanel;
|
||||
import forge.deck.DeckProxy;
|
||||
import forge.deckchooser.DecksComboBoxEvent;
|
||||
import forge.deckchooser.FDeckChooser;
|
||||
import forge.deckchooser.IDecksComboBoxListener;
|
||||
import forge.game.GameType;
|
||||
import forge.gui.CardDetailPanel;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
import forge.gui.framework.EDocID;
|
||||
@@ -25,25 +52,30 @@ import forge.properties.ForgePreferences.FPref;
|
||||
import forge.screens.deckeditor.CDeckEditorUI;
|
||||
import forge.screens.deckeditor.controllers.CEditorCommander;
|
||||
import forge.screens.deckeditor.controllers.CEditorVariant;
|
||||
import forge.screens.home.*;
|
||||
import forge.toolbox.*;
|
||||
import forge.screens.home.EMenuGroup;
|
||||
import forge.screens.home.IVSubmenu;
|
||||
import forge.screens.home.LblHeader;
|
||||
import forge.screens.home.StartButton;
|
||||
import forge.screens.home.VHomeUI;
|
||||
import forge.toolbox.FCheckBox;
|
||||
import forge.toolbox.FComboBox;
|
||||
import forge.toolbox.FComboBoxWrapper;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FList;
|
||||
import forge.toolbox.FMouseAdapter;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.toolbox.FPanel;
|
||||
import forge.toolbox.FRadioButton;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.toolbox.FScrollPanel;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinColor;
|
||||
import forge.toolbox.FSkin.SkinImage;
|
||||
import forge.toolbox.FTextField;
|
||||
import forge.util.Lang;
|
||||
import forge.util.MyRandom;
|
||||
import forge.util.NameGenerator;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* Assembles Swing components of constructed submenu singleton.
|
||||
@@ -312,7 +344,7 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
||||
FScrollPane scrAvatars = new FScrollPane(vgdAvatarList, true,
|
||||
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
|
||||
CardDetailPanel vgdDetail = new CardDetailPanel(null);
|
||||
CardDetailPanel vgdDetail = new CardDetailPanel();
|
||||
vgdAvatarDetails.add(vgdDetail);
|
||||
|
||||
vgdDeckPanel.setLayout(new MigLayout(sectionConstraints));
|
||||
@@ -1211,7 +1243,7 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
||||
|
||||
if (obj instanceof PaperCard) {
|
||||
pp.setVanguardButtonText(((PaperCard) obj).getName());
|
||||
cdp.setCard(Card.getCardForUi((PaperCard) obj));
|
||||
cdp.setCard(ViewUtil.getCardForUi((PaperCard) obj));
|
||||
cdp.setVisible(true);
|
||||
refreshPanels(false, true);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.screens.home.settings;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.UiCommand;
|
||||
import forge.download.GuiDownloadPicturesLQ;
|
||||
import forge.download.GuiDownloadPrices;
|
||||
@@ -37,7 +38,7 @@ public enum CSubmenuDownloaders implements ICDoc {
|
||||
private final UiCommand cmdImportPictures = new UiCommand() { @Override
|
||||
public void run() { new ImportDialog(null, null); } };
|
||||
private final UiCommand cmdReportBug = new UiCommand() { @Override
|
||||
public void run() { BugReporter.reportBug(null); }
|
||||
public void run() { BugReporter.reportBug(GuiBase.getInterface(), null); }
|
||||
};
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package forge.screens.home.settings;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.UiCommand;
|
||||
import forge.Singletons;
|
||||
import forge.ai.AiProfileUtil;
|
||||
@@ -339,7 +340,7 @@ public enum CSubmenuPreferences implements ICDoc {
|
||||
return new UiCommand() {
|
||||
@Override
|
||||
public void run() {
|
||||
GamePlayerUtil.setPlayerName();
|
||||
GamePlayerUtil.setPlayerName(GuiBase.getInterface());
|
||||
setPlayerNameButtonText();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -17,49 +17,67 @@
|
||||
*/
|
||||
package forge.screens.match;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.swing.JMenu;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
|
||||
import forge.LobbyPlayer;
|
||||
import forge.UiCommand;
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.ImageCache;
|
||||
import forge.LobbyPlayer;
|
||||
import forge.Singletons;
|
||||
import forge.UiCommand;
|
||||
import forge.events.IUiEventVisitor;
|
||||
import forge.events.UiEvent;
|
||||
import forge.events.UiEventAttackerDeclared;
|
||||
import forge.events.UiEventBlockerAssigned;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.Zone;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.framework.*;
|
||||
import forge.gui.framework.EDocID;
|
||||
import forge.gui.framework.FScreen;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.gui.framework.IVDoc;
|
||||
import forge.gui.framework.SDisplayUtil;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.menus.IMenuProvider;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.quest.QuestDraftUtils;
|
||||
import forge.screens.match.controllers.*;
|
||||
import forge.screens.match.controllers.CAntes;
|
||||
import forge.screens.match.controllers.CCombat;
|
||||
import forge.screens.match.controllers.CDetail;
|
||||
import forge.screens.match.controllers.CPicture;
|
||||
import forge.screens.match.controllers.CPrompt;
|
||||
import forge.screens.match.menus.CMatchUIMenus;
|
||||
import forge.screens.match.views.*;
|
||||
import forge.screens.match.views.VCommand;
|
||||
import forge.screens.match.views.VField;
|
||||
import forge.screens.match.views.VHand;
|
||||
import forge.screens.match.views.VPlayers;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.toolbox.FOverlay;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinImage;
|
||||
import forge.toolbox.special.PhaseLabel;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CombatView;
|
||||
import forge.view.GameEntityView;
|
||||
import forge.view.IGameView;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.arcane.CardPanel;
|
||||
import forge.view.arcane.PlayArea;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Constructs instance of match UI controller, used as a single point of
|
||||
* top-level control for child UIs. Tasks targeting the view of individual
|
||||
@@ -71,7 +89,8 @@ import java.util.*;
|
||||
public enum CMatchUI implements ICDoc, IMenuProvider {
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
private List<Player> sortedPlayers;
|
||||
private IGameView game;
|
||||
private List<PlayerView> sortedPlayers;
|
||||
private VMatchUI view;
|
||||
|
||||
private EventBus uiEvents;
|
||||
@@ -85,14 +104,12 @@ public enum CMatchUI implements ICDoc, IMenuProvider {
|
||||
uiEvents.register(visitor);
|
||||
}
|
||||
|
||||
private SkinImage getPlayerAvatar(final Player p, final int defaultIndex) {
|
||||
LobbyPlayer lp = p.getLobbyPlayer();
|
||||
|
||||
if (avatarImages.containsKey(lp)) {
|
||||
return ImageCache.getIcon(avatarImages.get(lp));
|
||||
private SkinImage getPlayerAvatar(final LobbyPlayer p, final int defaultIndex) {
|
||||
if (avatarImages.containsKey(p)) {
|
||||
return ImageCache.getIcon(avatarImages.get(p));
|
||||
}
|
||||
|
||||
int avatarIdx = lp.getAvatarIndex();
|
||||
int avatarIdx = p.getAvatarIndex();
|
||||
return FSkin.getAvatars().get(avatarIdx >= 0 ? avatarIdx : defaultIndex);
|
||||
}
|
||||
|
||||
@@ -108,7 +125,8 @@ public enum CMatchUI implements ICDoc, IMenuProvider {
|
||||
* @param numFieldPanels int
|
||||
* @param numHandPanels int
|
||||
*/
|
||||
public void initMatch(final List<Player> players, LobbyPlayer localPlayer) {
|
||||
public void initMatch(final IGameView game, final List<PlayerView> players, LobbyPlayer localPlayer) {
|
||||
this.game = game;
|
||||
view = VMatchUI.SINGLETON_INSTANCE;
|
||||
// TODO fix for use with multiplayer
|
||||
|
||||
@@ -121,7 +139,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider {
|
||||
final List<VCommand> commands = new ArrayList<VCommand>();
|
||||
|
||||
int i = 0;
|
||||
for (Player p : sortedPlayers) {
|
||||
for (final PlayerView p : sortedPlayers) {
|
||||
// A field must be initialized after it's instantiated, to update player info.
|
||||
// No player, no init.
|
||||
VField f = new VField(EDocID.Fields[i], p, localPlayer);
|
||||
@@ -130,7 +148,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider {
|
||||
commands.add(c);
|
||||
|
||||
//setAvatar(f, new ImageIcon(FSkin.getAvatars().get()));
|
||||
setAvatar(f, getPlayerAvatar(p, Integer.parseInt(indices[i > 2 ? 1 : 0])));
|
||||
setAvatar(f, getPlayerAvatar(p.getLobbyPlayer(), Integer.parseInt(indices[i > 2 ? 1 : 0])));
|
||||
f.getLayoutControl().initialize();
|
||||
c.getLayoutControl().initialize();
|
||||
i++;
|
||||
@@ -149,8 +167,8 @@ public enum CMatchUI implements ICDoc, IMenuProvider {
|
||||
final List<VHand> hands = new ArrayList<VHand>();
|
||||
|
||||
int i = 0;
|
||||
for (Player p : sortedPlayers) {
|
||||
if (p.getLobbyPlayer() == localPlayer) {
|
||||
for (final PlayerView p : sortedPlayers) {
|
||||
if (p.getLobbyPlayer().equals(localPlayer) || !p.getHandCards().isEmpty()) {
|
||||
VHand newHand = new VHand(EDocID.Hands[i], p);
|
||||
newHand.getLayoutControl().initialize();
|
||||
hands.add(newHand);
|
||||
@@ -158,17 +176,12 @@ public enum CMatchUI implements ICDoc, IMenuProvider {
|
||||
i++;
|
||||
}
|
||||
|
||||
if (hands.isEmpty()) { // add empty hand for matches without human
|
||||
VHand newHand = new VHand(EDocID.Hands[0], null);
|
||||
newHand.getLayoutControl().initialize();
|
||||
hands.add(newHand);
|
||||
}
|
||||
view.setHandViews(hands);
|
||||
}
|
||||
|
||||
private List<Player> shiftPlayersPlaceLocalFirst(final List<Player> players, LobbyPlayer localPlayer) {
|
||||
private List<PlayerView> shiftPlayersPlaceLocalFirst(final List<PlayerView> players, final LobbyPlayer localPlayer) {
|
||||
// get an arranged list so that the first local player is at index 0
|
||||
List<Player> sortedPlayers = Lists.newArrayList(players);
|
||||
final List<PlayerView> sortedPlayers = Lists.newArrayList(players);
|
||||
int ixFirstHuman = -1;
|
||||
for (int i = 0; i < players.size(); i++) {
|
||||
if (sortedPlayers.get(i).getLobbyPlayer() == localPlayer) {
|
||||
@@ -199,17 +212,17 @@ public enum CMatchUI implements ICDoc, IMenuProvider {
|
||||
CPrompt.SINGLETON_INSTANCE.setMessage(s0);
|
||||
}
|
||||
|
||||
public VField getFieldViewFor(Player p) {
|
||||
public VField getFieldViewFor(PlayerView p) {
|
||||
int idx = getPlayerIndex(p);
|
||||
return idx < 0 ? null :view.getFieldViews().get(idx);
|
||||
}
|
||||
|
||||
public VCommand getCommandFor(Player p) {
|
||||
public VCommand getCommandFor(PlayerView p) {
|
||||
int idx = getPlayerIndex(p);
|
||||
return idx < 0 ? null :view.getCommandViews().get(idx);
|
||||
}
|
||||
|
||||
public VHand getHandFor(Player p) {
|
||||
public VHand getHandFor(PlayerView p) {
|
||||
int idx = getPlayerIndex(p);
|
||||
List<VHand> allHands = view.getHands();
|
||||
return idx < 0 || idx >= allHands.size() ? null : allHands.get(idx);
|
||||
@@ -226,27 +239,27 @@ public enum CMatchUI implements ICDoc, IMenuProvider {
|
||||
* @param overrideOrder overriding combatant order
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public Map<Card, Integer> getDamageToAssign(final Card attacker, final List<Card> blockers, final int damage, final GameEntity defender, final boolean overrideOrder) {
|
||||
public Map<CardView, Integer> getDamageToAssign(final CardView attacker, final List<CardView> blockers, final int damage, final GameEntityView defender, final boolean overrideOrder) {
|
||||
if (damage <= 0) {
|
||||
return new HashMap<Card, Integer>();
|
||||
return Maps.newHashMap();
|
||||
}
|
||||
|
||||
// If the first blocker can absorb all of the damage, don't show the Assign Damage Frame
|
||||
Card firstBlocker = blockers.get(0);
|
||||
if (!overrideOrder && !attacker.hasKeyword("Deathtouch") && firstBlocker.getLethalDamage() >= damage) {
|
||||
Map<Card, Integer> res = new HashMap<Card, Integer>();
|
||||
final CardView firstBlocker = blockers.get(0);
|
||||
if (!overrideOrder && !attacker.getOriginal().hasDeathtouch() && firstBlocker.getLethalDamage() >= damage) {
|
||||
final Map<CardView, Integer> res = Maps.newHashMap();
|
||||
res.put(firstBlocker, damage);
|
||||
return res;
|
||||
}
|
||||
|
||||
final Object[] result = { null }; // how else can I extract a value from EDT thread?
|
||||
FThreads.invokeInEdtAndWait(new Runnable() {
|
||||
FThreads.invokeInEdtAndWait(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
VAssignDamage v = new VAssignDamage(attacker, blockers, damage, defender, overrideOrder);
|
||||
result[0] = v.getDamageMap();
|
||||
}});
|
||||
return (Map<Card, Integer>)result[0];
|
||||
return (Map<CardView, Integer>)result[0];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -257,20 +270,21 @@ public enum CMatchUI implements ICDoc, IMenuProvider {
|
||||
* @param phase   {@link java.lang.String}
|
||||
* @return boolean
|
||||
*/
|
||||
public final boolean stopAtPhase(final Player turn, final PhaseType phase) {
|
||||
public final boolean stopAtPhase(final PlayerView turn, final PhaseType phase) {
|
||||
VField vf = getFieldViewFor(turn);
|
||||
PhaseLabel label = vf.getPhaseIndicator().getLabelFor(phase);
|
||||
PhaseLabel label = vf.getPhaseIndicator()
|
||||
.getLabelFor(phase);
|
||||
return label == null || label.getEnabled();
|
||||
}
|
||||
|
||||
public void setCard(final Card c) {
|
||||
FThreads.assertExecutedByEdt(true);
|
||||
setCard(c, false);
|
||||
public void setCard(final CardView c) {
|
||||
this.setCard(c, false);
|
||||
}
|
||||
|
||||
public void setCard(final Card c, final boolean showFlipped) {
|
||||
CDetail.SINGLETON_INSTANCE.showCard(c);
|
||||
CPicture.SINGLETON_INSTANCE.showCard(c, showFlipped);
|
||||
public void setCard(final CardView c, final boolean isInAltState) {
|
||||
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
|
||||
CDetail.SINGLETON_INSTANCE.showCard(c, isInAltState);
|
||||
CPicture.SINGLETON_INSTANCE.showCard(c, isInAltState);
|
||||
}
|
||||
|
||||
public void setCard(final InventoryItem c) {
|
||||
@@ -278,12 +292,12 @@ public enum CMatchUI implements ICDoc, IMenuProvider {
|
||||
CPicture.SINGLETON_INSTANCE.showImage(c);
|
||||
}
|
||||
|
||||
private int getPlayerIndex(Player player) {
|
||||
private int getPlayerIndex(PlayerView player) {
|
||||
return sortedPlayers.indexOf(player);
|
||||
}
|
||||
|
||||
public void showCombat(Combat combat) {
|
||||
if (combat != null && combat.getAttackers().size() > 0 && combat.getAttackingPlayer().getGame().getStack().isEmpty()) {
|
||||
public void showCombat(final CombatView combat) {
|
||||
if (combat != null && combat.getNumAttackers() > 0 && game.peekStack() == null) {
|
||||
if (selectedDocBeforeCombat == null) {
|
||||
IVDoc<? extends ICDoc> combatDoc = EDocID.REPORT_COMBAT.getDoc();
|
||||
if (combatDoc.getParentCell() != null) {
|
||||
@@ -303,22 +317,22 @@ public enum CMatchUI implements ICDoc, IMenuProvider {
|
||||
}
|
||||
CCombat.SINGLETON_INSTANCE.setModel(combat);
|
||||
CCombat.SINGLETON_INSTANCE.update();
|
||||
} // showBlockers()
|
||||
} // showCombat(CombatView)
|
||||
|
||||
Set<Player> highlightedPlayers = new HashSet<Player>();
|
||||
public void setHighlighted(Player ge, boolean b) {
|
||||
final Set<PlayerView> highlightedPlayers = Sets.newHashSet();
|
||||
public void setHighlighted(PlayerView ge, boolean b) {
|
||||
if (b) highlightedPlayers.add(ge);
|
||||
else highlightedPlayers.remove(ge);
|
||||
}
|
||||
|
||||
public boolean isHighlighted(Player player) {
|
||||
public boolean isHighlighted(final PlayerView player) {
|
||||
return highlightedPlayers.contains(player);
|
||||
}
|
||||
|
||||
Set<Card> highlightedCards = new HashSet<Card>();
|
||||
Set<CardView> highlightedCards = Sets.newHashSet();
|
||||
// used to highlight cards in UI
|
||||
public void setUsedToPay(Card card, boolean value) {
|
||||
FThreads.assertExecutedByEdt(true);
|
||||
public void setUsedToPay(CardView card, boolean value) {
|
||||
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
|
||||
|
||||
boolean hasChanged = value ? highlightedCards.add(card) : highlightedCards.remove(card);
|
||||
if (hasChanged) { // since we are in UI thread, may redraw the card right now
|
||||
@@ -326,14 +340,14 @@ public enum CMatchUI implements ICDoc, IMenuProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isUsedToPay(Card card) {
|
||||
public boolean isUsedToPay(CardView card) {
|
||||
return highlightedCards.contains(card);
|
||||
}
|
||||
|
||||
public void updateZones(List<Pair<Player, ZoneType>> zonesToUpdate) {
|
||||
public void updateZones(List<Pair<PlayerView, ZoneType>> zonesToUpdate) {
|
||||
//System.out.println("updateZones " + zonesToUpdate);
|
||||
for (Pair<Player, ZoneType> kv : zonesToUpdate) {
|
||||
Player owner = kv.getKey();
|
||||
for (Pair<PlayerView, ZoneType> kv : zonesToUpdate) {
|
||||
PlayerView owner = kv.getKey();
|
||||
ZoneType zt = kv.getValue();
|
||||
|
||||
if (zt == ZoneType.Command) {
|
||||
@@ -349,47 +363,48 @@ public enum CMatchUI implements ICDoc, IMenuProvider {
|
||||
} else if (zt == ZoneType.Ante) {
|
||||
CAntes.SINGLETON_INSTANCE.update();
|
||||
} else {
|
||||
getFieldViewFor(owner).getDetailsPanel().updateZones();
|
||||
final VField vf = getFieldViewFor(owner);
|
||||
if (vf != null) {
|
||||
vf.getDetailsPanel().updateZones();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Player's mana pool changes
|
||||
public void updateManaPool(List<Player> manaPoolUpdate) {
|
||||
for (Player p : manaPoolUpdate) {
|
||||
public void updateManaPool(final List<PlayerView> manaPoolUpdate) {
|
||||
for (final PlayerView p : manaPoolUpdate) {
|
||||
getFieldViewFor(p).getDetailsPanel().updateManaPool();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Player's lives and poison counters
|
||||
public void updateLives(List<Player> livesUpdate) {
|
||||
for (Player p : livesUpdate) {
|
||||
public void updateLives(final List<PlayerView> livesUpdate) {
|
||||
for (final PlayerView p : livesUpdate) {
|
||||
getFieldViewFor(p).updateDetails();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void updateCards(Set<Card> cardsToUpdate) {
|
||||
for (Card c : cardsToUpdate) {
|
||||
public void updateCards(final Set<CardView> cardsToUpdate) {
|
||||
for (final CardView c : cardsToUpdate) {
|
||||
updateSingleCard(c);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateSingleCard(Card c) {
|
||||
Zone zone = c.getZone();
|
||||
if (zone != null && zone.getZoneType() == ZoneType.Battlefield) {
|
||||
PlayArea pa = getFieldViewFor(zone.getPlayer()).getTabletop();
|
||||
public void updateSingleCard(final CardView c) {
|
||||
if (ZoneType.Battlefield.equals(c.getZone())) {
|
||||
final PlayArea pa = getFieldViewFor(c.getController()).getTabletop();
|
||||
pa.updateCard(c, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshCardDetails(Collection<Card> cards) {
|
||||
for (Card c : cards) {
|
||||
Zone zone = c.getZone();
|
||||
if (zone != null && zone.getZoneType() == ZoneType.Battlefield) {
|
||||
PlayArea pa = getFieldViewFor(zone.getPlayer()).getTabletop();
|
||||
CardPanel pnl = pa.getCardPanel(c.getUniqueNumber());
|
||||
public void refreshCardDetails(final Iterable<CardView> cards) {
|
||||
for (final CardView c : cards) {
|
||||
if (ZoneType.Battlefield.equals(c.getZone())) {
|
||||
PlayArea pa = getFieldViewFor(c.getController()).getTabletop();
|
||||
CardPanel pnl = pa.getCardPanel(c.getId());
|
||||
if (pnl != null) {
|
||||
pnl.updatePTOverlay();
|
||||
}
|
||||
@@ -402,7 +417,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider {
|
||||
// UI-related events should arrive here
|
||||
public void fireEvent(UiEvent uiEvent) {
|
||||
if (LOG_UIEVENTS) {
|
||||
System.out.println("UI: " + uiEvent.toString() + " \t\t " + FThreads.debugGetStackTraceItem(4, true));
|
||||
System.out.println("UI: " + uiEvent.toString() + " \t\t " + FThreads.debugGetStackTraceItem(GuiBase.getInterface(), 4, true));
|
||||
}
|
||||
uiEvents.post(uiEvent);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package forge.screens.match;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.game.Game;
|
||||
import forge.game.Match;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.gui.framework.FScreen;
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.gui.framework.FScreen;
|
||||
import forge.view.IGameView;
|
||||
|
||||
/**
|
||||
* Default controller for a ViewWinLose object. This class can
|
||||
* be extended for various game modes to populate the custom
|
||||
@@ -18,13 +18,13 @@ import java.awt.event.ActionListener;
|
||||
*/
|
||||
public class ControlWinLose {
|
||||
private final ViewWinLose view;
|
||||
protected final Game lastGame;
|
||||
protected final IGameView lastGame;
|
||||
|
||||
/** @param v   ViewWinLose
|
||||
* @param match */
|
||||
public ControlWinLose(final ViewWinLose v, Game game) {
|
||||
public ControlWinLose(final ViewWinLose v, final IGameView game0) {
|
||||
this.view = v;
|
||||
this.lastGame = game;
|
||||
this.lastGame = game0;
|
||||
addListeners();
|
||||
}
|
||||
|
||||
@@ -59,17 +59,15 @@ public class ControlWinLose {
|
||||
saveOptions();
|
||||
|
||||
Singletons.getControl().endCurrentGame();
|
||||
Singletons.getControl().startGameWithUi(lastGame.getMatch());
|
||||
Singletons.getControl().startGameInSameMatch();
|
||||
}
|
||||
|
||||
/** Action performed when "restart" button is pressed in default win/lose UI. */
|
||||
public void actionOnRestart() {
|
||||
SOverlayUtils.hideOverlay();
|
||||
saveOptions();
|
||||
final Match match = lastGame.getMatch();
|
||||
match.clearGamesPlayed();
|
||||
Singletons.getControl().endCurrentGame();
|
||||
Singletons.getControl().startGameWithUi(match);
|
||||
Singletons.getControl().startGameAndClearMatch();
|
||||
}
|
||||
|
||||
/** Action performed when "quit" button is pressed in default win/lose UI. */
|
||||
|
||||
@@ -17,18 +17,21 @@ package forge.screens.match;
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.game.Game;
|
||||
import forge.gauntlet.GauntletWinLoseController;
|
||||
import forge.interfaces.IGuiBase;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedPanel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
import forge.view.IGameView;
|
||||
|
||||
/**
|
||||
* The Win/Lose handler for 'gauntlet' type tournament
|
||||
@@ -43,9 +46,9 @@ public class GauntletWinLose extends ControlWinLose {
|
||||
* @param view0 ViewWinLose object
|
||||
* @param match
|
||||
*/
|
||||
public GauntletWinLose(final ViewWinLose view0, Game lastGame) {
|
||||
super(view0, lastGame);
|
||||
controller = new GauntletWinLoseController(view0, lastGame) {
|
||||
public GauntletWinLose(final ViewWinLose view0, final IGameView game0, final IGuiBase gui) {
|
||||
super(view0, game0);
|
||||
controller = new GauntletWinLoseController(view0, game0, gui) {
|
||||
@Override
|
||||
protected void showOutcome(String message1, String message2, FSkinProp icon, List<String> lstEventNames, List<String> lstEventRecords, int len, int num) {
|
||||
final JLabel lblTitle = new FLabel.Builder().text("Gauntlet Progress")
|
||||
|
||||
@@ -21,12 +21,13 @@ import java.awt.Dimension;
|
||||
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.GuiBase;
|
||||
import forge.limited.LimitedWinLoseController;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.Colors;
|
||||
import forge.toolbox.FSkin.SkinColor;
|
||||
import forge.toolbox.FSkin.SkinnedLabel;
|
||||
import forge.view.IGameView;
|
||||
|
||||
/**
|
||||
* The Win/Lose handler for 'gauntlet' type tournament
|
||||
@@ -46,9 +47,9 @@ public class LimitedWinLose extends ControlWinLose {
|
||||
* @param view0 {@link forge.screens.match.ViewWinLose}
|
||||
* @param match {@link forge.game.Match}
|
||||
*/
|
||||
public LimitedWinLose(final ViewWinLose view0, Game lastGame) {
|
||||
super(view0, lastGame);
|
||||
controller = new LimitedWinLoseController(view0, lastGame) {
|
||||
public LimitedWinLose(final ViewWinLose view0, final IGameView game0) {
|
||||
super(view0, game0);
|
||||
controller = new LimitedWinLoseController(view0, game0, GuiBase.getInterface()) {
|
||||
@Override
|
||||
protected void showOutcome(Runnable runnable) {
|
||||
runnable.run(); //just run on GUI thread
|
||||
|
||||
@@ -24,8 +24,6 @@ import forge.GuiBase;
|
||||
import forge.LobbyPlayer;
|
||||
import forge.Singletons;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.game.Game;
|
||||
import forge.game.player.Player;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.gui.framework.FScreen;
|
||||
import forge.model.FModel;
|
||||
@@ -37,6 +35,8 @@ import forge.screens.home.quest.CSubmenuQuestDraft;
|
||||
import forge.screens.home.quest.VSubmenuQuestDraft;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.view.IGameView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -58,8 +58,8 @@ public class QuestDraftWinLose extends ControlWinLose {
|
||||
* @param view0 ViewWinLose object
|
||||
* @param match2
|
||||
*/
|
||||
public QuestDraftWinLose(final ViewWinLose view0, Game lastGame) {
|
||||
super(view0, lastGame);
|
||||
public QuestDraftWinLose(final ViewWinLose view0, final IGameView game0) {
|
||||
super(view0, game0);
|
||||
this.view = view0;
|
||||
qData = FModel.getQuest();
|
||||
}
|
||||
@@ -79,18 +79,18 @@ public class QuestDraftWinLose extends ControlWinLose {
|
||||
QuestController quest = FModel.getQuest();
|
||||
|
||||
final LobbyPlayer questLobbyPlayer = GuiBase.getInterface().getQuestPlayer();
|
||||
List<Player> players = lastGame.getRegisteredPlayers();
|
||||
final List<PlayerView> players = lastGame.getPlayers();
|
||||
boolean gameHadHumanPlayer = false;
|
||||
for (Player p : players) {
|
||||
for (final PlayerView p : players) {
|
||||
if (p.getLobbyPlayer().equals(questLobbyPlayer)) {
|
||||
gameHadHumanPlayer = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastGame.getMatch().isMatchOver()) {
|
||||
if (lastGame.isMatchOver()) {
|
||||
|
||||
String winner = lastGame.getOutcome().getWinningPlayer().getName();
|
||||
String winner = lastGame.getWinningPlayer().getName();
|
||||
|
||||
quest.getAchievements().getCurrentDraft().setWinner(winner);
|
||||
quest.save();
|
||||
@@ -99,13 +99,13 @@ public class QuestDraftWinLose extends ControlWinLose {
|
||||
|
||||
if (!gameHadHumanPlayer) {
|
||||
|
||||
if (lastGame.getMatch().isMatchOver()) {
|
||||
if (lastGame.isMatchOver()) {
|
||||
this.actionOnQuitMatch();
|
||||
QuestDraftUtils.matchInProgress = false;
|
||||
QuestDraftUtils.update();
|
||||
QuestDraftUtils.update(GuiBase.getInterface());
|
||||
} else {
|
||||
this.actionOnContinue();
|
||||
QuestDraftUtils.update();
|
||||
QuestDraftUtils.update(GuiBase.getInterface());
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -114,7 +114,7 @@ public class QuestDraftWinLose extends ControlWinLose {
|
||||
view.getBtnRestart().setEnabled(false);
|
||||
view.getBtnRestart().setVisible(false);
|
||||
|
||||
if (lastGame.getMatch().isMatchOver()) {
|
||||
if (lastGame.isMatchOver()) {
|
||||
view.getBtnQuit().setEnabled(true);
|
||||
view.getBtnContinue().setEnabled(false);
|
||||
view.getBtnQuit().setText("Continue Tournament");
|
||||
@@ -126,7 +126,7 @@ public class QuestDraftWinLose extends ControlWinLose {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
GuiBase.getInterface().endCurrentGame();
|
||||
QuestDraftUtils.matchInProgress = false;
|
||||
QuestDraftUtils.continueMatches();
|
||||
QuestDraftUtils.continueMatches(GuiBase.getInterface());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -141,7 +141,7 @@ public class QuestDraftWinLose extends ControlWinLose {
|
||||
if (FOptionPane.showOptionDialog("Quitting the match now will forfeit the tournament!\n\nReally quit?", "Really Quit Tournament?", FSkin.getImage(FSkinProp.ICO_WARNING).scale(2), new String[] { "Yes", "No" }, 1) == 0) {
|
||||
GuiBase.getInterface().endCurrentGame();
|
||||
QuestDraftUtils.matchInProgress = false;
|
||||
QuestDraftUtils.continueMatches();
|
||||
QuestDraftUtils.continueMatches(GuiBase.getInterface());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -16,12 +16,17 @@
|
||||
*/
|
||||
package forge.screens.match;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.game.Game;
|
||||
import forge.item.*;
|
||||
import forge.item.PaperCard;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.quest.*;
|
||||
import forge.quest.QuestWinLoseController;
|
||||
import forge.screens.home.quest.CSubmenuChallenges;
|
||||
import forge.screens.home.quest.CSubmenuDuels;
|
||||
import forge.toolbox.FSkin;
|
||||
@@ -29,11 +34,7 @@ import forge.toolbox.FSkin.Colors;
|
||||
import forge.toolbox.FSkin.SkinColor;
|
||||
import forge.toolbox.FSkin.SkinIcon;
|
||||
import forge.toolbox.FSkin.SkinnedLabel;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.SwingConstants;
|
||||
import forge.view.IGameView;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -61,10 +62,10 @@ public class QuestWinLose extends ControlWinLose {
|
||||
* @param view0 ViewWinLose object
|
||||
* @param match2
|
||||
*/
|
||||
public QuestWinLose(final ViewWinLose view0, Game lastGame) {
|
||||
super(view0, lastGame);
|
||||
public QuestWinLose(final ViewWinLose view0, final IGameView game0) {
|
||||
super(view0, game0);
|
||||
view = view0;
|
||||
controller = new QuestWinLoseController(lastGame) {
|
||||
controller = new QuestWinLoseController(game0, GuiBase.getInterface()) {
|
||||
@Override
|
||||
protected void showRewards(Runnable runnable) {
|
||||
runnable.run(); //just run on GUI thread
|
||||
|
||||
@@ -17,7 +17,15 @@
|
||||
*/
|
||||
package forge.screens.match;
|
||||
|
||||
import forge.game.card.Card;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.AbstractListModel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.gui.CardDetailPanel;
|
||||
import forge.gui.CardPicturePanel;
|
||||
import forge.item.PaperCard;
|
||||
@@ -27,14 +35,7 @@ import forge.toolbox.FList;
|
||||
import forge.toolbox.FPanel;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.toolbox.FSkin;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* A simple JPanel that shows three columns: card list, pic, and description..
|
||||
@@ -63,7 +64,7 @@ public class QuestWinLoseCardViewer extends FPanel {
|
||||
public QuestWinLoseCardViewer(final List<PaperCard> list) {
|
||||
this.list = Collections.unmodifiableList(list);
|
||||
this.jList = new FList<PaperCard>(new ChooserListModel());
|
||||
this.detail = new CardDetailPanel(null);
|
||||
this.detail = new CardDetailPanel();
|
||||
this.picture = new CardPicturePanel();
|
||||
this.scroller = new FScrollPane(this.jList, false);
|
||||
|
||||
@@ -111,7 +112,7 @@ public class QuestWinLoseCardViewer extends FPanel {
|
||||
// (String) jList.getSelectedValue();
|
||||
if ((row >= 0) && (row < QuestWinLoseCardViewer.this.list.size())) {
|
||||
final PaperCard cp = QuestWinLoseCardViewer.this.list.get(row);
|
||||
QuestWinLoseCardViewer.this.detail.setCard(Card.getCardForUi(cp));
|
||||
QuestWinLoseCardViewer.this.detail.setCard(ViewUtil.getCardForUi(cp));
|
||||
QuestWinLoseCardViewer.this.picture.setCard(cp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,20 +17,11 @@
|
||||
*/
|
||||
package forge.screens.match;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.gui.framework.FScreen;
|
||||
import forge.screens.match.controllers.CDock;
|
||||
import forge.screens.match.views.VField;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedPanel;
|
||||
import forge.view.FView;
|
||||
import forge.view.arcane.CardPanel;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.GeneralPath;
|
||||
@@ -39,6 +30,22 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.gui.framework.FScreen;
|
||||
import forge.screens.match.controllers.CDock;
|
||||
import forge.screens.match.views.VField;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedPanel;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CombatView;
|
||||
import forge.view.FView;
|
||||
import forge.view.GameEntityView;
|
||||
import forge.view.arcane.CardPanel;
|
||||
|
||||
/**
|
||||
* Semi-transparent overlay panel. Should be used with layered panes.
|
||||
*
|
||||
@@ -74,7 +81,7 @@ public enum TargetingOverlay {
|
||||
// TODO - this is called every repaint, regardless if card
|
||||
// positions have changed or not. Could perform better if
|
||||
// it checked for a state change. Doublestrike 28-09-12
|
||||
private void assembleArcs(Combat combat) {
|
||||
private void assembleArcs(final CombatView combat) {
|
||||
//List<VField> fields = VMatchUI.SINGLETON_INSTANCE.getFieldViews();
|
||||
arcsCombat.clear();
|
||||
arcsOther.clear();
|
||||
@@ -115,7 +122,7 @@ public enum TargetingOverlay {
|
||||
for (CardPanel c : cardPanels) {
|
||||
if (c.isShowing()) {
|
||||
cardLocOnScreen = c.getCardLocationOnScreen();
|
||||
endpoints.put(c.getCard().getUniqueNumber(), new Point(
|
||||
endpoints.put(c.getCard().getId(), new Point(
|
||||
(int) (cardLocOnScreen.getX() - locOnScreen.getX() + c.getWidth() / 4),
|
||||
(int) (cardLocOnScreen.getY() - locOnScreen.getY() + c.getHeight() / 2)
|
||||
));
|
||||
@@ -124,16 +131,16 @@ public enum TargetingOverlay {
|
||||
|
||||
if (CDock.SINGLETON_INSTANCE.getArcState() == 1) {
|
||||
// Only work with the active panel
|
||||
Card c = activePanel.getCard();
|
||||
final CardView c = activePanel.getCard();
|
||||
addArcsForCard(c, endpoints, combat);
|
||||
} else {
|
||||
// Work with all card panels currently visible
|
||||
List<Card> visualized = new ArrayList<Card>();
|
||||
for (CardPanel c : cardPanels) {
|
||||
final List<CardView> visualized = Lists.newArrayList();
|
||||
for (final CardPanel c : cardPanels) {
|
||||
if (!c.isShowing()) {
|
||||
continue;
|
||||
}
|
||||
Card card = c.getCard();
|
||||
final CardView card = c.getCard();
|
||||
if (visualized.contains(card)) { continue; }
|
||||
|
||||
visualized.addAll(addArcsForCard(card, endpoints, combat));
|
||||
@@ -141,23 +148,22 @@ public enum TargetingOverlay {
|
||||
}
|
||||
}
|
||||
|
||||
private List<Card> addArcsForCard(final Card c, final Map<Integer, Point> endpoints, final Combat combat) {
|
||||
List<Card> cardsVisualized = new ArrayList<Card>();
|
||||
cardsVisualized.add(c);
|
||||
private List<CardView> addArcsForCard(final CardView c, final Map<Integer, Point> endpoints, final CombatView combat) {
|
||||
final List<CardView> cardsVisualized = Lists.newArrayList(c);
|
||||
|
||||
Card enchanting = c.getEnchantingCard();
|
||||
Card equipping = c.getEquippingCard();
|
||||
Card fortifying = c.getFortifyingCard();
|
||||
List<Card> enchantedBy = c.getEnchantedBy();
|
||||
List<Card> equippedBy = c.getEquippedBy();
|
||||
List<Card> fortifiedBy = c.getFortifiedBy();
|
||||
Card paired = c.getPairedWith();
|
||||
final CardView enchanting = c.getEnchantingCard();
|
||||
final CardView equipping = c.getEquipping();
|
||||
final CardView fortifying = c.getFortifying();
|
||||
final Iterable<CardView> enchantedBy = c.getEnchantedBy();
|
||||
final Iterable<CardView> equippedBy = c.getEquippedBy();
|
||||
final Iterable<CardView> fortifiedBy = c.getFortifiedBy();
|
||||
final CardView paired = c.getPairedWith();
|
||||
|
||||
if (null != enchanting) {
|
||||
if (!enchanting.getController().equals(c.getController())) {
|
||||
arcsOther.add(new Point[] {
|
||||
endpoints.get(enchanting.getUniqueNumber()),
|
||||
endpoints.get(c.getUniqueNumber())
|
||||
endpoints.get(enchanting.getId()),
|
||||
endpoints.get(c.getId())
|
||||
});
|
||||
cardsVisualized.add(enchanting);
|
||||
}
|
||||
@@ -165,8 +171,8 @@ public enum TargetingOverlay {
|
||||
if (null != equipping) {
|
||||
if (!equipping.getController().equals(c.getController())) {
|
||||
arcsOther.add(new Point[] {
|
||||
endpoints.get(equipping.getUniqueNumber()),
|
||||
endpoints.get(c.getUniqueNumber())
|
||||
endpoints.get(equipping.getId()),
|
||||
endpoints.get(c.getId())
|
||||
});
|
||||
cardsVisualized.add(equipping);
|
||||
}
|
||||
@@ -174,40 +180,40 @@ public enum TargetingOverlay {
|
||||
if (null != fortifying) {
|
||||
if (!fortifying.getController().equals(c.getController())) {
|
||||
arcsOther.add(new Point[] {
|
||||
endpoints.get(fortifying.getUniqueNumber()),
|
||||
endpoints.get(c.getUniqueNumber())
|
||||
endpoints.get(fortifying.getId()),
|
||||
endpoints.get(c.getId())
|
||||
});
|
||||
cardsVisualized.add(fortifying);
|
||||
}
|
||||
}
|
||||
if (null != enchantedBy) {
|
||||
for (Card enc : enchantedBy) {
|
||||
for (final CardView enc : enchantedBy) {
|
||||
if (!enc.getController().equals(c.getController())) {
|
||||
arcsOther.add(new Point[] {
|
||||
endpoints.get(c.getUniqueNumber()),
|
||||
endpoints.get(enc.getUniqueNumber())
|
||||
endpoints.get(c.getId()),
|
||||
endpoints.get(enc.getId())
|
||||
});
|
||||
cardsVisualized.add(enc);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null != equippedBy) {
|
||||
for (Card eq : equippedBy) {
|
||||
for (final CardView eq : equippedBy) {
|
||||
if (!eq.getController().equals(c.getController())) {
|
||||
arcsOther.add(new Point[] {
|
||||
endpoints.get(c.getUniqueNumber()),
|
||||
endpoints.get(eq.getUniqueNumber())
|
||||
endpoints.get(c.getId()),
|
||||
endpoints.get(eq.getId())
|
||||
});
|
||||
cardsVisualized.add(eq);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null != fortifiedBy) {
|
||||
for (Card eq : fortifiedBy) {
|
||||
for (final CardView eq : fortifiedBy) {
|
||||
if (!eq.getController().equals(c.getController())) {
|
||||
arcsOther.add(new Point[] {
|
||||
endpoints.get(c.getUniqueNumber()),
|
||||
endpoints.get(eq.getUniqueNumber())
|
||||
endpoints.get(c.getId()),
|
||||
endpoints.get(eq.getId())
|
||||
});
|
||||
cardsVisualized.add(eq);
|
||||
}
|
||||
@@ -215,29 +221,36 @@ public enum TargetingOverlay {
|
||||
}
|
||||
if (null != paired) {
|
||||
arcsOther.add(new Point[] {
|
||||
endpoints.get(paired.getUniqueNumber()),
|
||||
endpoints.get(c.getUniqueNumber())
|
||||
endpoints.get(paired.getId()),
|
||||
endpoints.get(c.getId())
|
||||
});
|
||||
cardsVisualized.add(paired);
|
||||
}
|
||||
if ( null != combat ) {
|
||||
for (Card planeswalker : combat.getDefendingPlaneswalkers()) {
|
||||
List<Card> cards = combat.getAttackersOf(planeswalker);
|
||||
for (Card pwAttacker : cards) {
|
||||
if (!planeswalker.equals(c) && !pwAttacker.equals(c)) { continue; }
|
||||
if (null != combat) {
|
||||
final GameEntityView defender = combat.getDefender(c);
|
||||
// if c is attacking a planeswalker
|
||||
if (defender instanceof CardView) {
|
||||
arcsCombat.add(new Point[] {
|
||||
endpoints.get(planeswalker.getUniqueNumber()),
|
||||
endpoints.get(pwAttacker.getUniqueNumber())
|
||||
endpoints.get(((CardView)defender).getId()),
|
||||
endpoints.get(c.getId())
|
||||
});
|
||||
}
|
||||
// if c is a planeswalker that's being attacked
|
||||
final Iterable<CardView> attackers = combat.getAttackersOf(c);
|
||||
for (final CardView pwAttacker : attackers) {
|
||||
arcsCombat.add(new Point[] {
|
||||
endpoints.get(c.getId()),
|
||||
endpoints.get(pwAttacker.getId())
|
||||
});
|
||||
}
|
||||
for (Card attackingCard : combat.getAttackers()) {
|
||||
List<Card> cards = combat.getBlockers(attackingCard);
|
||||
for (Card blockingCard : cards) {
|
||||
for (final CardView attackingCard : combat.getAttackers()) {
|
||||
final Iterable<CardView> cards = combat.getBlockers(attackingCard);
|
||||
if (cards == null) continue;
|
||||
for (final CardView blockingCard : cards) {
|
||||
if (!attackingCard.equals(c) && !blockingCard.equals(c)) { continue; }
|
||||
arcsCombat.add(new Point[] {
|
||||
endpoints.get(attackingCard.getUniqueNumber()),
|
||||
endpoints.get(blockingCard.getUniqueNumber())
|
||||
endpoints.get(attackingCard.getId()),
|
||||
endpoints.get(blockingCard.getId())
|
||||
});
|
||||
cardsVisualized.add(blockingCard);
|
||||
}
|
||||
@@ -340,7 +353,6 @@ public enum TargetingOverlay {
|
||||
*/
|
||||
@Override
|
||||
public void paintComponent(final Graphics g) {
|
||||
final Combat combat = Singletons.getControl().getObservedGame().getCombat(); // this will get deprecated too
|
||||
// No need for this except in match view
|
||||
if (Singletons.getControl().getCurrentScreen() != FScreen.MATCH_SCREEN) { return; }
|
||||
|
||||
@@ -351,7 +363,7 @@ public enum TargetingOverlay {
|
||||
if (overlaystate == 0) { return; }
|
||||
|
||||
// Arc drawing
|
||||
assembleArcs(combat);
|
||||
assembleArcs(Singletons.getControl().getGameView().getCombat());
|
||||
|
||||
if (arcsCombat.isEmpty() && arcsOther.isEmpty()) { return; }
|
||||
|
||||
|
||||
@@ -17,33 +17,38 @@
|
||||
*/
|
||||
package forge.screens.match;
|
||||
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.player.Player;
|
||||
import java.awt.Dialog.ModalityType;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.border.Border;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import forge.control.FControl;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.toolbox.FButton;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedPanel;
|
||||
import forge.view.CardView;
|
||||
import forge.view.FDialog;
|
||||
import forge.view.GameEntityView;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.arcane.CardPanel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
|
||||
import java.awt.Dialog.ModalityType;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Assembles Swing components of assign damage dialog.
|
||||
@@ -68,7 +73,7 @@ public class VAssignDamage {
|
||||
private boolean attackerHasInfect = false;
|
||||
private boolean overrideCombatantOrder = false;
|
||||
|
||||
private final GameEntity defender;
|
||||
private final GameEntityView defender;
|
||||
|
||||
private final JLabel lblTotalDamage = new FLabel.Builder().text("Available damage points: Unknown").build();
|
||||
private final JLabel lblAssignRemaining = new FLabel.Builder().text("Distribute the remaining damage points among lethally wounded entities").build();
|
||||
@@ -79,24 +84,24 @@ public class VAssignDamage {
|
||||
|
||||
|
||||
private static class DamageTarget {
|
||||
public final Card card;
|
||||
public final CardView card;
|
||||
public final JLabel label;
|
||||
public int damage;
|
||||
|
||||
public DamageTarget(Card entity0, JLabel lbl) {
|
||||
card = entity0;
|
||||
public DamageTarget(final CardView c, final JLabel lbl) {
|
||||
card = c;
|
||||
label = lbl;
|
||||
}
|
||||
}
|
||||
|
||||
// Indexes of defenders correspond to their indexes in the damage list and labels.
|
||||
private final List<DamageTarget> defenders = new ArrayList<DamageTarget>(); // NULL in this map means defender
|
||||
private final Map<Card, DamageTarget> damage = new HashMap<Card, DamageTarget>(); // NULL in this map means defender
|
||||
private final List<DamageTarget> defenders = Lists.newArrayList(); // NULL in this map means defender
|
||||
private final Map<CardView, DamageTarget> damage = Maps.newHashMap(); // NULL in this map means defender
|
||||
|
||||
private boolean canAssignTo(Card card) {
|
||||
for(DamageTarget dt : defenders) {
|
||||
if ( dt.card == card ) return true;
|
||||
if ( getDamageToKill(dt.card) > dt.damage )
|
||||
private boolean canAssignTo(final CardView card) {
|
||||
for (DamageTarget dt : defenders) {
|
||||
if (dt.card == card ) return true;
|
||||
if (getDamageToKill(dt.card) > dt.damage )
|
||||
return false;
|
||||
}
|
||||
throw new RuntimeException("Asking to assign damage to object which is not present in defenders list");
|
||||
@@ -106,10 +111,10 @@ public class VAssignDamage {
|
||||
private final MouseAdapter mad = new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseEntered(final MouseEvent evt) {
|
||||
Card source = ((CardPanel) evt.getSource()).getCard();
|
||||
CardView source = ((CardPanel) evt.getSource()).getCard();
|
||||
if (!damage.containsKey(source)) source = null; // to get player instead of fake card
|
||||
|
||||
FSkin.Colors brdrColor = VAssignDamage.this.canAssignTo(source) ? FSkin.Colors.CLR_ACTIVE : FSkin.Colors.CLR_INACTIVE;
|
||||
final FSkin.Colors brdrColor = VAssignDamage.this.canAssignTo(source) ? FSkin.Colors.CLR_ACTIVE : FSkin.Colors.CLR_INACTIVE;
|
||||
((CardPanel) evt.getSource()).setBorder(new FSkin.LineSkinBorder(FSkin.getColor(brdrColor), 2));
|
||||
}
|
||||
|
||||
@@ -120,7 +125,7 @@ public class VAssignDamage {
|
||||
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent evt) {
|
||||
Card source = ((CardPanel) evt.getSource()).getCard(); // will be NULL for player
|
||||
CardView source = ((CardPanel) evt.getSource()).getCard(); // will be NULL for player
|
||||
|
||||
boolean meta = evt.isControlDown();
|
||||
boolean isLMB = SwingUtilities.isLeftMouseButton(evt);
|
||||
@@ -133,22 +138,22 @@ public class VAssignDamage {
|
||||
|
||||
/** Constructor.
|
||||
*
|
||||
* @param attacker0 {@link forge.game.card.Card}
|
||||
* @param defenderCards List<{@link forge.game.card.Card}>
|
||||
* @param attacker {@link forge.game.card.Card}
|
||||
* @param blockers List<{@link forge.game.card.Card}>
|
||||
* @param damage0 int
|
||||
* @param defender GameEntity that's bein attacked
|
||||
* @param overrideOrder override combatant order
|
||||
|
||||
*/
|
||||
public VAssignDamage(final Card attacker0, final List<Card> defenderCards, final int damage0, final GameEntity defender, boolean overrideOrder) {
|
||||
dlg.setTitle("Assign damage dealt by " + attacker0.getName());
|
||||
public VAssignDamage(final CardView attacker, final List<CardView> blockers, final int damage0, final GameEntityView defender, boolean overrideOrder) {
|
||||
dlg.setTitle("Assign damage dealt by " + attacker);
|
||||
|
||||
// Set damage storage vars
|
||||
this.totalDamageToAssign = damage0;
|
||||
this.defender = defender;
|
||||
this.attackerHasDeathtouch = attacker0.hasKeyword("Deathtouch");
|
||||
this.attackerHasInfect = attacker0.hasKeyword("Infect");
|
||||
this.attackerHasTrample = defender != null && attacker0.hasKeyword("Trample");
|
||||
this.attackerHasDeathtouch = attacker.getOriginal().hasDeathtouch();
|
||||
this.attackerHasInfect = attacker.getOriginal().hasInfect();
|
||||
this.attackerHasTrample = defender != null && attacker.getOriginal().hasTrample();
|
||||
this.overrideCombatantOrder = overrideOrder;
|
||||
|
||||
// Top-level UI stuff
|
||||
@@ -157,7 +162,7 @@ public class VAssignDamage {
|
||||
pnlMain.setBackground(FSkin.getColor(FSkin.Colors.CLR_THEME2));
|
||||
|
||||
// Attacker area
|
||||
final CardPanel pnlAttacker = new CardPanel(attacker0);
|
||||
final CardPanel pnlAttacker = new CardPanel(attacker);
|
||||
pnlAttacker.setOpaque(false);
|
||||
pnlAttacker.setCardBounds(0, 0, 105, 150);
|
||||
|
||||
@@ -170,14 +175,14 @@ public class VAssignDamage {
|
||||
// Defenders area
|
||||
final JPanel pnlDefenders = new JPanel();
|
||||
pnlDefenders.setOpaque(false);
|
||||
int cols = attackerHasTrample ? defenderCards.size() + 1 : defenderCards.size();
|
||||
int cols = attackerHasTrample ? blockers.size() + 1 : blockers.size();
|
||||
final String wrap = "wrap " + Integer.toString(cols);
|
||||
pnlDefenders.setLayout(new MigLayout("insets 0, gap 0, ax center, " + wrap));
|
||||
|
||||
final FScrollPane scrDefenders = new FScrollPane(pnlDefenders, false);
|
||||
|
||||
// Top row of cards...
|
||||
for (final Card c : defenderCards) {
|
||||
for (final CardView c : blockers) {
|
||||
DamageTarget dt = new DamageTarget(c, new FLabel.Builder().text("0").fontSize(18).fontAlign(SwingConstants.CENTER).build());
|
||||
this.damage.put(c, dt);
|
||||
this.defenders.add(dt);
|
||||
@@ -188,19 +193,18 @@ public class VAssignDamage {
|
||||
DamageTarget dt = new DamageTarget(null, new FLabel.Builder().text("0").fontSize(18).fontAlign(SwingConstants.CENTER).build());
|
||||
this.damage.put(null, dt);
|
||||
this.defenders.add(dt);
|
||||
Card fakeCard;
|
||||
if (defender instanceof Card)
|
||||
fakeCard = (Card)defender;
|
||||
else if (defender instanceof Player) {
|
||||
fakeCard = new Card(-1);
|
||||
fakeCard.setName(this.defender.getName());
|
||||
fakeCard.setOwner((Player)defender);
|
||||
Player p = (Player)defender;
|
||||
fakeCard.setImageKey(CMatchUI.SINGLETON_INSTANCE.avatarImages.get(p.getOriginalLobbyPlayer()));
|
||||
} else {
|
||||
fakeCard = new Card(-2);
|
||||
fakeCard.setName(this.defender.getName());
|
||||
CardView fakeCard = null;
|
||||
if (defender instanceof CardView)
|
||||
fakeCard = (CardView)defender;
|
||||
else if (defender instanceof PlayerView) {
|
||||
fakeCard = new CardView(true);
|
||||
fakeCard.getOriginal().setName(this.defender.toString());
|
||||
final PlayerView p = (PlayerView)defender;
|
||||
fakeCard.setOwner(p);
|
||||
fakeCard.setController(p);
|
||||
fakeCard.getOriginal().setImageKey(CMatchUI.SINGLETON_INSTANCE.avatarImages.get(p.getLobbyPlayer()));
|
||||
}
|
||||
|
||||
addPanelForDefender(pnlDefenders, fakeCard);
|
||||
}
|
||||
|
||||
@@ -259,7 +263,7 @@ public class VAssignDamage {
|
||||
* @param pnlDefenders
|
||||
* @param defender
|
||||
*/
|
||||
private void addPanelForDefender(final JPanel pnlDefenders, final Card defender) {
|
||||
private void addPanelForDefender(final JPanel pnlDefenders, final CardView defender) {
|
||||
final CardPanel cp = new CardPanel(defender);
|
||||
cp.setCardBounds(0, 0, 105, 150);
|
||||
cp.setOpaque(true);
|
||||
@@ -273,7 +277,7 @@ public class VAssignDamage {
|
||||
* @param meta
|
||||
* @param isLMB
|
||||
*/
|
||||
private void assignDamageTo(Card source, boolean meta, boolean isAdding) {
|
||||
private void assignDamageTo(CardView source, final boolean meta, final boolean isAdding) {
|
||||
if ( !damage.containsKey(source) )
|
||||
source = null;
|
||||
|
||||
@@ -366,14 +370,14 @@ public class VAssignDamage {
|
||||
dt.damage = 0;
|
||||
}
|
||||
|
||||
private void addDamage(final Card card, int addedDamage) {
|
||||
private void addDamage(final CardView card, int addedDamage) {
|
||||
// If we don't have enough left or we're trying to unassign too much return
|
||||
int canAssign = getRemainingDamage();
|
||||
final int canAssign = getRemainingDamage();
|
||||
if (canAssign < addedDamage) {
|
||||
addedDamage = canAssign;
|
||||
}
|
||||
|
||||
DamageTarget dt = damage.get(card);
|
||||
final DamageTarget dt = damage.get(card);
|
||||
dt.damage = Math.max(0, addedDamage + dt.damage);
|
||||
}
|
||||
|
||||
@@ -433,28 +437,28 @@ public class VAssignDamage {
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @param source
|
||||
* @param card
|
||||
* @return
|
||||
*/
|
||||
private int getDamageToKill(Card source) {
|
||||
private int getDamageToKill(final CardView card) {
|
||||
int lethalDamage = 0;
|
||||
if ( source == null ) {
|
||||
if ( defender instanceof Player ) {
|
||||
Player p = (Player)defender;
|
||||
lethalDamage = attackerHasInfect ? p.getGame().getRules().getPoisonCountersToLose() - p.getPoisonCounters() : p.getLife();
|
||||
} else if ( defender instanceof Card ) { // planeswalker
|
||||
Card pw = (Card)defender;
|
||||
lethalDamage = pw.getCounters(CounterType.LOYALTY);
|
||||
if (card == null) {
|
||||
if (defender instanceof PlayerView) {
|
||||
final PlayerView p = (PlayerView)defender;
|
||||
lethalDamage = attackerHasInfect ? FControl.instance.getGameView().getPoisonCountersToLose() - p.getPoisonCounters() : p.getLife();
|
||||
} else if (defender instanceof CardView) { // planeswalker
|
||||
final CardView pw = (CardView)defender;
|
||||
lethalDamage = pw.getOriginal().getLoyalty();
|
||||
}
|
||||
} else {
|
||||
lethalDamage = VAssignDamage.this.attackerHasDeathtouch ? 1 : Math.max(0, source.getLethalDamage());
|
||||
lethalDamage = VAssignDamage.this.attackerHasDeathtouch ? 1 : Math.max(0, card.getLethalDamage());
|
||||
}
|
||||
return lethalDamage;
|
||||
}
|
||||
|
||||
public Map<Card, Integer> getDamageMap() {
|
||||
Map<Card, Integer> result = new HashMap<Card, Integer>();
|
||||
for(DamageTarget dt : defenders)
|
||||
public Map<CardView, Integer> getDamageMap() {
|
||||
Map<CardView, Integer> result = Maps.newHashMapWithExpectedSize(defenders.size());
|
||||
for (DamageTarget dt : defenders)
|
||||
result.put(dt.card, dt.damage);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -10,14 +10,13 @@ import javax.swing.event.ChangeListener;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.UiCommand;
|
||||
import forge.game.Game;
|
||||
import forge.game.player.Player;
|
||||
import forge.toolbox.FButton;
|
||||
import forge.toolbox.FCheckBox;
|
||||
import forge.toolbox.FList;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.view.FDialog;
|
||||
import forge.view.IGameView;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class VAutoYields extends FDialog {
|
||||
@@ -32,12 +31,12 @@ public class VAutoYields extends FDialog {
|
||||
private final FCheckBox chkDisableAll;
|
||||
private final List<String> autoYields;
|
||||
|
||||
public VAutoYields(final Game game, final Player player) {
|
||||
public VAutoYields(final IGameView game) {
|
||||
super(true);
|
||||
setTitle("Auto-Yields");
|
||||
|
||||
autoYields = new ArrayList<String>();
|
||||
for (String autoYield : player.getController().getAutoYields()) {
|
||||
for (final String autoYield : game.getAutoYields()) {
|
||||
autoYields.add(autoYield);
|
||||
}
|
||||
lstAutoYields = new FList<String>(new AutoYieldsListModel());
|
||||
@@ -72,7 +71,7 @@ public class VAutoYields extends FDialog {
|
||||
if (selected != null) {
|
||||
autoYields.remove(selected);
|
||||
btnRemove.setEnabled(autoYields.size() > 0);
|
||||
player.getController().setShouldAutoYield(selected, false);
|
||||
game.setShouldAutoYield(selected, false);
|
||||
VAutoYields.this.revalidate();
|
||||
lstAutoYields.repaint();
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public enum VMatchUI implements IVTopLevelUI {
|
||||
}
|
||||
}
|
||||
|
||||
if (Singletons.getControl().getObservedGame().getRules().getGameType().isCommandZoneNeeded()) {
|
||||
if (Singletons.getControl().getGameView().isCommandZoneNeeded()) {
|
||||
// Add extra players alternatively to existing user/AI field panels.
|
||||
for (int i = 2; i < lstCommands.size(); i++) {
|
||||
// If already in layout, no need to add again.
|
||||
@@ -102,8 +102,7 @@ public enum VMatchUI implements IVTopLevelUI {
|
||||
lstCommands.get(i % 2).getParentCell().addDoc(cmdView);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
//If game goesn't need command zone, remove it from existing field panels
|
||||
for (int i = 0; i < 2; i++) {
|
||||
VCommand cmdView = lstCommands.get(i);
|
||||
@@ -206,7 +205,7 @@ public enum VMatchUI implements IVTopLevelUI {
|
||||
*/
|
||||
@Override
|
||||
public boolean onClosing(FScreen screen) {
|
||||
if (!Singletons.getControl().getObservedGame().isGameOver()) {
|
||||
if (!Singletons.getControl().getGameView().isGameOver()) {
|
||||
CMatchUI.SINGLETON_INSTANCE.concede();
|
||||
return false; //delay hiding tab even if concede successful
|
||||
}
|
||||
|
||||
@@ -11,13 +11,14 @@ import javax.swing.SwingConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.LobbyPlayer;
|
||||
import forge.UiCommand;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameLog;
|
||||
import forge.game.GameLogEntry;
|
||||
import forge.game.GameLogEntryType;
|
||||
import forge.game.GameOutcome;
|
||||
import forge.game.player.Player;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.interfaces.IWinLoseView;
|
||||
import forge.model.FModel;
|
||||
@@ -29,7 +30,7 @@ import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedLabel;
|
||||
import forge.toolbox.FSkin.SkinnedPanel;
|
||||
import forge.toolbox.FTextArea;
|
||||
|
||||
import forge.view.IGameView;
|
||||
|
||||
public class ViewWinLose implements IWinLoseView<FButton> {
|
||||
private final FButton btnContinue, btnRestart, btnQuit;
|
||||
@@ -39,12 +40,12 @@ public class ViewWinLose implements IWinLoseView<FButton> {
|
||||
private final SkinnedLabel lblStats = new SkinnedLabel("WinLoseFrame > lblStats needs updating.");
|
||||
private final JPanel pnlOutcomes = new JPanel(new MigLayout("wrap, align center"));
|
||||
|
||||
private final Game game;
|
||||
private final IGameView game;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public ViewWinLose(final Game game0) {
|
||||
public ViewWinLose(final IGameView game0) {
|
||||
|
||||
game = game0;
|
||||
this.game = game0;
|
||||
|
||||
final JPanel overlay = FOverlay.SINGLETON_INSTANCE.getPanel();
|
||||
|
||||
@@ -60,7 +61,7 @@ public class ViewWinLose implements IWinLoseView<FButton> {
|
||||
// Control of the win/lose is handled differently for various game
|
||||
// modes.
|
||||
ControlWinLose control = null;
|
||||
switch (game0.getRules().getGameType()) {
|
||||
switch (game0.getGameType()) {
|
||||
case Quest:
|
||||
control = new QuestWinLose(this, game0);
|
||||
break;
|
||||
@@ -68,14 +69,14 @@ public class ViewWinLose implements IWinLoseView<FButton> {
|
||||
control = new QuestDraftWinLose(this, game0);
|
||||
break;
|
||||
case Draft:
|
||||
if (!FModel.getGauntletMini().isGauntletDraft()) {
|
||||
if (!FModel.getGauntletMini(GuiBase.getInterface()).isGauntletDraft()) {
|
||||
break;
|
||||
}
|
||||
case Sealed:
|
||||
control = new LimitedWinLose(this, game0);
|
||||
break;
|
||||
case Gauntlet:
|
||||
control = new GauntletWinLose(this, game0);
|
||||
control = new GauntletWinLose(this, game0, GuiBase.getInterface());
|
||||
break;
|
||||
default: // will catch it after switch
|
||||
break;
|
||||
@@ -103,11 +104,11 @@ public class ViewWinLose implements IWinLoseView<FButton> {
|
||||
btnRestart.setFont(FSkin.getFont(22));
|
||||
btnQuit.setText("Quit Match");
|
||||
btnQuit.setFont(FSkin.getFont(22));
|
||||
btnContinue.setEnabled(!game0.getMatch().isMatchOver());
|
||||
btnContinue.setEnabled(!game0.isMatchOver());
|
||||
|
||||
// Assemble game log scroller.
|
||||
final FTextArea txtLog = new FTextArea();
|
||||
txtLog.setText(game.getGameLog().getLogText(null).replace("[COMPUTER]", "[AI]"));
|
||||
txtLog.setText(StringUtils.join(game.getLogEntries(null), "\r\n").replace("[COMPUTER]", "[AI]"));
|
||||
txtLog.setFont(FSkin.getFont(14));
|
||||
txtLog.setFocusable(true); // allow highlighting and copying of log
|
||||
|
||||
@@ -180,20 +181,20 @@ public class ViewWinLose implements IWinLoseView<FButton> {
|
||||
}
|
||||
});
|
||||
|
||||
lblTitle.setText(composeTitle(game0.getOutcome()));
|
||||
lblTitle.setText(composeTitle(game0));
|
||||
|
||||
showGameOutcomeSummary();
|
||||
showPlayerScores();
|
||||
|
||||
}
|
||||
|
||||
private String composeTitle(GameOutcome outcome) {
|
||||
Player winner = outcome.getWinningPlayer();
|
||||
int winningTeam = outcome.getWinningTeam();
|
||||
private String composeTitle(final IGameView game) {
|
||||
final LobbyPlayer winner = game.getWinningPlayer();
|
||||
final int winningTeam = game.getWinningTeam();
|
||||
if (winner == null) {
|
||||
return "It's a draw!";
|
||||
} else if (winningTeam != -1) {
|
||||
return "Team " + winner.getTeam() + " Won!";
|
||||
return "Team " + winningTeam + " Won!";
|
||||
} else {
|
||||
return winner.getName() + " Won!";
|
||||
}
|
||||
@@ -220,14 +221,12 @@ public class ViewWinLose implements IWinLoseView<FButton> {
|
||||
}
|
||||
|
||||
private void showGameOutcomeSummary() {
|
||||
GameLog log = game.getGameLog();
|
||||
for (GameLogEntry o : log.getLogEntriesExact(GameLogEntryType.GAME_OUTCOME))
|
||||
for (final GameLogEntry o : game.getLogEntriesExact(GameLogEntryType.GAME_OUTCOME))
|
||||
pnlOutcomes.add(new FLabel.Builder().text(o.message).fontSize(14).build(), "h 20!");
|
||||
}
|
||||
|
||||
private void showPlayerScores() {
|
||||
GameLog log = game.getGameLog();
|
||||
for (GameLogEntry o : log.getLogEntriesExact(GameLogEntryType.MATCH_RESULTS)) {
|
||||
for (final GameLogEntry o : game.getLogEntriesExact(GameLogEntryType.MATCH_RESULTS)) {
|
||||
lblStats.setText(removePlayerTypeFromLogMessage(o.message));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package forge.screens.match;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.card.CardCharacteristicName;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardFactory;
|
||||
import forge.game.zone.PlayerZone;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.ForgeAction;
|
||||
import forge.gui.GuiChoose;
|
||||
import forge.match.MatchConstants;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
/**
|
||||
* Receives click and programmatic requests for viewing data stacks in the
|
||||
@@ -20,7 +20,8 @@ import java.util.List;
|
||||
*/
|
||||
public class ZoneAction extends ForgeAction {
|
||||
private static final long serialVersionUID = -5822976087772388839L;
|
||||
private final PlayerZone zone;
|
||||
private final PlayerView player;
|
||||
private final ZoneType zone;
|
||||
private final String title;
|
||||
|
||||
/**
|
||||
@@ -33,9 +34,10 @@ public class ZoneAction extends ForgeAction {
|
||||
* @param property
|
||||
*   String obj
|
||||
*/
|
||||
public ZoneAction(final PlayerZone zone, MatchConstants property) {
|
||||
public ZoneAction(final PlayerView player, final ZoneType zone, final MatchConstants property) {
|
||||
super(property);
|
||||
this.title = property.title;
|
||||
this.player = player;
|
||||
this.zone = zone;
|
||||
}
|
||||
|
||||
@@ -45,37 +47,28 @@ public class ZoneAction extends ForgeAction {
|
||||
*/
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
final List<Card> choices = this.getCardsAsIterable();
|
||||
if (choices.isEmpty()) {
|
||||
final Iterable<CardView> choices = this.getCardsAsIterable();
|
||||
if (!choices.iterator().hasNext()) {
|
||||
GuiChoose.reveal(this.title, "no cards");
|
||||
return;
|
||||
}
|
||||
|
||||
final ArrayList<Card> choices2 = new ArrayList<Card>();
|
||||
for (Card crd : choices) {
|
||||
Card toAdd = crd;
|
||||
if (crd.isFaceDown()) {
|
||||
if (Singletons.getControl().mayShowCard(crd)) {
|
||||
toAdd = CardFactory.copyCard(crd, false);
|
||||
toAdd.setState(CardCharacteristicName.Original);
|
||||
} else {
|
||||
toAdd = new Card(0);
|
||||
toAdd.setName("Face Down");
|
||||
}
|
||||
}
|
||||
final List<CardStateView> choices2 = Lists.newLinkedList();
|
||||
for (final CardView crd : choices) {
|
||||
final CardStateView toAdd = crd.getOriginal();
|
||||
choices2.add(toAdd);
|
||||
}
|
||||
|
||||
final Card choice = GuiChoose.oneOrNone(this.title, choices2);
|
||||
final CardStateView choice = GuiChoose.oneOrNone(this.title, choices2);
|
||||
if (choice != null) {
|
||||
this.doAction(choice);
|
||||
this.doAction(choice.getCard());
|
||||
}
|
||||
}
|
||||
|
||||
protected List<Card> getCardsAsIterable() {
|
||||
return this.zone.getCards();
|
||||
protected Iterable<CardView> getCardsAsIterable() {
|
||||
return player.getCards(zone);
|
||||
}
|
||||
|
||||
protected void doAction(final Card c) {
|
||||
protected void doAction(final CardView c) {
|
||||
}
|
||||
} // End ZoneAction
|
||||
@@ -1,16 +1,18 @@
|
||||
package forge.screens.match.controllers;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.UiCommand;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.combat.AttackingBand;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.player.Player;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.screens.match.views.VCombat;
|
||||
import forge.util.Lang;
|
||||
|
||||
import java.util.List;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
import forge.view.CombatView;
|
||||
import forge.view.GameEntityView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
/**
|
||||
* Controls the combat panel in the match UI.
|
||||
@@ -22,7 +24,7 @@ public enum CCombat implements ICDoc {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
private Combat combat;
|
||||
private CombatView combat;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
|
||||
@@ -44,82 +46,92 @@ public enum CCombat implements ICDoc {
|
||||
*/
|
||||
@Override
|
||||
public void update() {
|
||||
Combat localCombat = this.combat; // noone will re-assign this from other thread.
|
||||
final CombatView localCombat = this.combat; // noone will re-assign this from other thread.
|
||||
if (localCombat != null) {
|
||||
VCombat.SINGLETON_INSTANCE.updateCombat(localCombat.getAttackers().size(), getCombatDescription(localCombat));
|
||||
}
|
||||
else {
|
||||
VCombat.SINGLETON_INSTANCE.updateCombat(localCombat.getNumAttackers(), getCombatDescription(localCombat));
|
||||
} else {
|
||||
VCombat.SINGLETON_INSTANCE.updateCombat(0, "");
|
||||
}
|
||||
}
|
||||
|
||||
public void setModel(Combat combat) {
|
||||
public void setModel(final CombatView combat) {
|
||||
this.combat = combat;
|
||||
}
|
||||
|
||||
private static String getCombatDescription(Combat combat) {
|
||||
private static String getCombatDescription(final CombatView localCombat) {
|
||||
final StringBuilder display = new StringBuilder();
|
||||
|
||||
// Not a big fan of the triple nested loop here
|
||||
for (GameEntity defender : combat.getDefenders()) {
|
||||
List<AttackingBand> bands = combat.getAttackingBandsOf(defender);
|
||||
if (bands == null || bands.isEmpty()) {
|
||||
continue;
|
||||
for (final GameEntityView defender : localCombat.getDefenders()) {
|
||||
display.append(getCombatDescription(localCombat, defender));
|
||||
}
|
||||
return display.toString().trim();
|
||||
}
|
||||
|
||||
private static String getCombatDescription(final CombatView localCombat, final GameEntityView defender) {
|
||||
final StringBuilder display = new StringBuilder();
|
||||
|
||||
Iterable<Iterable<CardView>> bands = localCombat.getAttackingBandsOf(defender);
|
||||
if (bands == null || Iterables.isEmpty(bands)) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
|
||||
if (display.length() > 0) {
|
||||
display.append("\n");
|
||||
}
|
||||
|
||||
if (defender instanceof Card) {
|
||||
Player controller = ((Card) defender).getController();
|
||||
if (defender instanceof CardView) {
|
||||
final PlayerView controller = ((CardView) defender).getController();
|
||||
display.append(Lang.getPossesive(controller.getName())).append(" ");
|
||||
}
|
||||
|
||||
display.append(defender.getName()).append(" is attacked by:\n");
|
||||
display.append(defender).append(" is attacked by:\n");
|
||||
|
||||
// Associate Bands, Attackers Blockers
|
||||
boolean previousBand = false;
|
||||
for(AttackingBand band : bands) {
|
||||
if (band.isEmpty())
|
||||
for (final Iterable<CardView> band : bands) {
|
||||
final int bandSize = Iterables.size(band);
|
||||
if (bandSize == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Space out band blocks from non-band blocks
|
||||
if (previousBand) {
|
||||
display.append("\n");
|
||||
}
|
||||
|
||||
Boolean blocked = band.isBlocked();
|
||||
boolean isBand = band.getAttackers().size() > 1;
|
||||
final Iterable<CardView> blockers = localCombat.getBlockers(band);
|
||||
final boolean blocked = (blockers != null);
|
||||
final boolean isBand = bandSize > 1;
|
||||
if (isBand) {
|
||||
// Only print Band data if it's actually a band
|
||||
display.append(" > BAND");
|
||||
|
||||
if( blocked != null )
|
||||
display.append(blocked.booleanValue() ? " (blocked)" : " >>>");
|
||||
|
||||
display.append(blocked ? " (blocked)" : " >>>");
|
||||
display.append("\n");
|
||||
}
|
||||
|
||||
for (final Card c : band.getAttackers()) {
|
||||
for (final CardView attacker : band) {
|
||||
display.append(" > ");
|
||||
display.append(combatantToString(c)).append("\n");
|
||||
display.append(combatantToString(attacker)).append("\n");
|
||||
}
|
||||
|
||||
List<Card> blockers = combat.getBlockers(band);
|
||||
if (!isBand && blockers.isEmpty()) {
|
||||
if (!isBand) {
|
||||
if (blockers != null && Iterables.isEmpty(blockers)) {
|
||||
// if single creature is blocked, but no longer has blockers, tell the user!
|
||||
if (blocked != null)
|
||||
display.append(blocked.booleanValue() ? " (blocked)\n" : " >>>\n");
|
||||
display.append(" (blocked)\n");
|
||||
} else {
|
||||
display.append(" >>>\n");
|
||||
}
|
||||
}
|
||||
|
||||
for (final Card element : blockers) {
|
||||
display.append(" < ").append(combatantToString(element)).append("\n");
|
||||
if (blockers != null) {
|
||||
for (final CardView blocker : blockers) {
|
||||
display.append(" < ")
|
||||
.append(combatantToString(blocker))
|
||||
.append("\n");
|
||||
}
|
||||
}
|
||||
previousBand = isBand;
|
||||
}
|
||||
}
|
||||
return display.toString().trim();
|
||||
|
||||
return display.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,15 +143,15 @@ public enum CCombat implements ICDoc {
|
||||
* a {@link forge.game.card.Card} object.
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
private static String combatantToString(final Card c) {
|
||||
private static String combatantToString(final CardView c) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
final CardStateView state = c.getOriginal();
|
||||
|
||||
final String name = (c.isFaceDown()) ? "Morph" : c.getName();
|
||||
final String name = state.getName();
|
||||
|
||||
sb.append("( ").append(c.getNetAttack()).append(" / ").append(c.getNetDefense()).append(" ) ... ");
|
||||
sb.append("( ").append(state.getPower()).append(" / ").append(state.getToughness()).append(" ) ... ");
|
||||
sb.append(name);
|
||||
sb.append(" [").append(c.getUniqueNumber()).append("] ");
|
||||
|
||||
sb.append(" [").append(c.getId()).append("] ");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -18,24 +18,25 @@
|
||||
package forge.screens.match.controllers;
|
||||
|
||||
import forge.UiCommand;
|
||||
import forge.game.player.Player;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.screens.match.views.VCommand;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
/**
|
||||
* Controls Swing components of a player's command instance.
|
||||
*/
|
||||
public class CCommand implements ICDoc {
|
||||
private final Player player;
|
||||
private final PlayerView player;
|
||||
private final VCommand view;
|
||||
|
||||
/**
|
||||
* Controls Swing components of a player's command instance.
|
||||
*
|
||||
* @param p0   {@link forge.game.player.Player}
|
||||
* @param player2   {@link forge.game.player.Player}
|
||||
* @param v0   {@link forge.screens.match.views.VCommand}
|
||||
*/
|
||||
public CCommand(final Player p0, final VCommand v0) {
|
||||
this.player = p0;
|
||||
public CCommand(final PlayerView player2, final VCommand v0) {
|
||||
this.player = player2;
|
||||
this.view = v0;
|
||||
}
|
||||
|
||||
@@ -48,7 +49,7 @@ public class CCommand implements ICDoc {
|
||||
}
|
||||
|
||||
/** @return {@link forge.game.player.Player} */
|
||||
public Player getPlayer() {
|
||||
public PlayerView getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,18 +17,17 @@
|
||||
*/
|
||||
package forge.screens.match.controllers;
|
||||
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import forge.UiCommand;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardDetailUtil;
|
||||
import forge.game.card.Card;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.InventoryItem;
|
||||
import forge.item.InventoryItemFromSet;
|
||||
import forge.screens.match.views.VDetail;
|
||||
import forge.toolbox.FMouseAdapter;
|
||||
|
||||
import java.awt.event.MouseEvent;
|
||||
import forge.view.CardView;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* Controls the card detail area in the match UI.
|
||||
@@ -43,30 +42,29 @@ public enum CDetail implements ICDoc {
|
||||
/**
|
||||
* Shows card details and/or picture in sidebar cardview tabber.
|
||||
*
|
||||
* @param c   Card object
|
||||
* @param c   {@link CardView} object
|
||||
*/
|
||||
public void showCard(Card c) {
|
||||
if (c != null) {
|
||||
c = c.getCardForUi();
|
||||
public void showCard(final CardView c) {
|
||||
this.showCard(c, false);
|
||||
}
|
||||
view.getLblFlipcard().setVisible(c != null && CardDetailUtil.isCardFlippable(c) && Singletons.getControl().mayShowCard(c));
|
||||
view.getPnlDetail().setCard(c);
|
||||
|
||||
public void showCard(final CardView c, final boolean isInAltState) {
|
||||
view.getLblFlipcard().setVisible(c != null && c.hasAltState());
|
||||
view.getPnlDetail().setCard(c, isInAltState);
|
||||
if (view.getParentCell() != null) {
|
||||
view.getParentCell().repaintSelf();
|
||||
}
|
||||
}
|
||||
|
||||
public void showCard(InventoryItem item) {
|
||||
public void showCard(final InventoryItem item) {
|
||||
if (item instanceof IPaperCard) {
|
||||
showCard(Card.getCardForUi((IPaperCard)item));
|
||||
}
|
||||
else if (item instanceof InventoryItemFromSet) {
|
||||
showCard(ViewUtil.getCardForUi((IPaperCard)item));
|
||||
} else if (item instanceof InventoryItemFromSet) {
|
||||
view.getLblFlipcard().setVisible(false);
|
||||
view.getPnlDetail().setItem((InventoryItemFromSet)item);
|
||||
view.getParentCell().repaintSelf();
|
||||
}
|
||||
else {
|
||||
showCard((Card)null);
|
||||
} else {
|
||||
showCard((CardView)null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
package forge.screens.match.controllers;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.UiCommand;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.game.player.Player;
|
||||
import forge.UiCommand;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.screens.match.views.VDev;
|
||||
import forge.util.GuiDisplayUtil;
|
||||
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
|
||||
/**
|
||||
* Controls the combat panel in the match UI.
|
||||
@@ -44,13 +41,8 @@ public enum CDev implements ICDoc {
|
||||
VDev.SINGLETON_INSTANCE.getLblUnlimitedLands().toggleEnabled();
|
||||
boolean newValue = VDev.SINGLETON_INSTANCE.getLblUnlimitedLands().getEnabled();
|
||||
FModel.getPreferences().setPref(FPref.DEV_UNLIMITED_LAND, String.valueOf(newValue));
|
||||
|
||||
for(Player p : Singletons.getControl().getObservedGame().getPlayers()) {
|
||||
if( p.getLobbyPlayer() == GuiBase.getInterface().getGuiPlayer() )
|
||||
p.canCheatPlayUnlimitedLands = newValue;
|
||||
}
|
||||
Singletons.getControl().getGameView().devTogglePlayManyLands(newValue);
|
||||
// probably will need to call a synchronized method to have the game thread see changed value of the variable
|
||||
|
||||
FModel.getPreferences().save();
|
||||
}
|
||||
|
||||
@@ -59,7 +51,7 @@ public enum CDev implements ICDoc {
|
||||
generateMana(); }
|
||||
};
|
||||
public void generateMana() {
|
||||
GuiDisplayUtil.devModeGenerateMana();
|
||||
Singletons.getControl().getGameView().devGenerateMana();
|
||||
}
|
||||
|
||||
private final MouseListener madSetup = new MouseAdapter() { @Override
|
||||
@@ -67,7 +59,7 @@ public enum CDev implements ICDoc {
|
||||
setupGameState(); }
|
||||
};
|
||||
public void setupGameState() {
|
||||
GuiDisplayUtil.devSetupGameState();
|
||||
Singletons.getControl().getGameView().devSetupGameState();
|
||||
}
|
||||
|
||||
private final MouseListener madTutor = new MouseAdapter() { @Override
|
||||
@@ -75,7 +67,7 @@ public enum CDev implements ICDoc {
|
||||
tutorForCard(); }
|
||||
};
|
||||
public void tutorForCard() {
|
||||
GuiDisplayUtil.devModeTutor();
|
||||
Singletons.getControl().getGameView().devTutorForCard();
|
||||
}
|
||||
|
||||
private final MouseListener madCardToHand = new MouseAdapter() { @Override
|
||||
@@ -83,7 +75,7 @@ public enum CDev implements ICDoc {
|
||||
addCardToHand(); }
|
||||
};
|
||||
public void addCardToHand() {
|
||||
GuiDisplayUtil.devModeCardToHand();
|
||||
Singletons.getControl().getGameView().devAddCardToHand();
|
||||
}
|
||||
|
||||
private final MouseListener madCounter = new MouseAdapter() { @Override
|
||||
@@ -91,7 +83,7 @@ public enum CDev implements ICDoc {
|
||||
addCounterToPermanent(); }
|
||||
};
|
||||
public void addCounterToPermanent() {
|
||||
GuiDisplayUtil.devModeAddCounter();
|
||||
Singletons.getControl().getGameView().devAddCounterToPermanent();
|
||||
}
|
||||
|
||||
private final MouseListener madTap = new MouseAdapter() { @Override
|
||||
@@ -99,7 +91,7 @@ public enum CDev implements ICDoc {
|
||||
tapPermanent(); }
|
||||
};
|
||||
public void tapPermanent() {
|
||||
GuiDisplayUtil.devModeTapPerm();
|
||||
Singletons.getControl().getGameView().devTapPermanent();
|
||||
}
|
||||
|
||||
private final MouseListener madUntap = new MouseAdapter() { @Override
|
||||
@@ -107,7 +99,7 @@ public enum CDev implements ICDoc {
|
||||
untapPermanent(); }
|
||||
};
|
||||
public void untapPermanent() {
|
||||
GuiDisplayUtil.devModeUntapPerm();
|
||||
Singletons.getControl().getGameView().devUntapPermanent();
|
||||
}
|
||||
|
||||
private final MouseListener madLife = new MouseAdapter() { @Override
|
||||
@@ -115,7 +107,7 @@ public enum CDev implements ICDoc {
|
||||
setPlayerLife(); }
|
||||
};
|
||||
public void setPlayerLife() {
|
||||
GuiDisplayUtil.devModeSetLife();
|
||||
Singletons.getControl().getGameView().devSetPlayerLife();
|
||||
}
|
||||
|
||||
private final MouseListener madWinGame = new MouseAdapter() { @Override
|
||||
@@ -123,15 +115,15 @@ public enum CDev implements ICDoc {
|
||||
winGame(); }
|
||||
};
|
||||
public void winGame() {
|
||||
GuiDisplayUtil.devModeWinGame();
|
||||
Singletons.getControl().getGameView().devWinGame();
|
||||
}
|
||||
|
||||
private final MouseListener madCardToBattlefield = new MouseAdapter() { @Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
addCardToPlay(); }
|
||||
addCardToBattlefield(); }
|
||||
};
|
||||
public void addCardToPlay() {
|
||||
GuiDisplayUtil.devModeCardToBattlefield();
|
||||
public void addCardToBattlefield() {
|
||||
Singletons.getControl().getGameView().devAddCardToBattlefield();
|
||||
}
|
||||
|
||||
private final MouseListener madRiggedRoll = new MouseAdapter() { @Override
|
||||
@@ -139,7 +131,7 @@ public enum CDev implements ICDoc {
|
||||
riggedPlanerRoll(); }
|
||||
};
|
||||
public void riggedPlanerRoll() {
|
||||
GuiDisplayUtil.devModeRiggedPlanarRoll();
|
||||
Singletons.getControl().getGameView().devRiggedPlanerRoll();
|
||||
}
|
||||
|
||||
private final MouseListener madWalkToPlane = new MouseAdapter() { @Override
|
||||
@@ -147,7 +139,7 @@ public enum CDev implements ICDoc {
|
||||
planeswalkTo(); }
|
||||
};
|
||||
public void planeswalkTo() {
|
||||
GuiDisplayUtil.devModePlaneswalkTo();
|
||||
Singletons.getControl().getGameView().devPlaneswalkTo();
|
||||
}
|
||||
|
||||
//========== End mouse listener inits
|
||||
|
||||
@@ -17,28 +17,20 @@
|
||||
*/
|
||||
package forge.screens.match.controllers;
|
||||
|
||||
import forge.LobbyPlayer;
|
||||
import forge.UiCommand;
|
||||
import java.io.File;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.Singletons;
|
||||
import forge.UiCommand;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.control.FControl;
|
||||
import forge.deck.Deck;
|
||||
import forge.deckchooser.FDeckViewer;
|
||||
import forge.game.Game;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardPredicates.Presets;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.combat.CombatUtil;
|
||||
import forge.game.phase.PhaseHandler;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.RegisteredPlayer;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.gui.framework.SLayoutIO;
|
||||
import forge.model.FModel;
|
||||
import forge.player.GamePlayerUtil;
|
||||
import forge.properties.FileLocation;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.screens.match.CMatchUI;
|
||||
@@ -47,9 +39,7 @@ import forge.toolbox.FSkin;
|
||||
import forge.toolbox.SaveOpenDialog;
|
||||
import forge.toolbox.SaveOpenDialog.Filetypes;
|
||||
import forge.view.FView;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import forge.view.IGameView;
|
||||
|
||||
/**
|
||||
* Controls the dock panel in the match UI.
|
||||
@@ -61,32 +51,24 @@ public enum CDock implements ICDoc {
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
private int arcState;
|
||||
private Game game;
|
||||
private IGameView game;
|
||||
|
||||
public void setModel(Game game0, LobbyPlayer player0) {
|
||||
public void setModel(final IGameView game0) {
|
||||
game = game0;
|
||||
}
|
||||
|
||||
public Player findAffectedPlayer() {
|
||||
return Singletons.getControl().getCurrentPlayer();
|
||||
}
|
||||
|
||||
/**
|
||||
* End turn.
|
||||
*/
|
||||
public void endTurn() {
|
||||
Player p = findAffectedPlayer();
|
||||
|
||||
if (p != null) {
|
||||
CPrompt.SINGLETON_INSTANCE.getInputControl().passPriority(p, PhaseType.CLEANUP);
|
||||
}
|
||||
CPrompt.SINGLETON_INSTANCE.passPriorityUntilEndOfTurn();
|
||||
}
|
||||
|
||||
public void revertLayout() {
|
||||
SOverlayUtils.genericOverlay();
|
||||
FView.SINGLETON_INSTANCE.getPnlContent().removeAll();
|
||||
|
||||
FThreads.invokeInEdtLater(new Runnable(){
|
||||
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable(){
|
||||
@Override public void run() {
|
||||
SLayoutIO.loadLayout(null);
|
||||
SOverlayUtils.hideOverlay();
|
||||
@@ -116,7 +98,7 @@ public enum CDock implements ICDoc {
|
||||
FView.SINGLETON_INSTANCE.getPnlContent().removeAll();
|
||||
// let it redraw everything first
|
||||
|
||||
FThreads.invokeInEdtLater(new Runnable() {
|
||||
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (loadFile != null) {
|
||||
@@ -133,9 +115,9 @@ public enum CDock implements ICDoc {
|
||||
* View deck list.
|
||||
*/
|
||||
public void viewDeckList() {
|
||||
RegisteredPlayer player = GamePlayerUtil.getGuiRegisteredPlayer(game);
|
||||
if (player != null) {
|
||||
FDeckViewer.show(player.getDeck());
|
||||
final Deck deck = FControl.instance.getGameView().getDeck(GuiBase.getInterface().getGuiPlayer());
|
||||
if (deck != null) {
|
||||
FDeckViewer.show(deck);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,12 +157,11 @@ public enum CDock implements ICDoc {
|
||||
|
||||
/** Attack with everyone. */
|
||||
public void alphaStrike() {
|
||||
final PhaseHandler ph = game.getPhaseHandler();
|
||||
|
||||
final Player p = findAffectedPlayer();
|
||||
final Game game = p.getGame();
|
||||
Combat combat = game.getCombat();
|
||||
if (ph.is(PhaseType.COMBAT_DECLARE_ATTACKERS, p) && combat!= null) { // ph.is(...) includes null check
|
||||
game.alphaStrike();
|
||||
/* TODO: rewrite this!
|
||||
final Player p = this.findAffectedPlayer();
|
||||
final Combat combat = FControl.instance.getObservedGame().getCombat();
|
||||
if (this.game.isCombatDeclareAttackers()) {
|
||||
List<Player> defenders = p.getOpponents();
|
||||
|
||||
for (Card c : CardLists.filter(p.getCardsIn(ZoneType.Battlefield), Presets.CREATURES)) {
|
||||
@@ -198,6 +179,7 @@ public enum CDock implements ICDoc {
|
||||
// TODO Is this redrawing immediately?
|
||||
FView.SINGLETON_INSTANCE.getFrame().repaint();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/** Toggle targeting overlay painting. */
|
||||
|
||||
@@ -17,35 +17,30 @@
|
||||
*/
|
||||
package forge.screens.match.controllers;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import forge.LobbyPlayer;
|
||||
import forge.UiCommand;
|
||||
import forge.Singletons;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.match.MatchConstants;
|
||||
import forge.match.input.Input;
|
||||
import forge.match.input.InputPayMana;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.screens.match.ZoneAction;
|
||||
import forge.screens.match.views.VField;
|
||||
import forge.toolbox.MouseTriggerEvent;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import forge.LobbyPlayer;
|
||||
import forge.Singletons;
|
||||
import forge.UiCommand;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.match.MatchConstants;
|
||||
import forge.screens.match.ZoneAction;
|
||||
import forge.screens.match.views.VField;
|
||||
import forge.toolbox.MouseTriggerEvent;
|
||||
import forge.view.CardView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
/**
|
||||
* Controls Swing components of a player's field instance.
|
||||
*/
|
||||
public class CField implements ICDoc {
|
||||
// The one who owns cards on this side of table
|
||||
private final Player player;
|
||||
private final PlayerView player;
|
||||
// Tho one who looks at screen and 'performs actions'
|
||||
private final LobbyPlayer viewer;
|
||||
private final VField view;
|
||||
@@ -54,81 +49,47 @@ public class CField implements ICDoc {
|
||||
private final MouseListener madAvatar = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(final MouseEvent e) {
|
||||
CPrompt.SINGLETON_INSTANCE.getInputControl().selectPlayer(player, new MouseTriggerEvent(e));
|
||||
CPrompt.SINGLETON_INSTANCE.selectPlayer(player, new MouseTriggerEvent(e));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Controls Swing components of a player's field instance.
|
||||
*
|
||||
* @param p0   {@link forge.game.player.Player}
|
||||
* @param player0   {@link forge.game.player.Player}
|
||||
* @param v0   {@link forge.screens.match.views.VField}
|
||||
* @param playerViewer
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public CField(final Player p0, final VField v0, LobbyPlayer playerViewer) {
|
||||
this.player = p0;
|
||||
public CField(final PlayerView player0, final VField v0, LobbyPlayer playerViewer) {
|
||||
this.player = player0;
|
||||
this.viewer = playerViewer;
|
||||
this.view = v0;
|
||||
|
||||
ZoneAction handAction = new ZoneAction(player.getZone(ZoneType.Hand), MatchConstants.HUMANHAND) {
|
||||
final ZoneAction handAction = new ZoneAction(player, ZoneType.Hand, MatchConstants.HUMANHAND);
|
||||
final ZoneAction libraryAction = new ZoneAction(player, ZoneType.Library, MatchConstants.HUMANLIBRARY);
|
||||
final ZoneAction exileAction = new ZoneAction(player, ZoneType.Exile, MatchConstants.HUMANEXILED);
|
||||
final ZoneAction graveAction = new ZoneAction(player, ZoneType.Graveyard, MatchConstants.HUMANGRAVEYARD);
|
||||
@SuppressWarnings("serial")
|
||||
final ZoneAction flashBackAction = new ZoneAction(player, null, MatchConstants.HUMANFLASHBACK) {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if ( player.getLobbyPlayer() == viewer || ForgePreferences.DEV_MODE || player.hasKeyword("Play with your hand revealed."))
|
||||
super.actionPerformed(e);
|
||||
}
|
||||
};
|
||||
|
||||
ZoneAction libraryAction = new ZoneAction(player.getZone(ZoneType.Library), MatchConstants.HUMANLIBRARY) {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (ForgePreferences.DEV_MODE)
|
||||
super.actionPerformed(e);
|
||||
}
|
||||
};
|
||||
|
||||
ZoneAction exileAction = new ZoneAction(player.getZone(ZoneType.Exile), MatchConstants.HUMANEXILED);
|
||||
ZoneAction graveAction = new ZoneAction(player.getZone(ZoneType.Graveyard), MatchConstants.HUMANGRAVEYARD);
|
||||
ZoneAction flashBackAction = new ZoneAction(player.getZone(ZoneType.Graveyard), MatchConstants.HUMANFLASHBACK) {
|
||||
@Override
|
||||
protected List<Card> getCardsAsIterable() {
|
||||
return player.getCardsActivableInExternalZones(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doAction(final Card c) {
|
||||
protected void doAction(final CardView c) {
|
||||
// activate cards only via your own flashback button
|
||||
if (player.getLobbyPlayer() != CField.this.viewer) {
|
||||
return;
|
||||
}
|
||||
|
||||
CPrompt.SINGLETON_INSTANCE.getInputControl().selectCard(c, null);
|
||||
// Temporarily commenting out the below to route, Flashback cards through the InputProxy
|
||||
/*
|
||||
final Game game = player.getGame();
|
||||
// TODO: "can play" check needed!
|
||||
|
||||
// should I check for who owns these cards? Are there any abilities to be played from opponent's graveyard?
|
||||
final SpellAbility ab = player.getController().getAbilityToPlay(c.getAllPossibleAbilities(player, true));
|
||||
if ( null != ab) {
|
||||
game.getAction().invoke(new Runnable(){
|
||||
@Override public void run() {
|
||||
HumanPlay.playSpellAbility(player, ab);
|
||||
game.getStack().addAllTirggeredAbilitiesToStack();
|
||||
}});
|
||||
CPrompt.SINGLETON_INSTANCE.selectCard(c, null);
|
||||
}
|
||||
*/
|
||||
@Override
|
||||
protected Iterable<CardView> getCardsAsIterable() {
|
||||
return player.getFlashbackCards();
|
||||
}
|
||||
};
|
||||
|
||||
Function<Byte, Void> manaAction = new Function<Byte, Void>() {
|
||||
public Void apply(Byte colorCode) {
|
||||
if (CField.this.player.getLobbyPlayer() == CField.this.viewer) {
|
||||
final Input in = Singletons.getControl().getInputQueue().getInput();
|
||||
if (in instanceof InputPayMana) {
|
||||
// Do something
|
||||
((InputPayMana) in).useManaFromPool(colorCode);
|
||||
}
|
||||
Singletons.getControl().getGameView().useMana(colorCode.byteValue());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -143,11 +104,6 @@ public class CField implements ICDoc {
|
||||
if (initializedAlready) { return; }
|
||||
initializedAlready = true;
|
||||
|
||||
// Observers
|
||||
// CField.this.player.getZone(ZoneType.Hand).addObserver(observerZones);
|
||||
// CField.this.player.getZone(ZoneType.Battlefield).addObserver(observerPlay);
|
||||
// CField.this.player.addObserver(observerDetails);
|
||||
|
||||
// Listeners
|
||||
// Player select
|
||||
this.view.getAvatarArea().addMouseListener(madAvatar);
|
||||
@@ -157,16 +113,6 @@ public class CField implements ICDoc {
|
||||
public void update() {
|
||||
}
|
||||
|
||||
/** @return {@link forge.game.player.Player} */
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/** @return {@link forge.screens.match.views.VField} */
|
||||
public VField getView() {
|
||||
return this.view;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
|
||||
*/
|
||||
|
||||
@@ -17,35 +17,39 @@
|
||||
*/
|
||||
package forge.screens.match.controllers;
|
||||
|
||||
import forge.UiCommand;
|
||||
import forge.FThreads;
|
||||
import forge.Singletons;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.screens.match.views.VField;
|
||||
import forge.screens.match.views.VHand;
|
||||
import forge.view.arcane.CardPanel;
|
||||
import forge.view.arcane.HandArea;
|
||||
import forge.view.arcane.util.Animation;
|
||||
import forge.view.arcane.util.CardPanelMouseAdapter;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Observable;
|
||||
|
||||
import javax.swing.JLayeredPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.Singletons;
|
||||
import forge.UiCommand;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.screens.match.views.VField;
|
||||
import forge.screens.match.views.VHand;
|
||||
import forge.view.CardView;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.arcane.CardPanel;
|
||||
import forge.view.arcane.HandArea;
|
||||
import forge.view.arcane.util.Animation;
|
||||
import forge.view.arcane.util.CardPanelMouseAdapter;
|
||||
|
||||
/**
|
||||
* Controls Swing components of a player's hand instance.
|
||||
*
|
||||
*/
|
||||
public class CHand implements ICDoc {
|
||||
private final Player player;
|
||||
private final PlayerView player;
|
||||
private final VHand view;
|
||||
private boolean initializedAlready = false;
|
||||
|
||||
@@ -55,15 +59,15 @@ public class CHand implements ICDoc {
|
||||
* @param p0   {@link forge.game.player.Player}
|
||||
* @param v0   {@link forge.screens.match.views.VHand}
|
||||
*/
|
||||
public CHand(final Player p0, final VHand v0) {
|
||||
public CHand(final PlayerView p0, final VHand v0) {
|
||||
this.player = p0;
|
||||
this.view = v0;
|
||||
v0.getHandArea().addCardPanelMouseListener(new CardPanelMouseAdapter() {
|
||||
@Override
|
||||
public void mouseDragEnd(CardPanel dragPanel, MouseEvent evt) {
|
||||
//update index of dragged card in hand zone to match new index within hand area
|
||||
int index = CHand.this.view.getHandArea().getCardPanels().indexOf(dragPanel);
|
||||
CHand.this.player.getZone(ZoneType.Hand).reposition(dragPanel.getCard(), index);
|
||||
//int index = CHand.this.view.getHandArea().getCardPanels().indexOf(dragPanel);
|
||||
//CHand.this.player.getZone(ZoneType.Hand).reposition(dragPanel.getCard(), index);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -78,7 +82,7 @@ public class CHand implements ICDoc {
|
||||
}
|
||||
|
||||
public void update(final Observable a, final Object b) {
|
||||
FThreads.invokeInEdtNowOrLater(updateRoutine);
|
||||
FThreads.invokeInEdtNowOrLater(GuiBase.getInterface(), updateRoutine);
|
||||
}
|
||||
|
||||
private final Runnable updateRoutine = new Runnable() {
|
||||
@@ -86,7 +90,7 @@ public class CHand implements ICDoc {
|
||||
};
|
||||
|
||||
public void updateHand() {
|
||||
FThreads.assertExecutedByEdt(true);
|
||||
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
|
||||
|
||||
final HandArea p = view.getHandArea();
|
||||
|
||||
@@ -103,12 +107,16 @@ public class CHand implements ICDoc {
|
||||
}
|
||||
|
||||
//update card panels in hand area
|
||||
final List<Card> cards = player.getZone(ZoneType.Hand).getCards();
|
||||
|
||||
final List<CardView> cards;
|
||||
synchronized (player) {
|
||||
cards = ImmutableList.copyOf(player.getHandCards());
|
||||
}
|
||||
final List<CardPanel> placeholders = new ArrayList<CardPanel>();
|
||||
final List<CardPanel> cardPanels = new ArrayList<CardPanel>();
|
||||
|
||||
for (Card card : cards) {
|
||||
CardPanel cardPanel = p.getCardPanel(card.getUniqueNumber());
|
||||
for (final CardView card : cards) {
|
||||
CardPanel cardPanel = p.getCardPanel(card.getId());
|
||||
if (cardPanel == null) { //create placeholders for new cards
|
||||
cardPanel = new CardPanel(card);
|
||||
cardPanel.setDisplayEnabled(false);
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package forge.screens.match.controllers;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.UiCommand;
|
||||
import forge.FThreads;
|
||||
import forge.game.GameLog;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.screens.match.views.VLog;
|
||||
import forge.view.IGameView;
|
||||
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
@@ -19,7 +20,8 @@ public enum CLog implements ICDoc, Observer {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
private GameLog model;
|
||||
private IGameView model;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
|
||||
*/
|
||||
@@ -45,18 +47,18 @@ public enum CLog implements ICDoc, Observer {
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @param gameLog
|
||||
* @param game0
|
||||
*/
|
||||
public void setModel(GameLog gameLog) {
|
||||
model = gameLog;
|
||||
model.addObserver(this);
|
||||
public void setModel(final IGameView game0) {
|
||||
model = game0;
|
||||
model.addLogObserver(this);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.Observer#update(java.util.Observable, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void update(Observable o, Object arg) {
|
||||
public void update(final Observable o, final Object arg) {
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -65,7 +67,7 @@ public enum CLog implements ICDoc, Observer {
|
||||
*/
|
||||
@Override
|
||||
public void update() {
|
||||
FThreads.invokeInEdtNowOrLater(r);
|
||||
FThreads.invokeInEdtNowOrLater(GuiBase.getInterface(), r);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,11 +17,13 @@
|
||||
*/
|
||||
package forge.screens.match.controllers;
|
||||
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.event.MouseWheelListener;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import forge.UiCommand;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardCharacteristicName;
|
||||
import forge.card.CardDetailUtil;
|
||||
import forge.game.card.Card;
|
||||
import forge.gui.CardPicturePanel;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.item.IPaperCard;
|
||||
@@ -29,13 +31,8 @@ import forge.item.InventoryItem;
|
||||
import forge.screens.match.views.VPicture;
|
||||
import forge.toolbox.FMouseAdapter;
|
||||
import forge.toolbox.special.CardZoomer;
|
||||
import forge.view.FDialog;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.event.MouseWheelListener;
|
||||
import forge.view.CardView;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* Singleton controller for VPicture.
|
||||
@@ -57,31 +54,23 @@ public enum CPicture implements ICDoc {
|
||||
private final JLabel flipIndicator = this.view.getLblFlipcard();
|
||||
private final CardZoomer zoomer = CardZoomer.SINGLETON_INSTANCE;
|
||||
|
||||
private Card currentCard = null;
|
||||
private CardCharacteristicName displayedState = CardCharacteristicName.Original;
|
||||
|
||||
private boolean mayShowCurrentCard() {
|
||||
if (currentCard == null) { return false; }
|
||||
if (FDialog.isModalOpen()) { return true; } //allow showing cards while modal open to account for revealing, picking, and ordering cards
|
||||
return Singletons.getControl().mayShowCard(currentCard);
|
||||
}
|
||||
private CardView currentView = null;
|
||||
private boolean isDisplayAlt = false;
|
||||
|
||||
/**
|
||||
* Shows card details and/or picture in sidebar cardview tabber.
|
||||
*
|
||||
*/
|
||||
public void showCard(Card c, boolean showFlipped) {
|
||||
if (c == null) {
|
||||
public void showCard(final CardView c, boolean showAlt) {
|
||||
if (null == c) {
|
||||
return;
|
||||
}
|
||||
|
||||
c = c.getCardForUi();
|
||||
currentCard = c;
|
||||
displayedState = c.getCurState();
|
||||
boolean isFlippable = isCurrentCardFlippable();
|
||||
flipIndicator.setVisible(isFlippable);
|
||||
picturePanel.setCard(c, mayShowCurrentCard());
|
||||
if (showFlipped && isFlippable) {
|
||||
currentView = c;
|
||||
isDisplayAlt = showAlt;
|
||||
flipIndicator.setVisible(c.hasAltState());
|
||||
picturePanel.setCard(c.getState(showAlt));
|
||||
if (showAlt && c.hasAltState()) {
|
||||
flipCard();
|
||||
}
|
||||
}
|
||||
@@ -92,23 +81,20 @@ public enum CPicture implements ICDoc {
|
||||
*/
|
||||
public void showImage(final InventoryItem item) {
|
||||
if (item instanceof IPaperCard) {
|
||||
IPaperCard paperCard = ((IPaperCard)item);
|
||||
Card c = Card.getCardForUi(paperCard);
|
||||
if (paperCard.isFoil() && c.getFoil() == 0) {
|
||||
final IPaperCard paperCard = ((IPaperCard)item);
|
||||
final CardView c = ViewUtil.getCardForUi(paperCard);
|
||||
if (paperCard.isFoil() && c.getFoilIndex() == 0) {
|
||||
c.setRandomFoil();
|
||||
}
|
||||
showCard(c, false);
|
||||
} else {
|
||||
currentCard = null;
|
||||
currentView = null;
|
||||
isDisplayAlt = false;
|
||||
flipIndicator.setVisible(false);
|
||||
picturePanel.setCard(item);
|
||||
}
|
||||
}
|
||||
|
||||
public Card getCurrentCard() {
|
||||
return currentCard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UiCommand getCommandOnSelect() {
|
||||
return null;
|
||||
@@ -137,7 +123,7 @@ public enum CPicture implements ICDoc {
|
||||
@Override
|
||||
public void onMiddleMouseDown(MouseEvent e) {
|
||||
if (isCardDisplayed()) {
|
||||
CardZoomer.SINGLETON_INSTANCE.doMouseButtonZoom(currentCard, displayedState);
|
||||
CardZoomer.SINGLETON_INSTANCE.doMouseButtonZoom(currentView);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +148,7 @@ public enum CPicture implements ICDoc {
|
||||
public void mouseWheelMoved(MouseWheelEvent arg0) {
|
||||
if (isCardDisplayed()) {
|
||||
if (arg0.getWheelRotation() < 0) {
|
||||
zoomer.doMouseWheelZoom(currentCard, displayedState);
|
||||
zoomer.doMouseWheelZoom(currentView);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -170,7 +156,7 @@ public enum CPicture implements ICDoc {
|
||||
}
|
||||
|
||||
private boolean isCardDisplayed() {
|
||||
return (currentCard != null);
|
||||
return (currentView != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -178,36 +164,11 @@ public enum CPicture implements ICDoc {
|
||||
}
|
||||
|
||||
public void flipCard() {
|
||||
if (isCurrentCardFlippable()) {
|
||||
displayedState = CardDetailUtil.getAlternateState(currentCard, displayedState);
|
||||
picturePanel.setCardImage(displayedState);
|
||||
setCardDetailPanel();
|
||||
if (currentView.hasAltState()) {
|
||||
isDisplayAlt = !isDisplayAlt;
|
||||
picturePanel.setCard(currentView.getState(isDisplayAlt));
|
||||
CDetail.SINGLETON_INSTANCE.showCard(currentView, isDisplayAlt);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays details about the current card state in appropriate GUI panel.
|
||||
* <p>
|
||||
* It does this by temporarily setting the {@code CardCharacteristicName} state
|
||||
* of the card, extracting the details and then setting the card back to its
|
||||
* original state.
|
||||
* <p>
|
||||
* TODO: at the moment setting the state of {@code Card} does not appear to
|
||||
* trigger any significant functionality but potentially this could cause
|
||||
* unforeseen consequences. Recommend that a read-only mechanism is implemented
|
||||
* to get card details for a given {@code CardCharacteristicName} state that does
|
||||
* not require temporarily setting state of {@code Card} instance.
|
||||
*/
|
||||
private void setCardDetailPanel() {
|
||||
CardCharacteristicName temp = currentCard.getCurState();
|
||||
currentCard.setState(displayedState);
|
||||
CDetail.SINGLETON_INSTANCE.showCard(currentCard);
|
||||
currentCard.setState(temp);
|
||||
}
|
||||
|
||||
private boolean isCurrentCardFlippable() {
|
||||
if (!mayShowCurrentCard()) { return false; }
|
||||
|
||||
return CardDetailUtil.isCardFlippable(currentCard);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package forge.screens.match.controllers;
|
||||
|
||||
import forge.UiCommand;
|
||||
import forge.game.Game;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.screens.match.views.VPlayers;
|
||||
import forge.view.IGameView;
|
||||
|
||||
/**
|
||||
* Controls the combat panel in the match UI.
|
||||
@@ -14,7 +14,7 @@ import forge.screens.match.views.VPlayers;
|
||||
public enum CPlayers implements ICDoc {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
private Game game;
|
||||
private IGameView game;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
|
||||
@@ -39,7 +39,7 @@ public enum CPlayers implements ICDoc {
|
||||
VPlayers.SINGLETON_INSTANCE.update(game);
|
||||
}
|
||||
|
||||
public void setModel(Game game) {
|
||||
public void setModel(IGameView game) {
|
||||
this.game = game;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,21 +17,28 @@
|
||||
*/
|
||||
package forge.screens.match.controllers;
|
||||
|
||||
import forge.UiCommand;
|
||||
import java.awt.Component;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameRules;
|
||||
import forge.game.Match;
|
||||
import forge.GuiBase;
|
||||
import forge.Singletons;
|
||||
import forge.UiCommand;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.gui.framework.SDisplayUtil;
|
||||
import forge.match.input.InputProxy;
|
||||
import forge.screens.match.views.VPrompt;
|
||||
import forge.toolbox.FSkin;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import forge.util.ITriggerEvent;
|
||||
import forge.view.CardView;
|
||||
import forge.view.IGameView;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.SpellAbilityView;
|
||||
|
||||
/**
|
||||
* Controls the prompt panel in the match UI.
|
||||
@@ -42,20 +49,19 @@ public enum CPrompt implements ICDoc {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
private InputProxy inputControl = new InputProxy();
|
||||
private Component lastFocusedButton = null;
|
||||
private VPrompt view = VPrompt.SINGLETON_INSTANCE;
|
||||
private final VPrompt view = VPrompt.SINGLETON_INSTANCE;
|
||||
|
||||
private final ActionListener actCancel = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent evt) {
|
||||
inputControl.selectButtonCancel();
|
||||
selectButtonCancel();
|
||||
}
|
||||
};
|
||||
private final ActionListener actOK = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent evt) {
|
||||
inputControl.selectButtonOK();
|
||||
selectButtonOk();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -83,13 +89,32 @@ public enum CPrompt implements ICDoc {
|
||||
_initButton(view.getBtnOK(), actOK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the input control.
|
||||
*
|
||||
* @return GuiInput
|
||||
*/
|
||||
public InputProxy getInputControl() {
|
||||
return this.inputControl;
|
||||
public void selectButtonOk() {
|
||||
Singletons.getControl().getGameView().selectButtonOk();
|
||||
}
|
||||
|
||||
public void selectButtonCancel() {
|
||||
Singletons.getControl().getGameView().selectButtonCancel();
|
||||
}
|
||||
|
||||
public boolean passPriority() {
|
||||
return Singletons.getControl().getGameView().passPriority();
|
||||
}
|
||||
|
||||
public boolean passPriorityUntilEndOfTurn() {
|
||||
return Singletons.getControl().getGameView().passPriorityUntilEndOfTurn();
|
||||
}
|
||||
|
||||
public void selectPlayer(final PlayerView player, final ITriggerEvent triggerEvent) {
|
||||
Singletons.getControl().getGameView().selectPlayer(player, triggerEvent);
|
||||
}
|
||||
|
||||
public void selectCard(final CardView card, final ITriggerEvent triggerEvent) {
|
||||
Singletons.getControl().getGameView().selectCard(card, triggerEvent);
|
||||
}
|
||||
|
||||
public void selectAbility(final SpellAbilityView sa) {
|
||||
Singletons.getControl().getGameView().selectAbility(sa);
|
||||
}
|
||||
|
||||
/** @param s0   {@link java.lang.String} */
|
||||
@@ -113,16 +138,6 @@ public enum CPrompt implements ICDoc {
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.Observer#update(java.util.Observable, java.lang.Object)
|
||||
*/
|
||||
|
||||
public void updateText(Game game) {
|
||||
FThreads.assertExecutedByEdt(true);
|
||||
final Match match = game.getMatch();
|
||||
final GameRules rules = game.getRules();
|
||||
final String text = String.format("T:%d G:%d/%d [%s]", game.getPhaseHandler().getTurn(), match.getPlayedGames().size() + 1, rules.getGamesPerMatch(), rules.getGameType());
|
||||
view.getLblGames().setText(text);
|
||||
view.getLblGames().setToolTipText(String.format("%s: Game #%d of %d, turn %d", rules.getGameType(), match.getPlayedGames().size() + 1, rules.getGamesPerMatch(), game.getPhaseHandler().getTurn()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
// set focus back to button that last had it
|
||||
@@ -130,4 +145,12 @@ public enum CPrompt implements ICDoc {
|
||||
lastFocusedButton.requestFocusInWindow();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateText() {
|
||||
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
|
||||
final IGameView game = Singletons.getControl().getGameView();
|
||||
final String text = String.format("T:%d G:%d/%d [%s]", game.getTurnNumber(), game.getNumPlayedGamesInMatch() + 1, game.getNumGamesInMatch(), game.getGameType());
|
||||
view.getLblGames().setText(text);
|
||||
view.getLblGames().setToolTipText(String.format("%s: Game #%d of %d, turn %d", game.getGameType(), game.getNumPlayedGamesInMatch() + 1, game.getNumGamesInMatch(), game.getTurnNumber()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package forge.screens.match.controllers;
|
||||
|
||||
import forge.UiCommand;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.MagicStack;
|
||||
import forge.gui.framework.EDocID;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.gui.framework.SDisplayUtil;
|
||||
import forge.screens.match.views.VStack;
|
||||
import forge.view.IGameView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
/**
|
||||
* Controls the combat panel in the match UI.
|
||||
@@ -18,8 +18,8 @@ public enum CStack implements ICDoc {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
private MagicStack model;
|
||||
private Player localPlayer;
|
||||
private IGameView model;
|
||||
private PlayerView localPlayer;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
|
||||
@@ -42,8 +42,9 @@ public enum CStack implements ICDoc {
|
||||
VStack.SINGLETON_INSTANCE.updateStack(model, localPlayer);
|
||||
}
|
||||
|
||||
public void setModel(MagicStack model0, Player localPlayer0) {
|
||||
model = model0;
|
||||
localPlayer = localPlayer0;
|
||||
public void setModel(final IGameView game0, final PlayerView localPlayer) {
|
||||
model = game0;
|
||||
this.localPlayer = localPlayer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ public class DevModeMenu implements ActionListener {
|
||||
ADD_CARD_TO_PLAY("Add card to play"),
|
||||
RIGGED_PLANAR_ROLL("Rigged planar roll"),
|
||||
PLANESWALK_TO("Planeswalk to"),
|
||||
// LOSS_BY_MILLING("Loss by Milling"),
|
||||
PLAY_MANY_LANDS("Play many lands per Turn"),
|
||||
SETUP_GAME_STATE("Setup Game State"),
|
||||
ADD_COUNTER("Add Counter to Permanent"),
|
||||
@@ -68,7 +67,6 @@ public class DevModeMenu implements ActionListener {
|
||||
menu.add(getMenuItem(DevMenuItem.RIGGED_PLANAR_ROLL));
|
||||
menu.add(getMenuItem(DevMenuItem.PLANESWALK_TO));
|
||||
menu.addSeparator();
|
||||
// menu.add(getCheckboxMenuItem(DevMenuItem.LOSS_BY_MILLING, prefs.getPrefBoolean(FPref.DEV_MILLING_LOSS)));
|
||||
menu.add(getCheckboxMenuItem(DevMenuItem.PLAY_MANY_LANDS, prefs.getPrefBoolean(FPref.DEV_UNLIMITED_LAND)));
|
||||
menu.add(getMenuItem(DevMenuItem.SETUP_GAME_STATE));
|
||||
menu.add(getMenuItem(DevMenuItem.ADD_COUNTER));
|
||||
@@ -104,10 +102,9 @@ public class DevModeMenu implements ActionListener {
|
||||
case GENERATE_MANA: { controller.generateMana(); break; }
|
||||
case TUTOR_FOR_CARD: { controller.tutorForCard(); break; }
|
||||
case ADD_CARD_TO_HAND: { controller.addCardToHand(); break; }
|
||||
case ADD_CARD_TO_PLAY: { controller.addCardToPlay(); break; }
|
||||
case ADD_CARD_TO_PLAY: { controller.addCardToBattlefield(); break; }
|
||||
case RIGGED_PLANAR_ROLL:{ controller.riggedPlanerRoll(); break; }
|
||||
case PLANESWALK_TO: { controller.planeswalkTo(); break; }
|
||||
// case LOSS_BY_MILLING: { controller.toggleLossByMilling(); break; }
|
||||
case PLAY_MANY_LANDS: { controller.togglePlayManyLandsPerTurn(); break; }
|
||||
case SETUP_GAME_STATE: { controller.setupGameState(); break; }
|
||||
case ADD_COUNTER: { controller.addCounterToPermanent(); break; }
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
package forge.screens.match.menus;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JPopupMenu;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.control.FControl;
|
||||
import forge.match.MatchUtil;
|
||||
import forge.menus.MenuUtil;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences;
|
||||
@@ -11,13 +18,11 @@ import forge.properties.ForgePreferences.FPref;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.screens.match.VAutoYields;
|
||||
import forge.screens.match.controllers.CDock;
|
||||
import forge.toolbox.FSkin.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import forge.toolbox.FSkin.SkinIcon;
|
||||
import forge.toolbox.FSkin.SkinnedCheckBoxMenuItem;
|
||||
import forge.toolbox.FSkin.SkinnedMenu;
|
||||
import forge.toolbox.FSkin.SkinnedMenuItem;
|
||||
import forge.toolbox.FSkin.SkinnedRadioButtonMenuItem;
|
||||
|
||||
/**
|
||||
* Returns a JMenu containing options associated with current game.
|
||||
@@ -80,7 +85,7 @@ public final class GameMenu {
|
||||
return new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
MatchUtil.undoLastAction();
|
||||
Singletons.getControl().getGameView().tryUndoLastAction();
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -198,8 +203,8 @@ public final class GameMenu {
|
||||
return new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
FControl control = Singletons.getControl();
|
||||
VAutoYields autoYields = new VAutoYields(control.getObservedGame(), control.getLocalPlayer());
|
||||
final FControl control = Singletons.getControl();
|
||||
final VAutoYields autoYields = new VAutoYields(control.getGameView());
|
||||
autoYields.showAutoYields();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -17,9 +17,15 @@
|
||||
*/
|
||||
package forge.screens.match.views;
|
||||
|
||||
import forge.game.card.Card;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import java.awt.Dimension;
|
||||
import java.util.List;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.gui.CardPicturePanel;
|
||||
import forge.gui.WrapLayout;
|
||||
import forge.gui.framework.DragCell;
|
||||
@@ -29,13 +35,8 @@ import forge.gui.framework.IVDoc;
|
||||
import forge.screens.match.controllers.CAntes;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import forge.view.CardView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
/**
|
||||
* Assembles Swing components of card ante area.
|
||||
@@ -54,7 +55,7 @@ public enum VAntes implements IVDoc<CAntes> {
|
||||
private final FScrollPane scroller = new FScrollPane(pnl, false);
|
||||
private final SortedSet<AntePanel> allAntes = new TreeSet<AntePanel>();
|
||||
|
||||
private Iterable<Player> players;
|
||||
private Iterable<PlayerView> players;
|
||||
//========== Constructor
|
||||
private VAntes() {
|
||||
pnl.setLayout(new WrapLayout());
|
||||
@@ -72,8 +73,8 @@ public enum VAntes implements IVDoc<CAntes> {
|
||||
parentCell.getBody().add(scroller, "w 100%!, h 100%!");
|
||||
}
|
||||
|
||||
public final void setModel(Iterable<Player> playerz) {
|
||||
players = playerz;
|
||||
public final void setModel(final List<PlayerView> players) {
|
||||
this.players = players;
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -121,8 +122,8 @@ public enum VAntes implements IVDoc<CAntes> {
|
||||
allAntes.clear();
|
||||
pnl.removeAll();
|
||||
|
||||
for(Player p : players) {
|
||||
for(Card c : p.getZone(ZoneType.Ante)) {
|
||||
for (final PlayerView p : players) {
|
||||
for (final CardView c : p.getAnteCards()) {
|
||||
final AntePanel pnlTemp = new AntePanel(c);
|
||||
allAntes.add(pnlTemp);
|
||||
}
|
||||
@@ -136,15 +137,15 @@ public enum VAntes implements IVDoc<CAntes> {
|
||||
//========= Private class handling
|
||||
@SuppressWarnings("serial")
|
||||
private class AntePanel extends JPanel implements Comparable<AntePanel> {
|
||||
private final Card card;
|
||||
private final CardView card;
|
||||
/**
|
||||
*
|
||||
* @param p0   {@link forge.game.player.Player}
|
||||
* @param c0   {@link forge.game.card.Card}
|
||||
* @param c   {@link forge.game.card.Card}
|
||||
*/
|
||||
public AntePanel(final Card c0) {
|
||||
public AntePanel(final CardView c) {
|
||||
super();
|
||||
card = c0;
|
||||
card = c;
|
||||
|
||||
final Dimension d = new Dimension(160, 250);
|
||||
setPreferredSize(d);
|
||||
@@ -157,12 +158,12 @@ public enum VAntes implements IVDoc<CAntes> {
|
||||
.fontAlign(SwingConstants.CENTER).build(), "w 160px, h 20px");
|
||||
CardPicturePanel picPanel = new CardPicturePanel();
|
||||
add(picPanel, "w 160px, h 230px");
|
||||
picPanel.setCard(c0, true);
|
||||
picPanel.setCard(c.getOriginal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(AntePanel o) {
|
||||
return o.card.getUniqueNumber() - card.getUniqueNumber();
|
||||
public int compareTo(final AntePanel o) {
|
||||
return o.card.getId() - card.getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
*/
|
||||
package forge.screens.match.views;
|
||||
|
||||
import forge.game.player.Player;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
@@ -26,10 +28,8 @@ import forge.gui.framework.IVDoc;
|
||||
import forge.screens.match.controllers.CCommand;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.arcane.PlayArea;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* Assembles Swing components of a player command instance.
|
||||
@@ -44,7 +44,7 @@ public class VCommand implements IVDoc<CCommand> {
|
||||
private final DragTab tab = new DragTab("Command");
|
||||
|
||||
// Other fields
|
||||
private Player player = null;
|
||||
private PlayerView player = null;
|
||||
|
||||
// Top-level containers
|
||||
private final FScrollPane scroller = new FScrollPane(false);
|
||||
@@ -54,20 +54,20 @@ public class VCommand implements IVDoc<CCommand> {
|
||||
/**
|
||||
* Assembles Swing components of a player command instance.
|
||||
*
|
||||
* @param player0   {@link forge.game.player.Player}
|
||||
* @param p   {@link forge.game.player.Player}
|
||||
* @param id0   {@link forge.gui.framework.EDocID}
|
||||
*/
|
||||
public VCommand(final EDocID id0, final Player player0) {
|
||||
public VCommand(final EDocID id0, final PlayerView p) {
|
||||
this.docID = id0;
|
||||
id0.setDoc(this);
|
||||
|
||||
this.player = player0;
|
||||
if (player0 != null) { tab.setText(player0.getName() + " Command"); }
|
||||
this.player = p;
|
||||
if (p != null) { tab.setText(p.getName() + " Command"); }
|
||||
else { tab.setText("NO PLAYER FOR " + docID.toString()); }
|
||||
|
||||
// TODO player is hard-coded into tabletop...should be dynamic
|
||||
// (haven't looked into it too deeply). Doublestrike 12-04-12
|
||||
tabletop = new PlayArea(scroller, id0 == EDocID.COMMAND_0, player.getZone(ZoneType.Command).getCards(false));
|
||||
tabletop = new PlayArea(scroller, id0 == EDocID.COMMAND_0, player, ZoneType.Command);
|
||||
|
||||
control = new CCommand(player, this);
|
||||
|
||||
@@ -135,7 +135,7 @@ public class VCommand implements IVDoc<CCommand> {
|
||||
* Gets the player currently associated with this command.
|
||||
* @return {@link forge.game.player.Player}
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
public PlayerView getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public enum VDetail implements IVDoc<CDetail> {
|
||||
private final DragTab tab = new DragTab("Card Detail");
|
||||
|
||||
// Top-level containers
|
||||
private final CardDetailPanel pnlDetail = new CardDetailPanel(null);
|
||||
private final CardDetailPanel pnlDetail = new CardDetailPanel();
|
||||
private final SkinnedLabel lblFlipcard = new SkinnedLabel();
|
||||
|
||||
//========= Constructor
|
||||
|
||||
@@ -17,8 +17,18 @@
|
||||
*/
|
||||
package forge.screens.match.views;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.LineBorder;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.LobbyPlayer;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
@@ -32,16 +42,8 @@ import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedPanel;
|
||||
import forge.toolbox.special.PhaseIndicator;
|
||||
import forge.toolbox.special.PlayerDetailsPanel;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.arcane.PlayArea;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.LineBorder;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
/**
|
||||
* Assembles Swing components of a player field instance.
|
||||
@@ -56,7 +58,7 @@ public class VField implements IVDoc<CField> {
|
||||
private final DragTab tab = new DragTab("Field");
|
||||
|
||||
// Other fields
|
||||
private Player player = null;
|
||||
private PlayerView player = null;
|
||||
|
||||
// Top-level containers
|
||||
private final FScrollPane scroller = new FScrollPane(false);
|
||||
@@ -79,22 +81,22 @@ public class VField implements IVDoc<CField> {
|
||||
/**
|
||||
* Assembles Swing components of a player field instance.
|
||||
*
|
||||
* @param playerOnwer   {@link forge.game.player.Player}
|
||||
* @param p   {@link forge.game.player.Player}
|
||||
* @param id0   {@link forge.gui.framework.EDocID}
|
||||
*/
|
||||
public VField(final EDocID id0, final Player playerOnwer, LobbyPlayer playerViewer) {
|
||||
public VField(final EDocID id0, final PlayerView p, final LobbyPlayer playerViewer) {
|
||||
this.docID = id0;
|
||||
id0.setDoc(this);
|
||||
|
||||
this.player = playerOnwer;
|
||||
if (playerOnwer != null) { tab.setText(playerOnwer.getName() + " Field"); }
|
||||
this.player = p;
|
||||
if (p != null) { tab.setText(p.getName() + " Field"); }
|
||||
else { tab.setText("NO PLAYER FOR " + docID.toString()); }
|
||||
|
||||
detailsPanel = new PlayerDetailsPanel(player);
|
||||
|
||||
// TODO player is hard-coded into tabletop...should be dynamic
|
||||
// (haven't looked into it too deeply). Doublestrike 12-04-12
|
||||
tabletop = new PlayArea(scroller, id0 == EDocID.FIELD_1, player.getZone(ZoneType.Battlefield).getCards(false));
|
||||
tabletop = new PlayArea(scroller, id0 == EDocID.FIELD_1, player, ZoneType.Battlefield);
|
||||
|
||||
control = new CField(player, this, playerViewer);
|
||||
|
||||
@@ -195,7 +197,7 @@ public class VField implements IVDoc<CField> {
|
||||
* Gets the player currently associated with this field.
|
||||
* @return {@link forge.game.player.Player}
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
public PlayerView getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,17 +17,17 @@
|
||||
*/
|
||||
package forge.screens.match.views;
|
||||
|
||||
import forge.game.player.Player;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
import forge.gui.framework.EDocID;
|
||||
import forge.gui.framework.IVDoc;
|
||||
import forge.screens.match.controllers.CHand;
|
||||
import forge.toolbox.FScrollPane;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.arcane.HandArea;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* Assembles Swing components of hand area.
|
||||
@@ -41,7 +41,6 @@ public class VHand implements IVDoc<CHand> {
|
||||
private final EDocID docID;
|
||||
private final DragTab tab = new DragTab("Your Hand");
|
||||
|
||||
|
||||
// Top-level containers
|
||||
private final FScrollPane scroller = new FScrollPane(false);
|
||||
private final HandArea hand = new HandArea(scroller);
|
||||
@@ -51,23 +50,23 @@ public class VHand implements IVDoc<CHand> {
|
||||
* Assembles Swing components of a player hand instance.
|
||||
*
|
||||
* @param id0   {@link forge.gui.framework.EDocID}
|
||||
* @param owner   {@link forge.game.player.Player}
|
||||
* @param p   {@link forge.game.player.Player}
|
||||
*/
|
||||
public VHand(final EDocID id0, final Player owner) {
|
||||
public VHand(final EDocID id0, final PlayerView p) {
|
||||
docID = id0;
|
||||
id0.setDoc(this);
|
||||
|
||||
if (owner == null) {
|
||||
if (p == null) {
|
||||
tab.setText("NO PLAYER Hand");
|
||||
} else {
|
||||
tab.setText(owner.getName() + " Hand");
|
||||
tab.setText(p.getName() + " Hand");
|
||||
}
|
||||
|
||||
scroller.setViewportView(VHand.this.hand);
|
||||
|
||||
hand.setOpaque(false);
|
||||
|
||||
control = new CHand(owner, this);
|
||||
control = new CHand(p, this);
|
||||
}
|
||||
|
||||
//========= Overridden methods
|
||||
|
||||
@@ -17,9 +17,14 @@
|
||||
*/
|
||||
package forge.screens.match.views;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.game.GameLog;
|
||||
import forge.game.GameLogEntry;
|
||||
import forge.game.GameLogEntryType;
|
||||
import forge.gui.framework.DragCell;
|
||||
@@ -32,12 +37,7 @@ import forge.screens.match.GameLogPanel;
|
||||
import forge.screens.match.controllers.CLog;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinFont;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import forge.view.IGameView;
|
||||
|
||||
/**
|
||||
* Assembles Swing components of game log report.
|
||||
@@ -50,10 +50,10 @@ public enum VLog implements IVDoc<CLog> {
|
||||
|
||||
// Keeps a record of log entries currently displayed so we can
|
||||
// easily identify new entries to be added to the game log.
|
||||
private List<GameLogEntry> displayedLogEntries = new ArrayList<GameLogEntry>();
|
||||
private final List<GameLogEntry> displayedLogEntries = Lists.newArrayList();
|
||||
|
||||
// Used to determine when a new game has started.
|
||||
private GameLog gameLogModel = null;
|
||||
private IGameView gameLogModel = null;
|
||||
|
||||
// Fields used with interface IVDoc
|
||||
private DragCell parentCell;
|
||||
@@ -122,12 +122,12 @@ public enum VLog implements IVDoc<CLog> {
|
||||
* <p>
|
||||
* This is an Observer update method.
|
||||
* <p>
|
||||
* @param activeGameLogModel contains list of log entries.
|
||||
* @param model contains list of log entries.
|
||||
*/
|
||||
public void updateConsole(GameLog activeGameLogModel) {
|
||||
public void updateConsole(final IGameView model) {
|
||||
if (isGameLogConsoleVisible()) {
|
||||
resetDisplayIfNewGame(activeGameLogModel);
|
||||
displayNewGameLogEntries(activeGameLogModel);
|
||||
resetDisplayIfNewGame(model);
|
||||
displayNewGameLogEntries(model);
|
||||
// Important : refreshLayout() needs to be called every update.
|
||||
refreshLayout();
|
||||
}
|
||||
@@ -137,11 +137,11 @@ public enum VLog implements IVDoc<CLog> {
|
||||
return parentCell.getSelected().equals(this);
|
||||
}
|
||||
|
||||
private void resetDisplayIfNewGame(GameLog activeGameLogModel) {
|
||||
if (this.gameLogModel != activeGameLogModel) {
|
||||
private void resetDisplayIfNewGame(final IGameView model) {
|
||||
if (this.gameLogModel != model) {
|
||||
gameLog.reset();
|
||||
this.displayedLogEntries.clear();
|
||||
this.gameLogModel = activeGameLogModel;
|
||||
this.gameLogModel = model;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,17 +164,17 @@ public enum VLog implements IVDoc<CLog> {
|
||||
p.add(gameLog, "w 10:100%, h 100%");
|
||||
}
|
||||
|
||||
private void displayNewGameLogEntries(GameLog activeGameLogModel) {
|
||||
List<GameLogEntry> newLogEntries = Lists.reverse(getNewGameLogEntries(activeGameLogModel));
|
||||
private void displayNewGameLogEntries(final IGameView model) {
|
||||
List<GameLogEntry> newLogEntries = Lists.reverse(getNewGameLogEntries(model));
|
||||
if (newLogEntries.size() > 0) {
|
||||
addNewLogEntriesToJPanel(newLogEntries);
|
||||
}
|
||||
}
|
||||
|
||||
private List<GameLogEntry> getNewGameLogEntries(GameLog activeGameLogModel) {
|
||||
private List<GameLogEntry> getNewGameLogEntries(final IGameView model) {
|
||||
String logEntryType = FModel.getPreferences().getPref(FPref.DEV_LOG_ENTRY_TYPE);
|
||||
GameLogEntryType logVerbosityFilter = GameLogEntryType.valueOf(logEntryType);
|
||||
List<GameLogEntry> logEntries = activeGameLogModel.getLogEntries(logVerbosityFilter);
|
||||
List<GameLogEntry> logEntries = model.getLogEntries(logVerbosityFilter);
|
||||
// Set subtraction - remove all log entries from new list which are already displayed.
|
||||
logEntries.removeAll(this.displayedLogEntries);
|
||||
return logEntries;
|
||||
|
||||
@@ -17,12 +17,15 @@
|
||||
*/
|
||||
package forge.screens.match.views;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.GameType;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardFactoryUtil;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
import forge.gui.framework.EDocID;
|
||||
@@ -33,14 +36,9 @@ import forge.screens.match.controllers.CPlayers;
|
||||
import forge.toolbox.FScrollPanel;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedLabel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import forge.view.CardView;
|
||||
import forge.view.IGameView;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
/**
|
||||
* Assembles Swing components of players report.
|
||||
@@ -59,7 +57,7 @@ public enum VPlayers implements IVDoc<CPlayers> {
|
||||
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
|
||||
// Other fields
|
||||
private Map<Player, JLabel[]> infoLBLs;
|
||||
private Map<PlayerView, JLabel[]> infoLBLs;
|
||||
|
||||
//========= Overridden methods
|
||||
|
||||
@@ -70,7 +68,7 @@ public enum VPlayers implements IVDoc<CPlayers> {
|
||||
public void populate() {
|
||||
scroller.removeAll();
|
||||
final String constraints = "w 97%!, gapleft 2%, gapbottom 1%";
|
||||
for (final Entry<Player, JLabel[]> p : infoLBLs.entrySet()) {
|
||||
for (final Entry<PlayerView, JLabel[]> p : infoLBLs.entrySet()) {
|
||||
for (JLabel label : p.getValue()) {
|
||||
scroller.add(label, constraints);
|
||||
}
|
||||
@@ -79,9 +77,9 @@ public enum VPlayers implements IVDoc<CPlayers> {
|
||||
parentCell.getBody().add(scroller, "w 100%, h 100%!");
|
||||
}
|
||||
|
||||
public void init(final Iterable<Player> players) {
|
||||
public void init(final Iterable<PlayerView> players) {
|
||||
this.infoLBLs = new HashMap<>();
|
||||
for (final Player p : players) {
|
||||
for (final PlayerView p : players) {
|
||||
// Create and store labels detailing various non-critical player info.
|
||||
final InfoLabel name = new InfoLabel();
|
||||
final InfoLabel life = new InfoLabel();
|
||||
@@ -142,19 +140,19 @@ public enum VPlayers implements IVDoc<CPlayers> {
|
||||
//========== Observer update methods
|
||||
|
||||
/** @param game {@link forge.game.player.Player} */
|
||||
public void update(Game game) {
|
||||
public void update(final IGameView game) {
|
||||
// No need to update if this panel isn't showing
|
||||
if (parentCell == null || !this.equals(parentCell.getSelected())) { return; }
|
||||
boolean isCommander = game.getRules().hasAppliedVariant(GameType.Commander);
|
||||
boolean isCommander = game.isCommander();
|
||||
|
||||
for(Entry<Player, JLabel[]> rr : infoLBLs.entrySet()) {
|
||||
Player p0 = rr.getKey();
|
||||
for(final Entry<PlayerView, JLabel[]> rr : infoLBLs.entrySet()) {
|
||||
PlayerView p0 = rr.getKey();
|
||||
final JLabel[] temp = rr.getValue();
|
||||
temp[1].setText("Life: " + String.valueOf(p0.getLife()) + " | Poison counters: "
|
||||
+ String.valueOf(p0.getPoisonCounters()));
|
||||
temp[2].setText("Maximum hand size: " + String.valueOf(p0.getMaxHandSize()));
|
||||
temp[3].setText("Cards drawn this turn: " + String.valueOf(p0.getNumDrawnThisTurn()));
|
||||
temp[4].setText("Damage Prevention: " + String.valueOf(p0.getPreventNextDamageTotalShields()));
|
||||
temp[4].setText("Damage Prevention: " + String.valueOf(p0.getPreventNextDamage()));
|
||||
List<String> keywords = p0.getKeywords();
|
||||
while (keywords.indexOf("CanSeeOpponentsFaceDownCards") != -1) {
|
||||
keywords.remove("CanSeeOpponentsFaceDownCards");
|
||||
@@ -165,8 +163,8 @@ public enum VPlayers implements IVDoc<CPlayers> {
|
||||
temp[5].setText("");
|
||||
}
|
||||
if (FModel.getPreferences().getPrefBoolean(FPref.UI_ANTE)) {
|
||||
List<Card> list = p0.getCardsIn(ZoneType.Ante);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
final List<CardView> list = p0.getAnteCards();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("Ante'd: ");
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
sb.append(list.get(i));
|
||||
@@ -177,7 +175,7 @@ public enum VPlayers implements IVDoc<CPlayers> {
|
||||
temp[6].setText(sb.toString());
|
||||
}
|
||||
if (isCommander) {
|
||||
temp[7].setText(CardFactoryUtil.getCommanderInfo(p0).trim().replace("\r\n", "; "));
|
||||
temp[7].setText(p0.getCommanderInfo());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,21 +17,30 @@
|
||||
*/
|
||||
package forge.screens.match.views;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.ScrollPaneConstants;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.ImageCache;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardDetailUtil;
|
||||
import forge.card.CardDetailUtil.DetailColors;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerController;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.SpellAbilityStackInstance;
|
||||
import forge.game.zone.MagicStack;
|
||||
import forge.gui.framework.DragCell;
|
||||
import forge.gui.framework.DragTab;
|
||||
import forge.gui.framework.EDocID;
|
||||
import forge.gui.framework.IVDoc;
|
||||
import forge.match.input.InputConfirm;
|
||||
import forge.screens.match.CMatchUI;
|
||||
import forge.screens.match.controllers.CPrompt;
|
||||
import forge.screens.match.controllers.CStack;
|
||||
@@ -39,18 +48,11 @@ import forge.toolbox.FMouseAdapter;
|
||||
import forge.toolbox.FScrollPanel;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedTextArea;
|
||||
import forge.view.CardView;
|
||||
import forge.view.IGameView;
|
||||
import forge.view.PlayerView;
|
||||
import forge.view.StackItemView;
|
||||
import forge.view.arcane.CardPanel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
/**
|
||||
* Assembles Swing components of stack report.
|
||||
@@ -129,10 +131,11 @@ public enum VStack implements IVDoc<CStack> {
|
||||
//========== Observer update methods
|
||||
|
||||
/**
|
||||
* @param stack
|
||||
* @param model
|
||||
* @param viewer */
|
||||
public void updateStack(final MagicStack stack, final Player localPlayer) {
|
||||
tab.setText("Stack : " + stack.size());
|
||||
public void updateStack(final IGameView model, final PlayerView localPlayer) {
|
||||
final java.util.List<StackItemView> items = model.getStack();
|
||||
tab.setText("Stack : " + items.size());
|
||||
|
||||
// No need to update the rest unless it's showing
|
||||
if (!parentCell.getSelected().equals(this)) { return; }
|
||||
@@ -140,15 +143,15 @@ public enum VStack implements IVDoc<CStack> {
|
||||
scroller.removeAll();
|
||||
|
||||
boolean isFirst = true;
|
||||
for (final SpellAbilityStackInstance spell : stack) {
|
||||
StackInstanceTextArea tar = new StackInstanceTextArea(stack, spell, localPlayer);
|
||||
for (final StackItemView item : items) {
|
||||
final StackInstanceTextArea tar = new StackInstanceTextArea(model, item, localPlayer);
|
||||
|
||||
scroller.add(tar, "pushx, growx" + (isFirst ? "" : ", gaptop 2px"));
|
||||
|
||||
//update the Card Picture/Detail when the spell is added to the stack
|
||||
if (isFirst) {
|
||||
isFirst = false;
|
||||
CMatchUI.SINGLETON_INSTANCE.setCard(spell.getSourceCard());
|
||||
CMatchUI.SINGLETON_INSTANCE.setCard(item.getSource());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,16 +172,14 @@ public enum VStack implements IVDoc<CStack> {
|
||||
private static final int CARD_WIDTH = 50;
|
||||
private static final int CARD_HEIGHT = Math.round((float)CARD_WIDTH * CardPanel.ASPECT_RATIO);
|
||||
|
||||
private final Card sourceCard;
|
||||
private final CardView sourceCard;
|
||||
|
||||
public StackInstanceTextArea(final MagicStack stack, final SpellAbilityStackInstance spell, final Player localPlayer) {
|
||||
sourceCard = spell.getSourceCard().getCardForUi();
|
||||
public StackInstanceTextArea(final IGameView game, final StackItemView item, final PlayerView localPlayer) {
|
||||
sourceCard = item.getSource();
|
||||
|
||||
final String txt = (item.isOptionalTrigger() && item.getActivatingPlayer().equals(localPlayer)
|
||||
? "(OPTIONAL) " : "") + item.getText();
|
||||
|
||||
String txt = spell.getStackDescription();
|
||||
if (spell.getSpellAbility().isOptionalTrigger()
|
||||
&& spell.getSourceCard().getController().equals(localPlayer)) {
|
||||
txt = "(OPTIONAL) " + txt;
|
||||
}
|
||||
setText(txt);
|
||||
setToolTipText(txt);
|
||||
setOpaque(true);
|
||||
@@ -193,13 +194,13 @@ public enum VStack implements IVDoc<CStack> {
|
||||
addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseEntered(final MouseEvent e) {
|
||||
if (!spell.getStackDescription().startsWith("Morph ")) {
|
||||
CMatchUI.SINGLETON_INSTANCE.setCard(spell.getSpellAbility().getHostCard());
|
||||
if (!txt.startsWith("Morph ")) {
|
||||
CMatchUI.SINGLETON_INSTANCE.setCard(item.getSource());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (spell.getSpellAbility().isAbility() && localPlayer != null) {
|
||||
if (item.isAbility() && localPlayer != null) {
|
||||
addMouseListener(new FMouseAdapter() {
|
||||
@Override
|
||||
public void onLeftClick(MouseEvent e) {
|
||||
@@ -210,13 +211,13 @@ public enum VStack implements IVDoc<CStack> {
|
||||
onClick(e);
|
||||
}
|
||||
private void onClick(MouseEvent e) {
|
||||
abilityMenu.setStackInstance(stack, spell.getSpellAbility(), localPlayer);
|
||||
abilityMenu.setStackInstance(game, item, localPlayer);
|
||||
abilityMenu.show(e.getComponent(), e.getX(), e.getY());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
DetailColors color = CardDetailUtil.getBorderColor(sourceCard, !spell.getStackDescription().startsWith("Morph "));
|
||||
final DetailColors color = CardDetailUtil.getBorderColor(item.getSource().getOriginal());
|
||||
setBackground(new Color(color.r, color.g, color.b));
|
||||
setForeground(FSkin.getHighContrastColor(getBackground()));
|
||||
}
|
||||
@@ -228,7 +229,7 @@ public enum VStack implements IVDoc<CStack> {
|
||||
final Graphics2D g2d = (Graphics2D) g;
|
||||
|
||||
//draw image for source card
|
||||
BufferedImage img = ImageCache.getImage(sourceCard, CARD_WIDTH, CARD_HEIGHT);
|
||||
final BufferedImage img = ImageCache.getImage(sourceCard, CARD_WIDTH, CARD_HEIGHT);
|
||||
if (img != null) {
|
||||
g2d.drawImage(img, null, PADDING, PADDING);
|
||||
}
|
||||
@@ -242,9 +243,8 @@ public enum VStack implements IVDoc<CStack> {
|
||||
private final JCheckBoxMenuItem jmiAutoYield;
|
||||
private final JCheckBoxMenuItem jmiAlwaysYes;
|
||||
private final JCheckBoxMenuItem jmiAlwaysNo;
|
||||
private MagicStack stack;
|
||||
private SpellAbility ability;
|
||||
private PlayerController controller;
|
||||
private IGameView game;
|
||||
private StackItemView item;
|
||||
|
||||
private Integer triggerID = 0;
|
||||
|
||||
@@ -253,12 +253,12 @@ public enum VStack implements IVDoc<CStack> {
|
||||
jmiAutoYield.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
final String key = ability.toUnsuppressedString();
|
||||
final boolean autoYield = controller.shouldAutoYield(key);
|
||||
controller.setShouldAutoYield(key, !autoYield);
|
||||
if (!autoYield && stack.peekAbility() == ability) {
|
||||
final String key = item.getKey();
|
||||
final boolean autoYield = game.shouldAutoYield(key);
|
||||
game.setShouldAutoYield(key, !autoYield);
|
||||
if (!autoYield && game.peekStack() == item) {
|
||||
//auto-pass priority if ability is on top of stack
|
||||
CPrompt.SINGLETON_INSTANCE.getInputControl().passPriority();
|
||||
CPrompt.SINGLETON_INSTANCE.passPriority();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -268,15 +268,14 @@ public enum VStack implements IVDoc<CStack> {
|
||||
jmiAlwaysYes.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
if (controller.shouldAlwaysAcceptTrigger(triggerID)) {
|
||||
controller.setShouldAlwaysAskTrigger(triggerID);
|
||||
if (game.shouldAlwaysAcceptTrigger(triggerID)) {
|
||||
game.setShouldAlwaysAskTrigger(triggerID);
|
||||
}
|
||||
else {
|
||||
controller.setShouldAlwaysAcceptTrigger(triggerID);
|
||||
if (stack.peekAbility() == ability &&
|
||||
Singletons.getControl().getInputQueue().getInput() instanceof InputConfirm) {
|
||||
game.setShouldAlwaysAcceptTrigger(triggerID);
|
||||
if (game.peekStack() == item) {
|
||||
//auto-yes if ability is on top of stack
|
||||
CPrompt.SINGLETON_INSTANCE.getInputControl().selectButtonOK();
|
||||
game.confirm();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -287,15 +286,14 @@ public enum VStack implements IVDoc<CStack> {
|
||||
jmiAlwaysNo.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
if (controller.shouldAlwaysDeclineTrigger(triggerID)) {
|
||||
controller.setShouldAlwaysAskTrigger(triggerID);
|
||||
if (game.shouldAlwaysDeclineTrigger(triggerID)) {
|
||||
game.setShouldAlwaysAskTrigger(triggerID);
|
||||
}
|
||||
else {
|
||||
controller.setShouldAlwaysDeclineTrigger(triggerID);
|
||||
if (stack.peekAbility() == ability &&
|
||||
Singletons.getControl().getInputQueue().getInput() instanceof InputConfirm) {
|
||||
game.setShouldAlwaysDeclineTrigger(triggerID);
|
||||
if (game.peekStack() == item) {
|
||||
//auto-no if ability is on top of stack
|
||||
CPrompt.SINGLETON_INSTANCE.getInputControl().selectButtonOK();
|
||||
game.confirm();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -303,17 +301,16 @@ public enum VStack implements IVDoc<CStack> {
|
||||
add(jmiAlwaysNo);
|
||||
}
|
||||
|
||||
public void setStackInstance(final MagicStack stack0, final SpellAbility ability0, final Player localPlayer) {
|
||||
stack = stack0;
|
||||
ability = ability0;
|
||||
controller = localPlayer.getController();
|
||||
triggerID = ability.getSourceTrigger();
|
||||
public void setStackInstance(final IGameView game, final StackItemView item, final PlayerView localPlayer) {
|
||||
this.game = game;
|
||||
this.item = item;
|
||||
triggerID = Integer.valueOf(item.getSourceTrigger());
|
||||
|
||||
jmiAutoYield.setSelected(controller.shouldAutoYield(ability.toUnsuppressedString()));
|
||||
jmiAutoYield.setSelected(game.shouldAutoYield(item.getKey()));
|
||||
|
||||
if (ability.isOptionalTrigger() && ability.getActivatingPlayer() == localPlayer) {
|
||||
jmiAlwaysYes.setSelected(controller.shouldAlwaysAcceptTrigger(triggerID));
|
||||
jmiAlwaysNo.setSelected(controller.shouldAlwaysDeclineTrigger(triggerID));
|
||||
if (item.isOptionalTrigger() && item.getActivatingPlayer().equals(localPlayer)) {
|
||||
jmiAlwaysYes.setSelected(game.shouldAlwaysAcceptTrigger(triggerID));
|
||||
jmiAlwaysNo.setSelected(game.shouldAlwaysDeclineTrigger(triggerID));
|
||||
jmiAlwaysYes.setVisible(true);
|
||||
jmiAlwaysNo.setVisible(true);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package forge.toolbox;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.interfaces.IProgressBar;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -36,7 +37,7 @@ public class FProgressBar extends JProgressBar implements IProgressBar {
|
||||
* @param s0   A description to prepend before statistics.
|
||||
*/
|
||||
public void setDescription(final String s0) {
|
||||
FThreads.assertExecutedByEdt(true);
|
||||
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
|
||||
desc = s0;
|
||||
setString(s0);
|
||||
}
|
||||
@@ -81,7 +82,7 @@ public class FProgressBar extends JProgressBar implements IProgressBar {
|
||||
|
||||
/** Resets the various values required for this class. Must be called from EDT. */
|
||||
public void reset() {
|
||||
FThreads.assertExecutedByEdt(true);
|
||||
FThreads.assertExecutedByEdt(GuiBase.getInterface(), true);
|
||||
setIndeterminate(true);
|
||||
setValue(0);
|
||||
tempVal = 0;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package forge.toolbox;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.Singletons;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.assets.ISkinImage;
|
||||
@@ -981,7 +982,7 @@ public class FSkin {
|
||||
public static void loadLight(final String skinName, final boolean onInit) {
|
||||
if (onInit) {
|
||||
// No need for this method to be loaded while on the EDT.
|
||||
FThreads.assertExecutedByEdt(false);
|
||||
FThreads.assertExecutedByEdt(GuiBase.getInterface(), false);
|
||||
|
||||
if (allSkins == null) { //initialize
|
||||
allSkins = new ArrayList<String>();
|
||||
@@ -1053,7 +1054,7 @@ public class FSkin {
|
||||
public static void loadFull(final boolean onInit) {
|
||||
if (onInit) {
|
||||
// No need for this method to be loaded while on the EDT.
|
||||
FThreads.assertExecutedByEdt(false);
|
||||
FThreads.assertExecutedByEdt(GuiBase.getInterface(), false);
|
||||
|
||||
// Preferred skin name must be called via loadLight() method,
|
||||
// which does some cleanup and init work.
|
||||
|
||||
@@ -18,17 +18,16 @@
|
||||
|
||||
package forge.toolbox.imaging;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ColorModel;
|
||||
|
||||
import forge.ImageCache;
|
||||
import forge.card.CardCharacteristicName;
|
||||
import forge.game.card.Card;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.toolbox.CardFaceSymbols;
|
||||
import forge.toolbox.FSkin.SkinIcon;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ColorModel;
|
||||
import forge.view.CardView.CardStateView;
|
||||
|
||||
/**
|
||||
* Common image-related routines specific to Forge images.
|
||||
@@ -37,16 +36,8 @@ import java.awt.image.ColorModel;
|
||||
*
|
||||
*/
|
||||
public final class FImageUtil {
|
||||
private FImageUtil() {}
|
||||
|
||||
public static BufferedImage getImage(Card card, CardCharacteristicName state) {
|
||||
BufferedImage image = ImageCache.getOriginalImage(card.getImageKey(state), true);
|
||||
int foilIndex = card.getFoil();
|
||||
if (image != null && foilIndex > 0) {
|
||||
image = getImageWithFoilEffect(image, foilIndex);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
private FImageUtil() {}
|
||||
|
||||
/**
|
||||
* Gets the image associated with a card.
|
||||
@@ -56,9 +47,9 @@ public final class FImageUtil {
|
||||
* For double-sided cards, returns the front-side image.<br>
|
||||
* For flip cards, returns the un-flipped image.
|
||||
*/
|
||||
public static BufferedImage getImage(Card card) {
|
||||
public static BufferedImage getImage(final CardStateView card) {
|
||||
BufferedImage image = ImageCache.getOriginalImage(card.getImageKey(), true);
|
||||
int foilIndex = card.getFoil();
|
||||
final int foilIndex = card.getCard().getFoilIndex();
|
||||
if (image != null && foilIndex > 0) {
|
||||
image = getImageWithFoilEffect(image, foilIndex);
|
||||
}
|
||||
|
||||
@@ -17,18 +17,20 @@
|
||||
*/
|
||||
package forge.toolbox.special;
|
||||
|
||||
import forge.game.card.Card;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.AbstractListModel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import forge.gui.CardDetailPanel;
|
||||
import forge.gui.CardPicturePanel;
|
||||
import forge.item.PaperCard;
|
||||
import forge.toolbox.FScrollPane;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import forge.view.ViewUtil;
|
||||
|
||||
/**
|
||||
* A simple JPanel that shows three columns: card list, pic, and description..
|
||||
@@ -56,7 +58,7 @@ public class CardViewer extends JPanel {
|
||||
public CardViewer(final List<PaperCard> list) {
|
||||
this.list = Collections.unmodifiableList(list);
|
||||
this.jList = new JList<PaperCard>(new ChooserListModel());
|
||||
this.detail = new CardDetailPanel(null);
|
||||
this.detail = new CardDetailPanel();
|
||||
this.picture = new CardPicturePanel();
|
||||
|
||||
this.add(new FScrollPane(this.jList, true));
|
||||
@@ -91,7 +93,7 @@ public class CardViewer extends JPanel {
|
||||
// (String) jList.getSelectedValue();
|
||||
if ((row >= 0) && (row < CardViewer.this.list.size())) {
|
||||
final PaperCard cp = CardViewer.this.list.get(row);
|
||||
CardViewer.this.detail.setCard(Card.getCardForUi(cp));
|
||||
CardViewer.this.detail.setCard(ViewUtil.getCardForUi(cp));
|
||||
CardViewer.this.picture.setCard(cp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,23 +18,29 @@
|
||||
|
||||
package forge.toolbox.special;
|
||||
|
||||
import forge.Singletons;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.event.MouseWheelListener;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.Timer;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.card.CardCharacteristicName;
|
||||
import forge.card.CardDetailUtil;
|
||||
import forge.game.card.Card;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.toolbox.FOverlay;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedLabel;
|
||||
import forge.toolbox.imaging.FImagePanel;
|
||||
import forge.toolbox.imaging.FImageUtil;
|
||||
import forge.toolbox.imaging.FImagePanel.AutoSizeImageMode;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.event.*;
|
||||
import forge.toolbox.imaging.FImageUtil;
|
||||
import forge.view.CardView;
|
||||
import forge.view.CardView.CardStateView;
|
||||
|
||||
/**
|
||||
* Displays card image at its original size and correct orientation.
|
||||
@@ -55,10 +61,8 @@ public enum CardZoomer {
|
||||
private SkinnedLabel lblFlipcard = new SkinnedLabel();
|
||||
|
||||
// Details about the current card being displayed.
|
||||
private Card thisCard;
|
||||
private CardCharacteristicName cardState = CardCharacteristicName.Original;
|
||||
private boolean isImageFlipped = false;
|
||||
private boolean isFaceDownCard = false;
|
||||
private CardView thisCard;
|
||||
private boolean isInAltState;
|
||||
|
||||
// The zoomer is in button mode when it is activated by holding down the
|
||||
// middle mouse button or left and right mouse buttons simultaneously.
|
||||
@@ -103,7 +107,8 @@ public enum CardZoomer {
|
||||
/**
|
||||
* Creates listener for mouse button events.
|
||||
* <p>
|
||||
* NOTE: Needed even if ButtonMode to prevent Zoom getting stuck open on certain systems.
|
||||
* NOTE: Needed even if ButtonMode to prevent Zoom getting stuck open on
|
||||
* certain systems.
|
||||
*/
|
||||
private void setMouseButtonListener() {
|
||||
overlay.addMouseListener(new MouseAdapter() {
|
||||
@@ -117,11 +122,13 @@ public enum CardZoomer {
|
||||
/**
|
||||
* Creates listener for mouse wheel events.
|
||||
* <p>
|
||||
* If the zoomer is opened using the mouse wheel then additional
|
||||
* actions can be performed dependent on the card type -
|
||||
* <p><ul>
|
||||
* If the zoomer is opened using the mouse wheel then additional actions can
|
||||
* be performed dependent on the card type -
|
||||
* <p>
|
||||
* <ul>
|
||||
* <li>If mouse wheel is rotated back then close zoomer.
|
||||
* <li>If mouse wheel is rotated forward and...<ul>
|
||||
* <li>If mouse wheel is rotated forward and...
|
||||
* <ul>
|
||||
* <li>if image is a flip card then rotate 180 degrees.
|
||||
* <li>if image is a double-sided card then show other side.
|
||||
*/
|
||||
@@ -146,47 +153,25 @@ public enum CardZoomer {
|
||||
|
||||
/**
|
||||
* Opens zoomer in mouse wheel mode and displays the image associated with
|
||||
* the given card based on its current {@code CardCharacteristicName} state.
|
||||
* the given card based.
|
||||
* <p>
|
||||
* This method should be called if the zoomer is activated by rotating the mouse wheel.
|
||||
* This method should be called if the zoomer is activated by rotating the
|
||||
* mouse wheel.
|
||||
*/
|
||||
public void doMouseWheelZoom(Card newCard) {
|
||||
doMouseWheelZoom(newCard, newCard.getCurState());
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens zoomer in mouse wheel mode and displays the image associated with
|
||||
* the given card based on the specified {@code CardCharacteristicName} state.
|
||||
* <p>
|
||||
* This method should be called if the zoomer is activated by rotating the mouse wheel.
|
||||
*/
|
||||
public void doMouseWheelZoom(Card newCard, CardCharacteristicName state) {
|
||||
public void doMouseWheelZoom(final CardView card) {
|
||||
isButtonMode = false;
|
||||
isFaceDownCard = (state == CardCharacteristicName.FaceDown);
|
||||
cardState = state;
|
||||
displayCard(newCard);
|
||||
displayCard(card);
|
||||
startMouseWheelCoolDownTimer(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens zoomer in mouse button mode and displays the image associated with
|
||||
* the given card based on its current {@code CardCharacteristicName} state.
|
||||
* the given card.
|
||||
* <p>
|
||||
* This method should be called if the zoomer is activated by holding down
|
||||
* the middle mouse button or left and right mouse buttons simultaneously.
|
||||
*/
|
||||
public void doMouseButtonZoom(Card newCard) {
|
||||
doMouseButtonZoom(newCard, newCard.getCurState());
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens zoomer in mouse button mode and displays the image associated with
|
||||
* the given card based on the specified {@code CardCharacteristicName} state.
|
||||
* <p>
|
||||
* This method should be called if the zoomer is activated by holding down
|
||||
* the middle mouse button or left and right mouse buttons simultaneously.
|
||||
*/
|
||||
public void doMouseButtonZoom(Card newCard, CardCharacteristicName state) {
|
||||
public void doMouseButtonZoom(final CardView newCard) {
|
||||
|
||||
// don't display zoom if already zoomed or just closed zoom
|
||||
// (handles mouse wheeling while middle clicking)
|
||||
@@ -195,8 +180,6 @@ public enum CardZoomer {
|
||||
}
|
||||
|
||||
isButtonMode = true;
|
||||
isFaceDownCard = (state == CardCharacteristicName.FaceDown);
|
||||
cardState = state;
|
||||
displayCard(newCard);
|
||||
}
|
||||
|
||||
@@ -204,10 +187,10 @@ public enum CardZoomer {
|
||||
return isOpen;
|
||||
}
|
||||
|
||||
private void displayCard(Card card) {
|
||||
private void displayCard(final CardView newCard) {
|
||||
isMouseWheelEnabled = false;
|
||||
isImageFlipped = false;
|
||||
thisCard = card.getCardForUi();
|
||||
thisCard = newCard;
|
||||
isInAltState = false;
|
||||
setLayout();
|
||||
setImage();
|
||||
SOverlayUtils.showOverlay();
|
||||
@@ -218,8 +201,7 @@ public enum CardZoomer {
|
||||
* Displays a graphical indicator that shows whether the current card can be flipped or transformed.
|
||||
*/
|
||||
private void setFlipIndicator() {
|
||||
boolean isFaceDownFlippable = (isFaceDownCard && Singletons.getControl().mayShowCard(thisCard));
|
||||
if (thisCard.isFlipCard() || thisCard.isDoubleFaced() || isFaceDownFlippable ) {
|
||||
if (thisCard.hasAltState()) {
|
||||
imagePanel.setLayout(new MigLayout("insets 0, w 100%!, h 100%!"));
|
||||
imagePanel.add(lblFlipcard, "pos (100% - 100px) 0");
|
||||
}
|
||||
@@ -230,7 +212,7 @@ public enum CardZoomer {
|
||||
*/
|
||||
private void setImage() {
|
||||
imagePanel = new FImagePanel();
|
||||
imagePanel.setImage(FImageUtil.getImage(thisCard, cardState), getInitialRotation(), AutoSizeImageMode.SOURCE);
|
||||
imagePanel.setImage(FImageUtil.getImage(getState()), getInitialRotation(), AutoSizeImageMode.SOURCE);
|
||||
pnlMain.removeAll();
|
||||
pnlMain.add(imagePanel, "w 80%!, h 80%!");
|
||||
pnlMain.validate();
|
||||
@@ -238,7 +220,7 @@ public enum CardZoomer {
|
||||
}
|
||||
|
||||
private int getInitialRotation() {
|
||||
return (thisCard.isSplitCard() || thisCard.isPlane() || thisCard.isPhenomenon() ? 90 : 0);
|
||||
return (thisCard.isSplitCard() ? 90 : 0);
|
||||
}
|
||||
|
||||
private void setLayout() {
|
||||
@@ -294,12 +276,8 @@ public enum CardZoomer {
|
||||
* Toggles between primary and alternate image associated with card if applicable.
|
||||
*/
|
||||
private void toggleCardImage() {
|
||||
if (thisCard.isFlipCard()) {
|
||||
if (thisCard.hasAltState()) {
|
||||
toggleFlipCard();
|
||||
} else if (thisCard.isDoubleFaced()) {
|
||||
toggleDoubleFacedCard();
|
||||
} else if (isFaceDownCard) {
|
||||
toggleFaceDownCard();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,26 +288,12 @@ public enum CardZoomer {
|
||||
* Can simply rotate current card image in situ to get same effect.
|
||||
*/
|
||||
private void toggleFlipCard() {
|
||||
isImageFlipped = !isImageFlipped;
|
||||
imagePanel.setRotation(isImageFlipped ? 180 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles between the front and back image of a card that can be
|
||||
* played face-down (eg. morph).
|
||||
* <p>
|
||||
* Uses constraint that prevents a player from identifying opponent's face-down cards.
|
||||
*/
|
||||
private void toggleFaceDownCard() {
|
||||
cardState = CardDetailUtil.getAlternateState(thisCard, cardState);
|
||||
isInAltState = !isInAltState;
|
||||
imagePanel.setRotation(thisCard.isFlipCard() && isInAltState ? 180 : 0);
|
||||
setImage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles between the front and back image of a double-sided card.
|
||||
*/
|
||||
private void toggleDoubleFacedCard() {
|
||||
cardState = CardDetailUtil.getAlternateState(thisCard, cardState);
|
||||
setImage();
|
||||
private CardStateView getState() {
|
||||
return thisCard.getState(isButtonMode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,34 @@
|
||||
package forge.toolbox.special;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.card.MagicColor;
|
||||
import forge.game.mana.ManaPool;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.ForgeAction;
|
||||
import forge.properties.ForgePreferences;
|
||||
import forge.screens.match.controllers.CPlayers;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedPanel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingConstants;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
import forge.assets.FSkinProp;
|
||||
import forge.card.MagicColor;
|
||||
import forge.gui.ForgeAction;
|
||||
import forge.screens.match.controllers.CPlayers;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.FSkin;
|
||||
import forge.toolbox.FSkin.SkinnedPanel;
|
||||
import forge.view.PlayerView;
|
||||
|
||||
public class PlayerDetailsPanel extends JPanel {
|
||||
private static final long serialVersionUID = 8444559244193214459L;
|
||||
|
||||
private Player player;
|
||||
private PlayerView player;
|
||||
|
||||
// Info labels
|
||||
private FLabel lblHand = getBuiltFLabel(FSkinProp.IMG_ZONE_HAND, "99", "Cards in hand");
|
||||
@@ -47,8 +46,7 @@ public class PlayerDetailsPanel extends JPanel {
|
||||
.text(s0).tooltip(s1).fontAlign(SwingConstants.RIGHT).build();
|
||||
}
|
||||
|
||||
public PlayerDetailsPanel(Player player) {
|
||||
|
||||
public PlayerDetailsPanel(final PlayerView player) {
|
||||
this.player = player;
|
||||
|
||||
manaLabels.add(Pair.of(getBuiltFLabel(FSkinProp.IMG_MANA_B, "99", "Black mana"), MagicColor.BLACK));
|
||||
@@ -121,14 +119,14 @@ public class PlayerDetailsPanel extends JPanel {
|
||||
* @param p0   {@link forge.game.player.Player}
|
||||
*/
|
||||
public void updateZones() {
|
||||
this.getLblHand().setText("" + player.getZone(ZoneType.Hand).size());
|
||||
final String handMaxToolTip = player.isUnlimitedHandSize()
|
||||
this.getLblHand().setText("" + player.getnHandCards());
|
||||
final String handMaxToolTip = player.hasUnlimitedHandSize()
|
||||
? "no maximum hand size" : String.valueOf(player.getMaxHandSize());
|
||||
this.getLblHand().setToolTipText("Cards in hand (max: " + handMaxToolTip + ")");
|
||||
this.getLblGraveyard().setText("" + player.getZone(ZoneType.Graveyard).size());
|
||||
this.getLblLibrary().setText("" + player.getZone(ZoneType.Library).size());
|
||||
this.getLblFlashback().setText("" + player.getCardsActivableInExternalZones(true).size());
|
||||
this.getLblExile().setText("" + player.getZone(ZoneType.Exile).size());
|
||||
this.getLblGraveyard().setText("" + player.getGraveCards().size());
|
||||
this.getLblLibrary().setText("" + player.getnLibraryCards());
|
||||
this.getLblFlashback().setText("" + player.getFlashbackCards().size());
|
||||
this.getLblExile().setText("" + player.getExileCards().size());
|
||||
}
|
||||
|
||||
|
||||
@@ -158,9 +156,8 @@ public class PlayerDetailsPanel extends JPanel {
|
||||
* @param p0   {@link forge.game.player.Player}
|
||||
*/
|
||||
public void updateManaPool() {
|
||||
ManaPool m = player.getManaPool();
|
||||
for(Pair<FLabel, Byte> label : manaLabels)
|
||||
label.getKey().setText(Integer.toString(m.getAmountOfColor(label.getRight())));
|
||||
for (final Pair<FLabel, Byte> label : manaLabels)
|
||||
label.getKey().setText(Integer.toString(player.getMana(label.getRight())));
|
||||
}
|
||||
|
||||
public FLabel getLblHand() {
|
||||
@@ -210,16 +207,14 @@ public class PlayerDetailsPanel extends JPanel {
|
||||
lblExile.setHoverable(true);
|
||||
lblExile.addMouseListener(new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) { exileAction.actionPerformed(null); } } );
|
||||
|
||||
if (ForgePreferences.DEV_MODE) {
|
||||
lblLibrary.setHoverable(true);
|
||||
lblLibrary.addMouseListener(new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) { libraryAction.actionPerformed(null); } } );
|
||||
}
|
||||
|
||||
lblHand.setHoverable(true);
|
||||
lblHand.addMouseListener(new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) { handAction.actionPerformed(null); } } );
|
||||
|
||||
lblFlashback.setHoverable(true);
|
||||
lblFlashback.addMouseListener(new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) {flashBackAction.actionPerformed(null); } } );
|
||||
lblFlashback.addMouseListener(new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) { flashBackAction.actionPerformed(null); } } );
|
||||
|
||||
for(final Pair<FLabel, Byte> labelPair : getManaLabels()) {
|
||||
labelPair.getLeft().setHoverable(true);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
package forge.view;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.GuiBase;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.screens.match.VMatchUI;
|
||||
|
||||
@@ -68,7 +69,7 @@ public class ButtonUtil {
|
||||
|
||||
// ensure we don't steal focus from an overlay
|
||||
if (!SOverlayUtils.overlayHasFocus()) {
|
||||
FThreads.invokeInEdtLater(new Runnable() { @Override public void run() { button.requestFocusInWindow(); } });
|
||||
FThreads.invokeInEdtLater(GuiBase.getInterface(), new Runnable() { @Override public void run() { button.requestFocusInWindow(); } });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,15 @@
|
||||
*/
|
||||
package forge.view;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.GuiDesktop;
|
||||
import forge.Singletons;
|
||||
import forge.card.CardReaderExperiments;
|
||||
import forge.error.ExceptionHandler;
|
||||
import forge.properties.ForgeConstants;
|
||||
import forge.util.BuildInfo;
|
||||
|
||||
/**
|
||||
* Main class for Forge's swing application view.
|
||||
@@ -31,6 +35,10 @@ public final class Main {
|
||||
* Main entrypoint for Forge
|
||||
*/
|
||||
public static void main(final String[] args) {
|
||||
// Init ForgeConstants
|
||||
final String assetsDir = StringUtils.containsIgnoreCase(BuildInfo.getVersionString(), "svn") ? "../forge-gui/" : "";
|
||||
ForgeConstants.init(assetsDir);
|
||||
|
||||
// HACK - temporary solution to "Comparison method violates it's general contract!" crash
|
||||
System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
|
||||
|
||||
@@ -41,7 +49,7 @@ public final class Main {
|
||||
GuiBase.setInterface(new GuiDesktop());
|
||||
|
||||
//install our error handler
|
||||
ExceptionHandler.registerErrorHandling();
|
||||
ExceptionHandler.registerErrorHandling(GuiBase.getInterface());
|
||||
|
||||
// Start splash screen first, then data models, then controller.
|
||||
if (args.length == 0) {
|
||||
|
||||
@@ -21,7 +21,7 @@ import forge.util.Lang;
|
||||
|
||||
public class SimulateMatch {
|
||||
public static void simulate(String[] args) {
|
||||
FModel.initialize(null);
|
||||
FModel.initialize(GuiBase.getInterface(), null);
|
||||
|
||||
System.out.println("Simulation mode");
|
||||
if(args.length < 3 ) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user