From 11f9520c1e9d645479a65bd18718db0606be800e Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Thu, 17 Jan 2019 09:35:52 -0500 Subject: [PATCH] Highlight sa targets in Desktop GUI --- [Help | 0 .../input/InputSelectEntitiesFromList.java | 17 ++++++++------- .../forge/match/input/InputSelectTargets.java | 21 +++++++++++++++++++ 3 files changed, 30 insertions(+), 8 deletions(-) delete mode 100644 [Help diff --git a/[Help b/[Help deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/forge-gui/src/main/java/forge/match/input/InputSelectEntitiesFromList.java b/forge-gui/src/main/java/forge/match/input/InputSelectEntitiesFromList.java index 6900ce5fed9..ecc85ed7409 100644 --- a/forge-gui/src/main/java/forge/match/input/InputSelectEntitiesFromList.java +++ b/forge-gui/src/main/java/forge/match/input/InputSelectEntitiesFromList.java @@ -33,8 +33,16 @@ public class InputSelectEntitiesFromList extends InputSele public InputSelectEntitiesFromList(final PlayerControllerHuman controller, final int min, final int max, final FCollectionView validChoices0, final SpellAbility sa0) { super(controller, Math.min(min, validChoices0.size()), Math.min(max, validChoices0.size()),sa0); validChoices = validChoices0; - if (min > validChoices.size()) { + if (min > validChoices.size()) { // pfps does this really do anything useful?? + System.out.println(String.format("Trying to choose at least %d things from a list with only %d things!", min, validChoices.size())); } + ArrayList vCards = new ArrayList(); + for ( T c : validChoices0 ) { + if ( c instanceof Card ) { + vCards.add(((Card)c).getView()) ; + } + } + controller.getGui().setSelectables(vCards); final PlayerZoneUpdates zonesToUpdate = new PlayerZoneUpdates(); for (final GameEntity c : validChoices) { final Zone cz = (c instanceof Card) ? ((Card) c).getZone() : null ; @@ -46,13 +54,6 @@ public class InputSelectEntitiesFromList extends InputSele zonesShown = controller.getGui().tempShowZones(controller.getPlayer().getView(),zonesToUpdate); } }); - ArrayList vCards = new ArrayList(); - for ( T c : validChoices0 ) { - if ( c instanceof Card ) { - vCards.add(((Card)c).getView()) ; - } - } - controller.getGui().setSelectables(vCards); } @Override diff --git a/forge-gui/src/main/java/forge/match/input/InputSelectTargets.java b/forge-gui/src/main/java/forge/match/input/InputSelectTargets.java index e7f131aeb2a..c3aa5f6cef8 100644 --- a/forge-gui/src/main/java/forge/match/input/InputSelectTargets.java +++ b/forge-gui/src/main/java/forge/match/input/InputSelectTargets.java @@ -22,6 +22,9 @@ import forge.properties.ForgeConstants; import forge.properties.ForgePreferences; import forge.util.ITriggerEvent; import forge.util.TextUtil; +import forge.player.PlayerZoneUpdate; +import forge.player.PlayerZoneUpdates; +import forge.FThreads; public final class InputSelectTargets extends InputSyncronizedBase { private final List choices; @@ -44,6 +47,16 @@ public final class InputSelectTargets extends InputSyncronizedBase { this.tgt = sa.getTargetRestrictions(); this.sa = sa; this.mandatory = mandatory; + controller.getGui().setSelectables(CardView.getCollection(choices)); + final PlayerZoneUpdates zonesToUpdate = new PlayerZoneUpdates(); + for (final Card c : choices) { + zonesToUpdate.add(new PlayerZoneUpdate(c.getZone().getPlayer().getView(),c.getZone().getZoneType())); + } + FThreads.invokeInEdtNowOrLater(new Runnable() { + @Override public void run() { + controller.getGui().updateZones(zonesToUpdate); + } + }); } @Override @@ -297,4 +310,12 @@ public final class InputSelectTargets extends InputSyncronizedBase { private boolean hasAllTargets() { return tgt.isMaxTargetsChosen(sa.getHostCard(), sa) || ( tgt.getStillToDivide() == 0 && tgt.isDividedAsYouChoose()); } + + + @Override + protected void onStop() { + getController().getGui().clearSelectables(); + super.onStop(); + } + }