- Targeting Overlay: Card mouseover mode fixed and enabled, should work fine and should show only the targeting arrows (both combat and non-combat) for the card the mouse is hovering over.

This commit is contained in:
Agetian
2012-11-25 11:36:35 +00:00
parent 98825de96c
commit 7846036229
2 changed files with 90 additions and 42 deletions

View File

@@ -61,7 +61,7 @@ public enum TargetingOverlay {
private final List<CardPanel> cardPanels = new ArrayList<CardPanel>();
private final List<Point[]> arcs = new ArrayList<Point[]>();
private Rectangle rectMouseOver = null;
private CardPanel activePanel = null;
/**
* Semi-transparent overlay panel. Should be used with layered panes.
@@ -84,19 +84,19 @@ public enum TargetingOverlay {
cardPanels.clear();
List<VField> fields = VMatchUI.SINGLETON_INSTANCE.getFieldViews();
rectMouseOver = null;
switch (CDock.SINGLETON_INSTANCE.getArcState()) {
case 0:
return;
case 1:
// Draw only hovered card
activePanel = null;
for (CField f : CMatchUI.SINGLETON_INSTANCE.getFieldControls()) {
cardPanels.addAll(f.getView().getTabletop().getCardPanels());
}
for (VField f : fields) {
if (f.getTabletop().getCardFromMouseOverPanel() != null) {
rectMouseOver = f.getTabletop().getMouseOverPanel().getVisibleRect();
activePanel = f.getTabletop().getMouseOverPanel();
break;
}
}
@@ -122,9 +122,72 @@ public enum TargetingOverlay {
List<Card> temp = new ArrayList<Card>();
if (CDock.SINGLETON_INSTANCE.getArcState() == 1) {
// Only work with the active panel
if (activePanel == null) { return; }
Card c = activePanel.getCard();
Card enchanting = c.getEnchantingCard();
List<Card> enchantedBy = c.getEnchantedBy();
List<Card> blocking = c.getBlockedThisTurn();
List<Card> blockedBy = c.getBlockedByThisTurn();
if (null != enchanting) {
if (!enchanting.getController().equals(c.getController())) {
arcs.add(new Point[] {
endpoints.get(enchanting.getUniqueNumber()),
endpoints.get(c.getUniqueNumber())
});
}
}
if (null != enchantedBy) {
for (Card enc : enchantedBy) {
if (!enc.getController().equals(c.getController())) {
arcs.add(new Point[] {
endpoints.get(c.getUniqueNumber()),
endpoints.get(enc.getUniqueNumber())
});
}
}
}
for (Card attackingCard : Singletons.getModel().getGame().getCombat().getAttackers()) {
temp = Singletons.getModel().getGame().getCombat().getBlockers(attackingCard);
for (Card blockingCard : temp) {
if (!attackingCard.equals(c) && !blockingCard.equals(c)) { continue; }
arcs.add(new Point[] {
endpoints.get(attackingCard.getUniqueNumber()),
endpoints.get(blockingCard.getUniqueNumber())
});
}
}
if (null != blocking) {
for (Card b : blocking) {
arcs.add(new Point[]{
endpoints.get(c.getUniqueNumber()),
endpoints.get(b.getUniqueNumber())
});
}
}
if (null != blockedBy) {
for (Card b : blockedBy) {
arcs.add(new Point[]{
endpoints.get(c.getUniqueNumber()),
endpoints.get(b.getUniqueNumber())
});
}
}
} else {
// Work with all card panels currently visible
// Global cards
for (CardPanel c : cardPanels) {
if (!c.isShowing()) { continue; }
if (!c.isShowing()) {
continue;
}
// Enchantments
Card enchanting = c.getCard().getEnchantingCard();
@@ -132,7 +195,7 @@ public enum TargetingOverlay {
if (enchanting.getController().equals(c.getCard().getController())) {
continue;
}
arcs.add(new Point[] {
arcs.add(new Point[]{
endpoints.get(enchanting.getUniqueNumber()),
endpoints.get(c.getCard().getUniqueNumber())
});
@@ -143,12 +206,13 @@ public enum TargetingOverlay {
for (Card attackingCard : Singletons.getModel().getGame().getCombat().getAttackers()) {
temp = Singletons.getModel().getGame().getCombat().getBlockers(attackingCard);
for (Card blockingCard : temp) {
arcs.add(new Point[] {
arcs.add(new Point[]{
endpoints.get(attackingCard.getUniqueNumber()),
endpoints.get(blockingCard.getUniqueNumber())
});
}
}
}
temp.clear();
endpoints.clear();
@@ -253,12 +317,6 @@ public enum TargetingOverlay {
continue;
}
if (rectMouseOver != null) {
if ( !rectMouseOver.contains(p[0]) ) {
continue;
}
}
int endX = (int)p[0].getX();
int endY = (int)p[0].getY();
int startX = (int)p[1].getX();

View File

@@ -205,19 +205,9 @@ public enum CDock implements ICDoc {
/** Toggle targeting overlay painting. */
public void toggleTargeting() {
//arcState++;
arcState++;
//if (arcState == 3) { arcState = 0; }
// TODO: This code currently skips the "mouse-over only" mode at
// (arcState == 1). If that mode is ever implemented correctly,
// the "if" block below may be removed and the code above (the
// original code which wraps at (arcState == 3) may be enabled.
if (arcState == 0) {
arcState = 2;
} else {
arcState = 0;
}
if (arcState == 3) { arcState = 0; }
refreshArcStateDisplay();
FView.SINGLETON_INSTANCE.getFrame().repaint(); // repaint the match UI