mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 10:18:01 +00:00
Merge remote-tracking branch 'upstream/master' into collector-number-in-card-list-and-card-db-refactoring
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<artifactId>forge</artifactId>
|
||||
<groupId>forge</groupId>
|
||||
<version>1.6.43-SNAPSHOT</version>
|
||||
<version>1.6.44-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>forge-gui-desktop</artifactId>
|
||||
|
||||
@@ -414,4 +414,3 @@ public enum FControl implements KeyEventDispatcher {
|
||||
return GamePlayerUtil.getGuiPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +194,6 @@ public final class DeckManager extends ItemManager<DeckProxy> implements IHasGam
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
protected void buildAddFilterMenu(final JMenu menu) {
|
||||
GuiUtils.addSeparator(menu); //separate from current search item
|
||||
|
||||
@@ -228,7 +227,6 @@ public final class DeckManager extends ItemManager<DeckProxy> implements IHasGam
|
||||
}
|
||||
menu.add(fmt);
|
||||
|
||||
|
||||
GuiUtils.addMenuItem(menu, localizer.getMessage("lblFormats") + "...", null, new Runnable() {
|
||||
@Override public void run() {
|
||||
final DeckFormatFilter existingFilter = getFilter(DeckFormatFilter.class);
|
||||
|
||||
@@ -340,4 +340,3 @@ public enum CDeckEditorUI implements ICDoc {
|
||||
@Override
|
||||
public void update() { }
|
||||
}
|
||||
|
||||
|
||||
@@ -288,8 +288,7 @@ public class DeckController<T extends DeckBase> {
|
||||
final String name = getModelName();
|
||||
if (name.isEmpty()) {
|
||||
newModel();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
load(name);
|
||||
}
|
||||
}
|
||||
@@ -297,8 +296,7 @@ public class DeckController<T extends DeckBase> {
|
||||
public void load(final String path, final String name) {
|
||||
if (StringUtils.isBlank(path)) {
|
||||
currentFolder = rootFolder;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
currentFolder = rootFolder.tryGetFolder(path);
|
||||
}
|
||||
modelPath = path;
|
||||
@@ -380,8 +378,7 @@ public class DeckController<T extends DeckBase> {
|
||||
public void refreshModel() {
|
||||
if (model == null) {
|
||||
newModel();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
setModel(model, modelInStorage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,7 +501,7 @@ public final class CMatchUI
|
||||
|
||||
@Override
|
||||
public void hideZones(final PlayerView controller, final Iterable<PlayerZoneUpdate> zonesToUpdate) {
|
||||
if ( zonesToUpdate != null ) {
|
||||
if (zonesToUpdate != null) {
|
||||
for (final PlayerZoneUpdate update : zonesToUpdate) {
|
||||
final PlayerView player = update.getPlayer();
|
||||
for (final ZoneType zone : update.getZones()) {
|
||||
@@ -532,7 +532,6 @@ public final class CMatchUI
|
||||
for (final PlayerView p : manaPoolUpdate) {
|
||||
getFieldViewFor(p).updateManaPool();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Player's lives and poison counters
|
||||
@@ -575,15 +574,15 @@ public final class CMatchUI
|
||||
|
||||
@Override
|
||||
public void setSelectables(final Iterable<CardView> cards) {
|
||||
super.setSelectables(cards);
|
||||
// update zones on tabletop and floating zones - non-selectable cards may be rendered differently
|
||||
FThreads.invokeInEdtNowOrLater(new Runnable() {
|
||||
super.setSelectables(cards);
|
||||
// update zones on tabletop and floating zones - non-selectable cards may be rendered differently
|
||||
FThreads.invokeInEdtNowOrLater(new Runnable() {
|
||||
@Override public final void run() {
|
||||
for (final PlayerView p : getGameView().getPlayers()) {
|
||||
if ( p.getCards(ZoneType.Battlefield) != null ) {
|
||||
if (p.getCards(ZoneType.Battlefield) != null) {
|
||||
updateCards(p.getCards(ZoneType.Battlefield));
|
||||
}
|
||||
if ( p.getCards(ZoneType.Hand) != null ) {
|
||||
if (p.getCards(ZoneType.Hand) != null) {
|
||||
updateCards(p.getCards(ZoneType.Hand));
|
||||
}
|
||||
}
|
||||
@@ -594,15 +593,15 @@ public final class CMatchUI
|
||||
|
||||
@Override
|
||||
public void clearSelectables() {
|
||||
super.clearSelectables();
|
||||
// update zones on tabletop and floating zones - non-selectable cards may be rendered differently
|
||||
FThreads.invokeInEdtNowOrLater(new Runnable() {
|
||||
super.clearSelectables();
|
||||
// update zones on tabletop and floating zones - non-selectable cards may be rendered differently
|
||||
FThreads.invokeInEdtNowOrLater(new Runnable() {
|
||||
@Override public final void run() {
|
||||
for (final PlayerView p : getGameView().getPlayers()) {
|
||||
if ( p.getCards(ZoneType.Battlefield) != null ) {
|
||||
if (p.getCards(ZoneType.Battlefield) != null) {
|
||||
updateCards(p.getCards(ZoneType.Battlefield));
|
||||
}
|
||||
if ( p.getCards(ZoneType.Hand) != null ) {
|
||||
if (p.getCards(ZoneType.Hand) != null) {
|
||||
updateCards(p.getCards(ZoneType.Hand));
|
||||
}
|
||||
}
|
||||
@@ -617,7 +616,7 @@ public final class CMatchUI
|
||||
FThreads.invokeInEdtNowOrLater(new Runnable() {
|
||||
@Override public final void run() {
|
||||
for (final PlayerView p : getGameView().getPlayers()) {
|
||||
if ( p.getCards(ZoneType.Battlefield) != null ) {
|
||||
if (p.getCards(ZoneType.Battlefield) != null) {
|
||||
updateCards(p.getCards(ZoneType.Battlefield));
|
||||
}
|
||||
}
|
||||
@@ -787,7 +786,7 @@ public final class CMatchUI
|
||||
final PhaseType ph = getGameView().getPhase();
|
||||
// this should never happen, but I've seen it periodically... so, need to get to the bottom of it
|
||||
PhaseLabel lbl = null;
|
||||
if (ph != null ) {
|
||||
if (ph != null) {
|
||||
lbl = p == null ? null : getFieldViewFor(p).getPhaseIndicator().getLabelFor(ph);
|
||||
} else {
|
||||
// not sure what debugging information would help here, log for now
|
||||
@@ -1295,79 +1294,78 @@ public final class CMatchUI
|
||||
boolean isAi = sa.getActivatingPlayer().isAI();
|
||||
boolean isTrigger = sa.isTrigger();
|
||||
int stackIndex = event.stackIndex;
|
||||
if(stackIndex == nextNotifiableStackIndex) {
|
||||
if(ForgeConstants.STACK_EFFECT_NOTIFICATION_ALWAYS.equals(stackNotificationPolicy) || (ForgeConstants.STACK_EFFECT_NOTIFICATION_AI_AND_TRIGGERED.equals(stackNotificationPolicy) && (isAi || isTrigger))) {
|
||||
// We can go and show the modal
|
||||
SpellAbilityStackInstance si = event.si;
|
||||
if (stackIndex == nextNotifiableStackIndex) {
|
||||
if (ForgeConstants.STACK_EFFECT_NOTIFICATION_ALWAYS.equals(stackNotificationPolicy) || (ForgeConstants.STACK_EFFECT_NOTIFICATION_AI_AND_TRIGGERED.equals(stackNotificationPolicy) && (isAi || isTrigger))) {
|
||||
// We can go and show the modal
|
||||
SpellAbilityStackInstance si = event.si;
|
||||
|
||||
MigLayout migLayout = new MigLayout("insets 15, left, gap 30, fill");
|
||||
JPanel mainPanel = new JPanel(migLayout);
|
||||
final Dimension parentSize = JOptionPane.getRootFrame().getSize();
|
||||
Dimension maxSize = new Dimension(1400, parentSize.height - 100);
|
||||
mainPanel.setMaximumSize(maxSize);
|
||||
mainPanel.setOpaque(false);
|
||||
MigLayout migLayout = new MigLayout("insets 15, left, gap 30, fill");
|
||||
JPanel mainPanel = new JPanel(migLayout);
|
||||
final Dimension parentSize = JOptionPane.getRootFrame().getSize();
|
||||
Dimension maxSize = new Dimension(1400, parentSize.height - 100);
|
||||
mainPanel.setMaximumSize(maxSize);
|
||||
mainPanel.setOpaque(false);
|
||||
|
||||
// Big Image
|
||||
addBigImageToStackModalPanel(mainPanel, si);
|
||||
// Big Image
|
||||
addBigImageToStackModalPanel(mainPanel, si);
|
||||
|
||||
// Text
|
||||
addTextToStackModalPanel(mainPanel,sa,si);
|
||||
// Text
|
||||
addTextToStackModalPanel(mainPanel,sa,si);
|
||||
|
||||
// Small images
|
||||
int numSmallImages = 0;
|
||||
// Small images
|
||||
int numSmallImages = 0;
|
||||
|
||||
// If current effect is a triggered/activated ability of an enchantment card, I want to show the enchanted card
|
||||
GameEntityView enchantedEntityView = null;
|
||||
Card hostCard = sa.getHostCard();
|
||||
if(hostCard.isEnchantment()) {
|
||||
GameEntity enchantedEntity = hostCard.getEntityAttachedTo();
|
||||
if(enchantedEntity != null) {
|
||||
enchantedEntityView = enchantedEntity.getView();
|
||||
numSmallImages++;
|
||||
} else if ((sa.getRootAbility() != null)
|
||||
&& (sa.getRootAbility().getPaidList("Sacrificed") != null)
|
||||
&& !sa.getRootAbility().getPaidList("Sacrificed").isEmpty()) {
|
||||
// If the player activated its ability by sacrificing the enchantment, the enchantment has not anything attached anymore and the ex-enchanted card has to be searched in other ways.. for example, the green enchantment "Carapace"
|
||||
enchantedEntity = sa.getRootAbility().getPaidList("Sacrificed").get(0).getEnchantingCard();
|
||||
if(enchantedEntity != null) {
|
||||
// If current effect is a triggered/activated ability of an enchantment card, I want to show the enchanted card
|
||||
GameEntityView enchantedEntityView = null;
|
||||
Card hostCard = sa.getHostCard();
|
||||
if (hostCard.isEnchantment()) {
|
||||
GameEntity enchantedEntity = hostCard.getEntityAttachedTo();
|
||||
if (enchantedEntity != null) {
|
||||
enchantedEntityView = enchantedEntity.getView();
|
||||
numSmallImages++;
|
||||
} else if ((sa.getRootAbility() != null)
|
||||
&& (sa.getRootAbility().getPaidList("Sacrificed") != null)
|
||||
&& !sa.getRootAbility().getPaidList("Sacrificed").isEmpty()) {
|
||||
// If the player activated its ability by sacrificing the enchantment, the enchantment has not anything attached anymore and the ex-enchanted card has to be searched in other ways.. for example, the green enchantment "Carapace"
|
||||
enchantedEntity = sa.getRootAbility().getPaidList("Sacrificed").get(0).getEnchantingCard();
|
||||
if (enchantedEntity != null) {
|
||||
enchantedEntityView = enchantedEntity.getView();
|
||||
numSmallImages++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If current effect is a triggered ability, I want to show the triggering card if present
|
||||
SpellAbility sourceSA = (SpellAbility) si.getTriggeringObject(AbilityKey.SourceSA);
|
||||
CardView sourceCardView = null;
|
||||
if(sourceSA != null) {
|
||||
sourceCardView = sourceSA.getHostCard().getView();
|
||||
numSmallImages++;
|
||||
}
|
||||
// If current effect is a triggered ability, I want to show the triggering card if present
|
||||
SpellAbility sourceSA = (SpellAbility) si.getTriggeringObject(AbilityKey.SourceSA);
|
||||
CardView sourceCardView = null;
|
||||
if (sourceSA != null) {
|
||||
sourceCardView = sourceSA.getHostCard().getView();
|
||||
numSmallImages++;
|
||||
}
|
||||
|
||||
// I also want to show each type of targets (both cards and players)
|
||||
List<GameEntityView> targets = getTargets(si,new ArrayList<GameEntityView>());
|
||||
numSmallImages = numSmallImages + targets.size();
|
||||
// I also want to show each type of targets (both cards and players)
|
||||
List<GameEntityView> targets = getTargets(si,new ArrayList<GameEntityView>());
|
||||
numSmallImages = numSmallImages + targets.size();
|
||||
|
||||
// Now I know how many small images - on to render them
|
||||
if(enchantedEntityView != null) {
|
||||
addSmallImageToStackModalPanel(enchantedEntityView,mainPanel,numSmallImages);
|
||||
}
|
||||
if(sourceCardView != null) {
|
||||
addSmallImageToStackModalPanel(sourceCardView,mainPanel,numSmallImages);
|
||||
}
|
||||
for(GameEntityView gev : targets) {
|
||||
addSmallImageToStackModalPanel(gev, mainPanel, numSmallImages);
|
||||
}
|
||||
// Now I know how many small images - on to render them
|
||||
if (enchantedEntityView != null) {
|
||||
addSmallImageToStackModalPanel(enchantedEntityView,mainPanel,numSmallImages);
|
||||
}
|
||||
if (sourceCardView != null) {
|
||||
addSmallImageToStackModalPanel(sourceCardView,mainPanel,numSmallImages);
|
||||
}
|
||||
for (GameEntityView gev : targets) {
|
||||
addSmallImageToStackModalPanel(gev, mainPanel, numSmallImages);
|
||||
}
|
||||
|
||||
FOptionPane.showOptionDialog(null, "Forge", null, mainPanel, ImmutableList.of(Localizer.getInstance().getMessage("lblOK")));
|
||||
// here the user closed the modal - time to update the next notifiable stack index
|
||||
FOptionPane.showOptionDialog(null, "Forge", null, mainPanel, ImmutableList.of(Localizer.getInstance().getMessage("lblOK")));
|
||||
// here the user closed the modal - time to update the next notifiable stack index
|
||||
|
||||
}
|
||||
// In any case, I have to increase the counter
|
||||
nextNotifiableStackIndex++;
|
||||
|
||||
} else {
|
||||
|
||||
// Not yet time to show the modal - schedule the method again, and try again later
|
||||
Runnable tryAgainThread = new Runnable() {
|
||||
@Override
|
||||
@@ -1381,21 +1379,21 @@ public final class CMatchUI
|
||||
}
|
||||
|
||||
private List<GameEntityView> getTargets(SpellAbilityStackInstance si, List<GameEntityView> result){
|
||||
if(si == null) {
|
||||
if (si == null) {
|
||||
return result;
|
||||
}
|
||||
FCollectionView<CardView> targetCards = CardView.getCollection(si.getTargetChoices().getTargetCards());
|
||||
for(CardView currCardView: targetCards) {
|
||||
for (CardView currCardView: targetCards) {
|
||||
result.add(currCardView);
|
||||
}
|
||||
|
||||
for(SpellAbility currSA : si.getTargetChoices().getTargetSpells()) {
|
||||
for (SpellAbility currSA : si.getTargetChoices().getTargetSpells()) {
|
||||
CardView currCardView = currSA.getCardView();
|
||||
result.add(currCardView);
|
||||
}
|
||||
|
||||
FCollectionView<PlayerView> targetPlayers = PlayerView.getCollection(si.getTargetChoices().getTargetPlayers());
|
||||
for(PlayerView currPlayerView : targetPlayers) {
|
||||
for (PlayerView currPlayerView : targetPlayers) {
|
||||
result.add(currPlayerView);
|
||||
}
|
||||
|
||||
@@ -1443,7 +1441,7 @@ public final class CMatchUI
|
||||
}
|
||||
|
||||
private void addSmallImageToStackModalPanel(GameEntityView gameEntityView, JPanel mainPanel, int numTarget) {
|
||||
if(gameEntityView instanceof CardView) {
|
||||
if (gameEntityView instanceof CardView) {
|
||||
CardView cardView = (CardView) gameEntityView;
|
||||
int currRotation = getRotation(cardView);
|
||||
FImagePanel targetPanel = new FImagePanel();
|
||||
@@ -1454,7 +1452,7 @@ public final class CMatchUI
|
||||
Dimension targetPanelDimension = new Dimension(imageWidth,imageHeight);
|
||||
targetPanel.setMinimumSize(targetPanelDimension);
|
||||
mainPanel.add(targetPanel, "cell 1 1, split " + numTarget+ ", aligny bottom");
|
||||
} else if(gameEntityView instanceof PlayerView) {
|
||||
} else if (gameEntityView instanceof PlayerView) {
|
||||
PlayerView playerView = (PlayerView) gameEntityView;
|
||||
SkinImage playerAvatar = getPlayerAvatar(playerView, 0);
|
||||
final FLabel lblIcon = new FLabel.Builder().icon(playerAvatar).build();
|
||||
@@ -1499,11 +1497,10 @@ public final class CMatchUI
|
||||
}
|
||||
|
||||
private void createLandPopupPanel(Card land) {
|
||||
|
||||
String landPlayedNotificationPolicy = FModel.getPreferences().getPref(FPref.UI_LAND_PLAYED_NOTIFICATION_POLICY);
|
||||
Player cardController = land.getController();
|
||||
boolean isAi = cardController.isAI();
|
||||
if(ForgeConstants.LAND_PLAYED_NOTIFICATION_ALWAYS.equals(landPlayedNotificationPolicy)
|
||||
if (ForgeConstants.LAND_PLAYED_NOTIFICATION_ALWAYS.equals(landPlayedNotificationPolicy)
|
||||
|| (ForgeConstants.LAND_PLAYED_NOTIFICATION_AI.equals(landPlayedNotificationPolicy) && (isAi))
|
||||
|| (ForgeConstants.LAND_PLAYED_NOTIFICATION_ALWAYS_FOR_NONBASIC_LANDS.equals(landPlayedNotificationPolicy) && !land.isBasicLand())
|
||||
|| (ForgeConstants.LAND_PLAYED_NOTIFICATION_AI_FOR_NONBASIC_LANDS.equals(landPlayedNotificationPolicy) && !land.isBasicLand()) && (isAi)) {
|
||||
|
||||
@@ -121,7 +121,6 @@ public class GameLogPanel extends JPanel {
|
||||
}
|
||||
|
||||
public void addLogEntry(final String text) {
|
||||
|
||||
final boolean useAlternateBackColor = (scrollablePanel.getComponents().length % 2 == 0);
|
||||
final JTextArea tar = createNewLogEntryJTextArea(text, useAlternateBackColor);
|
||||
|
||||
@@ -138,7 +137,6 @@ public class GameLogPanel extends JPanel {
|
||||
}
|
||||
|
||||
forceVerticalScrollbarToMax();
|
||||
|
||||
}
|
||||
|
||||
public void setTextFont(final SkinFont newFont) {
|
||||
|
||||
@@ -107,8 +107,8 @@ public class VAssignCombatDamage {
|
||||
|
||||
private boolean canAssignTo(final CardView card) {
|
||||
for (DamageTarget dt : defenders) {
|
||||
if (dt.card == card ) return true;
|
||||
if (getDamageToKill(dt.card) > dt.damage )
|
||||
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");
|
||||
@@ -145,7 +145,7 @@ public class VAssignCombatDamage {
|
||||
boolean isLMB = SwingUtilities.isLeftMouseButton(evt);
|
||||
boolean isRMB = SwingUtilities.isRightMouseButton(evt);
|
||||
|
||||
if ( isLMB || isRMB)
|
||||
if (isLMB || isRMB)
|
||||
assignDamageTo(source, meta, isLMB);
|
||||
}
|
||||
};
|
||||
@@ -305,7 +305,7 @@ public class VAssignCombatDamage {
|
||||
int leftToAssign = getRemainingDamage();
|
||||
// Left click adds damage, right click substracts damage.
|
||||
// Hold Ctrl to assign lethal damage, Ctrl-click again on a creature with lethal damage to assign all available damage to it
|
||||
if ( meta ) {
|
||||
if (meta) {
|
||||
if (isAdding) {
|
||||
damageToAdd = leftToKill > 0 ? leftToKill : leftToAssign;
|
||||
} else {
|
||||
@@ -313,7 +313,7 @@ public class VAssignCombatDamage {
|
||||
}
|
||||
}
|
||||
|
||||
if ( damageToAdd > leftToAssign )
|
||||
if (damageToAdd > leftToAssign)
|
||||
damageToAdd = leftToAssign;
|
||||
|
||||
// cannot assign first blocker less than lethal damage except when overriding order
|
||||
@@ -321,7 +321,7 @@ public class VAssignCombatDamage {
|
||||
if (!overrideCombatantOrder && isFirstBlocker && damageToAdd + damageItHad < lethalDamage )
|
||||
return;
|
||||
|
||||
if ( 0 == damageToAdd || damageToAdd + damageItHad < 0)
|
||||
if (0 == damageToAdd || damageToAdd + damageItHad < 0)
|
||||
return;
|
||||
|
||||
addDamage(source, damageToAdd);
|
||||
@@ -335,12 +335,12 @@ public class VAssignCombatDamage {
|
||||
}
|
||||
// Clear out any Damage that shouldn't be assigned to other combatants
|
||||
boolean hasAliveEnemy = false;
|
||||
for(DamageTarget dt : defenders) {
|
||||
for (DamageTarget dt : defenders) {
|
||||
int lethal = getDamageToKill(dt.card);
|
||||
int damage = dt.damage;
|
||||
// If overriding combatant order, make sure everything has lethal if defender has damage assigned to it
|
||||
// Otherwise, follow normal combatant order
|
||||
if ( hasAliveEnemy && (!overrideCombatantOrder || dt.card == null || dt.card == defender))
|
||||
if (hasAliveEnemy && (!overrideCombatantOrder || dt.card == null || dt.card == defender))
|
||||
dt.damage = 0;
|
||||
else
|
||||
hasAliveEnemy |= damage < lethal;
|
||||
@@ -357,15 +357,15 @@ public class VAssignCombatDamage {
|
||||
|
||||
int dmgLeft = totalDamageToAssign;
|
||||
DamageTarget dtLast = null;
|
||||
for(DamageTarget dt : defenders) { // MUST NOT RUN WITH EMPTY collection
|
||||
for (DamageTarget dt : defenders) { // MUST NOT RUN WITH EMPTY collection
|
||||
int lethal = getDamageToKill(dt.card);
|
||||
int damage = Math.min(lethal, dmgLeft);
|
||||
addDamage(dt.card, damage);
|
||||
dmgLeft -= damage;
|
||||
dtLast = dt;
|
||||
if ( dmgLeft <= 0 || !toAllBlockers ) break;
|
||||
if (dmgLeft <= 0 || !toAllBlockers) break;
|
||||
}
|
||||
if ( dmgLeft < 0 )
|
||||
if (dmgLeft < 0)
|
||||
throw new RuntimeException("initialAssignDamage managed to assign more damage than it could");
|
||||
if (toAllBlockers && dmgLeft > 0) {
|
||||
// flush the remaining damage into last defender if assigning all damage
|
||||
@@ -376,7 +376,7 @@ public class VAssignCombatDamage {
|
||||
|
||||
/** Reset Assign Damage back to how it was at the beginning. */
|
||||
private void resetAssignedDamage() {
|
||||
for(DamageTarget dt : defenders)
|
||||
for (DamageTarget dt : defenders)
|
||||
dt.damage = 0;
|
||||
}
|
||||
|
||||
@@ -398,7 +398,7 @@ public class VAssignCombatDamage {
|
||||
*/
|
||||
private int getRemainingDamage() {
|
||||
int spent = 0;
|
||||
for(DamageTarget dt : defenders) {
|
||||
for (DamageTarget dt : defenders) {
|
||||
spent += dt.damage;
|
||||
}
|
||||
return totalDamageToAssign - spent;
|
||||
@@ -407,11 +407,10 @@ public class VAssignCombatDamage {
|
||||
/** Updates labels and other UI elements.
|
||||
* @param index index of the last assigned damage*/
|
||||
private void updateLabels() {
|
||||
|
||||
int damageLeft = totalDamageToAssign;
|
||||
boolean allHaveLethal = true;
|
||||
|
||||
for ( DamageTarget dt : defenders )
|
||||
for (DamageTarget dt : defenders)
|
||||
{
|
||||
int dmg = dt.damage;
|
||||
damageLeft -= dmg;
|
||||
@@ -438,7 +437,7 @@ public class VAssignCombatDamage {
|
||||
// assigned dynamically, the cards die off and further damage to them can't
|
||||
// be modified.
|
||||
private void finish() {
|
||||
if ( getRemainingDamage() > 0 )
|
||||
if (getRemainingDamage() > 0)
|
||||
return;
|
||||
|
||||
dlg.dispose();
|
||||
@@ -456,8 +455,7 @@ public class VAssignCombatDamage {
|
||||
final CardView pw = (CardView)defender;
|
||||
lethalDamage = Integer.valueOf(pw.getCurrentState().getLoyalty());
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
lethalDamage = Math.max(0, card.getLethalDamage());
|
||||
if (card.getCurrentState().getType().isPlaneswalker()) {
|
||||
lethalDamage = Integer.valueOf(card.getCurrentState().getLoyalty());
|
||||
|
||||
@@ -156,7 +156,7 @@ public class CCombat implements ICDoc {
|
||||
sb.append("( ").append(state.getPower()).append(" / ").append(state.getToughness()).append(" ) ... ");
|
||||
if (c.isFaceDown()) {
|
||||
sb.append("Morph");
|
||||
} else {
|
||||
} else {
|
||||
sb.append(name);
|
||||
}
|
||||
sb.append(" [").append(state.getDisplayId()).append("] ");
|
||||
|
||||
@@ -78,7 +78,6 @@ public class CDetail implements ICDoc {
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -269,7 +269,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
g2d.rotate(getTappedAngle(), cardXOffset + edgeOffset, (cardYOffset + cardHeight)
|
||||
- edgeOffset);
|
||||
}
|
||||
super.paint(g2d);
|
||||
super.paint(g2d);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -284,12 +284,12 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
final int cornerSize = noBorderPref && !cardImgHasAlpha ? 0 : Math.max(4, Math.round(cardWidth * CardPanel.ROUNDED_CORNER_SIZE));
|
||||
final int offset = isTapped() && (!noBorderPref || cardImgHasAlpha) ? 1 : 0;
|
||||
|
||||
// Magenta outline for when card is chosen
|
||||
// Magenta outline for when card is chosen
|
||||
if (matchUI.isUsedToPay(getCard())) {
|
||||
g2d.setColor(Color.magenta);
|
||||
final int n2 = Math.max(1, Math.round(2 * cardWidth * CardPanel.SELECTED_BORDER_SIZE));
|
||||
g2d.fillRoundRect(cardXOffset - n2, (cardYOffset - n2) + offset, cardWidth + (n2 * 2), cardHeight + (n2 * 2), cornerSize + n2, cornerSize + n2);
|
||||
}
|
||||
}
|
||||
|
||||
// Green outline for hover
|
||||
if (isSelected) {
|
||||
@@ -311,24 +311,24 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
final CardStateView state = getCard().getCurrentState();
|
||||
final CardEdition ed = FModel.getMagicDb().getEditions().get(state.getSetCode());
|
||||
boolean colorIsSet = false;
|
||||
if (state.getType().isEmblem() || state.getType().hasStringType("Effect")) {
|
||||
if (getCard().isImmutable()) {
|
||||
// Effects are drawn with orange border
|
||||
g2d.setColor(Color.ORANGE);
|
||||
colorIsSet = true;
|
||||
} else if (ed != null && state.getFoilIndex() == 0) {
|
||||
// Non-foil cards from white-bordered sets are drawn with white border
|
||||
switch (ed.getBorderColor()) {
|
||||
case WHITE:
|
||||
g2d.setColor(Color.WHITE);
|
||||
colorIsSet = true;
|
||||
break;
|
||||
case GOLD:
|
||||
g2d.setColor(Color.ORANGE);
|
||||
colorIsSet = true;
|
||||
break;
|
||||
case SILVER:
|
||||
g2d.setColor(Color.GRAY);
|
||||
colorIsSet = true;
|
||||
case WHITE:
|
||||
g2d.setColor(Color.WHITE);
|
||||
colorIsSet = true;
|
||||
break;
|
||||
case GOLD:
|
||||
g2d.setColor(Color.ORANGE);
|
||||
colorIsSet = true;
|
||||
break;
|
||||
case SILVER:
|
||||
g2d.setColor(Color.GRAY);
|
||||
colorIsSet = true;
|
||||
}
|
||||
}
|
||||
if (colorIsSet) {
|
||||
@@ -337,11 +337,11 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
}
|
||||
}
|
||||
|
||||
if (matchUI.isSelectable(getCard())) { // White border for selectable cards to further highlight them
|
||||
g2d.setColor(Color.WHITE);
|
||||
final int ins = 1;
|
||||
g2d.fillRoundRect(cardXOffset+ins, cardYOffset+ins, cardWidth-ins*2, cardHeight-ins*2, cornerSize-ins, cornerSize-ins);
|
||||
}
|
||||
if (matchUI.isSelectable(getCard())) { // White border for selectable cards to further highlight them
|
||||
g2d.setColor(Color.WHITE);
|
||||
final int ins = 1;
|
||||
g2d.fillRoundRect(cardXOffset+ins, cardYOffset+ins, cardWidth-ins*2, cardHeight-ins*2, cornerSize-ins, cornerSize-ins);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawManaCost(final Graphics g, final ManaCost cost, final int deltaY) {
|
||||
@@ -366,16 +366,16 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
cardWidth, cardHeight, Math.round(cardWidth * BLACK_BORDER_SIZE));
|
||||
}
|
||||
|
||||
boolean nonselectable = matchUI.isSelecting() && !matchUI.isSelectable(getCard());
|
||||
// if selecting, darken non-selectable cards
|
||||
if ( nonselectable ) {
|
||||
boolean noBorderPref = !isPreferenceEnabled(FPref.UI_RENDER_BLACK_BORDERS);
|
||||
boolean cardImgHasAlpha = imagePanel != null && imagePanel.getSrcImage() != null && imagePanel.getSrcImage().getColorModel().hasAlpha();
|
||||
final int cornerSize = noBorderPref && !cardImgHasAlpha ? 0 : Math.max(4, Math.round(cardWidth * CardPanel.ROUNDED_CORNER_SIZE));
|
||||
final int offset = isTapped() && (!noBorderPref || cardImgHasAlpha) ? 1 : 0;
|
||||
g.setColor(new Color(0.0f,0.0f,0.0f,0.6f));
|
||||
g.fillRoundRect(cardXOffset, cardYOffset + offset, cardWidth, cardHeight, cornerSize, cornerSize);
|
||||
}
|
||||
boolean nonselectable = matchUI.isSelecting() && !matchUI.isSelectable(getCard());
|
||||
// if selecting, darken non-selectable cards
|
||||
if (nonselectable) {
|
||||
boolean noBorderPref = !isPreferenceEnabled(FPref.UI_RENDER_BLACK_BORDERS);
|
||||
boolean cardImgHasAlpha = imagePanel != null && imagePanel.getSrcImage() != null && imagePanel.getSrcImage().getColorModel().hasAlpha();
|
||||
final int cornerSize = noBorderPref && !cardImgHasAlpha ? 0 : Math.max(4, Math.round(cardWidth * CardPanel.ROUNDED_CORNER_SIZE));
|
||||
final int offset = isTapped() && (!noBorderPref || cardImgHasAlpha) ? 1 : 0;
|
||||
g.setColor(new Color(0.0f,0.0f,0.0f,0.6f));
|
||||
g.fillRoundRect(cardXOffset, cardYOffset + offset, cardWidth, cardHeight, cornerSize, cornerSize);
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawFoilEffect(final Graphics g, final CardView card2, final int x, final int y, final int width, final int height, final int borderSize) {
|
||||
@@ -390,7 +390,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
|
||||
@Override
|
||||
public final void doLayout() {
|
||||
|
||||
int borderSize = calculateBorderSize();
|
||||
|
||||
final Point imgPos = new Point(cardXOffset + borderSize, cardYOffset + borderSize);
|
||||
@@ -408,7 +407,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
}
|
||||
|
||||
private int calculateBorderSize() {
|
||||
|
||||
// Determine whether to render border from properties
|
||||
boolean noBorderPref = !isPreferenceEnabled(FPref.UI_RENDER_BLACK_BORDERS);
|
||||
|
||||
@@ -426,7 +424,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
private Dimension calculateImageSize() {
|
||||
@@ -491,7 +488,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (card.getCounters() != null && !card.getCounters().isEmpty()) {
|
||||
|
||||
switch (CounterDisplayType.from(FModel.getPreferences().getPref(FPref.UI_CARD_COUNTER_DISPLAY_TYPE))) {
|
||||
@@ -734,8 +730,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
abiY += abiSpace;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
String keywordKey = card.getCurrentState().getKeywordKey();
|
||||
String abilityText = card.getCurrentState().getAbilityText();
|
||||
if (((keywordKey.indexOf("Flashback") == -1)
|
||||
@@ -752,7 +747,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
}
|
||||
|
||||
private void drawCounterTabs(final Graphics g) {
|
||||
|
||||
final Dimension imgSize = calculateImageSize();
|
||||
final int titleY = Math.round(imgSize.height * (54f / 640)) - 15;
|
||||
|
||||
@@ -767,7 +761,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
FontMetrics largeFontMetrics = g.getFontMetrics(largeCounterFont);
|
||||
|
||||
if (CounterDisplayType.from(FModel.getPreferences().getPref(FPref.UI_CARD_COUNTER_DISPLAY_TYPE)) == CounterDisplayType.OLD_WHEN_SMALL) {
|
||||
|
||||
int maxCounters = 0;
|
||||
for (Integer numberOfCounters : card.getCounters().values()) {
|
||||
maxCounters = Math.max(maxCounters, numberOfCounters);
|
||||
@@ -780,9 +773,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
|
||||
}
|
||||
|
||||
|
||||
for (Map.Entry<CounterType, Integer> counterEntry : card.getCounters().entrySet()) {
|
||||
|
||||
final CounterType counter = counterEntry.getKey();
|
||||
final int numberOfCounters = counterEntry.getValue();
|
||||
final int counterBoxRealWidth = counterBoxBaseWidth + largeFontMetrics.stringWidth(String.valueOf(numberOfCounters));
|
||||
@@ -827,7 +818,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
}
|
||||
|
||||
private void drawCounterImage(final Graphics g) {
|
||||
|
||||
int counters = 0;
|
||||
for (final Integer i : card.getCounters().values()) {
|
||||
counters += i;
|
||||
@@ -848,7 +838,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
}
|
||||
|
||||
private void drawMarkersTabs(final Graphics g, List<String> markers) {
|
||||
|
||||
final Dimension imgSize = calculateImageSize();
|
||||
final int titleY = Math.round(imgSize.height * (54f / 640)) - 15;
|
||||
|
||||
@@ -862,7 +851,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
FontMetrics smallFontMetrics = g.getFontMetrics(smallCounterFont);
|
||||
|
||||
for (String marker : markers) {
|
||||
|
||||
final int markerBoxRealWidth = markerBoxBaseWidth + smallFontMetrics.stringWidth(marker);
|
||||
final int markerYOffset;
|
||||
|
||||
@@ -907,7 +895,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
* @param font The font to use to draw the text.
|
||||
*/
|
||||
private void drawVerticallyCenteredString(Graphics g, String text, Rectangle area, Font font, final FontMetrics fontMetrics) {
|
||||
|
||||
Font oldFont = g.getFont();
|
||||
|
||||
int x = area.x;
|
||||
@@ -1114,8 +1101,7 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
}
|
||||
|
||||
private boolean showCardManaCostOverlay() {
|
||||
return isShowingOverlays() &&
|
||||
isPreferenceEnabled(FPref.UI_OVERLAY_CARD_MANA_COST);
|
||||
return isShowingOverlays() && isPreferenceEnabled(FPref.UI_OVERLAY_CARD_MANA_COST);
|
||||
}
|
||||
|
||||
private boolean showCardIdOverlay() {
|
||||
|
||||
@@ -183,7 +183,7 @@ public abstract class CardPanelContainer extends SkinnedPanel {
|
||||
}
|
||||
|
||||
protected boolean cardPanelDraggable(final CardPanel panel) {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
private MouseMotionListener setupMotionMouseListener() {
|
||||
@@ -212,22 +212,22 @@ public abstract class CardPanelContainer extends SkinnedPanel {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cardPanelDraggable(panel)) { // allow for non-draggable cards
|
||||
if (intialMouseDragX == -1) {
|
||||
intialMouseDragX = x;
|
||||
intialMouseDragY = y;
|
||||
return;
|
||||
}
|
||||
if ((Math.abs(x - intialMouseDragX) < CardPanelContainer.DRAG_SMUDGE)
|
||||
&& (Math.abs(y - intialMouseDragY) < CardPanelContainer.DRAG_SMUDGE)) {
|
||||
return;
|
||||
}
|
||||
mouseDownPanel = null;
|
||||
setMouseDragPanel(panel);
|
||||
mouseDragOffsetX = panel.getX() - intialMouseDragX;
|
||||
mouseDragOffsetY = panel.getY() - intialMouseDragY;
|
||||
mouseDragStart(getMouseDragPanel(), evt);
|
||||
}
|
||||
if (cardPanelDraggable(panel)) { // allow for non-draggable cards
|
||||
if (intialMouseDragX == -1) {
|
||||
intialMouseDragX = x;
|
||||
intialMouseDragY = y;
|
||||
return;
|
||||
}
|
||||
if ((Math.abs(x - intialMouseDragX) < CardPanelContainer.DRAG_SMUDGE)
|
||||
&& (Math.abs(y - intialMouseDragY) < CardPanelContainer.DRAG_SMUDGE)) {
|
||||
return;
|
||||
}
|
||||
mouseDownPanel = null;
|
||||
setMouseDragPanel(panel);
|
||||
mouseDragOffsetX = panel.getX() - intialMouseDragX;
|
||||
mouseDragOffsetY = panel.getY() - intialMouseDragY;
|
||||
mouseDragStart(getMouseDragPanel(), evt);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -291,7 +291,7 @@ public abstract class CardPanelContainer extends SkinnedPanel {
|
||||
}
|
||||
|
||||
public final void removeCardPanel(final CardPanel fromPanel) {
|
||||
removeCardPanel(fromPanel,true);
|
||||
removeCardPanel(fromPanel,true);
|
||||
}
|
||||
|
||||
public final void removeCardPanel(final CardPanel fromPanel, final boolean repaint) {
|
||||
@@ -307,11 +307,11 @@ public abstract class CardPanelContainer extends SkinnedPanel {
|
||||
fromPanel.dispose();
|
||||
getCardPanels().remove(fromPanel);
|
||||
remove(fromPanel);
|
||||
if ( repaint ) {
|
||||
invalidate();
|
||||
repaint();
|
||||
doingLayout();
|
||||
}
|
||||
if (repaint) {
|
||||
invalidate();
|
||||
repaint();
|
||||
doingLayout();
|
||||
}
|
||||
}
|
||||
|
||||
public final void setCardPanels(final List<CardPanel> cardPanels) {
|
||||
@@ -331,14 +331,14 @@ public abstract class CardPanelContainer extends SkinnedPanel {
|
||||
for (final CardPanel cardPanel : cardPanels) {
|
||||
this.add(cardPanel);
|
||||
}
|
||||
//pfps the validate just below will do the layout, so don't do it here this.doLayout();
|
||||
//pfps the validate just below will do the layout, so don't do it here this.doLayout();
|
||||
this.invalidate();
|
||||
this.getParent().validate();
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
public final void clear() {
|
||||
clear(true);
|
||||
clear(true);
|
||||
}
|
||||
public final void clear(final boolean repaint) {
|
||||
FThreads.assertExecutedByEdt(true);
|
||||
@@ -347,12 +347,12 @@ public abstract class CardPanelContainer extends SkinnedPanel {
|
||||
}
|
||||
getCardPanels().clear();
|
||||
removeAll();
|
||||
if ( repaint ) {
|
||||
setPreferredSize(new Dimension(0, 0));
|
||||
invalidate();
|
||||
getParent().validate();
|
||||
repaint();
|
||||
}
|
||||
if (repaint) {
|
||||
setPreferredSize(new Dimension(0, 0));
|
||||
invalidate();
|
||||
getParent().validate();
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
public final FScrollPane getScrollPane() {
|
||||
|
||||
@@ -57,10 +57,10 @@ public abstract class FloatingCardArea extends CardArea {
|
||||
protected abstract Iterable<CardView> getCards();
|
||||
|
||||
protected FloatingCardArea(final CMatchUI matchUI) {
|
||||
this(matchUI, new FScrollPane(false, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
|
||||
this(matchUI, new FScrollPane(false, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER));
|
||||
}
|
||||
protected FloatingCardArea(final CMatchUI matchUI, final FScrollPane scrollPane) {
|
||||
super(matchUI, scrollPane);
|
||||
super(matchUI, scrollPane);
|
||||
}
|
||||
|
||||
protected void showWindow() {
|
||||
@@ -127,7 +127,7 @@ public abstract class FloatingCardArea extends CardArea {
|
||||
}
|
||||
|
||||
protected FDialog getWindow() {
|
||||
return window;
|
||||
return window;
|
||||
}
|
||||
|
||||
protected void loadLocation() {
|
||||
|
||||
@@ -624,8 +624,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
|
||||
if (toDelete.size() == getCardPanels().size()) {
|
||||
clear(false);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
for (final CardView card : toDelete) {
|
||||
removeCardPanel(getCardPanel(card.getId()),false);
|
||||
}
|
||||
@@ -649,9 +648,9 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
needLayoutRefresh = true;
|
||||
}
|
||||
}
|
||||
if (needLayoutRefresh) {
|
||||
doLayout();
|
||||
}
|
||||
if (needLayoutRefresh) {
|
||||
doLayout();
|
||||
}
|
||||
|
||||
invalidate(); //pfps do the extra invalidate before any scrolling
|
||||
if (!newPanels.isEmpty()) {
|
||||
@@ -681,8 +680,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
if (card.isTapped()) {
|
||||
toPanel.setTapped(true);
|
||||
toPanel.setTappedAngle(forge.view.arcane.CardPanel.TAPPED_ANGLE);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
toPanel.setTapped(false);
|
||||
toPanel.setTappedAngle(0);
|
||||
}
|
||||
@@ -705,8 +703,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
CardPanel attachedToPanel;
|
||||
if (card.getAttachedTo() != null) {
|
||||
attachedToPanel = getCardPanel(card.getAttachedTo().getId());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
attachedToPanel = null;
|
||||
}
|
||||
if (toPanel.getAttachedToPanel() != attachedToPanel) {
|
||||
|
||||
@@ -103,8 +103,6 @@ public class ScaledImagePanel extends JPanel {
|
||||
if (src == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
//System.out.println(sz + " -- " + src);
|
||||
|
||||
//ResampleOp resizer = new ResampleOp(DimensionConstrain.createMaxDimension(this.getWidth(), this.getHeight(), !scaleLarger));
|
||||
//resizer.setUnsharpenMask(UnsharpenMask.Soft);
|
||||
@@ -112,10 +110,7 @@ public class ScaledImagePanel extends JPanel {
|
||||
|
||||
boolean needsScale = img.getWidth() < sz.width;
|
||||
float scaleFactor = ((float)img.getWidth()) / sz.width;
|
||||
if ( needsScale && ( scaleFactor < 0.95 || scaleFactor > 1.05 ) ) { // This should very low-quality scaling to draw during animation
|
||||
|
||||
//System.out.println("Painting: " + img.getWidth() + " -> " + sz.width );
|
||||
|
||||
if (needsScale && ( scaleFactor < 0.95 || scaleFactor > 1.05 )) { // This should very low-quality scaling to draw during animation
|
||||
float maxZoomX = ((float)sz.width) / img.getWidth();
|
||||
float maxZoomY = ((float)sz.height) / img.getHeight();
|
||||
float zoom = Math.min(maxZoomX, maxZoomY);
|
||||
|
||||
Reference in New Issue
Block a user