mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
[Mobile] add zoom view for mutated cards
This commit is contained in:
@@ -80,6 +80,7 @@ public class MutateEffect extends SpellAbilityEffect {
|
||||
host.setTapped(target.isTapped());
|
||||
host.setFlipped(target.isFlipped());
|
||||
target.setTimesMutated(target.getTimesMutated() + 1);
|
||||
target.updateStateForView();
|
||||
target.updateTokenView();
|
||||
if (host.isCommander()) {
|
||||
host.getOwner().updateMergedCommanderInfo(target, host);
|
||||
|
||||
@@ -330,6 +330,10 @@ public class CardView extends GameEntityView {
|
||||
set(TrackableProperty.ChosenColors, c.getChosenColors());
|
||||
}
|
||||
|
||||
public FCollectionView<CardView> getMergedCardsCollection() {
|
||||
return get(TrackableProperty.MergedCardsCollection);
|
||||
}
|
||||
|
||||
public FCollectionView<CardView> getChosenCards() {
|
||||
return get(TrackableProperty.ChosenCards);
|
||||
}
|
||||
@@ -433,6 +437,7 @@ public class CardView extends GameEntityView {
|
||||
//cards in these zones are visible to all
|
||||
return true;
|
||||
case Exile:
|
||||
case Merged:
|
||||
//in exile, only face up cards and face down cards you can look at should be shown (since "exile face down" is a thing)
|
||||
if (!isFaceDown()) {
|
||||
return true;
|
||||
@@ -786,6 +791,7 @@ public class CardView extends GameEntityView {
|
||||
//CardStateView cloner = CardView.getState(c, CardStateName.Cloner);
|
||||
set(TrackableProperty.Cloner, cloner == null ? null : cloner.getName() + " (" + cloner.getId() + ")");
|
||||
|
||||
CardCollection mergedCollection = new CardCollection();
|
||||
if (c.hasMergedCard()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
CardCollectionView mergedCards = c.getMergedCards();
|
||||
@@ -796,7 +802,19 @@ public class CardView extends GameEntityView {
|
||||
sb.append(" (").append(card.getId()).append(")");
|
||||
}
|
||||
set(TrackableProperty.MergedCards, sb.toString());
|
||||
for (int i = 0; i < mergedCards.size(); i++) {
|
||||
final Card card = mergedCards.get(i);
|
||||
if (i == 0) { //get the original view of the top card
|
||||
if (!card.isFaceDown())
|
||||
mergedCollection.add(Card.getCardForUi(c.getPaperCard()));
|
||||
else
|
||||
mergedCollection.add(card);
|
||||
} else {
|
||||
mergedCollection.add(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
updateMergeCollections(mergedCollection);
|
||||
|
||||
CardState currentState = c.getCurrentState();
|
||||
if (isSplitCard) {
|
||||
@@ -1407,4 +1425,18 @@ public class CardView extends GameEntityView {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
void updateMergeCollections(CardCollection cards) {
|
||||
TrackableCollection<CardView> views = get(TrackableProperty.MergedCardsCollection);
|
||||
if (views == null) {
|
||||
views = new TrackableCollection<>();
|
||||
set(TrackableProperty.MergedCardsCollection, views);
|
||||
} else {
|
||||
views.clear();
|
||||
}
|
||||
if (cards != null) {
|
||||
for (Card c : cards)
|
||||
views.add(c.getView());
|
||||
}
|
||||
flagAsChanged(TrackableProperty.MergedCardsCollection);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ public enum TrackableProperty {
|
||||
FlipCard(TrackableTypes.BooleanType),
|
||||
SplitCard(TrackableTypes.BooleanType),
|
||||
MergedCards(TrackableTypes.StringType),
|
||||
MergedCardsCollection(TrackableTypes.CardViewCollectionType, FreezeMode.IgnoresFreeze),
|
||||
|
||||
Attacking(TrackableTypes.BooleanType),
|
||||
Blocking(TrackableTypes.BooleanType),
|
||||
|
||||
@@ -45,8 +45,10 @@ public class CardZoom extends FOverlay {
|
||||
private static ActivateHandler activateHandler;
|
||||
private static String currentActivateAction;
|
||||
private static Rectangle flipIconBounds;
|
||||
private static Rectangle mutateIconBounds;
|
||||
private static boolean showAltState;
|
||||
private static boolean showBackSide = false;
|
||||
private static boolean showMerged = false;
|
||||
|
||||
public static void show(Object item) {
|
||||
show(item, false);
|
||||
@@ -116,6 +118,7 @@ public class CardZoom extends FOverlay {
|
||||
}
|
||||
|
||||
private static void onCardChanged() {
|
||||
mutateIconBounds = null;
|
||||
if (activateHandler != null) {
|
||||
currentActivateAction = activateHandler.getActivateAction(currentIndex);
|
||||
}
|
||||
@@ -124,6 +127,11 @@ public class CardZoom extends FOverlay {
|
||||
} else {
|
||||
flipIconBounds = null;
|
||||
}
|
||||
if (currentCard != null) {
|
||||
if (currentCard.getMergedCardsCollection() != null )
|
||||
if (currentCard.getMergedCardsCollection().size() > 0)
|
||||
mutateIconBounds = new Rectangle();
|
||||
}
|
||||
showAltState = false;
|
||||
}
|
||||
|
||||
@@ -162,6 +170,15 @@ public class CardZoom extends FOverlay {
|
||||
|
||||
@Override
|
||||
public boolean tap(float x, float y, int count) {
|
||||
if (mutateIconBounds != null && mutateIconBounds.contains(x, y)) {
|
||||
if(showMerged) {
|
||||
showMerged = false;
|
||||
} else {
|
||||
showMerged = true;
|
||||
show(currentCard.getMergedCardsCollection(), 0, null);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (flipIconBounds != null && flipIconBounds.contains(x, y)) {
|
||||
if (!showBackSide)
|
||||
showAltState = !showAltState;
|
||||
@@ -172,6 +189,7 @@ public class CardZoom extends FOverlay {
|
||||
hide();
|
||||
showBackSide = false;
|
||||
showAltState = false;
|
||||
showMerged = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -303,17 +321,22 @@ public class CardZoom extends FOverlay {
|
||||
CardImageRenderer.drawDetails(g, currentCard, gameView, showBackSide? showBackSide : showAltState, x, y, cardWidth, cardHeight);
|
||||
}
|
||||
|
||||
if (flipIconBounds != null) {
|
||||
float imageWidth = cardWidth / 2;
|
||||
if (Forge.hdbuttons){
|
||||
float imageHeight = imageWidth * FSkinImage.HDFLIPCARD.getHeight() / FSkinImage.HDFLIPCARD.getWidth();
|
||||
flipIconBounds.set(x + (cardWidth - imageWidth) / 2, y + (cardHeight - imageHeight) / 2, imageWidth, imageHeight);
|
||||
g.drawImage(FSkinImage.HDFLIPCARD, flipIconBounds.x, flipIconBounds.y, flipIconBounds.width, flipIconBounds.height);
|
||||
} else {
|
||||
float imageHeight = imageWidth * FSkinImage.FLIPCARD.getHeight() / FSkinImage.FLIPCARD.getWidth();
|
||||
flipIconBounds.set(x + (cardWidth - imageWidth) / 2, y + (cardHeight - imageHeight) / 2, imageWidth, imageHeight);
|
||||
g.drawImage(FSkinImage.FLIPCARD, flipIconBounds.x, flipIconBounds.y, flipIconBounds.width, flipIconBounds.height);
|
||||
if (!showMerged) {
|
||||
if (mutateIconBounds != null) {
|
||||
float oldAlpha = g.getfloatAlphaComposite();
|
||||
try {
|
||||
g.setAlphaComposite(0.6f);
|
||||
drawIconBounds(g, mutateIconBounds, Forge.hdbuttons ? FSkinImage.HDLIBRARY : FSkinImage.LIBRARY, x, y, cardWidth, cardHeight);
|
||||
g.setAlphaComposite(oldAlpha);
|
||||
} catch (Exception e) {
|
||||
mutateIconBounds = null;
|
||||
g.setAlphaComposite(oldAlpha);
|
||||
}
|
||||
} else if (flipIconBounds != null) {
|
||||
drawIconBounds(g, flipIconBounds, Forge.hdbuttons ? FSkinImage.HDFLIPCARD : FSkinImage.FLIPCARD, x, y, cardWidth, cardHeight);
|
||||
}
|
||||
} else if (flipIconBounds != null) {
|
||||
drawIconBounds(g, flipIconBounds, Forge.hdbuttons ? FSkinImage.HDFLIPCARD : FSkinImage.FLIPCARD, x, y, cardWidth, cardHeight);
|
||||
}
|
||||
|
||||
if (currentActivateAction != null) {
|
||||
@@ -326,6 +349,13 @@ public class CardZoom extends FOverlay {
|
||||
interrupt(false);
|
||||
}
|
||||
|
||||
private void drawIconBounds(Graphics g, Rectangle iconBounds, FSkinImage skinImage, float x, float y, float cardWidth, float cardHeight) {
|
||||
float imageWidth = cardWidth / 2;
|
||||
float imageHeight = imageWidth * skinImage.getHeight() / skinImage.getWidth();
|
||||
iconBounds.set(x + (cardWidth - imageWidth) / 2, y + (cardHeight - imageHeight) / 2, imageWidth, imageHeight);
|
||||
g.drawImage(skinImage, iconBounds.x, iconBounds.y, iconBounds.width, iconBounds.height);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doLayout(float width, float height) {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user