mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
- 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:
@@ -61,7 +61,7 @@ public enum TargetingOverlay {
|
|||||||
private final List<CardPanel> cardPanels = new ArrayList<CardPanel>();
|
private final List<CardPanel> cardPanels = new ArrayList<CardPanel>();
|
||||||
private final List<Point[]> arcs = new ArrayList<Point[]>();
|
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.
|
* Semi-transparent overlay panel. Should be used with layered panes.
|
||||||
@@ -84,19 +84,19 @@ public enum TargetingOverlay {
|
|||||||
cardPanels.clear();
|
cardPanels.clear();
|
||||||
|
|
||||||
List<VField> fields = VMatchUI.SINGLETON_INSTANCE.getFieldViews();
|
List<VField> fields = VMatchUI.SINGLETON_INSTANCE.getFieldViews();
|
||||||
rectMouseOver = null;
|
|
||||||
|
|
||||||
switch (CDock.SINGLETON_INSTANCE.getArcState()) {
|
switch (CDock.SINGLETON_INSTANCE.getArcState()) {
|
||||||
case 0:
|
case 0:
|
||||||
return;
|
return;
|
||||||
case 1:
|
case 1:
|
||||||
// Draw only hovered card
|
// Draw only hovered card
|
||||||
|
activePanel = null;
|
||||||
for (CField f : CMatchUI.SINGLETON_INSTANCE.getFieldControls()) {
|
for (CField f : CMatchUI.SINGLETON_INSTANCE.getFieldControls()) {
|
||||||
cardPanels.addAll(f.getView().getTabletop().getCardPanels());
|
cardPanels.addAll(f.getView().getTabletop().getCardPanels());
|
||||||
}
|
}
|
||||||
for (VField f : fields) {
|
for (VField f : fields) {
|
||||||
if (f.getTabletop().getCardFromMouseOverPanel() != null) {
|
if (f.getTabletop().getCardFromMouseOverPanel() != null) {
|
||||||
rectMouseOver = f.getTabletop().getMouseOverPanel().getVisibleRect();
|
activePanel = f.getTabletop().getMouseOverPanel();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,31 +122,95 @@ public enum TargetingOverlay {
|
|||||||
|
|
||||||
List<Card> temp = new ArrayList<Card>();
|
List<Card> temp = new ArrayList<Card>();
|
||||||
|
|
||||||
// Global cards
|
if (CDock.SINGLETON_INSTANCE.getArcState() == 1) {
|
||||||
for (CardPanel c : cardPanels) {
|
// Only work with the active panel
|
||||||
if (!c.isShowing()) { continue; }
|
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();
|
||||||
|
|
||||||
// Enchantments
|
if (null != enchanting) {
|
||||||
Card enchanting = c.getCard().getEnchantingCard();
|
if (!enchanting.getController().equals(c.getController())) {
|
||||||
if (enchanting != null) {
|
arcs.add(new Point[] {
|
||||||
if (enchanting.getController().equals(c.getCard().getController())) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
arcs.add(new Point[] {
|
|
||||||
endpoints.get(enchanting.getUniqueNumber()),
|
|
||||||
endpoints.get(c.getCard().getUniqueNumber())
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Combat cards
|
// Enchantments
|
||||||
for (Card attackingCard : Singletons.getModel().getGame().getCombat().getAttackers()) {
|
Card enchanting = c.getCard().getEnchantingCard();
|
||||||
temp = Singletons.getModel().getGame().getCombat().getBlockers(attackingCard);
|
if (enchanting != null) {
|
||||||
for (Card blockingCard : temp) {
|
if (enchanting.getController().equals(c.getCard().getController())) {
|
||||||
arcs.add(new Point[] {
|
continue;
|
||||||
endpoints.get(attackingCard.getUniqueNumber()),
|
}
|
||||||
endpoints.get(blockingCard.getUniqueNumber())
|
arcs.add(new Point[]{
|
||||||
});
|
endpoints.get(enchanting.getUniqueNumber()),
|
||||||
|
endpoints.get(c.getCard().getUniqueNumber())
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Combat cards
|
||||||
|
for (Card attackingCard : Singletons.getModel().getGame().getCombat().getAttackers()) {
|
||||||
|
temp = Singletons.getModel().getGame().getCombat().getBlockers(attackingCard);
|
||||||
|
for (Card blockingCard : temp) {
|
||||||
|
arcs.add(new Point[]{
|
||||||
|
endpoints.get(attackingCard.getUniqueNumber()),
|
||||||
|
endpoints.get(blockingCard.getUniqueNumber())
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,12 +317,6 @@ public enum TargetingOverlay {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rectMouseOver != null) {
|
|
||||||
if ( !rectMouseOver.contains(p[0]) ) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int endX = (int)p[0].getX();
|
int endX = (int)p[0].getX();
|
||||||
int endY = (int)p[0].getY();
|
int endY = (int)p[0].getY();
|
||||||
int startX = (int)p[1].getX();
|
int startX = (int)p[1].getX();
|
||||||
|
|||||||
@@ -205,19 +205,9 @@ public enum CDock implements ICDoc {
|
|||||||
|
|
||||||
/** Toggle targeting overlay painting. */
|
/** Toggle targeting overlay painting. */
|
||||||
public void toggleTargeting() {
|
public void toggleTargeting() {
|
||||||
//arcState++;
|
arcState++;
|
||||||
|
|
||||||
//if (arcState == 3) { arcState = 0; }
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
refreshArcStateDisplay();
|
refreshArcStateDisplay();
|
||||||
FView.SINGLETON_INSTANCE.getFrame().repaint(); // repaint the match UI
|
FView.SINGLETON_INSTANCE.getFrame().repaint(); // repaint the match UI
|
||||||
|
|||||||
Reference in New Issue
Block a user