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.setTapped(target.isTapped());
|
||||||
host.setFlipped(target.isFlipped());
|
host.setFlipped(target.isFlipped());
|
||||||
target.setTimesMutated(target.getTimesMutated() + 1);
|
target.setTimesMutated(target.getTimesMutated() + 1);
|
||||||
|
target.updateStateForView();
|
||||||
target.updateTokenView();
|
target.updateTokenView();
|
||||||
if (host.isCommander()) {
|
if (host.isCommander()) {
|
||||||
host.getOwner().updateMergedCommanderInfo(target, host);
|
host.getOwner().updateMergedCommanderInfo(target, host);
|
||||||
|
|||||||
@@ -330,6 +330,10 @@ public class CardView extends GameEntityView {
|
|||||||
set(TrackableProperty.ChosenColors, c.getChosenColors());
|
set(TrackableProperty.ChosenColors, c.getChosenColors());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FCollectionView<CardView> getMergedCardsCollection() {
|
||||||
|
return get(TrackableProperty.MergedCardsCollection);
|
||||||
|
}
|
||||||
|
|
||||||
public FCollectionView<CardView> getChosenCards() {
|
public FCollectionView<CardView> getChosenCards() {
|
||||||
return get(TrackableProperty.ChosenCards);
|
return get(TrackableProperty.ChosenCards);
|
||||||
}
|
}
|
||||||
@@ -433,6 +437,7 @@ public class CardView extends GameEntityView {
|
|||||||
//cards in these zones are visible to all
|
//cards in these zones are visible to all
|
||||||
return true;
|
return true;
|
||||||
case Exile:
|
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)
|
//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()) {
|
if (!isFaceDown()) {
|
||||||
return true;
|
return true;
|
||||||
@@ -786,6 +791,7 @@ public class CardView extends GameEntityView {
|
|||||||
//CardStateView cloner = CardView.getState(c, CardStateName.Cloner);
|
//CardStateView cloner = CardView.getState(c, CardStateName.Cloner);
|
||||||
set(TrackableProperty.Cloner, cloner == null ? null : cloner.getName() + " (" + cloner.getId() + ")");
|
set(TrackableProperty.Cloner, cloner == null ? null : cloner.getName() + " (" + cloner.getId() + ")");
|
||||||
|
|
||||||
|
CardCollection mergedCollection = new CardCollection();
|
||||||
if (c.hasMergedCard()) {
|
if (c.hasMergedCard()) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
CardCollectionView mergedCards = c.getMergedCards();
|
CardCollectionView mergedCards = c.getMergedCards();
|
||||||
@@ -796,7 +802,19 @@ public class CardView extends GameEntityView {
|
|||||||
sb.append(" (").append(card.getId()).append(")");
|
sb.append(" (").append(card.getId()).append(")");
|
||||||
}
|
}
|
||||||
set(TrackableProperty.MergedCards, sb.toString());
|
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();
|
CardState currentState = c.getCurrentState();
|
||||||
if (isSplitCard) {
|
if (isSplitCard) {
|
||||||
@@ -1407,4 +1425,18 @@ public class CardView extends GameEntityView {
|
|||||||
}
|
}
|
||||||
return null;
|
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),
|
FlipCard(TrackableTypes.BooleanType),
|
||||||
SplitCard(TrackableTypes.BooleanType),
|
SplitCard(TrackableTypes.BooleanType),
|
||||||
MergedCards(TrackableTypes.StringType),
|
MergedCards(TrackableTypes.StringType),
|
||||||
|
MergedCardsCollection(TrackableTypes.CardViewCollectionType, FreezeMode.IgnoresFreeze),
|
||||||
|
|
||||||
Attacking(TrackableTypes.BooleanType),
|
Attacking(TrackableTypes.BooleanType),
|
||||||
Blocking(TrackableTypes.BooleanType),
|
Blocking(TrackableTypes.BooleanType),
|
||||||
|
|||||||
@@ -45,8 +45,10 @@ public class CardZoom extends FOverlay {
|
|||||||
private static ActivateHandler activateHandler;
|
private static ActivateHandler activateHandler;
|
||||||
private static String currentActivateAction;
|
private static String currentActivateAction;
|
||||||
private static Rectangle flipIconBounds;
|
private static Rectangle flipIconBounds;
|
||||||
|
private static Rectangle mutateIconBounds;
|
||||||
private static boolean showAltState;
|
private static boolean showAltState;
|
||||||
private static boolean showBackSide = false;
|
private static boolean showBackSide = false;
|
||||||
|
private static boolean showMerged = false;
|
||||||
|
|
||||||
public static void show(Object item) {
|
public static void show(Object item) {
|
||||||
show(item, false);
|
show(item, false);
|
||||||
@@ -116,6 +118,7 @@ public class CardZoom extends FOverlay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void onCardChanged() {
|
private static void onCardChanged() {
|
||||||
|
mutateIconBounds = null;
|
||||||
if (activateHandler != null) {
|
if (activateHandler != null) {
|
||||||
currentActivateAction = activateHandler.getActivateAction(currentIndex);
|
currentActivateAction = activateHandler.getActivateAction(currentIndex);
|
||||||
}
|
}
|
||||||
@@ -124,6 +127,11 @@ public class CardZoom extends FOverlay {
|
|||||||
} else {
|
} else {
|
||||||
flipIconBounds = null;
|
flipIconBounds = null;
|
||||||
}
|
}
|
||||||
|
if (currentCard != null) {
|
||||||
|
if (currentCard.getMergedCardsCollection() != null )
|
||||||
|
if (currentCard.getMergedCardsCollection().size() > 0)
|
||||||
|
mutateIconBounds = new Rectangle();
|
||||||
|
}
|
||||||
showAltState = false;
|
showAltState = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,6 +170,15 @@ public class CardZoom extends FOverlay {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean tap(float x, float y, int count) {
|
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 (flipIconBounds != null && flipIconBounds.contains(x, y)) {
|
||||||
if (!showBackSide)
|
if (!showBackSide)
|
||||||
showAltState = !showAltState;
|
showAltState = !showAltState;
|
||||||
@@ -172,6 +189,7 @@ public class CardZoom extends FOverlay {
|
|||||||
hide();
|
hide();
|
||||||
showBackSide = false;
|
showBackSide = false;
|
||||||
showAltState = false;
|
showAltState = false;
|
||||||
|
showMerged = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,17 +321,22 @@ public class CardZoom extends FOverlay {
|
|||||||
CardImageRenderer.drawDetails(g, currentCard, gameView, showBackSide? showBackSide : showAltState, x, y, cardWidth, cardHeight);
|
CardImageRenderer.drawDetails(g, currentCard, gameView, showBackSide? showBackSide : showAltState, x, y, cardWidth, cardHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flipIconBounds != null) {
|
if (!showMerged) {
|
||||||
float imageWidth = cardWidth / 2;
|
if (mutateIconBounds != null) {
|
||||||
if (Forge.hdbuttons){
|
float oldAlpha = g.getfloatAlphaComposite();
|
||||||
float imageHeight = imageWidth * FSkinImage.HDFLIPCARD.getHeight() / FSkinImage.HDFLIPCARD.getWidth();
|
try {
|
||||||
flipIconBounds.set(x + (cardWidth - imageWidth) / 2, y + (cardHeight - imageHeight) / 2, imageWidth, imageHeight);
|
g.setAlphaComposite(0.6f);
|
||||||
g.drawImage(FSkinImage.HDFLIPCARD, flipIconBounds.x, flipIconBounds.y, flipIconBounds.width, flipIconBounds.height);
|
drawIconBounds(g, mutateIconBounds, Forge.hdbuttons ? FSkinImage.HDLIBRARY : FSkinImage.LIBRARY, x, y, cardWidth, cardHeight);
|
||||||
} else {
|
g.setAlphaComposite(oldAlpha);
|
||||||
float imageHeight = imageWidth * FSkinImage.FLIPCARD.getHeight() / FSkinImage.FLIPCARD.getWidth();
|
} catch (Exception e) {
|
||||||
flipIconBounds.set(x + (cardWidth - imageWidth) / 2, y + (cardHeight - imageHeight) / 2, imageWidth, imageHeight);
|
mutateIconBounds = null;
|
||||||
g.drawImage(FSkinImage.FLIPCARD, flipIconBounds.x, flipIconBounds.y, flipIconBounds.width, flipIconBounds.height);
|
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) {
|
if (currentActivateAction != null) {
|
||||||
@@ -326,6 +349,13 @@ public class CardZoom extends FOverlay {
|
|||||||
interrupt(false);
|
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
|
@Override
|
||||||
protected void doLayout(float width, float height) {
|
protected void doLayout(float width, float height) {
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user