better way to schedule visual updates to non-selectable cards

This commit is contained in:
Peter F. Patel-Schneider
2019-01-27 21:09:52 -05:00
parent 70f0f1108b
commit 25003aa74e
3 changed files with 46 additions and 5 deletions

View File

@@ -524,6 +524,45 @@ 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() {
@Override public final void run() {
for (final PlayerView p : getGameView().getPlayers()) {
if ( p.getCards(ZoneType.Battlefield) != null ) {
updateCards(p.getCards(ZoneType.Battlefield));
}
if ( p.getCards(ZoneType.Hand) != null ) {
updateCards(p.getCards(ZoneType.Hand));
}
}
FloatingZone.refreshAll();
}
});
}
@Override
public void clearSelectables() {
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 ) {
updateCards(p.getCards(ZoneType.Battlefield));
}
if ( p.getCards(ZoneType.Hand) != null ) {
updateCards(p.getCards(ZoneType.Hand));
}
}
FloatingZone.refreshAll();
}
});
}
@Override @Override
public List<JMenu> getMenus() { public List<JMenu> getMenus() {
return menus.getMenus(); return menus.getMenus();

View File

@@ -335,11 +335,9 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
cardWidth, cardHeight, Math.round(cardWidth * BLACK_BORDER_SIZE)); cardWidth, cardHeight, Math.round(cardWidth * BLACK_BORDER_SIZE));
} }
System.out.println("Painting " + getCard() + " selecting " + matchUI.isSelecting());
boolean nonselectable = matchUI.isSelecting() && !matchUI.isSelectable(getCard()); boolean nonselectable = matchUI.isSelecting() && !matchUI.isSelectable(getCard());
// if selecting, darken non-selectable cards - pfps - needs fixes to refreshing to do right // if selecting, darken non-selectable cards
if ( nonselectable ) { if ( nonselectable ) {
System.out.println("Paint nonselectable " + card);
boolean noBorderPref = !isPreferenceEnabled(FPref.UI_RENDER_BLACK_BORDERS); boolean noBorderPref = !isPreferenceEnabled(FPref.UI_RENDER_BLACK_BORDERS);
boolean cardImgHasAlpha = imagePanel != null && imagePanel.getSrcImage() != null && imagePanel.getSrcImage().getColorModel().hasAlpha(); 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 cornerSize = noBorderPref && !cardImgHasAlpha ? 0 : Math.max(4, Math.round(cardWidth * CardPanel.ROUNDED_CORNER_SIZE));
@@ -373,7 +371,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
final boolean canShow = matchUI.mayView(card); final boolean canShow = matchUI.mayView(card);
final boolean showText = !imagePanel.hasImage() || !isAnimationPanel; final boolean showText = !imagePanel.hasImage() || !isAnimationPanel;
System.out.println("doLayout " + card);
displayCardNameOverlay(showText && canShow && showCardNameOverlay(), imgSize, imgPos); displayCardNameOverlay(showText && canShow && showCardNameOverlay(), imgSize, imgPos);
displayPTOverlay(showText && (canShow || card.isFaceDown()) && showCardPowerOverlay(), imgSize, imgPos); displayPTOverlay(showText && (canShow || card.isFaceDown()) && showCardPowerOverlay(), imgSize, imgPos);
displayCardIdOverlay(showText && canShow && showCardIdOverlay(), imgSize, imgPos); displayCardIdOverlay(showText && canShow && showCardIdOverlay(), imgSize, imgPos);

View File

@@ -94,6 +94,11 @@ public class FloatingZone extends FloatingCardArea {
} }
floatingAreas.clear(); floatingAreas.clear();
} }
public static void refreshAll() {
for (final FloatingZone cardArea : floatingAreas.values()) {
cardArea.refresh();
}
}
private final ZoneType zone; private final ZoneType zone;
private PlayerView player; private PlayerView player;