mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
Fix (hopefully) attack icons on cards and a possible NPE.
This commit is contained in:
@@ -11,7 +11,6 @@ import java.net.URI;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JPopupMenu;
|
||||
@@ -440,7 +439,7 @@ public class GuiDesktop implements IGuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCards(final Set<CardView> cardsToUpdate) {
|
||||
public void updateCards(final Iterable<CardView> cardsToUpdate) {
|
||||
CMatchUI.SINGLETON_INSTANCE.updateCards(cardsToUpdate);
|
||||
}
|
||||
|
||||
|
||||
@@ -388,7 +388,7 @@ public enum CMatchUI implements ICDoc, IMenuProvider {
|
||||
|
||||
}
|
||||
|
||||
public void updateCards(final Set<CardView> cardsToUpdate) {
|
||||
public void updateCards(final Iterable<CardView> cardsToUpdate) {
|
||||
for (final CardView c : cardsToUpdate) {
|
||||
updateSingleCard(c);
|
||||
}
|
||||
|
||||
@@ -386,7 +386,6 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
displayCardNameOverlay(showText && showCardNameOverlay(), imgSize, imgPos);
|
||||
displayPTOverlay(showText && showCardPowerOverlay(), imgSize, imgPos);
|
||||
displayCardIdOverlay(showText && showCardIdOverlay(), imgSize, imgPos);
|
||||
displayIconOverlay(getGraphics());
|
||||
}
|
||||
|
||||
private void displayCardIdOverlay(boolean isVisible, Dimension imgSize, Point imgPos) {
|
||||
@@ -656,11 +655,9 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.card != cardView) {
|
||||
this.updatePTOverlay(); //update PT Overlay if card changes
|
||||
}
|
||||
|
||||
this.card = cardView;
|
||||
this.doLayout();
|
||||
|
||||
if (!this.isShowing()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -707,7 +707,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
|
||||
toPanel.setAttachedToPanel(null);
|
||||
}
|
||||
|
||||
toPanel.setCard(toPanel.getCard());
|
||||
toPanel.setCard(card);
|
||||
if (fromRefresh) {
|
||||
toPanel.updatePTOverlay(); //ensure PT Overlay updated on refresh
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -391,7 +390,7 @@ public class GuiMobile implements IGuiBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCards(Set<CardView> cardsToUpdate) {
|
||||
public void updateCards(Iterable<CardView> cardsToUpdate) {
|
||||
FControl.updateCards(cardsToUpdate);
|
||||
}
|
||||
|
||||
|
||||
@@ -446,7 +446,7 @@ public class FControl {
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateCards(Set<CardView> cardsToUpdate) {
|
||||
public static void updateCards(Iterable<CardView> cardsToUpdate) {
|
||||
for (CardView c : cardsToUpdate) {
|
||||
updateSingleCard(c);
|
||||
}
|
||||
|
||||
@@ -271,7 +271,8 @@ public class FControlGameEventHandler extends IGameEventVisitor.Base<Void> {
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (cardsToUpdate) {
|
||||
gui.updateCards(cardsToUpdate);
|
||||
final Iterable<CardView> newCardsToUpdate = gameView.getRefreshedCardViews(cardsToUpdate);
|
||||
gui.updateCards(newCardsToUpdate);
|
||||
cardsToUpdate.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -76,7 +75,7 @@ public interface IGuiBase {
|
||||
void restoreOldZones(Map<PlayerView, Object> playersToRestoreZonesFor);
|
||||
void updateStack();
|
||||
void updateZones(List<Pair<PlayerView, ZoneType>> zonesToUpdate);
|
||||
void updateCards(Set<CardView> cardsToUpdate);
|
||||
void updateCards(Iterable<CardView> cardsToUpdate);
|
||||
void refreshCardDetails(Iterable<CardView> cards);
|
||||
void updateManaPool(List<PlayerView> manaPoolUpdate);
|
||||
void updateLives(List<PlayerView> livesUpdate);
|
||||
|
||||
@@ -31,6 +31,22 @@ public class Cache<K, V> {
|
||||
return inverseCache.get(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a value as it is present in this Cache, compared using the equals
|
||||
* method.
|
||||
*
|
||||
* @param value
|
||||
* @return a value equal to value, if such a value is present in the Cache.
|
||||
*/
|
||||
public synchronized V getValue(final V value) {
|
||||
for (final V currentValue : inverseCache.keySet()) {
|
||||
if (currentValue.equals(value)) {
|
||||
return currentValue;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key
|
||||
* @param value
|
||||
|
||||
@@ -426,6 +426,15 @@ public abstract class LocalGameView implements IGameView {
|
||||
return ViewUtil.transformIfNotNull(cards, FN_GET_CARD_VIEW);
|
||||
}
|
||||
|
||||
public final List<CardView> getRefreshedCardViews(final Iterable<CardView> cardViews) {
|
||||
return ViewUtil.transformIfNotNull(cardViews, new Function<CardView, CardView>() {
|
||||
@Override
|
||||
public CardView apply(CardView input) {
|
||||
return cards.getValue(input);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private CardView getCardViewFast(final Card c) {
|
||||
if (c == null) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user